Commit 65d5c5d3 authored by Spiros Koulouzis's avatar Spiros Koulouzis

returned provisoned tosca

parent 831c481b
......@@ -209,20 +209,12 @@ public class ToscaHelper {
}
}
public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplateMap vmTopologyMap) {
public ToscaTemplate setNodeInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplateMap node) {
Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates();
nodes.put(vmTopologyMap.getName(), vmTopologyMap.getNodeTemplate());
nodes.put(node.getName(), node.getNodeTemplate());
return toscaTemplate;
}
// public Map<String, Object> getProvisionInterface(Provisioner provisioner, String operation) throws ApiException {
// List<String> toscaInterfaceTypes = new ArrayList<>();
// toscaInterfaceTypes.add(provisioner.getToscaInterfaceType());
// List<Map<String, Object>> definitions = getProvisionInterfaceDefinitions(toscaInterfaceTypes);
// Map<String, Object> definition = getBestProvisionInterfaceDefinition(definitions);
// Map<String, Object> provisionInterface = getProvisionInterfaceInstanceDefaultValues(definition, operation);
// return provisionInterface;
// }
public Map<String, Object> getProvisionerInterfaceFromVMTopology(NodeTemplateMap vmTopologyMap) {
return (Map<String, Object>) vmTopologyMap.getNodeTemplate().getInterfaces().get("CloudsStorm");
}
......
......@@ -203,7 +203,7 @@ public class ToscaHelperTest {
credential.setTokenType("passwrd");
credential.setUser("user");
vmTopologyMap = instance.setCredentialsInVMTopology(vmTopologyMap, credential);
toscaTemplateWithCredentials = instance.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap);
toscaTemplateWithCredentials = instance.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
}
instance.uploadToscaTemplate(toscaTemplateWithCredentials);
......@@ -246,7 +246,7 @@ public class ToscaHelperTest {
// }
// }
// vmTopologyMap = instance.setProvisionerInterfaceInVMTopology(vmTopologyMap, provisionInterface);
// toscaTemplateWithInterface = instance.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap);
// toscaTemplateWithInterface = instance.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
//// }
// instance.uploadToscaTemplate(toscaTemplateWithInterface);
// topology_1 = toscaTemplateWithCredentials.getTopologyTemplate().getNodeTemplates().get("topology_1");
......
......@@ -106,7 +106,7 @@ public class DRIPService {
} else {
Credential credential = getBestCredential(credentials);
vmTopologyMap = helper.setCredentialsInVMTopology(vmTopologyMap, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap);
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
}
}
......@@ -142,7 +142,7 @@ public class DRIPService {
provisionMap.put("inputs", inputsMap);
provisionerInterface.put(operation, caller);
vmTopologyMap = helper.setProvisionerInterfaceInVMTopology(vmTopologyMap, provisionerInterface);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate, vmTopologyMap);
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
}
}
return toscaTemplate;
......
......@@ -68,9 +68,10 @@ class CloudStormService {
private final String TOPOLOGY_RELATIVE_PATH = File.separator
+ INFS_FOLDER_NAME + File.separator + TOPOLOGY_FOLDER_NAME + File.separator;
private ToscaTemplate toscaTemplate;
CloudStormService(Properties properties, ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException {
// this.toscaTemplate = toscaTemplate;
this.toscaTemplate = toscaTemplate;
cloudStormDBPath = properties.getProperty("cloud.storm.db.path");
cloudStormDAO = new CloudStormDAO(cloudStormDBPath);
String sureToscaBasePath = properties.getProperty("sure-tosca.base.path");
......@@ -119,7 +120,7 @@ class CloudStormService {
writeCloudStormInfrasCodeFiles(infrasCodeTempInputDirPath, cloudStormSubtopologies);
ToscaTemplate toscaTemplate = runCloudStorm(tempInputDirPath);
helper.uploadToscaTemplate(toscaTemplate);
return toscaTemplate;
}
......@@ -296,8 +297,9 @@ class CloudStormService {
List<NodeTemplateMap> vmTopologiesMaps = helper.getVMTopologyTemplates();
int i = 0;
for (CloudsStormSubTopology subTopology : subTopologies) {
NodeTemplateMap nodeTemplateMap = vmTopologiesMaps.get(i);
Map<String, Object> att = nodeTemplateMap.getNodeTemplate().getAttributes();
NodeTemplateMap vmTopologyMap = vmTopologiesMaps.get(i);
Map<String, Object> att = vmTopologyMap.getNodeTemplate().getAttributes();
if (att == null) {
att = new HashMap<>();
}
......@@ -320,10 +322,10 @@ class CloudStormService {
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()+".yml"),
CloudsStormVMs cloudsStormVMs = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH + File.separator + subTopology.getTopology() + ".yml"),
CloudsStormVMs.class);
List<CloudsStormVM> vms = cloudsStormVMs.getVms();
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(nodeTemplateMap);
List<NodeTemplateMap> vmTemplatesMap = helper.getTemplateVMsForVMTopology(vmTopologyMap);
int j = 0;
for (CloudsStormVM vm : vms) {
NodeTemplateMap vmTemplateMap = vmTemplatesMap.get(j);
......@@ -334,18 +336,21 @@ class CloudStormService {
vmAttributes.put("private_ip", vm.getSelfEthAddresses());
vmAttributes.put("public_ip", vm.getPublicAddress());
if (j > 0) {
vmAttributes.put("role", "master");
} else {
vmAttributes.put("role", "worker");
} else {
vmAttributes.put("role", "master");
}
vmAttributes.put("node_type", vm.getNodeType());
vmAttributes.put("host_name", vm.getName());
vmAttributes.put("root_key_pair", rootKeyPairCredential);
vmAttributes.put("user_key_pair", userKeyPairCredential);
vmTemplateMap.getNodeTemplate().setAttributes(vmAttributes);
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTemplateMap);
}
toscaTemplate = helper.setNodeInToscaTemplate(toscaTemplate, vmTopologyMap);
}
return null;
return toscaTemplate;
}
}
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