Commit 05902775 authored by Spiros Koulouzis's avatar Spiros Koulouzis

write cloudstrom schema

parent 38af6e0b
...@@ -2,185 +2,180 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -2,185 +2,180 @@ 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) public class CloudsStormVM {
@JsonRootName(value = "VMs")
public class CloudsStormVM {
@JsonIgnore
private String name = null;
@JsonProperty("nodeType") @JsonProperty("name")
private String nodeType = null; private String name = null;
@JsonProperty("OSType") @JsonProperty("nodeType")
private String osType = null; private String nodeType = null;
@JsonProperty("script") @JsonProperty("OSType")
private String script = null; private String osType = null;
@JsonProperty("publicAddress") @JsonProperty("script")
private String publicAddress = null; private String script = null;
public CloudsStormVM name(String name) { @JsonProperty("publicAddress")
this.name = name; private String publicAddress = null;
return this;
}
/** public CloudsStormVM name(String name) {
* Get name this.name = name;
* @return name return this;
**/ }
@ApiModelProperty(value = "")
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty(value = "")
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public CloudsStormVM nodeType(String nodeType) { public CloudsStormVM nodeType(String nodeType) {
this.nodeType = nodeType; this.nodeType = nodeType;
return this; return this;
} }
/** /**
* Get nodeType * Get nodeType
* @return nodeType *
**/ * @return nodeType
@ApiModelProperty(value = "") *
*/
@ApiModelProperty(value = "")
public String getNodeType() {
return nodeType; public String getNodeType() {
} return nodeType;
}
public void setNodeType(String nodeType) {
this.nodeType = nodeType; public void setNodeType(String nodeType) {
} this.nodeType = nodeType;
}
public CloudsStormVM osType(String osType) {
this.osType = osType; public CloudsStormVM osType(String osType) {
return this; this.osType = osType;
} return this;
}
/**
* Get osType /**
* @return osType * Get osType
**/ *
@ApiModelProperty(value = "") * @return osType
*
*/
public String getOsType() { @ApiModelProperty(value = "")
return osType;
} public String getOsType() {
return osType;
public void setOsType(String osType) { }
this.osType = osType;
} public void setOsType(String osType) {
this.osType = osType;
public CloudsStormVM script(String script) { }
this.script = script;
return this; public CloudsStormVM script(String script) {
} this.script = script;
return this;
/** }
* Get script
* @return script /**
**/ * Get script
@ApiModelProperty(value = "") *
* @return script
*
public String getScript() { */
return script; @ApiModelProperty(value = "")
}
public void setScript(String script) {
this.script = script;
}
public CloudsStormVM publicAddress(String publicAddress) {
this.publicAddress = publicAddress;
return this;
}
/**
* Get publicAddress
* @return publicAddress
**/
@ApiModelProperty(value = "")
public String getPublicAddress() {
return publicAddress;
}
public void setPublicAddress(String publicAddress) {
this.publicAddress = publicAddress;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CloudsStormVM cloudsStormVM = (CloudsStormVM) o;
return Objects.equals(this.name, cloudsStormVM.name) &&
Objects.equals(this.nodeType, cloudsStormVM.nodeType) &&
Objects.equals(this.osType, cloudsStormVM.osType) &&
Objects.equals(this.script, cloudsStormVM.script) &&
Objects.equals(this.publicAddress, cloudsStormVM.publicAddress);
}
@Override
public int hashCode() {
return Objects.hash(name, nodeType, osType, script, publicAddress);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVM {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" nodeType: ").append(toIndentedString(nodeType)).append("\n");
sb.append(" osType: ").append(toIndentedString(osType)).append("\n");
sb.append(" script: ").append(toIndentedString(script)).append("\n");
sb.append(" publicAddress: ").append(toIndentedString(publicAddress)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
public String getScript() {
return script;
}
public void setScript(String script) {
this.script = script;
}
public CloudsStormVM publicAddress(String publicAddress) {
this.publicAddress = publicAddress;
return this;
}
/**
* Get publicAddress
*
* @return publicAddress
*
*/
@ApiModelProperty(value = "")
public String getPublicAddress() {
return publicAddress;
}
public void setPublicAddress(String publicAddress) {
this.publicAddress = publicAddress;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CloudsStormVM cloudsStormVM = (CloudsStormVM) o;
return Objects.equals(this.name, cloudsStormVM.name)
&& Objects.equals(this.nodeType, cloudsStormVM.nodeType)
&& Objects.equals(this.osType, cloudsStormVM.osType)
&& Objects.equals(this.script, cloudsStormVM.script)
&& Objects.equals(this.publicAddress, cloudsStormVM.publicAddress);
}
@Override
public int hashCode() {
return Objects.hash(name, nodeType, osType, script, publicAddress);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVM {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" nodeType: ").append(toIndentedString(nodeType)).append("\n");
sb.append(" osType: ").append(toIndentedString(osType)).append("\n");
sb.append(" script: ").append(toIndentedString(script)).append("\n");
sb.append(" publicAddress: ").append(toIndentedString(publicAddress)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
...@@ -2,118 +2,90 @@ package nl.uva.sne.drip.model.cloud.storm; ...@@ -2,118 +2,90 @@ 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 {
@JsonProperty("name")
private String name = null;
@JsonProperty("CloudsStormVM") public class CloudsStormVMs {
@Valid
private List<CloudsStormVM> cloudsStormVM = null;
public CloudsStormVMs name(String name) { @JsonProperty("VMs")
this.name = name; @Valid
return this; private List<CloudsStormVM> vms = null;
}
/** public CloudsStormVMs vms(List<CloudsStormVM> vms) {
* Get name this.vms = vms;
* @return name return this;
**/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
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;
}
/** public CloudsStormVMs addVmsItem(CloudsStormVM vmsItem) {
* Get cloudsStormVM if (this.vms == null) {
* @return cloudsStormVM this.vms = new ArrayList<CloudsStormVM>();
**/ }
@ApiModelProperty(value = "") this.vms.add(vmsItem);
return this;
}
@Valid /**
* Get vms
*
* @return vms
*
*/
@ApiModelProperty(value = "")
public List<CloudsStormVM> getCloudsStormVM() { @Valid
return cloudsStormVM;
}
public void setCloudsStormVM(List<CloudsStormVM> cloudsStormVM) { public List<CloudsStormVM> getVms() {
this.cloudsStormVM = cloudsStormVM; return vms;
} }
public void setVms(List<CloudsStormVM> vms) {
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) {
return true; return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CloudsStormVMs cloudsStormVMs = (CloudsStormVMs) o;
return Objects.equals(this.vms, cloudsStormVMs.vms);
} }
if (o == null || getClass() != o.getClass()) {
return false; @Override
public int hashCode() {
return Objects.hash(vms);
} }
CloudsStormVMs cloudsStormVMs = (CloudsStormVMs) o;
return Objects.equals(this.name, cloudsStormVMs.name) &&
Objects.equals(this.cloudsStormVM, cloudsStormVMs.cloudsStormVM);
}
@Override @Override
public int hashCode() { public String toString() {
return Objects.hash(name, cloudsStormVM); StringBuilder sb = new StringBuilder();
} sb.append("class CloudsStormVMs {\n");
@Override sb.append(" vms: ").append(toIndentedString(vms)).append("\n");
public String toString() { sb.append("}");
StringBuilder sb = new StringBuilder(); return sb.toString();
sb.append("class CloudsStormVMs {\n"); }
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" cloudsStormVM: ").append(toIndentedString(cloudsStormVM)).append("\n");
sb.append("}");
return sb.toString();
}
/** /**
* Convert the given object to string with each line indented by 4 spaces * Convert the given object to string with each line indented by 4 spaces
* (except the first line). * (except the first line).
*/ */
private String toIndentedString(java.lang.Object o) { private String toIndentedString(java.lang.Object o) {
if (o == null) { if (o == null) {
return "null"; return "null";
}
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,8 +225,17 @@ class CloudStormService { ...@@ -219,8 +225,17 @@ 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