Commit c10f0682 authored by Spiros Koulouzis's avatar Spiros Koulouzis

write cloud storm files

parent 8f3f9331
......@@ -46,6 +46,7 @@ public class ToscaHelper {
private static final String VM_NUM_OF_CORES = "num_cores";
private static final String MEM_SIZE = "mem_size";
private static final String VM_OS = "os";
private static final String VM_TOPOLOGY = "tosca.nodes.ARTICONF.VM.topology";
/**
* @return the id
......@@ -148,4 +149,20 @@ public class ToscaHelper {
}
}
public String getTopologyDomain(NodeTemplate nodeTemplate) throws Exception {
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("domain");
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
public String getTopologyProvider(NodeTemplate nodeTemplate) throws Exception {
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
return (String) nodeTemplate.getProperties().get("provider");
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
}
......@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model;
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;
......@@ -18,7 +19,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-10T16:27:40.329Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class NodeTemplate {
@JsonProperty("derived_from")
......
package nl.uva.sne.drip.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
......@@ -11,7 +12,7 @@ import org.springframework.data.annotation.Id;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T11:37:55.458Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class User {
@JsonProperty("id")
......
......@@ -3,6 +3,7 @@ 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 org.springframework.validation.annotation.Validated;
......@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudDB {
@JsonProperty("cloudProvider")
private String cloudProvider = null;
......
......@@ -3,6 +3,7 @@ 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 org.springframework.validation.annotation.Validated;
......@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubMembers {
@JsonProperty("vmName")
private String vmName = null;
......
......@@ -3,6 +3,7 @@ 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 org.springframework.validation.annotation.Validated;
......@@ -14,7 +15,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubTopology {
@JsonProperty("topology")
private String topology = null;
......
......@@ -3,6 +3,7 @@ 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 nl.uva.sne.drip.model.cloud.storm.CloudsStormSubMembers;
......@@ -17,7 +18,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormSubnets {
@JsonProperty("name")
private String name = null;
......
......@@ -3,6 +3,7 @@ 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 nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
......@@ -18,7 +19,7 @@ import javax.validation.constraints.*;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CloudsStormTopTopology {
@JsonProperty("userName")
private String userName = null;
......
/*
* Copyright 2019 S. Koulouzis
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
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.*;
/**
*
* @author S. Koulouzis
* CloudsStormVM
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2019-12-09T16:51:48.830052+01:00[Europe/Amsterdam]")
public class CloudsStormVM {
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T19:44:34.555Z")
public static final String SERIALIZED_NAME_NODE_TYPE = "nodeType";
@SerializedName(SERIALIZED_NAME_NODE_TYPE)
private String nodeType;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonRootName(value = "VMs")
public class CloudsStormVM {
@JsonIgnore
private String name = null;
public static final String SERIALIZED_NAME_OS_TYPE = "OSType";
@SerializedName(SERIALIZED_NAME_OS_TYPE)
private String osType;
@JsonProperty("nodeType")
private String nodeType = null;
public static final String SERIALIZED_NAME_SCRIPT = "script";
@SerializedName(SERIALIZED_NAME_SCRIPT)
private String script;
@JsonProperty("OSType")
private String osType = null;
public static final String SERIALIZED_NAME_PUBLIC_ADDRESS = "publicAddress";
@SerializedName(SERIALIZED_NAME_PUBLIC_ADDRESS)
private String publicAddress;
@JsonProperty("script")
private String script = null;
@JsonProperty("publicAddress")
private String publicAddress = null;
public CloudsStormVM name(String name) {
this.name = name;
return this;
}
/**
/**
* Get name
* @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CloudsStormVM nodeType(String nodeType) {
this.nodeType = nodeType;
return this;
}
/**
/**
* Get nodeType
* @return nodeType
**/
@javax.annotation.Nullable
@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
**/
@javax.annotation.Nullable
@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
**/
@javax.annotation.Nullable
@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
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")
public String getPublicAddress() {
return publicAddress;
}
public void setPublicAddress(String publicAddress) {
this.publicAddress = publicAddress;
}
......@@ -182,11 +158,11 @@ public class CloudsStormVM {
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");
......@@ -206,6 +182,5 @@ public class CloudsStormVM {
}
return o.toString().replace("\n", "\n ");
}
}
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;
@JsonProperty("CloudsStormVM")
@Valid
private List<CloudsStormVM> cloudsStormVM = null;
public CloudsStormVMs name(String name) {
this.name = name;
return this;
}
/**
* 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>();
}
this.cloudsStormVM.add(cloudsStormVMItem);
return this;
}
/**
* Get cloudsStormVM
* @return cloudsStormVM
**/
@ApiModelProperty(value = "")
@Valid
public List<CloudsStormVM> getCloudsStormVM() {
return cloudsStormVM;
}
public void setCloudsStormVM(List<CloudsStormVM> cloudsStormVM) {
this.cloudsStormVM = cloudsStormVM;
}
@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.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");
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
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
package nl.uva.sne.drip.model.cloud.storm;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
......@@ -13,7 +14,7 @@ import javax.validation.Valid;
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:52:11.688Z")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DB {
@JsonProperty("cloudDBs")
......
......@@ -243,22 +243,22 @@
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" />
<state width="2465" height="410" key="GridCell.Tab.0.bottom" timestamp="1576064606672">
<state width="2465" height="410" key="GridCell.Tab.0.bottom" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606672" />
<state width="2465" height="410" key="GridCell.Tab.0.center" timestamp="1576064606669">
<state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.center" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606669" />
<state width="2465" height="410" key="GridCell.Tab.0.left" timestamp="1576064606668">
<state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.left" timestamp="1576092018570">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606668" />
<state width="2465" height="410" key="GridCell.Tab.0.right" timestamp="1576064606671">
<state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018570" />
<state width="2465" height="410" key="GridCell.Tab.0.right" timestamp="1576092018571">
<screen x="67" y="34" width="2493" height="1406" />
</state>
<state width="2465" height="410" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1576064606671" />
<state width="2465" height="410" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="471" key="GridCell.Tab.1.bottom" timestamp="1575891470098">
<screen x="67" y="34" width="2493" height="1406" />
</state>
......
......@@ -6,6 +6,10 @@
package nl.uva.sne.drip.provisioner;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
......@@ -13,6 +17,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -22,6 +27,7 @@ import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVMs;
import nl.uva.sne.drip.model.cloud.storm.VMMetaInfo;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
......@@ -34,10 +40,11 @@ import org.apache.commons.io.FilenameUtils;
class CloudStormService {
private List<Map.Entry> vmTopologies;
private String tempInputDirPath;
// private String tempInputDirPath;
private final ToscaTemplate toscaTemplate;
private final ToscaHelper helper;
private final CloudStormDAO cloudStormDAO;
private final ObjectMapper objectMapper;
CloudStormService(Properties properties, ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException {
this.toscaTemplate = toscaTemplate;
......@@ -45,33 +52,38 @@ class CloudStormService {
cloudStormDAO = new CloudStormDAO(cloudStormDBPath);
String sureToscaBasePath = properties.getProperty("sure-tosca.base.path");
this.helper = new ToscaHelper(toscaTemplate, sureToscaBasePath);
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException, Exception {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
buildCloudStormTopTopology(toscaTemplate);
writeCloudStormTopology(toscaTemplate, tempInputDirPath);
return toscaTemplate;
}
private CloudsStormTopTopology buildCloudStormTopTopology(ToscaTemplate toscaTemplate) throws JSchException, IOException, ApiException, Exception {
private void writeCloudStormTopology(ToscaTemplate toscaTemplate, String tempInputDirPath) throws JSchException, IOException, ApiException, Exception {
CloudsStormTopTopology topTopology = new CloudsStormTopTopology();
String publicKeyPath = buildSSHKeyPair();
String publicKeyPath = buildSSHKeyPair(tempInputDirPath);
topTopology.setPublicKeyPath(publicKeyPath);
topTopology.setUserName(getUserName());
List<CloudsStormSubTopology> topologies = getCloudsStormSubTopologies(toscaTemplate);
topTopology.setTopologies(topologies);
Map<String, Object> subTopologiesAndVMs = getCloudsStormSubTopologiesAndVMs(toscaTemplate, tempInputDirPath);
List<CloudsStormSubTopology> cloudsStormSubTopology = (List<CloudsStormSubTopology>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
topTopology.setTopologies(cloudsStormSubTopology);
return topTopology;
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "top.yml"), topTopology);
// <CloudsStormVMs > cloudsStormVMsList = (List<CloudsStormVMs>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
}
private String buildSSHKeyPair() throws JSchException, IOException {
private String buildSSHKeyPair(String tempInputDirPath) throws JSchException, IOException {
String userPublicKeyName = "id_rsa.pub";
String publicKeyPath = "name@" + userPublicKeyName;
JSch jsch = new JSch();
......@@ -87,33 +99,46 @@ class CloudStormService {
return "vm_user";
}
private List<CloudsStormSubTopology> getCloudsStormSubTopologies(ToscaTemplate toscaTemplate) throws ApiException, IOException, Exception {
private Map<String, Object> getCloudsStormSubTopologiesAndVMs(ToscaTemplate toscaTemplate, String tempInputDirPath) throws ApiException, IOException, Exception {
List<NodeTemplate> vmTopologyTemplates = helper.getVMTopologyTemplates();
List<CloudsStormSubTopology> cloudsStormSubTopologies = new ArrayList<>();
Map<String, Object> cloudsStormMap = new HashMap<>();
List<CloudsStormVMs> cloudsStormVMsList = new ArrayList<>();
int i = 0;
for (NodeTemplate nodeTemplate : vmTopologyTemplates) {
CloudsStormSubTopology cloudsStormSubTopology = new CloudsStormSubTopology();
Map<String, Object> properties = nodeTemplate.getProperties();
String domain = (String) properties.get("domain");
String provider = (String) properties.get("provider");
String domain = helper.getTopologyDomain(nodeTemplate);
String provider = helper.getTopologyProvider(nodeTemplate);
cloudsStormSubTopology.setDomain(domain);
cloudsStormSubTopology.setCloudProvider(provider);
cloudsStormSubTopology.setTopology("vm_topology" + i);
cloudsStormSubTopology.setStatus("fresh");
CloudsStormVMs cloudsStormVMs = new CloudsStormVMs();
List<NodeTemplate> vmTemplates = helper.getTopologyTemplateVMs(nodeTemplate);
List<CloudsStormVM> vms = new ArrayList<>();
cloudsStormVMs.setName("vm_topology" + i);
List<NodeTemplate> vmTemplates = helper.getTopologyTemplateVMs(nodeTemplate);
int j = 0;
for (NodeTemplate vm : vmTemplates) {
CloudsStormVM cloudsStormVM = new CloudsStormVM();
String vmType = getVMType(vm, provider);
cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vm);
cloudsStormVM.setOsType(os);
vms.add(cloudsStormVM);
j++;
}
cloudsStormVMs.setCloudsStormVM(vms);
objectMapper.writeValue(new File(tempInputDirPath + File.separator + "vm_topology" + i + ".yml"), cloudsStormVMs);
cloudsStormVMsList.add(cloudsStormVMs);
cloudsStormSubTopologies.add(cloudsStormSubTopology);
i++;
}
return cloudsStormSubTopologies;
cloudsStormMap.put("cloud_storm_vm", cloudsStormVMsList);
cloudsStormMap.put("cloud_storm_subtopologies", cloudsStormSubTopologies);
return cloudsStormMap;
}
private String getVMType(NodeTemplate vm, String provider) throws IOException, Exception {
......@@ -122,14 +147,10 @@ class CloudStormService {
String os = helper.getVMNOS(vm);
List<VMMetaInfo> vmInfos = cloudStormDAO.findVmMetaInfoByProvider(provider);
for (VMMetaInfo vmInfo : vmInfos) {
System.err.println("numOfCores: " + numOfCores + " = " + vmInfo.getCPU());
System.err.println("memSize: " + numOfCores + " = " + vmInfo.getMEM());
System.err.println("os: " + os + " = " + vmInfo.getOS());
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 null;
}
......
......@@ -9,10 +9,3 @@
type: "string"
status:
type: "string"
#VMs:
#type: array
#items:
#$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormVM.yml#/CloudsStormVM'
......@@ -11,4 +11,3 @@
type: array
items:
$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubMembers.yml#/CloudsStormSubMembers'
......@@ -14,3 +14,6 @@
items:
$ref: 'https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormSubnets.yml#/CloudsStormSubnets'
CloudsStormVMs:
type: "object"
properties:
name:
type: "string"
CloudsStormVM:
type: "array"
items:
$ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/CloudStorm/CloudsStormVM.yml#/CloudsStormVM"
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