Commit 4ae22a0e authored by Spiros Koulouzis's avatar Spiros Koulouzis

successfully provisioned topology

parent 7e2c4eef
...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
import nl.uva.sne.drip.api.dao.CloudCredentialsDao; import nl.uva.sne.drip.api.dao.CloudCredentialsDao;
import nl.uva.sne.drip.api.service.UserService; import nl.uva.sne.drip.api.service.UserService;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
/** /**
* *
...@@ -46,7 +47,7 @@ public class CloudConfigurationController { ...@@ -46,7 +47,7 @@ public class CloudConfigurationController {
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody public @ResponseBody
String postConf(CloudCredentials cc) { String postConf(@RequestBody CloudCredentials cc) {
cloudCredentialsDao.save(cc); cloudCredentialsDao.save(cc);
return cc.getId(); return cc.getId();
} }
......
...@@ -88,7 +88,7 @@ public class PlannerController { ...@@ -88,7 +88,7 @@ public class PlannerController {
dripComponetens.add(planner); dripComponetens.add(planner);
Message plannerReturnedMessage = planner.call(plannerInvokationMessage); Message plannerReturnedMessage = planner.call(plannerInvokationMessage);
Message provisionerInvokationMessage = buildProvisionerMessage(plannerReturnedMessage, "58a1f0a963d42f004b1d63ad"); Message provisionerInvokationMessage = buildProvisionerMessage(plannerReturnedMessage, "58a7281c55363e65b3c9eb82");
provisioner = new ProvisionerCaller(messageBrokerHost); provisioner = new ProvisionerCaller(messageBrokerHost);
dripComponetens.add(provisioner); dripComponetens.add(provisioner);
provisioner.call(provisionerInvokationMessage); provisioner.call(provisionerInvokationMessage);
......
...@@ -116,6 +116,24 @@ public class ToscaController { ...@@ -116,6 +116,24 @@ public class ToscaController {
return null; return null;
} }
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
ToscaRepresentation getToscaRepresentation(@PathVariable("id") String id) {
ToscaRepresentation tosca = dao.findOne(id);
return tosca;
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String delete(@PathVariable("id") String id) {
dao.delete(id);
return "Deleted tosca :" + id;
}
// http://localhost:8080/drip-api/tosca/ids // http://localhost:8080/drip-api/tosca/ids
@RequestMapping(value = "/ids") @RequestMapping(value = "/ids")
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
......
...@@ -82,19 +82,16 @@ public class Consumer extends DefaultConsumer { ...@@ -82,19 +82,16 @@ public class Consumer extends DefaultConsumer {
List<File> files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath()); List<File> files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath());
//Here we do the same as above with a different API //Here we do the same as above with a different API
inputFiles = simpleJsonUnmarshalExample(message); // inputFiles = simpleJsonUnmarshalExample(message);
//Call the method with the extracted parameters //Call the method with the extracted parameters
files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath()); // files = panner.plan(inputFiles[0].getAbsolutePath(), inputFiles[1].getAbsolutePath(), tempDir.getAbsolutePath());
//Now we need to put the result of the call to a message and respond //Now we need to put the result of the call to a message and respond
//Example 1 //Example 1
response = jacksonMarshalExample(files); response = jacksonMarshalExample(files);
//Example 2 //Example 2
response = simpleJsonMarshalExample(files); // response = simpleJsonMarshalExample(files);
} catch (Exception ex) {
} catch (IOException | JSONException ex) {
response = ex.getMessage(); response = ex.getMessage();
Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex);
} finally { } finally {
...@@ -136,7 +133,7 @@ public class Consumer extends DefaultConsumer { ...@@ -136,7 +133,7 @@ public class Consumer extends DefaultConsumer {
} }
private File[] simpleJsonUnmarshalExample(String message) throws JSONException, FileNotFoundException, IOException { private File[] simpleJsonUnmarshalExample(String message) throws JSONException, FileNotFoundException, IOException {
//Use the JSONObject API to convert json to Object (Message) //Use the JSONObject API to convert json to Object (Message)
File[] files = new File[2]; File[] files = new File[2];
JSONObject jo = new JSONObject(message); JSONObject jo = new JSONObject(message);
JSONArray parameters = jo.getJSONArray("parameters"); JSONArray parameters = jo.getJSONArray("parameters");
...@@ -183,7 +180,7 @@ public class Consumer extends DefaultConsumer { ...@@ -183,7 +180,7 @@ public class Consumer extends DefaultConsumer {
} }
private String simpleJsonMarshalExample(List<File> files) throws JSONException, IOException { private String simpleJsonMarshalExample(List<File> files) throws JSONException, IOException {
//Use the JSONObject API to convert Object (Message) to json //Use the JSONObject API to convert Object (Message) to json
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("creationDate", (System.currentTimeMillis())); jo.put("creationDate", (System.currentTimeMillis()));
List parameters = new ArrayList(); List parameters = new ArrayList();
......
...@@ -24,6 +24,7 @@ import java.io.IOException; ...@@ -24,6 +24,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import nl.uva.sne.drip.commons.utils.Converter;
/** /**
* *
...@@ -45,9 +46,12 @@ public class Planner { ...@@ -45,9 +46,12 @@ public class Planner {
} }
if (check) { if (check) {
if (line.contains("file")) { if (line.contains("file")) {
String content = line.trim().replace('\"', ' '); String content = line.trim().replace('\'', ' ').replace('\"', ' ');
String[] cs = content.split(":"); String[] cs = content.split(":");
String docker_name = cs[1].trim(); String docker_name = cs[1].trim();
if (docker_name.equals("{file")) {
docker_name = cs[2].trim();
}
dockerNames.add(docker_name); dockerNames.add(docker_name);
} }
} }
...@@ -111,7 +115,6 @@ public class Planner { ...@@ -111,7 +115,6 @@ public class Planner {
outputFiles.add(new File(outfPath)); outputFiles.add(new File(outfPath));
outputFiles.add(new File(allFilePath)); outputFiles.add(new File(allFilePath));
return outputFiles; return outputFiles;
} }
private String generateVM(String block, String nodeName, String dockerName, String privateAddress, String role) { private String generateVM(String block, String nodeName, String dockerName, String privateAddress, String role) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment