Commit 0e54d79b authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed recursive method returns none

parent fb075c17
...@@ -6,8 +6,9 @@ from toscaparser.tosca_template import ToscaTemplate ...@@ -6,8 +6,9 @@ from toscaparser.tosca_template import ToscaTemplate
import toscaparser.utils.yamlparser import toscaparser.utils.yamlparser
import urllib import urllib
import urllib.parse import urllib.parse
import sys
class DumpPlanner: class WineryPlanner:
service_template_names = ['serviceTemplateOrNodeTypeOrNodeTypeImplementation'] service_template_names = ['serviceTemplateOrNodeTypeOrNodeTypeImplementation']
topology_template_names = ['topologyTemplate'] topology_template_names = ['topologyTemplate']
node_template_names = ['nodeTemplates'] node_template_names = ['nodeTemplates']
...@@ -73,11 +74,13 @@ class DumpPlanner: ...@@ -73,11 +74,13 @@ class DumpPlanner:
def target_meets_requirement(self, target_relationship_element, requirement): def target_meets_requirement(self, target_relationship_element, requirement):
node = self.get_node(target_relationship_element) node = self.get_node(target_relationship_element)
print(node)
if 'capabilities' in node: if 'capabilities' in node:
print(node['capabilities']) print('dddddddddddd')
else: else:
supertypes = self.get_super_types(node['type'], None) supertypes = self.get_super_types(node['type'], None)
print(supertypes)
# print(supertypes)
def get_relationship_of_source_node(self, source_id, relationships): def get_relationship_of_source_node(self, source_id, relationships):
for rel in relationships: for rel in relationships:
...@@ -98,7 +101,6 @@ class DumpPlanner: ...@@ -98,7 +101,6 @@ class DumpPlanner:
for node_template in node_templates: for node_template in node_templates:
node_type = node_template['type'] node_type = node_template['type']
all_requirements = self.get_super_types_requirements(node_type, None) all_requirements = self.get_super_types_requirements(node_type, None)
print(all_requirements)
id = node_template['id'] id = node_template['id']
req = self.get_requirements(node_template) req = self.get_requirements(node_template)
if(req): if(req):
...@@ -140,12 +142,11 @@ class DumpPlanner: ...@@ -140,12 +142,11 @@ class DumpPlanner:
res = urllib.request.urlopen(req, timeout=5) res = urllib.request.urlopen(req, timeout=5)
res_body = res.read() res_body = res.read()
component = json.loads(res_body.decode("utf-8")) component = json.loads(res_body.decode("utf-8"))
if component: if component:
comp = component['serviceTemplateOrNodeTypeOrNodeTypeImplementation'][0] comp = component['serviceTemplateOrNodeTypeOrNodeTypeImplementation'][0]
supertypes.append(comp) supertypes.append(comp)
if 'derivedFrom' in comp: if 'derivedFrom' in comp:
supertypes = self.get_super_types(comp['derivedFrom']['typeRef'], supertypes) return self.get_super_types(comp['derivedFrom']['typeRef'], supertypes)
else: else:
return supertypes return supertypes
......
...@@ -8,7 +8,7 @@ import os ...@@ -8,7 +8,7 @@ import os
import os.path import os.path
from os.path import expanduser from os.path import expanduser
import pika import pika
from planner.dum_planner import * from planner.winery_planner import *
import sys import sys
import tempfile import tempfile
import time import time
...@@ -115,7 +115,7 @@ if __name__ == "__main__": ...@@ -115,7 +115,7 @@ if __name__ == "__main__":
tosca_reposetory_api_base_url = "http://localhost:8080/winery" tosca_reposetory_api_base_url = "http://localhost:8080/winery"
namespace = "http%253A%252F%252Fsne.uva.nl%252Fservicetemplates" namespace = "http%253A%252F%252Fsne.uva.nl%252Fservicetemplates"
servicetemplate_id = "wordpress_w1-wip1" servicetemplate_id = "wordpress_w1-wip1"
planner = DumpPlanner(tosca_reposetory_api_base_url,namespace,servicetemplate_id) planner = WineryPlanner(tosca_reposetory_api_base_url,namespace,servicetemplate_id)
else: else:
logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2]) logger.info("Input args: " + sys.argv[0] + ' ' + sys.argv[1] + ' ' + sys.argv[2])
channel = init_chanel(sys.argv) channel = init_chanel(sys.argv)
......
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