Commit c4e39763 authored by Spiros Koulouzis's avatar Spiros Koulouzis

lots of stuff

parent a167ffb1
...@@ -8,49 +8,49 @@ from sure_tosca import util ...@@ -8,49 +8,49 @@ from sure_tosca import util
from sure_tosca.service import tosca_template_service from sure_tosca.service import tosca_template_service
def get_all_ancestor_properties(id, node_root_key): # noqa: E501 def get_all_ancestor_properties(id, node_name): # noqa: E501
""" """
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501 Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: List[Dict[str, object]] :rtype: List[Dict[str, object]]
""" """
return tosca_template_service.get_all_ancestor_properties(id, node_root_key) return tosca_template_service.get_all_ancestor_properties(id, node_name)
def get_all_ancestor_types(id, node_root_key): # noqa: E501 def get_all_ancestor_types(id, node_name): # noqa: E501
""" """
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501 Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: List[str] :rtype: List[str]
""" """
return tosca_template_service.get_all_ancestor_types(id, node_root_key) return tosca_template_service.get_all_ancestor_types(id, node_name)
def get_ancestors_requirements(id, node_root_key): # noqa: E501 def get_ancestors_requirements(id, node_name): # noqa: E501
""" """
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501 Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: Dict[str, object] :rtype: Dict[str, object]
""" """
return tosca_template_service.get_all_ancestors_requirements(id, node_root_key) return tosca_template_service.get_all_ancestors_requirements(id, node_name)
def get_dsl_definitions(id, anchors=None, derived_from=None): # noqa: E501 def get_dsl_definitions(id, anchors=None, derived_from=None): # noqa: E501
...@@ -83,54 +83,52 @@ def get_imports(id): # noqa: E501 ...@@ -83,54 +83,52 @@ def get_imports(id): # noqa: E501
return tosca_template_service.get_tosca_template_model_by_id(id).imports return tosca_template_service.get_tosca_template_model_by_id(id).imports
def get_node_outputs(id, node_root_key): # noqa: E501 def get_node_outputs(id, node_name): # noqa: E501
""" """
s # noqa: E501 s # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: Dict[str, object] :rtype: Dict[str, object]
""" """
return tosca_template_service.get_node_outputs(id, name_key=node_root_key) return tosca_template_service.get_node_outputs(id, node_name)
def get_node_properties(id, node_root_key): # noqa: E501 def get_node_properties(id, node_name): # noqa: E501
""" """
s # noqa: E501 s # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: Dict[str, object] :rtype: Dict[str, object]
""" """
return tosca_template_service.get_node_templates(id, name_key=node_root_key)[0].properties return tosca_template_service.get_node_properties(id, node_name)
def get_node_requirements(id, node_root_key): # noqa: E501 def get_node_requirements(id, node_name): # noqa: E501
"""get_node_requirements """get_node_requirements
Returns the requirements for an input node as described in the template not in the node's definition # noqa: E501 Returns the requirements for an input node as described in the template not in the node's definition # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: Dict[str, object] :rtype: Dict[str, object]
""" """
return tosca_template_service.get_node_templates(id, name_key=node_root_key)[0].requirements return tosca_template_service.get_node_requirements(id, node_name)
def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, has_properties=None, has_attributes=None, def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None, has_attributes=None, has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None): # noqa: E501
has_requirements=None, has_capabilities=None, has_artifacts=None,
derived_from=None): # noqa: E501
"""get_node_templates """get_node_templates
returns nodes templates in topology # noqa: E501 returns nodes templates in topology # noqa: E501
...@@ -139,8 +137,8 @@ def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, h ...@@ -139,8 +137,8 @@ def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, h
:type id: str :type id: str
:param type_name: The type :param type_name: The type
:type type_name: str :type type_name: str
:param name_key: the name key :param node_name: the name
:type name_key: str :type node_name: str
:param has_interfaces: filter if has interfaces :param has_interfaces: filter if has interfaces
:type has_interfaces: bool :type has_interfaces: bool
:param has_properties: filter if has properties :param has_properties: filter if has properties
...@@ -158,56 +156,56 @@ def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, h ...@@ -158,56 +156,56 @@ def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, h
:rtype: List[NodeTemplate] :rtype: List[NodeTemplate]
""" """
return tosca_template_service.get_node_templates(id, type_name=type_name, name_key=name_key, return tosca_template_service.get_node_templates(id, type_name=type_name, node_name=node_name,
has_interfaces=has_interfaces, has_properties=has_properties, has_interfaces=has_interfaces, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements, has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts, has_capabilities=has_capabilities, has_artifacts=has_artifacts,
derived_from=derived_from) derived_from=derived_from)
def get_node_type_name(id, node_root_key): # noqa: E501 def get_node_type_name(id, node_name): # noqa: E501
""" """
# noqa: E501 # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: str :rtype: str
""" """
return tosca_template_service.get_node_type_name(id, node_root_key) return tosca_template_service.get_node_type_name(id, node_name)
def get_parent_type_name(id, node_root_key): # noqa: E501 def get_parent_type_name(id, node_name): # noqa: E501
""" """
# noqa: E501 # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: str :rtype: str
""" """
return tosca_template_service.get_parent_type_name(id, node_root_key) return tosca_template_service.get_parent_type_name(id, node_name)
def get_related_nodes(id, node_root_key): # noqa: E501 def get_related_nodes(id, node_name): # noqa: E501
""" """
s # noqa: E501 s # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: List[NodeTemplate] :rtype: List[NodeTemplate]
""" """
return tosca_template_service.get_related_nodes(id, node_root_key) return tosca_template_service.get_related_nodes(id, node_name)
def get_relationship_templates(id, type_name=None, derived_from=None): # noqa: E501 def get_relationship_templates(id, type_name=None, derived_from=None): # noqa: E501
...@@ -253,8 +251,7 @@ def get_tosca_template(id): # noqa: E501 ...@@ -253,8 +251,7 @@ def get_tosca_template(id): # noqa: E501
return tosca_template_service.get_tosca_template_model_by_id(id) return tosca_template_service.get_tosca_template_model_by_id(id)
def get_types(id, kind_of_type=None, has_interfaces=None, type_name=None, has_properties=None, has_attributes=None, def get_types(id, kind_of_type=None, has_interfaces=None, type_name=None, has_properties=None, has_attributes=None, has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None): # noqa: E501
has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None): # noqa: E501
""" """
returns the interface types # noqa: E501 returns the interface types # noqa: E501
...@@ -289,7 +286,7 @@ def get_types(id, kind_of_type=None, has_interfaces=None, type_name=None, has_pr ...@@ -289,7 +286,7 @@ def get_types(id, kind_of_type=None, has_interfaces=None, type_name=None, has_pr
derived_from=derived_from) derived_from=derived_from)
def set_node_properties(id, properties, node_root_key): # noqa: E501 def set_node_properties(id, properties, node_name): # noqa: E501
""" """
s # noqa: E501 s # noqa: E501
...@@ -298,12 +295,12 @@ def set_node_properties(id, properties, node_root_key): # noqa: E501 ...@@ -298,12 +295,12 @@ def set_node_properties(id, properties, node_root_key): # noqa: E501
:type id: str :type id: str
:param properties: :param properties:
:type properties: :type properties:
:param node_root_key: node_root_key :param node_name: node_name
:type node_root_key: str :type node_name: str
:rtype: Dict[str, object] :rtype: NodeTemplate
""" """
return tosca_template_service.set_node_properties(id, properties, node_root_key) return tosca_template_service.set_node_properties(id, properties, node_name)
def upload_tosca_template(file): # noqa: E501 def upload_tosca_template(file): # noqa: E501
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
from __future__ import absolute_import from __future__ import absolute_import
from datetime import date, datetime # noqa: F401 from datetime import date, datetime # noqa: F401
from toscaparser.nodetemplate import NodeTemplate
from typing import List, Dict # noqa: F401 from typing import List, Dict # noqa: F401
from sure_tosca.models.base_model_ import Model from sure_tosca.models.base_model_ import Model
from sure_tosca.models.node_template import NodeTemplate # noqa: F401,E501
from sure_tosca import util from sure_tosca import util
...@@ -28,7 +28,7 @@ class TopologyTemplate(Model): ...@@ -28,7 +28,7 @@ class TopologyTemplate(Model):
:param relationship_templates: The relationship_templates of this TopologyTemplate. # noqa: E501 :param relationship_templates: The relationship_templates of this TopologyTemplate. # noqa: E501
:type relationship_templates: Dict[str, object] :type relationship_templates: Dict[str, object]
:param outputs: The outputs of this TopologyTemplate. # noqa: E501 :param outputs: The outputs of this TopologyTemplate. # noqa: E501
:type outputs: Dict[str, object] :type outputs: str
:param groups: The groups of this TopologyTemplate. # noqa: E501 :param groups: The groups of this TopologyTemplate. # noqa: E501
:type groups: Dict[str, object] :type groups: Dict[str, object]
:param substitution_mappings: The substitution_mappings of this TopologyTemplate. # noqa: E501 :param substitution_mappings: The substitution_mappings of this TopologyTemplate. # noqa: E501
...@@ -41,7 +41,7 @@ class TopologyTemplate(Model): ...@@ -41,7 +41,7 @@ class TopologyTemplate(Model):
'inputs': List[Dict[str, object]], 'inputs': List[Dict[str, object]],
'node_templates': Dict[str, NodeTemplate], 'node_templates': Dict[str, NodeTemplate],
'relationship_templates': Dict[str, object], 'relationship_templates': Dict[str, object],
'outputs': Dict[str, object], 'outputs': str,
'groups': Dict[str, object], 'groups': Dict[str, object],
'substitution_mappings': Dict[str, object], 'substitution_mappings': Dict[str, object],
'policies': List[Dict[str, object]] 'policies': List[Dict[str, object]]
...@@ -168,7 +168,7 @@ class TopologyTemplate(Model): ...@@ -168,7 +168,7 @@ class TopologyTemplate(Model):
:return: The outputs of this TopologyTemplate. :return: The outputs of this TopologyTemplate.
:rtype: Dict[str, object] :rtype: str
""" """
return self._outputs return self._outputs
...@@ -178,7 +178,7 @@ class TopologyTemplate(Model): ...@@ -178,7 +178,7 @@ class TopologyTemplate(Model):
:param outputs: The outputs of this TopologyTemplate. :param outputs: The outputs of this TopologyTemplate.
:type outputs: Dict[str, object] :type outputs: str
""" """
self._outputs = outputs self._outputs = outputs
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
from __future__ import absolute_import from __future__ import absolute_import
from datetime import date, datetime # noqa: F401 from datetime import date, datetime # noqa: F401
from toscaparser.topology_template import TopologyTemplate
from typing import List, Dict # noqa: F401 from typing import List, Dict # noqa: F401
from sure_tosca.models.base_model_ import Model from sure_tosca.models.base_model_ import Model
from sure_tosca.models.topology_template import TopologyTemplate # noqa: F401,E501
from sure_tosca import util from sure_tosca import util
......
...@@ -106,6 +106,28 @@ def get_node_types_with_interface(nodes): ...@@ -106,6 +106,28 @@ def get_node_types_with_interface(nodes):
return node_types_with_interface return node_types_with_interface
def node_dict_2_node_template(node_dict, all_custom_def):
node_name = next(iter(node_dict))
node_type = node_dict[node_name]['type']
# for name_to_remove in node_type_key_names_to_remove:
# if name_to_remove in node_dict[node_name][node_name]:
# node_dict[node_name].pop(name_to_remove)
node_template = NodeTemplate(node_name, node_templates=node_dict, custom_def=all_custom_def)
# For some reason the tosca.nodes.ARTICONF.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.ARTICONF.Orchestrator"
# is not a valid type.'
if len(node_template.custom_def) < len(all_custom_def):
for def_key in all_custom_def:
if isinstance(def_key, dict):
node_template.custom_def.update(def_key)
else:
node_template.custom_def[def_key] = all_custom_def[def_key]
return node_template
def node_type_2_node_template(node_type, all_custom_def): def node_type_2_node_template(node_type, all_custom_def):
node_template_dict = {} node_template_dict = {}
type_name = next(iter(node_type)) type_name = next(iter(node_type))
...@@ -166,6 +188,10 @@ def contains_node_type(node_types_list, node_type_name): ...@@ -166,6 +188,10 @@ def contains_node_type(node_types_list, node_type_name):
def get_node_properties(node): def get_node_properties(node):
node_type_name = get_node_type_name(node) node_type_name = get_node_type_name(node)
if 'properties' in node[node_type_name]:
return node[node_type_name]['properties']
if 'properties' in node.entity_tpl:
return node.entity_tpl['properties']
return node[node_type_name]['properties'] return node[node_type_name]['properties']
......
...@@ -3,9 +3,12 @@ import sys ...@@ -3,9 +3,12 @@ import sys
import uuid import uuid
import yaml import yaml
from tinydb.database import Document
from tinydb.middlewares import CachingMiddleware from tinydb.middlewares import CachingMiddleware
from toscaparser.functions import GetAttribute
from typing import re from typing import re
from sure_tosca.models.base_model_ import Model
from sure_tosca.models.node_template import NodeTemplate as NodeTemplateModel from sure_tosca.models.node_template import NodeTemplate as NodeTemplateModel
from sure_tosca.models.topology_template import TopologyTemplate as TopologyTemplateModel from sure_tosca.models.topology_template import TopologyTemplate as TopologyTemplateModel
from sure_tosca.models.tosca_template import ToscaTemplate as ToscaTemplateModel from sure_tosca.models.tosca_template import ToscaTemplate as ToscaTemplateModel
...@@ -15,6 +18,7 @@ import tempfile ...@@ -15,6 +18,7 @@ import tempfile
from toscaparser.nodetemplate import NodeTemplate from toscaparser.nodetemplate import NodeTemplate
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
from toscaparser.topology_template import TopologyTemplate from toscaparser.topology_template import TopologyTemplate
from toscaparser.parameters import Output
from tinydb.storages import MemoryStorage from tinydb.storages import MemoryStorage
from functools import reduce from functools import reduce
from sure_tosca.service import tosca_helper from sure_tosca.service import tosca_helper
...@@ -26,24 +30,29 @@ tosca_templates_db_file_path = os.path.join(db_dir_path, "tosca_templates.json") ...@@ -26,24 +30,29 @@ tosca_templates_db_file_path = os.path.join(db_dir_path, "tosca_templates.json")
tosca_templates_db = TinyDB(tosca_templates_db_file_path) tosca_templates_db = TinyDB(tosca_templates_db_file_path)
# tosca_templates_db = TinyDB(storage=CachingMiddleware(MemoryStorage)) # tosca_templates_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
tmp_db = TinyDB(storage=CachingMiddleware(MemoryStorage)) node_template_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
# interface_types_db = TinyDB(storage=CachingMiddleware(MemoryStorage)) dsl_definitions_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
relationship_template_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
interface_types_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
model_id_names = ['id'] model_id_names = ['id']
root_key = 'root_key' root_key = 'root_key'
def query_tmp_db(queries): def query_db(queries, db=None):
if queries: if queries:
query = reduce(lambda a, b: a & b, queries) query = reduce(lambda a, b: a & b, queries)
results = tmp_db.search(query) results = db.search(query)
else: else:
results = tmp_db.all() results = db.all()
if results: if results:
updated_results = [] updated_results = []
for res in results: for res in results:
key = res.pop(root_key) if root_key in res:
node = {key: res} key = res.pop(root_key)
node = {key: res}
else:
node = res
updated_results.append(node) updated_results.append(node)
return updated_results return updated_results
return 'Not Found', 404 return 'Not Found', 404
...@@ -74,13 +83,29 @@ def get_tosca_template_dict_by_id(id): ...@@ -74,13 +83,29 @@ def get_tosca_template_dict_by_id(id):
return 'Not Found', 404 return 'Not Found', 404
def deTOSCAfy_topology_template(dictionary):
# outputs out of nowhere is instantiated as GetAttribute
if 'outputs' in dictionary['topology_template']:
outputs = dictionary['topology_template']['outputs']
for output_name in outputs:
output = outputs[output_name]
if isinstance(output['value'], GetAttribute):
args = output['value'].args
assert isinstance(args, list)
output['value'] = {'get_attribute': args}
return dictionary
def save(file): def save(file):
try: try:
# tosca_template_file_path = os.path.join(db_dir_path, file.filename) # tosca_template_file_path = os.path.join(db_dir_path, file.filename)
tosca_template_dict = yaml.safe_load(file.stream) dictionary = yaml.safe_load(file.stream)
tosca_template_model = ToscaTemplateModel.from_dict(tosca_template_dict)
tosca_template = ToscaTemplate(yaml_dict_tpl=tosca_template_dict) tosca_template = ToscaTemplate(yaml_dict_tpl=dictionary)
dictionary = deTOSCAfy_topology_template(dictionary)
tosca_template_model = ToscaTemplateModel.from_dict(dictionary)
doc_id = str(uuid.uuid4()) doc_id = str(uuid.uuid4())
tosca_template_dict_with_id = {model_id_names[0]: doc_id} tosca_template_dict_with_id = {model_id_names[0]: doc_id}
...@@ -94,76 +119,94 @@ def save(file): ...@@ -94,76 +119,94 @@ def save(file):
def get_interface_types(id, interface_type=None): def get_interface_types(id, interface_type=None):
interface_types = get_tosca_template_model_by_id(id).interface_types if len(interface_types_db) <= 1:
tmp_db.purge() interface_types = get_tosca_template_model_by_id(id).interface_types
if interface_types: if interface_types:
for interface_type_name in interface_types: for interface_type_name in interface_types:
interface = {root_key: interface_type_name} interface = {root_key: interface_type_name}
interface.update(interface_types[interface_type_name]) interface.update(interface_types[interface_type_name])
queries = [] queries = []
if interface_type: if interface_type:
query = Query() query = Query()
queries.append(query._name_key == interface_type) queries.append(query._node_nme == interface_type)
return query_tmp_db(queries) return query_db(queries, db=interface_types_db)
def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, has_properties=None, has_attributes=None, def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None,
has_attributes=None,
has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None): has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None):
tmp_db.purge() # tmp_db.purge()
object_list = get_tosca_template_model_by_id(id).topology_template.node_templates
if object_list: if len(node_template_db) <= 1:
for key in object_list: tosca_template_model = get_tosca_template_model_by_id(id)
node = {root_key: key} object_list = tosca_template_model.topology_template.node_templates
node.update(object_list[key].to_dict()) # tosca_template = get_tosca_template(tosca_template_model.to_dict())
tmp_db.insert(node) # tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
# all_custom_def = tosca_template.nodetemplates[0].custom_def
queries = [] # object_list.update(tosca_node_types)
if name_key: # object_list.update(all_custom_def)
query = Query() if object_list:
queries.append(query.root_key == name_key) for key in object_list:
if type_name: node = {root_key: key}
query = Query() if isinstance(object_list[key], dict):
queries.append(query.type == type_name) node.update(object_list[key])
if derived_from: elif isinstance(object_list[key], Model):
query = Query() node.update(object_list[key].to_dict())
queries.append(query.derived_from == derived_from) node_template_db.insert(node)
if has_properties:
query = Query() queries = []
prop = None if node_name:
queries.append(query.properties != prop) if isinstance(node_name, list):
if has_interfaces: for n in node_name:
query = Query() query = Query()
prop = None queries.append(query.root_key == n)
queries.append(query.interfaces != prop) elif isinstance(node_name, str):
if has_attributes:
query = Query()
prop = None
queries.append(query.attributes != prop)
if has_requirements:
query = Query()
prop = None
queries.append(query.requirements != prop)
if has_capabilities:
query = Query()
prop = None
queries.append(query.capabilities != prop)
if has_artifacts:
query = Query() query = Query()
prop = None queries.append(query.root_key == node_name)
queries.append(query.artifacts != prop) if type_name:
query = Query()
queries.append(query.type == type_name)
if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if has_properties:
query = Query()
prop = None
queries.append(query.properties != prop)
if has_interfaces:
query = Query()
prop = None
queries.append(query.interfaces != prop)
if has_attributes:
query = Query()
prop = None
queries.append(query.attributes != prop)
if has_requirements:
query = Query()
prop = None
queries.append(query.requirements != prop)
if has_capabilities:
query = Query()
prop = None
queries.append(query.capabilities != prop)
if has_artifacts:
query = Query()
prop = None
queries.append(query.artifacts != prop)
query_results = query_tmp_db(queries) query_results = query_db(queries, db=node_template_db)
return query_results return query_results
def get_tosca_template_get_dsl_definitions(id, anchors, derived_from): def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
tmp_db.purge() # interface_types_db.purge()
object_list = get_tosca_template_model_by_id(id).dsl_definitions if len(dsl_definitions_db) <= 1:
if object_list: object_list = get_tosca_template_model_by_id(id).dsl_definitions
for key in object_list: if object_list:
node = {key: object_list[key]} for key in object_list:
tmp_db.insert(node) node = {key: object_list[key]}
interface_types_db.insert(node)
queries = [] queries = []
if derived_from: if derived_from:
...@@ -172,17 +215,18 @@ def get_tosca_template_get_dsl_definitions(id, anchors, derived_from): ...@@ -172,17 +215,18 @@ def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
if anchors: if anchors:
for anchor in anchors: for anchor in anchors:
query = Query() query = Query()
queries.append(query.anchor == anchor)
return query_tmp_db(queries) return query_db(queries, db=dsl_definitions_db)
def get_relationship_templates(id, type_name, derived_from): def get_relationship_templates(id, type_name=None, derived_from=None):
tmp_db.purge() if len(relationship_template_db) <= 1:
object_list = get_tosca_template_model_by_id(id).relationship_templates object_list = get_tosca_template_model_by_id(id).relationship_templates
if object_list: if object_list:
for key in object_list: for key in object_list:
node = {key: object_list[key]} node = {key: object_list[key]}
tmp_db.insert(node) relationship_template_db.insert(node)
queries = [] queries = []
if derived_from: if derived_from:
...@@ -192,10 +236,10 @@ def get_relationship_templates(id, type_name, derived_from): ...@@ -192,10 +236,10 @@ def get_relationship_templates(id, type_name, derived_from):
query = Query() query = Query()
queries.append(query.type == type_name) queries.append(query.type == type_name)
return query_tmp_db(queries) return query_db(queries, db=relationship_template_db)
def find_node_template(id, node_root_key): def node_dict_2_node_template(id, node_name):
tosca_template_dict = get_tosca_template_dict_by_id(id) tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template = get_tosca_template(tosca_template_dict) tosca_template = get_tosca_template(tosca_template_dict)
tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
...@@ -204,25 +248,23 @@ def find_node_template(id, node_root_key): ...@@ -204,25 +248,23 @@ def find_node_template(id, node_root_key):
all_node_types.update(tosca_node_types.items()) all_node_types.update(tosca_node_types.items())
all_node_types.update(all_custom_def.items()) all_node_types.update(all_custom_def.items())
the_node = None node_template_dict = get_node_templates(id, node_name=node_name)[0]
for node in tosca_template.nodetemplates: node_template_dict = {node_name: node_template_dict}
if node.name == node_root_key: if isinstance(node_template_dict, dict):
the_node = node the_node = tosca_helper.node_dict_2_node_template(node_template_dict, all_node_types)
break
if not the_node: return the_node, all_node_types, all_custom_def
template = all_node_types[node_root_key] return None
the_node = tosca_helper.node_type_2_node_template({node_root_key: template}, all_custom_def)
return the_node, all_node_types, all_custom_def
def get_all_ancestors_requirements(id, node_root_key): def get_all_ancestors_requirements(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key) the_node, all_node_types, all_custom_def = node_dict_2_node_template(id, node_root_key)
parent_requirements = tosca_helper.get_all_ancestors_requirements(the_node, all_node_types, all_custom_def) parent_requirements = tosca_helper.get_all_ancestors_requirements(the_node, all_node_types, all_custom_def)
return parent_requirements return parent_requirements
def get_all_ancestor_properties(id, node_root_key): def get_all_ancestor_properties(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key) the_node, all_node_types, all_custom_def = node_dict_2_node_template(id, node_root_key)
properties = tosca_helper.get_all_ancestors_properties(the_node, all_node_types, all_custom_def) properties = tosca_helper.get_all_ancestors_properties(the_node, all_node_types, all_custom_def)
properties_list = [] properties_list = []
for prop in properties: for prop in properties:
...@@ -232,16 +274,92 @@ def get_all_ancestor_properties(id, node_root_key): ...@@ -232,16 +274,92 @@ def get_all_ancestor_properties(id, node_root_key):
def get_all_ancestor_types(id, node_root_key): def get_all_ancestor_types(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key) try:
the_node, all_node_types, all_custom_def = node_dict_2_node_template(id, node_root_key)
except Exception as e:
return 'Not Found', 404
all_ancestor_types = tosca_helper.get_all_ancestors_types(the_node, all_node_types, all_custom_def) all_ancestor_types = tosca_helper.get_all_ancestors_types(the_node, all_node_types, all_custom_def)
return all_ancestor_types return all_ancestor_types
def get_parent_type_name(id, node_root_key): def get_parent_type_name(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key) try:
the_node, all_node_types, all_custom_def = node_dict_2_node_template(id, node_root_key)
except Exception as e:
return 'Not Found', 404
return tosca_helper.get_parent_type(the_node) return tosca_helper.get_parent_type(the_node)
def get_node_outputs(id, name_key): def get_node_outputs(id, node_nme):
outputs = get_tosca_template_model_by_id(id).topology_template.outputs matching_outputs = {}
return None matching_output_names = []
tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template = get_tosca_template(tosca_template_dict)
outputs = tosca_template.topology_template.outputs
for output in outputs:
if node_nme == output.value.node_template_name:
matching_output_names.append(output.name)
tosca_template_model = ToscaTemplateModel.from_dict(deTOSCAfy_topology_template(tosca_template_dict))
for matching_output_name in matching_output_names:
matching_outputs[matching_output_name] = tosca_template_model.topology_template.outputs[matching_output_name]
return matching_outputs
def get_node_properties(id, node_name):
node_template_dict = get_node_templates(id, node_name=node_name)[0]
if node_name in node_template_dict:
node_template_dict = node_template_dict[node_name]
properties = NodeTemplateModel.from_dict(node_template_dict).properties
if properties:
return properties
return 'Not Found', 404
def get_node_requirements(id, node_name):
node_template_dict = get_node_templates(id, node_name=node_name)[0]
if node_name in node_template_dict:
node_template_dict = node_template_dict[node_name]
requirements = NodeTemplateModel.from_dict(node_template_dict).requirements
if requirements:
return requirements
return 'Not Found', 404
def get_related_nodes(id, node_name):
tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template = get_tosca_template(tosca_template_dict)
related_node_names = []
for node_template in tosca_template.topology_template.nodetemplates:
if node_template.name == node_name:
related_nodes = node_template.related_nodes
for related_node in related_nodes:
related_node_names.append(related_node.name)
related_nodes = []
for name in related_node_names:
related_node = get_node_templates(id, node_name=name)
related_nodes.append(related_node)
return related_nodes
def get_node_type_name(id, node_name):
node_template_dict = get_node_templates(id, node_name=node_name)[0]
if node_name in node_template_dict:
node_template_dict = node_template_dict[node_name]
type_name = NodeTemplateModel.from_dict(node_template_dict).type
if type_name:
return type_name
return 'Not Found', 404
def set_node_properties(id, properties, node_name):
node_template_dict = get_node_templates(id, node_name=node_name)[0]
if node_name in node_template_dict:
node_template_dict = node_template_dict[node_name]
return None
\ No newline at end of file
...@@ -286,9 +286,9 @@ paths: ...@@ -286,9 +286,9 @@ paths:
description: "The type" description: "The type"
required: false required: false
type: "string" type: "string"
- name: "name_key" - name: "node_name"
in: "query" in: "query"
description: "the name key" description: "the name"
required: false required: false
type: "string" type: "string"
- name: "has_interfaces" - name: "has_interfaces"
...@@ -338,7 +338,7 @@ paths: ...@@ -338,7 +338,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/type_name: /tosca_template/{id}/topology_template/node_templates/{node_name}/type_name:
get: get:
summary: "" summary: ""
description: "" description: ""
...@@ -351,9 +351,9 @@ paths: ...@@ -351,9 +351,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -366,7 +366,7 @@ paths: ...@@ -366,7 +366,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/requirements: /tosca_template/{id}/topology_template/node_templates/{node_name}/requirements:
get: get:
description: "Returns the requirements for an input node as described in the\ description: "Returns the requirements for an input node as described in the\
\ template not in the node's definition " \ template not in the node's definition "
...@@ -379,9 +379,9 @@ paths: ...@@ -379,9 +379,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -397,7 +397,7 @@ paths: ...@@ -397,7 +397,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/derived_from: /tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from:
get: get:
summary: "" summary: ""
description: "" description: ""
...@@ -410,9 +410,9 @@ paths: ...@@ -410,9 +410,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -425,7 +425,7 @@ paths: ...@@ -425,7 +425,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_requirements: /tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements:
get: get:
summary: "" summary: ""
description: "Recursively get all requirements all the way to the ROOT including\ description: "Recursively get all requirements all the way to the ROOT including\
...@@ -439,9 +439,9 @@ paths: ...@@ -439,9 +439,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -457,7 +457,7 @@ paths: ...@@ -457,7 +457,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_types: /tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types:
get: get:
summary: "" summary: ""
description: "Recursively get all requirements all the way to the ROOT including\ description: "Recursively get all requirements all the way to the ROOT including\
...@@ -471,9 +471,9 @@ paths: ...@@ -471,9 +471,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -488,7 +488,7 @@ paths: ...@@ -488,7 +488,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_properties: /tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties:
get: get:
summary: "" summary: ""
description: "Recursively get all requirements all the way to the ROOT including\ description: "Recursively get all requirements all the way to the ROOT including\
...@@ -502,9 +502,9 @@ paths: ...@@ -502,9 +502,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -522,7 +522,7 @@ paths: ...@@ -522,7 +522,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/properties: /tosca_template/{id}/topology_template/node_templates/{node_name}/properties:
get: get:
summary: "" summary: ""
description: "s" description: "s"
...@@ -535,9 +535,9 @@ paths: ...@@ -535,9 +535,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -571,26 +571,24 @@ paths: ...@@ -571,26 +571,24 @@ paths:
schema: schema:
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "string" type: "object"
- name: "node_root_key" properties: {}
- name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
schema: schema:
type: "object" $ref: "#/definitions/NodeTemplate"
additionalProperties:
type: "object"
properties: {}
404: 404:
description: "Not found" description: "Not found"
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/outputs: /tosca_template/{id}/topology_template/node_templates/{node_name}/outputs:
get: get:
summary: "" summary: ""
description: "s" description: "s"
...@@ -603,9 +601,9 @@ paths: ...@@ -603,9 +601,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -621,7 +619,7 @@ paths: ...@@ -621,7 +619,7 @@ paths:
405: 405:
description: "Invalid input" description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller" x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_root_key}/related: /tosca_template/{id}/topology_template/node_templates/{node_name}/related:
get: get:
summary: "" summary: ""
description: "s" description: "s"
...@@ -634,9 +632,9 @@ paths: ...@@ -634,9 +632,9 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_root_key" - name: "node_name"
in: "path" in: "path"
description: "node_root_key" description: "node_name"
required: true required: true
type: "string" type: "string"
responses: responses:
...@@ -736,8 +734,7 @@ definitions: ...@@ -736,8 +734,7 @@ definitions:
policy_types: policy_types:
key: "policy_types" key: "policy_types"
topology_template: topology_template:
outputs: outputs: "outputs"
key: "{}"
substitution_mappings: substitution_mappings:
key: "{}" key: "{}"
inputs: inputs:
...@@ -821,10 +818,7 @@ definitions: ...@@ -821,10 +818,7 @@ definitions:
type: "object" type: "object"
properties: {} properties: {}
outputs: outputs:
type: "object" type: "string"
additionalProperties:
type: "object"
properties: {}
groups: groups:
type: "object" type: "object"
additionalProperties: additionalProperties:
...@@ -843,8 +837,7 @@ definitions: ...@@ -843,8 +837,7 @@ definitions:
type: "object" type: "object"
properties: {} properties: {}
example: example:
outputs: outputs: "outputs"
key: "{}"
substitution_mappings: substitution_mappings:
key: "{}" key: "{}"
inputs: inputs:
......
...@@ -20,7 +20,7 @@ class TestDefaultController(BaseTestCase): ...@@ -20,7 +20,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_properties'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -31,7 +31,7 @@ class TestDefaultController(BaseTestCase): ...@@ -31,7 +31,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_types'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -42,7 +42,7 @@ class TestDefaultController(BaseTestCase): ...@@ -42,7 +42,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_requirements'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -78,7 +78,7 @@ class TestDefaultController(BaseTestCase): ...@@ -78,7 +78,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/outputs'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -89,7 +89,7 @@ class TestDefaultController(BaseTestCase): ...@@ -89,7 +89,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/properties'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -100,7 +100,7 @@ class TestDefaultController(BaseTestCase): ...@@ -100,7 +100,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/requirements'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -111,7 +111,7 @@ class TestDefaultController(BaseTestCase): ...@@ -111,7 +111,7 @@ class TestDefaultController(BaseTestCase):
""" """
query_string = [('type_name', 'type_name_example'), query_string = [('type_name', 'type_name_example'),
('name_key', 'name_key_example'), ('node_name', 'node_name_example'),
('has_interfaces', true), ('has_interfaces', true),
('has_properties', true), ('has_properties', true),
('has_attributes', true), ('has_attributes', true),
...@@ -132,7 +132,7 @@ class TestDefaultController(BaseTestCase): ...@@ -132,7 +132,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/type_name'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -143,7 +143,7 @@ class TestDefaultController(BaseTestCase): ...@@ -143,7 +143,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/derived_from'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -154,7 +154,7 @@ class TestDefaultController(BaseTestCase): ...@@ -154,7 +154,7 @@ class TestDefaultController(BaseTestCase):
""" """
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/related'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/related'.format(id='id_example', node_name='node_name_example'),
method='GET') method='GET')
self.assert200(response, self.assert200(response,
'Response body is : ' + response.data.decode('utf-8')) 'Response body is : ' + response.data.decode('utf-8'))
...@@ -223,7 +223,7 @@ class TestDefaultController(BaseTestCase): ...@@ -223,7 +223,7 @@ class TestDefaultController(BaseTestCase):
""" """
properties = None properties = None
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/properties'.format(id='id_example', node_root_key='node_root_key_example'), '/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(id='id_example', node_name='node_name_example'),
method='PUT', method='PUT',
data=json.dumps(properties), data=json.dumps(properties),
content_type='application/json') content_type='application/json')
......
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