Commit 09b88064 authored by Spiros Koulouzis's avatar Spiros Koulouzis

get capabilities

parent 483595ad
......@@ -26,14 +26,44 @@ if __name__ == "__main__":
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'])
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:
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)
......
......@@ -12,6 +12,7 @@ class Service:
topology_template_names = ['topologyTemplate']
node_template_names = ['nodeTemplates']
requirement_deff_names = ['requirementDefinitions']
capability_deff_names = ['capabilityDefinitions']
type_names = ['type']
relationships_names = ['relationshipTemplates']
service_templates = None
......@@ -61,7 +62,15 @@ class Service:
def get_requirements(self,node_type):
requirements = self.find(node_type,self.requirement_deff_names)
return requirements['requirementDefinition']
if requirements:
return requirements['requirementDefinition']
def get_capabilities(self,node_type):
requirements = self.find(node_type,self.capability_deff_names)
if requirements:
return requirements['capabilityDefinition']
def get_object(self,type_str):
regex = r"\{(.*?)\}"
......
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