Commit 9a3a26eb authored by Spiros Koulouzis's avatar Spiros Koulouzis

get all capabilities / requirements

parent 09b88064
...@@ -23,47 +23,15 @@ if __name__ == "__main__": ...@@ -23,47 +23,15 @@ if __name__ == "__main__":
tt= repo.get_topology_template(servicetemplates) tt= repo.get_topology_template(servicetemplates)
node_templates = repo.get_node_templates(tt) node_templates = repo.get_node_templates(tt)
parents = repo.get_parents(node_templates[1])
requrements=[]
requrements_types = set()
node_type = repo.get_object(node_templates[1]['type'])['serviceTemplateOrNodeTypeOrNodeTypeImplementation'][0]
child_requrements = repo.get_requirements(node_type)
if child_requrements:
for c_req in child_requrements:
if not c_req['requirementType'] in requrements_types:
requrements.append(c_req)
requrements_types.add(c_req['requirementType'])
for parent in parents:
parent_requrements = repo.get_requirements(parent)
for p_req in parent_requrements:
if not p_req['requirementType'] in requrements_types:
requrements.append(p_req)
requrements_types.add(p_req['requirementType'])
requrements = repo.get_all_requirements(node_templates[1])
# print(requrements) # print(requrements)
capabilities=[]
capabilities_types = set()
child_capabilities = repo.get_capabilities(node_type)
if child_capabilities:
for c_cap in child_capabilities:
if not c_cap['capabilityType'] in capabilities_types:
capabilities.append(c_cap)
capabilities_types.add(c_cap['capabilityType'])
for parent in parents: capabilities = repo.get_all_capabilities(node_templates[1])
parent_capabilities = repo.get_capabilities(parent)
if(parent_capabilities):
for p_cap in parent_capabilities:
if not p_cap['capabilityType'] in capabilities_types:
capabilities.append(p_cap)
capabilities_types.add(p_cap['capabilityType'])
print(capabilities_types) print(capabilities)
......
...@@ -65,6 +65,47 @@ class Service: ...@@ -65,6 +65,47 @@ class Service:
if requirements: if requirements:
return requirements['requirementDefinition'] return requirements['requirementDefinition']
def get_all_requirements(self,node_template):
parents = self.get_parents(node_template)
node_type = self.get_object(node_template['type'])['serviceTemplateOrNodeTypeOrNodeTypeImplementation'][0]
requrements=[]
requrements_types = set()
child_requrements = self.get_requirements(node_type)
if child_requrements:
for c_req in child_requrements:
if not c_req['requirementType'] in requrements_types:
requrements.append(c_req)
requrements_types.add(c_req['requirementType'])
for parent in parents:
parent_requrements = self.get_requirements(parent)
for p_req in parent_requrements:
if not p_req['requirementType'] in requrements_types:
requrements.append(p_req)
requrements_types.add(p_req['requirementType'])
return requrements
def get_all_capabilities(self,node_template):
parents = self.get_parents(node_template)
node_type = self.get_object(node_template['type'])['serviceTemplateOrNodeTypeOrNodeTypeImplementation'][0]
child_capabilities = self.get_capabilities(node_type)
capabilities=[]
capabilities_types = set()
if child_capabilities:
for c_cap in child_capabilities:
if not c_cap['capabilityType'] in capabilities_types:
capabilities.append(c_cap)
capabilities_types.add(c_cap['capabilityType'])
for parent in parents:
parent_capabilities = self.get_capabilities(parent)
if(parent_capabilities):
for p_cap in parent_capabilities:
if not p_cap['capabilityType'] in capabilities_types:
capabilities.append(p_cap)
capabilities_types.add(p_cap['capabilityType'])
return capabilities
def get_capabilities(self,node_type): def get_capabilities(self,node_type):
requirements = self.find(node_type,self.capability_deff_names) requirements = self.find(node_type,self.capability_deff_names)
if requirements: if requirements:
......
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