Commit 321fbae0 authored by Spiros Koulouzis's avatar Spiros Koulouzis

set tosca template attributes

parent 2a9b1fb1
......@@ -12,14 +12,9 @@ import javax.validation.Valid;
* CloudsStormVMs
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-30T16:13:55.433Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-01-12T18:26:54.530Z")
public class CloudsStormVMs {
@JsonProperty("SEngineClass")
private String sEngineClass;
@JsonProperty("VMs")
@Valid
......
......@@ -2,20 +2,17 @@ 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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import nl.uva.sne.drip.model.cloud.storm.DCMetaInfo;
import org.springframework.validation.annotation.Validated;
import javax.validation.Valid;
import javax.validation.constraints.*;
/**
* DBInfo
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-01-12T18:26:54.530Z")
public class DBInfo {
......@@ -23,6 +20,7 @@ public class DBInfo {
private String globalEntry = null;
@JsonProperty("DCMetaInfo")
@Valid
private List<DCMetaInfo> dcMetaInfo = null;
public DBInfo globalEntry(String globalEntry) {
......@@ -34,7 +32,7 @@ public class DBInfo {
* Get globalEntry
*
* @return globalEntry
*
*
*/
@ApiModelProperty(value = "")
......@@ -51,11 +49,19 @@ public class DBInfo {
return this;
}
public DBInfo addDcMetaInfoItem(DCMetaInfo dcMetaInfoItem) {
if (this.dcMetaInfo == null) {
this.dcMetaInfo = new ArrayList<DCMetaInfo>();
}
this.dcMetaInfo.add(dcMetaInfoItem);
return this;
}
/**
* Get dcMetaInfo
*
* @return dcMetaInfo
*
*
*/
@ApiModelProperty(value = "")
......
......@@ -3,6 +3,7 @@ package nl.uva.sne.drip.model.cloud.storm;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -13,7 +14,7 @@ import javax.validation.Valid;
* DCMetaInfo
*/
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-12-11T15:13:55.016Z")
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2020-01-12T18:26:54.530Z")
public class DCMetaInfo {
......@@ -36,6 +37,7 @@ public class DCMetaInfo {
private String availability = null;
@JsonProperty("VMMetaInfo")
@Valid
private List<CloudsStormVM> vmMetaInfo = null;
@JsonProperty("extraInfo")
......@@ -51,7 +53,7 @@ public class DCMetaInfo {
* Get domain
*
* @return domain
*
*
*/
@ApiModelProperty(value = "")
......@@ -72,7 +74,7 @@ public class DCMetaInfo {
* Get endpoint
*
* @return endpoint
*
*
*/
@ApiModelProperty(value = "")
......@@ -93,7 +95,7 @@ public class DCMetaInfo {
* Get country
*
* @return country
*
*
*/
@ApiModelProperty(value = "")
......@@ -114,7 +116,7 @@ public class DCMetaInfo {
* Get longitude
*
* @return longitude
*
*
*/
@ApiModelProperty(value = "")
......@@ -135,7 +137,7 @@ public class DCMetaInfo {
* Get latitude
*
* @return latitude
*
*
*/
@ApiModelProperty(value = "")
......@@ -156,7 +158,7 @@ public class DCMetaInfo {
* Get availability
*
* @return availability
*
*
*/
@ApiModelProperty(value = "")
......@@ -173,11 +175,19 @@ public class DCMetaInfo {
return this;
}
public DCMetaInfo addVmMetaInfoItem(CloudsStormVM vmMetaInfoItem) {
if (this.vmMetaInfo == null) {
this.vmMetaInfo = new ArrayList<CloudsStormVM>();
}
this.vmMetaInfo.add(vmMetaInfoItem);
return this;
}
/**
* Get vmMetaInfo
*
* @return vmMetaInfo
*
*
*/
@ApiModelProperty(value = "")
......@@ -208,7 +218,7 @@ public class DCMetaInfo {
* Get extraInfo
*
* @return extraInfo
*
*
*/
@ApiModelProperty(value = "")
......
......@@ -18,6 +18,7 @@ import nl.uva.sne.drip.model.cloud.storm.CloudDB;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.cloud.storm.DB;
import nl.uva.sne.drip.model.cloud.storm.DBInfo;
import nl.uva.sne.drip.model.cloud.storm.DCMetaInfo;
/**
*
......@@ -51,8 +52,8 @@ class CloudStormDAO {
List<CloudsStormVM> vMMetaInfos = new ArrayList<>();
DBInfo dbInfo = objectMapper.readValue(new File(cloudStormDBPath + File.separator + targetCloudDB.getDbInfoFile()), DBInfo.class);
List<CloudsStormVM> metaInfos = dbInfo.getDcMetaInfo();
for (CloudsStormVM metaInfo : metaInfos) {
List<DCMetaInfo> metaInfos = dbInfo.getDcMetaInfo();
for (DCMetaInfo metaInfo : metaInfos) {
vMMetaInfos.addAll(metaInfo.getVmMetaInfo());
}
return vMMetaInfos;
......
......@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.uva.sne.drip.commons.utils.Converter;
......@@ -176,7 +175,8 @@ class CloudStormService {
cloudsStormVM.setNodeType(vmType);
cloudsStormVM.setName("vm" + j);
String os = helper.getVMNOS(vmMap);
cloudsStormVM.setOsType(os);
cloudsStormVM.setOS(os);
cloudsStormVM.setOstype(os);
vms.add(cloudsStormVM);
j++;
}
......@@ -200,8 +200,8 @@ class CloudStormService {
for (CloudsStormVM vmInfo : vmInfos) {
Logger.getLogger(CloudStormService.class.getName()).log(Level.FINE, "vmInfo: {0}", vmInfo);
Logger.getLogger(CloudStormService.class.getName()).log(Level.FINE, "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();
}
}
......@@ -303,20 +303,6 @@ class CloudStormService {
}
att.put("status", subTopology.getStatus().toString());
CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology()),
CloudsStormVMs.class);
List<CloudsStormVM> vms = cloudsStormVMs.getVms();
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0;
for (CloudsStormVM vm : vms) {
NodeTemplateMap vmTemplateMap = vmTemplatesMap.get(j);
Map<String, Object> vmAttributes = vmTemplateMap.getNodeTemplate().getAttributes();
if (vmAttributes==null){
vmAttributes = new HashMap<>();
}
vmAttributes.put("private_ip", vm.get);
}
String rootKeyPairFolder = tempInputDirPath + TOPOLOGY_RELATIVE_PATH
+ TOP_TOPOLOGY_FILE_NAME + File.separator + subTopology.getSshKeyPairId();
Credential rootKeyPairCredential = new Credential();
......@@ -329,12 +315,36 @@ class CloudStormService {
String userKyePairFolder = tempInputDirPath + TOPOLOGY_RELATIVE_PATH
+ TOP_TOPOLOGY_FILE_NAME;
Credential userKeyPairCredential = new Credential();
rootKeyPairCredential.setProtocol("ssh");
userKeyPairCredential.setProtocol("ssh");
keys = new HashMap<>();
keys.put("private_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa"));
keys.put("public_key", Converter.encodeFileToBase64Binary(userKyePairFolder + File.separator + "id_rsa.pub"));
userKeyPairCredential.setKeys(keys);
CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology()),
CloudsStormVMs.class);
List<CloudsStormVM> vms = cloudsStormVMs.getVms();
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
int j = 0;
for (CloudsStormVM vm : vms) {
NodeTemplateMap vmTemplateMap = vmTemplatesMap.get(j);
Map<String, Object> vmAttributes = vmTemplateMap.getNodeTemplate().getAttributes();
if (vmAttributes == null) {
vmAttributes = new HashMap<>();
}
vmAttributes.put("private_ip", vm.getSelfEthAddresses());
vmAttributes.put("public_ip", vm.getPublicAddress());
if (j > 0) {
vmAttributes.put("role", "master");
} else {
vmAttributes.put("role", "worker");
}
vmAttributes.put("node_type", vm.getNodeType());
vmAttributes.put("host_name", vm.getName());
vmAttributes.put("root_key_pair", rootKeyPairCredential);
vmAttributes.put("user_key_pair", userKeyPairCredential);
}
}
return null;
}
......
......@@ -31,5 +31,9 @@
type: "string"
availability:
type: "string"
selfEthAddresses:
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