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;
import java.util.Objects;
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 org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* CloudsStormVM
*/
@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 {
@JsonIgnore
private String name = null;
public class CloudsStormVM {
@JsonProperty("nodeType")
private String nodeType = null;
@JsonProperty("name")
private String name = null;
@JsonProperty("OSType")
private String osType = null;
@JsonProperty("nodeType")
private String nodeType = null;
@JsonProperty("script")
private String script = null;
@JsonProperty("OSType")
private String osType = null;
@JsonProperty("publicAddress")
private String publicAddress = null;
@JsonProperty("script")
private String script = null;
public CloudsStormVM name(String name) {
this.name = name;
return this;
}
@JsonProperty("publicAddress")
private String publicAddress = null;
/**
* Get name
* @return name
**/
@ApiModelProperty(value = "")
public CloudsStormVM name(String name) {
this.name = name;
return this;
}
/**
* Get name
*
* @return name
*
*/
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public CloudsStormVM nodeType(String nodeType) {
this.nodeType = nodeType;
return this;
}
public CloudsStormVM nodeType(String nodeType) {
this.nodeType = nodeType;
return this;
}
/**
* Get nodeType
* @return nodeType
**/
@ApiModelProperty(value = "")
public String getNodeType() {
return nodeType;
}
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
public CloudsStormVM osType(String osType) {
this.osType = osType;
return this;
}
/**
* Get osType
* @return osType
**/
@ApiModelProperty(value = "")
public String getOsType() {
return osType;
}
public void setOsType(String osType) {
this.osType = osType;
}
public CloudsStormVM script(String script) {
this.script = script;
return this;
}
/**
* Get script
* @return script
**/
@ApiModelProperty(value = "")
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 ");
}
}
/**
* Get nodeType
*
* @return nodeType
*
*/
@ApiModelProperty(value = "")
public String getNodeType() {
return nodeType;
}
public void setNodeType(String nodeType) {
this.nodeType = nodeType;
}
public CloudsStormVM osType(String osType) {
this.osType = osType;
return this;
}
/**
* Get osType
*
* @return osType
*
*/
@ApiModelProperty(value = "")
public String getOsType() {
return osType;
}
public void setOsType(String osType) {
this.osType = osType;
}
public CloudsStormVM script(String script) {
this.script = script;
return this;
}
/**
* Get script
*
* @return script
*
*/
@ApiModelProperty(value = "")
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;
import java.util.Objects;
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 java.util.ArrayList;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* CloudsStormVMs
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormVMs {
@JsonProperty("name")
private String name = null;
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-30T16:13:55.433Z")
@JsonProperty("CloudsStormVM")
@Valid
private List<CloudsStormVM> cloudsStormVM = null;
public class CloudsStormVMs {
public CloudsStormVMs name(String name) {
this.name = name;
return this;
}
@JsonProperty("VMs")
@Valid
private List<CloudsStormVM> vms = null;
/**
* Get name
* @return name
**/
@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>();
public CloudsStormVMs vms(List<CloudsStormVM> vms) {
this.vms = vms;
return this;
}
this.cloudsStormVM.add(cloudsStormVMItem);
return this;
}
/**
* Get cloudsStormVM
* @return cloudsStormVM
**/
@ApiModelProperty(value = "")
public CloudsStormVMs addVmsItem(CloudsStormVM vmsItem) {
if (this.vms == null) {
this.vms = new ArrayList<CloudsStormVM>();
}
this.vms.add(vmsItem);
return this;
}
@Valid
/**
* Get vms
*
* @return vms
*
*/
@ApiModelProperty(value = "")
public List<CloudsStormVM> getCloudsStormVM() {
return cloudsStormVM;
}
@Valid
public void setCloudsStormVM(List<CloudsStormVM> cloudsStormVM) {
this.cloudsStormVM = cloudsStormVM;
}
public List<CloudsStormVM> getVms() {
return vms;
}
public void setVms(List<CloudsStormVM> vms) {
this.vms = vms;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
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
public int hashCode() {
return Objects.hash(name, cloudsStormVM);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CloudsStormVMs {\n");
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
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();
}
sb.append(" vms: ").append(toIndentedString(vms)).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";
/**
* 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 ");
}
return o.toString().replace("\n", "\n ");
}
}
......@@ -835,7 +835,7 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu/ub1404-v1.0.4.xml"
OS_GUID: "9394ca154aa35eb55e604503ae7943ddaecc6ca5"
DiskSize: 75
- OS: "Ubuntu 16.04"
- OS: "Ubuntu 18.04"
CPU: 4
MEM: 12
VMType: "XOXLarge"
......@@ -845,7 +845,7 @@ DCMetaInfo:
OS_URL: "http://geni-images.renci.org/images/standard/ubuntu-comet/ubuntu-18.04/ubuntu-18.04.xml"
OS_GUID: "fe66b08bffa14c385ad64edd124350a2da826af9"
DiskSize: 75
- OS: "Ubuntu 16.04"
- OS: "Ubuntu 18.04"
CPU: 2
MEM: 6
VMType: "XOLarge"
......
......@@ -24,6 +24,8 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
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.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplateMap;
......@@ -75,7 +77,7 @@ class CloudStormService {
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
writeCloudStormTopologyFiles(topologyTempInputDirPath);
Map<String, Object> subTopologiesAndVMs = writeCloudStormTopologyFiles(topologyTempInputDirPath);
String credentialsTempInputDirPath = tempInputDirPath + File.separator + "credentials";
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
......@@ -88,11 +90,12 @@ class CloudStormService {
if (!(infrasCodeTempInputDir.mkdirs())) {
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;
}
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();
String publicKeyPath = buildSSHKeyPair(tempInputDirPath);
topTopology.setPublicKeyPath(publicKeyPath);
......@@ -103,6 +106,8 @@ class CloudStormService {
topTopology.setTopologies(cloudsStormSubTopology);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "top.yml"), topTopology);
return subTopologiesAndVMs;
}
private String buildSSHKeyPair(String tempInputDirPath) throws JSchException, IOException {
......@@ -138,7 +143,6 @@ class CloudStormService {
CloudsStormVMs cloudsStormVMs = new CloudsStormVMs();
List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0;
for (NodeTemplateMap vmMap : vmTemplatesMap) {
......@@ -151,7 +155,7 @@ class CloudStormService {
vms.add(cloudsStormVM);
j++;
}
cloudsStormVMs.setCloudsStormVM(vms);
cloudsStormVMs.setVms(vms);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "vm_topology" + i + ".yml"), cloudsStormVMs);
cloudsStormVMsList.add(cloudsStormVMs);
cloudsStormSubTopologies.add(cloudsStormSubTopology);
......@@ -168,6 +172,8 @@ class CloudStormService {
String os = helper.getVMNOS(vmMap);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
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())) {
return vmInfo.getVmType();
}
......@@ -219,8 +225,17 @@ class CloudStormService {
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