Commit ec6a10f1 authored by Spiros Koulouzis's avatar Spiros Koulouzis

get available credentials

parent 3310ed45
......@@ -2,6 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- data:
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
......
tosca_definitions_version: tosca_simple_yaml_1_0
data_types:
tosca.datatypes.ARTICONF.Credential:
derived_from: tosca.datatypes.ARTICONF.Credential
properties:
cloud_provider_name:
type: string
required: true
......@@ -114,7 +114,7 @@ node_types:
description: The name of the provider e.g. EC2, ExoGeni etc.
attributes:
credential:
type: tosca.datatypes.Credential
type: tosca.datatypes.ARTICONF.Credential
required: false
interfaces:
Standard:
......@@ -187,8 +187,6 @@ node_types:
Standard:
create: dumy.yaml
tosca.nodes.ARTICONF.Infrastructure:
derived_from: tosca.nodes.ARTICONF.Root
description: Base infrastructure node
......
......@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
import org.apache.commons.io.FileUtils;
......@@ -174,4 +175,12 @@ public class ToscaHelper {
}
}
public void setCredentialsInVMTopology(NodeTemplate vmTopology, Credential credential) throws Exception {
if (vmTopology.getType().equals(VM_TOPOLOGY)) {
vmTopology.getAttributes();
} else {
throw new Exception("NodeTemplate is not of type: " + VM_TOPOLOGY + " it is of type: " + vmTopology.getType());
}
}
}
......@@ -50,9 +50,15 @@ public class DRIPService {
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology);
List<Credential> credentials = credentialService.findByProvider(provider);
credentials = credentialService.findByProvider(provider.toLowerCase());
if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials);
helper.setCredentialsInVMTopology(vmTopology, credential);
break;
}
}
Message message = new Message();
......@@ -90,4 +96,8 @@ public class DRIPService {
this.requestQeueName = requestQeueName;
}
private Credential getBestCredential(NodeTemplate vmTopology, List<Credential> credentials) {
return credentials.get(0);
}
}
Credential:
Credential:
type: "object"
properties:
protocol:
type: "string"
description: "The optional protocol name. e.g. http,xauth,oauth2,ssh"
token_type:
type: "string"
description: "The required token type. default: password. e.g. basic_auth,X-Auth-Token, bearer, identifier"
token:
type: "string"
description: "The required token used as a credential for authorization or access to a networked resource. e.g. mypassword, myusername:mypassword, 604bbe45ac7143a79e14f3158df67091, keypair_id"
keys:
type: object
additionalProperties:
type: string
description: "The optional list of protocol-specific keys or assertions."
user:
type: "string"
description: "The optional user (name or ID) used for non-token based credentials."
cloud_provider_name:
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