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

look for capable nodes

parent d40869d5
...@@ -58,4 +58,3 @@ node_types: ...@@ -58,4 +58,3 @@ node_types:
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
...@@ -19,14 +19,21 @@ class BasicPlanner: ...@@ -19,14 +19,21 @@ class BasicPlanner:
def __init__(self, path): def __init__(self, path):
self.template = ToscaTemplate(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: for node in self.template.nodetemplates:
capable_nodes = []
missing_requirements = self.get_missing_requirements(node) missing_requirements = self.get_missing_requirements(node)
print(missing_requirements)
for req in 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) node.requirements.append(req)
# print((node.type_definition._get_node_type_by_cap('tosca.capabilities.ARTICONF.Orchestrator')))
# print(node.get_properties().keys()) print('------------------')
# print(node.get_capabilities().keys) # print(node.get_capabilities().keys)
...@@ -50,3 +57,12 @@ class BasicPlanner: ...@@ -50,3 +57,12 @@ class BasicPlanner:
missing_requirements = missing_requirements + node.parent_type.requirements missing_requirements = missing_requirements + node.parent_type.requirements
return missing_requirements return missing_requirements
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