Commit b611da67 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added NodeTemplateMap

parent c95c94cc
......@@ -153,7 +153,7 @@ node_types:
os:
type: string
required: true
default: "Ubuntu 14.04"
default: "Ubuntu 18.04"
# outputs for this node
attributes:
private_ip:
......
......@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
......@@ -179,6 +180,9 @@ public class ToscaHelper {
public NodeTemplate setCredentialsInVMTopology(NodeTemplate vmTopology, Credential credential) throws Exception {
if (vmTopology.getType().equals(VM_TOPOLOGY)) {
Map<String, Object> att = vmTopology.getAttributes();
if (att == null) {
att = new HashMap<>();
}
Map<String, Object> toscaCredential = new HashMap<>();
toscaCredential.put("protocol", credential.getProtocol());
toscaCredential.put("token_type", credential.getTokenType());
......@@ -187,14 +191,39 @@ public class ToscaHelper {
toscaCredential.put("user", credential.getUser());
toscaCredential.put("cloud_provider_name", credential.getCloudProviderName());
att.put("credential", toscaCredential);
vmTopology.setAttributes(att);
return vmTopology;
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + vmTopology.getType());
}
}
public ToscaTemplate setVMTopologyInToscaTemplate(NodeTemplate vmTopology) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
public Credential getCredentialsFromVMTopology(NodeTemplate vmTopology) throws Exception {
if (vmTopology.getType().equals(VM_TOPOLOGY)) {
Map<String, Object> att = vmTopology.getAttributes();
Object credentialMap = att.get("credential");
// Map<String, Object> toscaCredential = new HashMap<>();
// toscaCredential.put("protocol", credential.getProtocol());
// toscaCredential.put("token_type", credential.getTokenType());
// toscaCredential.put("token", credential.getToken());
// toscaCredential.put("keys", credential.getKeys());
// toscaCredential.put("user", credential.getUser());
// toscaCredential.put("cloud_provider_name", credential.getCloudProviderName());
// att.put("credential", toscaCredential);
// vmTopology.setAttributes(att);
// return vmTopology;
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + vmTopology.getType());
}
return null;
}
public ToscaTemplate setVMTopologyInToscaTemplate(ToscaTemplate toscaTemplate, NodeTemplate vmTopology) {
Map<String, NodeTemplate> nodes = toscaTemplate.getTopologyTemplate().getNodeTemplates();
Set<String> keys = nodes.keySet();
for(String key :keys){
NodeTemplate node = nodes.get(key);
}
}
}
......@@ -102,11 +102,11 @@ public class DRIPService {
if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials);
vmTopology = helper.setCredentialsInVMTopology(vmTopology, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(vmTopology);
toscaTemplate = helper.setVMTopologyInToscaTemplate(toscaTemplate,vmTopology);
return toscaTemplate;
}
}
return toscaTemplate;
return null;
}
}
......@@ -29,6 +29,7 @@ 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.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.apache.commons.io.FilenameUtils;
......@@ -64,20 +65,20 @@ class CloudStormService {
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
String topologyTempInputDirPath = File.separator + "topology";
String topologyTempInputDirPath = tempInputDirPath + File.separator + "topology";
File topologyTempInputDir = new File(topologyTempInputDirPath);
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
writeCloudStormTopologyFiles(toscaTemplate, topologyTempInputDirPath);
String credentialsTempInputDirPath = File.separator + "credentials";
String credentialsTempInputDirPath = tempInputDirPath + File.separator + "credentials";
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
writeCloudStormCredentialsFiles(toscaTemplate, credentialsTempInputDirPath);
String infrasCodeTempInputDirPath = File.separator + "infrasCodes";
String infrasCodeTempInputDirPath = tempInputDirPath + File.separator + "infrasCodes";
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
......@@ -172,8 +173,11 @@ class CloudStormService {
return null;
}
private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) {
private void writeCloudStormCredentialsFiles(ToscaTemplate toscaTemplate, String credentialsTempInputDirPath) throws ApiException, Exception {
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplate vmTopology : vmTopologies) {
Credential credentials = helper.getCredentialsFromVMTopology(vmTopology);
}
}
}
NodeTemplateMap:
type: "object"
properties:
name:
type: "string"
nodeTemplate:
type: $ref: "https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/openAPI/schema/TOSCA/NodeTemplate.yml#/NodeTemplate"
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