Commit 05902775 authored by Spiros Koulouzis's avatar Spiros Koulouzis

write cloudstrom schema

parent 38af6e0b
...@@ -2,26 +2,18 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -2,26 +2,18 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonRootName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/** /**
* CloudsStormVM * CloudsStormVM
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-30T16:13:55.433Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonRootName(value = "VMs")
public class CloudsStormVM { public class CloudsStormVM {
@JsonIgnore
@JsonProperty("name")
private String name = null; private String name = null;
@JsonProperty("nodeType") @JsonProperty("nodeType")
...@@ -43,11 +35,12 @@ public class CloudsStormVM { ...@@ -43,11 +35,12 @@ public class CloudsStormVM {
/** /**
* Get name * Get name
*
* @return name * @return name
**/ *
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getName() { public String getName() {
return name; return name;
} }
...@@ -63,11 +56,12 @@ public class CloudsStormVM { ...@@ -63,11 +56,12 @@ public class CloudsStormVM {
/** /**
* Get nodeType * Get nodeType
*
* @return nodeType * @return nodeType
**/ *
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getNodeType() { public String getNodeType() {
return nodeType; return nodeType;
} }
...@@ -83,11 +77,12 @@ public class CloudsStormVM { ...@@ -83,11 +77,12 @@ public class CloudsStormVM {
/** /**
* Get osType * Get osType
*
* @return osType * @return osType
**/ *
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getOsType() { public String getOsType() {
return osType; return osType;
} }
...@@ -103,11 +98,12 @@ public class CloudsStormVM { ...@@ -103,11 +98,12 @@ public class CloudsStormVM {
/** /**
* Get script * Get script
*
* @return script * @return script
**/ *
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getScript() { public String getScript() {
return script; return script;
} }
...@@ -123,11 +119,12 @@ public class CloudsStormVM { ...@@ -123,11 +119,12 @@ public class CloudsStormVM {
/** /**
* Get publicAddress * Get publicAddress
*
* @return publicAddress * @return publicAddress
**/ *
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
public String getPublicAddress() { public String getPublicAddress() {
return publicAddress; return publicAddress;
} }
...@@ -136,7 +133,6 @@ public class CloudsStormVM { ...@@ -136,7 +133,6 @@ public class CloudsStormVM {
this.publicAddress = publicAddress; this.publicAddress = publicAddress;
} }
@Override @Override
public boolean equals(java.lang.Object o) { public boolean equals(java.lang.Object o) {
if (this == o) { if (this == o) {
...@@ -146,11 +142,11 @@ public class CloudsStormVM { ...@@ -146,11 +142,11 @@ public class CloudsStormVM {
return false; return false;
} }
CloudsStormVM cloudsStormVM = (CloudsStormVM) o; CloudsStormVM cloudsStormVM = (CloudsStormVM) o;
return Objects.equals(this.name, cloudsStormVM.name) && return Objects.equals(this.name, cloudsStormVM.name)
Objects.equals(this.nodeType, cloudsStormVM.nodeType) && && Objects.equals(this.nodeType, cloudsStormVM.nodeType)
Objects.equals(this.osType, cloudsStormVM.osType) && && Objects.equals(this.osType, cloudsStormVM.osType)
Objects.equals(this.script, cloudsStormVM.script) && && Objects.equals(this.script, cloudsStormVM.script)
Objects.equals(this.publicAddress, cloudsStormVM.publicAddress); && Objects.equals(this.publicAddress, cloudsStormVM.publicAddress);
} }
@Override @Override
...@@ -183,4 +179,3 @@ public class CloudsStormVM { ...@@ -183,4 +179,3 @@ public class CloudsStormVM {
return o.toString().replace("\n", "\n "); return o.toString().replace("\n", "\n ");
} }
} }
...@@ -2,80 +2,55 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -2,80 +2,55 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects; import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.*;
/** /**
* CloudsStormVMs * CloudsStormVMs
*/ */
@Validated @Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z") @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-30T16:13:55.433Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormVMs { public class CloudsStormVMs {
@JsonProperty("name")
private String name = null;
@JsonProperty("CloudsStormVM") @JsonProperty("VMs")
@Valid @Valid
private List<CloudsStormVM> cloudsStormVM = null; private List<CloudsStormVM> vms = null;
public CloudsStormVMs name(String name) { public CloudsStormVMs vms(List<CloudsStormVM> vms) {
this.name = name; this.vms = vms;
return this; return this;
} }
/** public CloudsStormVMs addVmsItem(CloudsStormVM vmsItem) {
* Get name if (this.vms == null) {
* @return name this.vms = new ArrayList<CloudsStormVM>();
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
} }
this.vms.add(vmsItem);
public CloudsStormVMs cloudsStormVM(List<CloudsStormVM> cloudsStormVM) {
this.cloudsStormVM = cloudsStormVM;
return this;
}
public CloudsStormVMs addCloudsStormVMItem(CloudsStormVM cloudsStormVMItem) {
if (this.cloudsStormVM == null) {
this.cloudsStormVM = new ArrayList<CloudsStormVM>();
}
this.cloudsStormVM.add(cloudsStormVMItem);
return this; return this;
} }
/** /**
* Get cloudsStormVM * Get vms
* @return cloudsStormVM *
**/ * @return vms
*
*/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@Valid @Valid
public List<CloudsStormVM> getCloudsStormVM() { public List<CloudsStormVM> getVms() {
return cloudsStormVM; return vms;
} }
public void setCloudsStormVM(List<CloudsStormVM> cloudsStormVM) { public void setVms(List<CloudsStormVM> vms) {
this.cloudsStormVM = cloudsStormVM; this.vms = vms;
} }
@Override @Override
public boolean equals(java.lang.Object o) { public boolean equals(java.lang.Object o) {
if (this == o) { if (this == o) {
...@@ -85,13 +60,12 @@ public class CloudsStormVMs { ...@@ -85,13 +60,12 @@ public class CloudsStormVMs {
return false; return false;
} }
CloudsStormVMs cloudsStormVMs = (CloudsStormVMs) o; CloudsStormVMs cloudsStormVMs = (CloudsStormVMs) o;
return Objects.equals(this.name, cloudsStormVMs.name) && return Objects.equals(this.vms, cloudsStormVMs.vms);
Objects.equals(this.cloudsStormVM, cloudsStormVMs.cloudsStormVM);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name, cloudsStormVM); return Objects.hash(vms);
} }
@Override @Override
...@@ -99,8 +73,7 @@ public class CloudsStormVMs { ...@@ -99,8 +73,7 @@ public class CloudsStormVMs {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVMs {\n"); sb.append("class CloudsStormVMs {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" vms: ").append(toIndentedString(vms)).append("\n");
sb.append(" cloudsStormVM: ").append(toIndentedString(cloudsStormVM)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); return sb.toString();
} }
...@@ -116,4 +89,3 @@ public class CloudsStormVMs { ...@@ -116,4 +89,3 @@ public class CloudsStormVMs {
return o.toString().replace("\n", "\n "); return o.toString().replace("\n", "\n ");
} }
} }
...@@ -835,7 +835,7 @@ DCMetaInfo: ...@@ -835,7 +835,7 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml" OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5" OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75 DiskSize: 75
- OS: "Ubuntu 16.04" - OS: "Ubuntu 18.04"
CPU: 4 CPU: 4
MEM: 12 MEM: 12
VMType: "XOXLarge" VMType: "XOXLarge"
...@@ -845,7 +845,7 @@ DCMetaInfo: ...@@ -845,7 +845,7 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml" OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9" OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75 DiskSize: 75
- OS: "Ubuntu 16.04" - OS: "Ubuntu 18.04"
CPU: 2 CPU: 2
MEM: 6 MEM: 6
VMType: "XOLarge" VMType: "XOLarge"
......
...@@ -24,6 +24,8 @@ import java.util.List; ...@@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.ToscaHelper; import nl.uva.sne.drip.commons.utils.ToscaHelper;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM; import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplateMap; import nl.uva.sne.drip.model.NodeTemplateMap;
...@@ -75,7 +77,7 @@ class CloudStormService { ...@@ -75,7 +77,7 @@ class CloudStormService {
if (!(topologyTempInputDir.mkdirs())) { if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath()); throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
} }
writeCloudStormTopologyFiles(topologyTempInputDirPath); Map<String, Object> subTopologiesAndVMs = writeCloudStormTopologyFiles(topologyTempInputDirPath);
String credentialsTempInputDirPath = tempInputDirPath + File.separator + "credentials"; String credentialsTempInputDirPath = tempInputDirPath + File.separator + "credentials";
File credentialsTempInputDir = new File(credentialsTempInputDirPath); File credentialsTempInputDir = new File(credentialsTempInputDirPath);
...@@ -88,11 +90,12 @@ class CloudStormService { ...@@ -88,11 +90,12 @@ class CloudStormService {
if (!(infrasCodeTempInputDir.mkdirs())) { if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath()); throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
} }
writeCloudStormInfrasCodeFiles(infrasCodeTempInputDirPath); List<CloudsStormSubTopology> cloudStormSubtopologies = (List<CloudsStormSubTopology>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
writeCloudStormInfrasCodeFiles(infrasCodeTempInputDirPath, cloudStormSubtopologies);
return toscaTemplate; return toscaTemplate;
} }
private void writeCloudStormTopologyFiles(String tempInputDirPath) throws JSchException, IOException, ApiException, Exception { private Map<String, Object> writeCloudStormTopologyFiles(String tempInputDirPath) throws JSchException, IOException, ApiException, Exception {
CloudsStormTopTopology topTopology = new CloudsStormTopTopology(); CloudsStormTopTopology topTopology = new CloudsStormTopTopology();
String publicKeyPath = buildSSHKeyPair(tempInputDirPath); String publicKeyPath = buildSSHKeyPair(tempInputDirPath);
topTopology.setPublicKeyPath(publicKeyPath); topTopology.setPublicKeyPath(publicKeyPath);
...@@ -103,6 +106,8 @@ class CloudStormService { ...@@ -103,6 +106,8 @@ class CloudStormService {
topTopology.setTopologies(cloudsStormSubTopology); topTopology.setTopologies(cloudsStormSubTopology);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "top.yml"), topTopology); objectMapper.writeValue(new File(tempInputDirPath + File.separator + "top.yml"), topTopology);
return subTopologiesAndVMs;
} }
private String buildSSHKeyPair(String tempInputDirPath) throws JSchException, IOException { private String buildSSHKeyPair(String tempInputDirPath) throws JSchException, IOException {
...@@ -138,7 +143,6 @@ class CloudStormService { ...@@ -138,7 +143,6 @@ class CloudStormService {
CloudsStormVMs cloudsStormVMs = new CloudsStormVMs(); CloudsStormVMs cloudsStormVMs = new CloudsStormVMs();
List<CloudsStormVM> vms = new ArrayList<>(); List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap); List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0; int j = 0;
for (NodeTemplateMap vmMap : vmTemplatesMap) { for (NodeTemplateMap vmMap : vmTemplatesMap) {
...@@ -151,7 +155,7 @@ class CloudStormService { ...@@ -151,7 +155,7 @@ class CloudStormService {
vms.add(cloudsStormVM); vms.add(cloudsStormVM);
j++; j++;
} }
cloudsStormVMs.setCloudsStormVM(vms); cloudsStormVMs.setVms(vms);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "vm_topology" + i + ".yml"), cloudsStormVMs); objectMapper.writeValue(new File(tempInputDirPath + File.separator + "vm_topology" + i + ".yml"), cloudsStormVMs);
cloudsStormVMsList.add(cloudsStormVMs); cloudsStormVMsList.add(cloudsStormVMs);
cloudsStormSubTopologies.add(cloudsStormSubTopology); cloudsStormSubTopologies.add(cloudsStormSubTopology);
...@@ -168,6 +172,8 @@ class CloudStormService { ...@@ -168,6 +172,8 @@ class CloudStormService {
String os = helper.getVMNOS(vmMap); String os = helper.getVMNOS(vmMap);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider); List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
for (VMMetaInfo vmInfo : vmInfos) { for (VMMetaInfo vmInfo : vmInfos) {
Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "vmInfo: {0}", vmInfo);
Logger.getLogger(CloudStormService.class.getName()).log(Level.INFO, "numOfCores:{0} memSize: {1} os: {2}", new Object[]{numOfCores, memSize, os});
if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) { if (Objects.equals(numOfCores, Double.valueOf(vmInfo.getCPU())) && Objects.equals(memSize, Double.valueOf(vmInfo.getMEM())) && os.toLowerCase().equals(vmInfo.getOS().toLowerCase())) {
return vmInfo.getVmType(); return vmInfo.getVmType();
} }
...@@ -219,7 +225,16 @@ class CloudStormService { ...@@ -219,7 +225,16 @@ class CloudStormService {
return null; return null;
} }
private void writeCloudStormInfrasCodeFiles(String infrasCodeTempInputDirPath) { private void writeCloudStormInfrasCodeFiles(String infrasCodeTempInputDirPath, List<CloudsStormSubTopology> cloudStormSubtopologies) throws ApiException {
List<NodeTemplateMap> vmTopologiesMaps = helper.getVMTopologyTemplates();
int i = 0;
for (NodeTemplateMap vmTopologyMap : vmTopologiesMaps) {
Map<String, Object> provisionInterface = helper.getProvisionerInterfaceFromVMTopology(vmTopologyMap);
String operation = provisionInterface.keySet().iterator().next();
Map<String, Object> inputs = (Map<String, Object>) provisionInterface.get(operation);
inputs.put("object_type", cloudStormSubtopologies.get(i).getTopology());
}
} }
......
CloudsStormInfrasCode:
type: "object"
properties:
Mode:
type: "string"
InfrasCodes:
type: "array"
items:
$ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/InfrasCode.yml#/InfrasCode"
InfrasCode:
type: "object"
properties:
CodeType:
type: "string"
OpCode:
$ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/OpCode.yml#/OpCode"
Count:
type: "integer"
OpCodes:
type: "array"
items:
$ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/OpCode.yml#/OpCode"
OpCode:
type: "object"
properties:
Operation:
type: "string"
Operation:
type: "string"
Objects:
type: "string"
Command:
type: "string"
Log:
type: "boolean"
Options:
type: $ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/Options.yml#/Options"
Options:
type: "object"
properties:
Src:
type: "string"
Dst:
type: "string"
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