Commit ddb85e7c authored by Spiros Koulouzis's avatar Spiros Koulouzis

check if we plan or provision

parent ec6a10f1
...@@ -2,7 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0 ...@@ -2,7 +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: - data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- 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
......
...@@ -48,17 +48,8 @@ public class DRIPService { ...@@ -48,17 +48,8 @@ public class DRIPService {
caller.init(); caller.init();
String ymlToscaTemplate = toscaTemplateService.findByID(id); String ymlToscaTemplate = toscaTemplateService.findByID(id);
ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate); ToscaTemplate toscaTemplate = toscaTemplateService.getYaml2ToscaTemplate(ymlToscaTemplate);
helper.uploadToscaTemplate(toscaTemplate); if (requestQeueName.equals("provisioner")) {
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates(); toscaTemplate = addCredentials(toscaTemplate);
List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology);
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();
...@@ -69,6 +60,7 @@ public class DRIPService { ...@@ -69,6 +60,7 @@ public class DRIPService {
caller.setRequestQeueName(requestQeueName); caller.setRequestQeueName(requestQeueName);
Message plannerResponse = caller.call(message); Message plannerResponse = caller.call(message);
ToscaTemplate plannedToscaTemplate = plannerResponse.getToscaTemplate(); ToscaTemplate plannedToscaTemplate = plannerResponse.getToscaTemplate();
return toscaTemplateService.save(plannedToscaTemplate); return toscaTemplateService.save(plannedToscaTemplate);
} catch (IOException | TimeoutException | InterruptedException ex) { } catch (IOException | TimeoutException | InterruptedException ex) {
Logger.getLogger(DRIPService.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(DRIPService.class.getName()).log(Level.SEVERE, null, ex);
...@@ -100,4 +92,21 @@ public class DRIPService { ...@@ -100,4 +92,21 @@ public class DRIPService {
return credentials.get(0); return credentials.get(0);
} }
private ToscaTemplate addCredentials(ToscaTemplate toscaTemplate) throws IOException, JsonProcessingException, ApiException, Exception {
helper.uploadToscaTemplate(toscaTemplate);
List<NodeTemplate> vmTopologies = helper.getVMTopologyTemplates();
List<Credential> credentials = null;
for (NodeTemplate vmTopology : vmTopologies) {
String provider = helper.getTopologyProvider(vmTopology);
credentials = credentialService.findByProvider(provider.toLowerCase());
if (credentials != null && credentials.size() > 0) {
Credential credential = getBestCredential(vmTopology, credentials);
helper.setCredentialsInVMTopology(vmTopology, credential);
return toscaTemplate;
}
}
return toscaTemplate;
}
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="e478ccae-5352-4e8e-9efb-3f5cda44e877" name="Default Changelist" comment="" /> <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" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -243,21 +245,25 @@ ...@@ -243,21 +245,25 @@
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
</state> </state>
<state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" /> <state x="1043" y="437" width="530" height="598" key="FileChooserDialogImpl/67.34.2493.1406@67.34.2493.1406" timestamp="1575907769017" />
<state width="2465" height="410" key="GridCell.Tab.0.bottom" timestamp="1576092018571"> <state width="1825" height="283" key="GridCell.Tab.0.bottom" timestamp="1576165003401">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="283" key="GridCell.Tab.0.bottom/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003401" />
<state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" /> <state width="2465" height="410" key="GridCell.Tab.0.bottom/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.center" timestamp="1576092018571"> <state width="1825" height="283" key="GridCell.Tab.0.center" timestamp="1576165003399">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="283" key="GridCell.Tab.0.center/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003399" />
<state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" /> <state width="2465" height="410" key="GridCell.Tab.0.center/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" />
<state width="2465" height="410" key="GridCell.Tab.0.left" timestamp="1576092018570"> <state width="1825" height="283" key="GridCell.Tab.0.left" timestamp="1576165003398">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="283" key="GridCell.Tab.0.left/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003398" />
<state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018570" /> <state width="2465" height="410" key="GridCell.Tab.0.left/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018570" />
<state width="2465" height="410" key="GridCell.Tab.0.right" timestamp="1576092018571"> <state width="1825" height="283" key="GridCell.Tab.0.right" timestamp="1576165003400">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="1853" height="1046" />
</state> </state>
<state width="1825" height="283" key="GridCell.Tab.0.right/67.34.1853.1046@67.34.1853.1046" timestamp="1576165003400" />
<state width="2465" height="410" key="GridCell.Tab.0.right/67.34.2493.1406@67.34.2493.1406" timestamp="1576092018571" /> <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"> <state width="2465" height="471" key="GridCell.Tab.1.bottom" timestamp="1575891470098">
<screen x="67" y="34" width="2493" height="1406" /> <screen x="67" y="34" width="2493" height="1406" />
......
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