Commit cbe0c324 authored by Spiros Koulouzis's avatar Spiros Koulouzis

changed default disk size. Added disk size to cloudstorm vm

parent 0662df0a
...@@ -29,15 +29,15 @@ topology_template: ...@@ -29,15 +29,15 @@ topology_template:
repository: docker_hub repository: docker_hub
#topology: topology:
#type: tosca.nodes.ARTICONF.VM.topology type: tosca.nodes.ARTICONF.VM.topology
#interfaces: interfaces:
#CloudsStorm: CloudsStorm:
#provision: provision:
#inputs: inputs:
#code_type: SEQ code_type: SEQ
#object_type: SubTopology object_type: SubTopology
#properties: properties:
#domain: UvA (Amsterdam, The Netherlands) XO Rack domain: UvA (Amsterdam, The Netherlands) XO Rack
#provider: ExoGENI provider: ExoGENI
...@@ -179,7 +179,7 @@ node_types: ...@@ -179,7 +179,7 @@ node_types:
disk_size: disk_size:
type: scalar-unit.size type: scalar-unit.size
required: true required: true
default: 40000 MB default: 25000 MB
constraints: constraints:
- greater_or_equal: 15000 MB - greater_or_equal: 15000 MB
mem_size: mem_size:
......
...@@ -116,10 +116,10 @@ services: ...@@ -116,10 +116,10 @@ services:
ports: ports:
- "30000:8080" - "30000:8080"
#sure-tosca: sure-tosca:
#image: sure-tosca:3.0.0 image: sure-tosca:3.0.0
#ports: ports:
#- "8081:8081" - "8081:8081"
planner: planner:
depends_on: depends_on:
...@@ -129,14 +129,14 @@ services: ...@@ -129,14 +129,14 @@ services:
environment: environment:
RABBITMQ_HOST: rabbit RABBITMQ_HOST: rabbit
provisioner: #provisioner:
depends_on: #depends_on:
- rabbit #- rabbit
- sure-tosca #- sure-tosca
image: provisioner:3.0.0 #image: provisioner:3.0.0
environment: #environment:
RABBITMQ_HOST: rabbit #RABBITMQ_HOST: rabbit
SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0 #SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
deployer: deployer:
depends_on: depends_on:
......
...@@ -16,8 +16,10 @@ import javax.validation.Valid; ...@@ -16,8 +16,10 @@ import javax.validation.Valid;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level; import java.util.logging.Level;
import nl.uva.sne.drip.model.Exceptions.TypeExeption; import nl.uva.sne.drip.model.Exceptions.TypeExeption;
import nl.uva.sne.drip.service.DRIPService;
import nl.uva.sne.drip.service.ToscaTemplateService; import nl.uva.sne.drip.service.ToscaTemplateService;
import nl.uva.sne.drip.sure.tosca.client.ApiException; import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -34,6 +36,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -34,6 +36,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
@Autowired @Autowired
private ToscaTemplateService toscaTemplateService; private ToscaTemplateService toscaTemplateService;
@Autowired
private DRIPService dripService;
@org.springframework.beans.factory.annotation.Autowired @org.springframework.beans.factory.annotation.Autowired
public ToscaTemplateApiController(ObjectMapper objectMapper, HttpServletRequest request) { public ToscaTemplateApiController(ObjectMapper objectMapper, HttpServletRequest request) {
this.request = request; this.request = request;
...@@ -44,9 +49,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi { ...@@ -44,9 +49,9 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
String accept = request.getHeader("Accept"); String accept = request.getHeader("Accept");
if (accept != null && accept.contains("*/*")) { if (accept != null && accept.contains("*/*")) {
try { try {
toscaTemplateService.deleteByID(id); String deleteedYemplateId = dripService.delete(id);
return new ResponseEntity<>("", HttpStatus.OK); return new ResponseEntity<>(deleteedYemplateId, HttpStatus.OK);
} catch (NotFoundException | IOException | ApiException | TypeExeption ex) { } catch (NotFoundException | IOException | ApiException | TypeExeption | TimeoutException | InterruptedException ex) {
java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, ex); java.util.logging.Logger.getLogger(ToscaTemplateApiController.class.getName()).log(Level.SEVERE, null, ex);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
} }
......
...@@ -61,7 +61,6 @@ public class DRIPService { ...@@ -61,7 +61,6 @@ public class DRIPService {
} }
private String execute(ToscaTemplate toscaTemplate) throws JsonProcessingException, ApiException, IOException, TimeoutException, InterruptedException { private String execute(ToscaTemplate toscaTemplate) throws JsonProcessingException, ApiException, IOException, TimeoutException, InterruptedException {
caller.init(); caller.init();
Logger.getLogger(DRIPService.class.getName()).log(Level.INFO, "toscaTemplate:\n{0}", toscaTemplate); Logger.getLogger(DRIPService.class.getName()).log(Level.INFO, "toscaTemplate:\n{0}", toscaTemplate);
Message message = new Message(); Message message = new Message();
...@@ -172,19 +171,19 @@ public class DRIPService { ...@@ -172,19 +171,19 @@ public class DRIPService {
return toscaTemplate; return toscaTemplate;
} }
void deleteActions(ToscaTemplate toscaTemplate) throws ApiException, TypeExeption, IOException { public String delete(String id) throws NotFoundException, IOException, JsonProcessingException, ApiException, TypeExeption, TimeoutException, InterruptedException {
helper.uploadToscaTemplate(toscaTemplate); ToscaTemplate toscaTemplate = initExecution(id);
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
if (vmTopologies != null) { if (vmTopologies != null) {
for (NodeTemplateMap vmTopology : vmTopologies) { for (NodeTemplateMap vmTopology : vmTopologies) {
CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology); CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology);
if (!status.equals(CloudsStormSubTopology.StatusEnum.DELETED)) { if (!status.equals(CloudsStormSubTopology.StatusEnum.DELETED)) {
Logger.getLogger(ToscaHelper.class.getName()).log(Level.FINE, "Deleting VMs from " + vmTopology); toscaTemplate = setProvisionerOperation(toscaTemplate, PROVISIONER_OPERATION.DELETE);
} }
} }
return execute(toscaTemplate);
} }
return null;
} }
} }
...@@ -44,8 +44,7 @@ public class ToscaTemplateService { ...@@ -44,8 +44,7 @@ public class ToscaTemplateService {
@Autowired @Autowired
private ToscaTemplateDAO dao; private ToscaTemplateDAO dao;
@Autowired
private DRIPService dripService;
public String save(ToscaTemplate tt) { public String save(ToscaTemplate tt) {
dao.save(tt); dao.save(tt);
...@@ -85,7 +84,6 @@ public class ToscaTemplateService { ...@@ -85,7 +84,6 @@ public class ToscaTemplateService {
public void deleteByID(String id) throws JsonProcessingException, NotFoundException, IOException, ApiException, TypeExeption { public void deleteByID(String id) throws JsonProcessingException, NotFoundException, IOException, ApiException, TypeExeption {
ToscaTemplate toscaTemplate = getYaml2ToscaTemplate(findByID(id)); ToscaTemplate toscaTemplate = getYaml2ToscaTemplate(findByID(id));
dripService.deleteActions(toscaTemplate);
dao.deleteById(id); dao.deleteById(id);
} }
......
...@@ -206,20 +206,27 @@ class CloudStormService { ...@@ -206,20 +206,27 @@ class CloudStormService {
} }
private CloudsStormVM getBestMatchingCloudStormVM(NodeTemplateMap vmMap, String provider) throws IOException, Exception { private CloudsStormVM getBestMatchingCloudStormVM(NodeTemplateMap vmMap, String provider) throws IOException, Exception {
Double numOfCores = helper.getVMNumOfCores(vmMap); Double requestedNumOfCores = helper.getVMNumOfCores(vmMap);
Double memSize = helper.getVMNMemSize(vmMap); Double requestedMemSize = helper.getVMNMemSize(vmMap);
String os = helper.getVMNOS(vmMap); String requestedOs = helper.getVMNOS(vmMap);
Double diskSize = helper.getVMNDiskSize(vmMap); Double requestedDiskSize = helper.getVMNDiskSize(vmMap);
double[] requestedVector = convert2ArrayofDoubles(numOfCores, memSize, diskSize); double[] requestedVector = convert2ArrayofDoubles(requestedNumOfCores, requestedMemSize, requestedDiskSize);
double min = Double.MAX_VALUE; double min = Double.MAX_VALUE;
CloudsStormVM bestMatchingVM = null; CloudsStormVM bestMatchingVM = null;
List<CloudsStormVM> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(CloudProviderEnum.fromValue(provider)); List<CloudsStormVM> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(CloudProviderEnum.fromValue(provider));
for (CloudsStormVM vmInfo : vmInfos) { for (CloudsStormVM vmInfo : vmInfos) {
if (os.toLowerCase().equals(vmInfo.getOstype().toLowerCase())) { if (requestedOs.toLowerCase().equals(vmInfo.getOstype().toLowerCase())) {
Double cloudsStormVMdiskSize = null; Double cloudsStormVMdiskSize;
if (vmInfo.getDiskSize() == null) { if (vmInfo.getDiskSize() == null) {
cloudsStormVMdiskSize = Double.valueOf(7.0); if (vmInfo.getExtraInfo() != null && vmInfo.getExtraInfo().containsKey("DiskSize")) {
int intSize = (int) vmInfo.getExtraInfo().get("DiskSize");
cloudsStormVMdiskSize = Double.valueOf(intSize);
vmInfo.setDiskSize(intSize);
} else {
cloudsStormVMdiskSize = 7.0;
}
} else { } else {
cloudsStormVMdiskSize = Double.valueOf(vmInfo.getDiskSize()); cloudsStormVMdiskSize = Double.valueOf(vmInfo.getDiskSize());
} }
...@@ -232,8 +239,9 @@ class CloudStormService { ...@@ -232,8 +239,9 @@ class CloudStormService {
} }
} }
} }
if (bestMatchingVM != null && bestMatchingVM.getDiskSize() == null){ if (bestMatchingVM != null && bestMatchingVM.getDiskSize() == null
bestMatchingVM.setDiskSize(diskSize.intValue()); && bestMatchingVM.getExtraInfo() == null && !bestMatchingVM.getExtraInfo().containsKey("DiskSize")) {
bestMatchingVM.setDiskSize(requestedDiskSize.intValue());
} }
Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "Found best matching VM: {0}", bestMatchingVM); Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "Found best matching VM: {0}", bestMatchingVM);
return bestMatchingVM; return bestMatchingVM;
......
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