Commit 97fcf58a authored by Spiros Koulouzis's avatar Spiros Koulouzis

implementing vm scaling. We hit null pointer exception at EGISEngine line 654

parent a3d328f3
...@@ -53,7 +53,7 @@ import nl.uva.sne.drip.api.exception.KeyException; ...@@ -53,7 +53,7 @@ import nl.uva.sne.drip.api.exception.KeyException;
import nl.uva.sne.drip.commons.utils.Converter; import nl.uva.sne.drip.commons.utils.Converter;
import nl.uva.sne.drip.drip.commons.data.v1.external.ConfigurationRepresentation; import nl.uva.sne.drip.drip.commons.data.v1.external.ConfigurationRepresentation;
import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair; import nl.uva.sne.drip.drip.commons.data.v1.external.KeyPair;
import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleDeploymetRequest; import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput; import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleOutput;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult; import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.AnsibleResult;
import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult; import nl.uva.sne.drip.drip.commons.data.v1.external.ansible.BenchmarkResult;
...@@ -274,19 +274,19 @@ public class DeployService { ...@@ -274,19 +274,19 @@ public class DeployService {
return scaleParameter; return scaleParameter;
} }
public DeployResponse scale(ScaleDeploymetRequest scaleReq) throws IOException, TimeoutException, InterruptedException, JSONException, Exception { public DeployResponse scale(ScaleRequest scaleReq) throws IOException, TimeoutException, InterruptedException, JSONException, Exception {
//Deployer needs configurationID -> name_of_deployment //Deployer needs configurationID -> name_of_deployment
String deployId = scaleReq.getDeployID(); String deployId = scaleReq.getScaleTargetID();
DeployResponse deployment = this.findOne(deployId); DeployResponse deployment = this.findOne(deployId);
String confID = deployment.getConfigurationID(); String confID = deployment.getConfigurationID();
ConfigurationRepresentation configuration = configurationService.findOne(confID); ConfigurationRepresentation configuration = configurationService.findOne(confID);
Map<String, Object> map = configuration.getKeyValue(); Map<String, Object> map = configuration.getKeyValue();
Map<String, Object> services = (Map<String, Object>) map.get("services"); Map<String, Object> services = (Map<String, Object>) map.get("services");
if (!services.containsKey(scaleReq.getServiceName())) { if (!services.containsKey(scaleReq.getScaleTargetName())) {
throw new BadRequestException("Service name does not exist in this deployment"); throw new BadRequestException("Service name does not exist in this deployment");
} }
Message message = buildDeployerMessage(deployment.getProvisionID(), "scale", confID, scaleReq.getServiceName(), scaleReq.getNumOfInstances()); Message message = buildDeployerMessage(deployment.getProvisionID(), "scale", confID, scaleReq.getScaleTargetName(), scaleReq.getNumOfInstances());
try (DRIPCaller deployer = new DeployerCaller(messageBrokerHost);) { try (DRIPCaller deployer = new DeployerCaller(messageBrokerHost);) {
Message response = (deployer.call(message)); Message response = (deployer.call(message));
......
...@@ -35,7 +35,6 @@ import nl.uva.sne.drip.api.service.DeployService; ...@@ -35,7 +35,6 @@ import nl.uva.sne.drip.api.service.DeployService;
import nl.uva.sne.drip.api.service.UserService; import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployRequest; import nl.uva.sne.drip.drip.commons.data.v1.external.DeployRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse; import nl.uva.sne.drip.drip.commons.data.v1.external.DeployResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleDeploymetRequest;
import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest; import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -91,9 +90,8 @@ public class DeployController { ...@@ -91,9 +90,8 @@ public class DeployController {
@RequestMapping(value = "/scale", method = RequestMethod.POST) @RequestMapping(value = "/scale", method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody public @ResponseBody
String scaleDeployment(@RequestBody ScaleDeploymetRequest scaleRequest) { String scaleDeployment(@RequestBody ScaleRequest scaleRequest) {
try { try {
return deployService.scale(scaleRequest).getId(); return deployService.scale(scaleRequest).getId();
......
...@@ -37,6 +37,7 @@ import nl.uva.sne.drip.api.exception.NotFoundException; ...@@ -37,6 +37,7 @@ import nl.uva.sne.drip.api.exception.NotFoundException;
import nl.uva.sne.drip.api.service.ProvisionService; import nl.uva.sne.drip.api.service.ProvisionService;
import nl.uva.sne.drip.api.service.UserService; import nl.uva.sne.drip.api.service.UserService;
import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse; import nl.uva.sne.drip.drip.commons.data.v1.external.ProvisionResponse;
import nl.uva.sne.drip.drip.commons.data.v1.external.ScaleRequest;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -188,6 +189,19 @@ public class ProvisionController { ...@@ -188,6 +189,19 @@ public class ProvisionController {
return resp.getId(); return resp.getId();
} }
@RequestMapping(value = "/scale", method = RequestMethod.POST)
@RolesAllowed({UserService.USER, UserService.ADMIN})
public @ResponseBody
String scaleDeployment(@RequestBody ScaleRequest scaleRequest) {
try {
return provisionService.scale(scaleRequest).getId();
} catch (IOException | TimeoutException | JSONException ex) {
Logger.getLogger(ProvisionController.class.getName()).log(Level.SEVERE, null, ex);
} catch (Exception ex) {
Logger.getLogger(ProvisionController.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
@RequestMapping(value = "/sample", method = RequestMethod.GET) @RequestMapping(value = "/sample", method = RequestMethod.GET)
@RolesAllowed({UserService.USER, UserService.ADMIN}) @RolesAllowed({UserService.USER, UserService.ADMIN})
......
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