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 ...@@ -2,6 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
imports: imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml - 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 - 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 - 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 - 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: ...@@ -114,7 +114,7 @@ node_types:
description: The name of the provider e.g. EC2, ExoGeni etc. description: The name of the provider e.g. EC2, ExoGeni etc.
attributes: attributes:
credential: credential:
type: tosca.datatypes.Credential type: tosca.datatypes.ARTICONF.Credential
required: false required: false
interfaces: interfaces:
Standard: Standard:
...@@ -187,8 +187,6 @@ node_types: ...@@ -187,8 +187,6 @@ node_types:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
tosca.nodes.ARTICONF.Infrastructure: tosca.nodes.ARTICONF.Infrastructure:
derived_from: tosca.nodes.ARTICONF.Root derived_from: tosca.nodes.ARTICONF.Root
description: Base infrastructure node description: Base infrastructure node
......
...@@ -26,6 +26,7 @@ import java.util.ArrayList; ...@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import nl.uva.sne.drip.model.NodeTemplate; 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.model.tosca.ToscaTemplate;
import nl.uva.sne.drip.sure.tosca.client.DefaultApi; import nl.uva.sne.drip.sure.tosca.client.DefaultApi;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -174,4 +175,12 @@ public class ToscaHelper { ...@@ -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 { ...@@ -50,9 +50,15 @@ public class DRIPService {
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
helper.uploadToscaTemplate(toscaTemplate); helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) { for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology); 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(); Message message = new Message();
...@@ -90,4 +96,8 @@ public class DRIPService { ...@@ -90,4 +96,8 @@ public class DRIPService {
this.requestQeueName = requestQeueName; this.requestQeueName = requestQeueName;
} }
private Credential getBestCredential(NodeTemplate vmTopology, List<Credential> credentials) {
return credentials.get(0);
}
} }
Credential: Credential:
type: "object" type: "object"
properties: properties:
protocol: protocol:
type: "string" type: "string"
description: "The optional protocol name. e.g. http,xauth,oauth2,ssh"
token_type: token_type:
type: "string" type: "string"
description: "The required token type. default: password. e.g. basic_auth,X-Auth-Token, bearer, identifier"
token: token:
type: "string" 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: keys:
type: object type: object
additionalProperties: additionalProperties:
type: string type: string
description: "The optional list of protocol-specific keys or assertions."
user: user:
type: "string" type: "string"
description: "The optional user (name or ID) used for non-token based credentials."
cloud_provider_name: cloud_provider_name:
type: "string" 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