Commit c95c94cc authored by Spiros Koulouzis's avatar Spiros Koulouzis

add credential to VM topology

parent ddb85e7c
......@@ -3,7 +3,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
tosca.datatypes.ARTICONF.Credential:
derived_from: tosca.datatypes.ARTICONF.Credential
derived_from: tosca.datatypes.Credential
properties:
cloud_provider_name:
type: string
......
......@@ -23,6 +23,7 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate;
......@@ -175,12 +176,25 @@ public class ToscaHelper {
}
}
public void setCredentialsInVMTopology(NodeTemplate vmTopology, Credential credential) throws Exception {
public NodeTemplate setCredentialsInVMTopology(NodeTemplate vmTopology, Credential credential) throws Exception {
if (vmTopology.getType().equals(VM_TOPOLOGY)) {
vmTopology.getAttributes();
Map<String, Object> att = vmTopology.getAttributes();
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);
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.
}
}
......@@ -101,8 +101,8 @@ public class DRIPService {
credentials = credentialService.findByProvider(provider.toLowerCase());
if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials);
helper.setCredentialsInVMTopology(vmTopology, credential);
vmTopology = helper.setCredentialsInVMTopology(vmTopology, credential);
toscaTemplate = helper.setVMTopologyInToscaTemplate(vmTopology);
return toscaTemplate;
}
}
......
......@@ -2,7 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -245,25 +245,25 @@
<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="1825" height="283" key="GridCell.Tab.0.bottom" timestamp="1576165003401">
<state width="1825" height="283" key="GridCell.Tab.0.bottom" timestamp="1576165782177">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="283" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003401" />
<state width="1825" height="283" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1576165782177" />
<state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="1825" height="283" key="GridCell.Tab.0.center" timestamp="1576165003399">
<state width="1825" height="283" key="GridCell.Tab.0.center" timestamp="1576165782175">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="283" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003399" />
<state width="1825" height="283" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1576165782175" />
<state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="1825" height="283" key="GridCell.Tab.0.left" timestamp="1576165003398">
<state width="1825" height="283" key="GridCell.Tab.0.left" timestamp="1576165782174">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="283" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003398" />
<state width="1825" height="283" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1576165782174" />
<state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018570" />
<state width="1825" height="283" key="GridCell.Tab.0.right" timestamp="1576165003400">
<state width="1825" height="283" key="GridCell.Tab.0.right" timestamp="1576165782176">
<screen x="67" y="34" width="1853" height="1046" />
</state>
<state width="1825" height="283" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003400" />
<state width="1825" height="283" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1576165782176" />
<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" />
......
......@@ -20,3 +20,4 @@
description: "The optional user (name or ID) used for non-token based credentials."
cloud_provider_name:
type: "string"
description: "The cloud provider name e.g. ec2."
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