Commit 80d57fd6 authored by Spiros Koulouzis's avatar Spiros Koulouzis

look for capable nodes

parent d40869d5
......@@ -33,7 +33,7 @@ node_types:
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: tosca.nodes.ARTICONF.Orchestrator
relationship: tosca.relationships.HostedOn
relationship: tosca.relationships.HostedOn
tosca.nodes.ARTICONF.Orchestrator:
derived_from: tosca.nodes.SoftwareComponent
......@@ -58,4 +58,3 @@ node_types:
relationship: tosca.relationships.HostedOn
......@@ -19,14 +19,21 @@ class BasicPlanner:
def __init__(self, path):
self.template = ToscaTemplate(path)
self.tosca_node_types = self.template.nodetemplates[0].type_definition.TOSCA_DEF
self.all_custom_def = self.template.nodetemplates[0].custom_def
self.all_nodes = {}
self.all_nodes.update(self.tosca_node_types.items())
self.all_nodes.update(self.all_custom_def.items())
for node in self.template.nodetemplates:
capable_nodes = []
missing_requirements = self.get_missing_requirements(node)
print(missing_requirements)
for req in missing_requirements:
for key in req:
capable_nodes.append(self.get_node_types_by_capability(req[key]['capability']))
node.requirements.append(req)
# print(node.get_properties().keys())
# print((node.type_definition._get_node_type_by_cap('tosca.capabilities.ARTICONF.Orchestrator')))
print('------------------')
# print(node.get_capabilities().keys)
......@@ -49,4 +56,13 @@ class BasicPlanner:
if node.parent_type:
missing_requirements = missing_requirements + node.parent_type.requirements
return missing_requirements
\ No newline at end of file
def get_node_types_by_capability(self,cap):
capable_nodes = []
for tosca_node in self.all_nodes:
if 'capabilities' in self.all_nodes[tosca_node]:
for caps in self.all_nodes[tosca_node]['capabilities']:
if self.all_nodes[tosca_node]['capabilities'][caps]['type'] == cap:
capable_nodes.append(tosca_node)
return capable_nodes
\ No newline at end of file
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