Commit ab6a1a17 authored by Spiros Koulouzis's avatar Spiros Koulouzis

removed policies

parent ae0db377
......@@ -2,7 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
......
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
description: >
TOSCA example
- nodes: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml
- data: https://raw.githubusercontent.com/skoulouzis/CONF/DRIP_3.0/TOSCA/types/data.yml
- capabilities: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml
topology_template:
node_templates:
node_templates:
#topology:
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: SEQ
#object_type: SubTopology
#properties:
#domain: UvA (Amsterdam, The Netherlands) XO Rack
#provider: ExoGENI
#type: tosca.nodes.ARTICONF.VM.topology
ws-pema-lifewatch:
type: tosca.nodes.ARTICONF.Container.Application.Docker
properties:
......@@ -26,5 +34,16 @@ topology_template:
image:
type: tosca.artifacts.Deployment.Image.Container.Docker
file: alogo53/ws-pema-lifewatch
repository: docker_hub
repository: docker_hub
requirements:
- host:
capability: tosca.capabilities.ARTICONF.docker.Orchestrator
node: kubernetes
relationship: tosca.relationships.HostedOn
kubernetes:
type: tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes
properties:
min_masters_num: 1
min_workers_num: 1
......@@ -6,7 +6,7 @@ node_types:
description: root ARTICONF node
tosca.nodes.ARTICONF.Container.Application.Docker:
derived_from: tosca.nodes.ARTICONF.Root
derived_from: tosca.nodes.ARTICONF.Root
description: description of container
properties:
ports:
......
......@@ -14,13 +14,13 @@ services:
- "4369:4369"
- "15671:15671"
planner:
depends_on:
- rabbit
- sure-tosca
image: alogo53/planner:3.0.0
environment:
RABBITMQ_HOST: rabbit
#planner:
#depends_on:
#- rabbit
#- sure-tosca
#image: alogo53/planner:3.0.0
#environment:
#RABBITMQ_HOST: rabbit
provisioner:
depends_on:
......@@ -52,17 +52,17 @@ services:
ports:
- "30000:8080"
sure-tosca:
image: alogo53/sure-tosca:3.0.0
ports:
- "8081:8081"
#logspout:
#sure-tosca:
#image: alogo53/sure-tosca:3.0.0
#ports:
#- "30002:80"
#volumes:
#- /etc/hostname:/etc/host_hostname:ro
#- /var/run/docker.sock:/var/run/docker.sock
#environment:
#publish: "127.0.0.1:30002:80"
#image: gliderlabs/logspout:latest
#- "8081:8081"
logspout:
ports:
- "30002:80"
volumes:
- /etc/hostname:/etc/host_hostname:ro
- /var/run/docker.sock:/var/run/docker.sock
environment:
publish: "127.0.0.1:30002:80"
image: gliderlabs/logspout:latest
......@@ -36,7 +36,7 @@
artifacts:
type: object
additionalProperties:
type: object
type: object
......
......@@ -12,6 +12,33 @@ from service.simple_spec_alayzer import SimpleAnalyzer
from util import tosca_helper
def add_requirements(node, missing_requirements, capable_node_name):
"""Add the requirements to the node """
for req in missing_requirements:
req[next(iter(req))]['node'] = capable_node_name
if isinstance(node, NodeTemplate):
contains_requirement = False
for node_requirement in node.requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node.requirements.append(req)
elif isinstance(node, dict):
type_name = next(iter(node))
if 'requirements' not in node[type_name]:
node[type_name]['requirements'] = []
node_requirements = node[type_name]['requirements']
contains_requirement = False
for node_requirement in node_requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node[type_name]['requirements'].append(req)
return node
class Planner:
def __init__(self, tosca_path=None, yaml_dict_tpl=None, spec_service=None):
......@@ -105,7 +132,7 @@ class Planner:
matching_node_type_name = next(iter(matching_node))
matching_node_template = tosca_helper.node_type_2_node_template(matching_node, self.all_custom_def)
# Add the requirements to the node we analyzed. e.g. docker needed host now we added the type and name of host
node = self.add_requirements(node, all_requirements, matching_node_template.name)
node = add_requirements(node, all_requirements, matching_node_template.name)
if not tosca_helper.contains_node_type(self.required_nodes, matching_node_type_name) and \
not tosca_helper.contains_node_type(self.tosca_template.nodetemplates, matching_node_type_name):
logging.info(' Adding: ' + str(matching_node_template.name))
......@@ -179,11 +206,15 @@ class Planner:
def find_best_node_for_requirements(self, all_requirements):
"""Returns the 'best' node for a set of requirements. Here we count the number of requiremets that the node
can cover and return the one which covers the most """
# Check if we have a preference from policies
matching_nodes = {}
number_of_matching_requirement = {}
for req in all_requirements:
if 'capability' in req[next(iter(req))]:
capability = req[next(iter(req))]['capability']
logging.info(' Looking for nodes with capability: ' + capability)
# Check if we already cover the requirements within the topology
capable_nodes = self.get_node_templates_by_capability(capability)
# Loop requirements to find nodes per requirement
for req in all_requirements:
if 'capability' in req[next(iter(req))]:
......@@ -226,28 +257,9 @@ class Planner:
child_nodes[tosca_node_type] = self.all_node_types[tosca_node_type]
return child_nodes
def add_requirements(self, node, missing_requirements, capable_node_name):
"""Add the requirements to the node """
for req in missing_requirements:
req[next(iter(req))]['node'] = capable_node_name
if isinstance(node, NodeTemplate):
contains_requirement = False
for node_requirement in node.requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node.requirements.append(req)
elif isinstance(node, dict):
type_name = next(iter(node))
if 'requirements' not in node[type_name]:
node[type_name]['requirements'] = []
node_requirements = node[type_name]['requirements']
contains_requirement = False
for node_requirement in node_requirements:
if node_requirement == req:
contains_requirement = True
break
if not contains_requirement:
node[type_name]['requirements'].append(req)
return node
def get_node_templates_by_capability(self, capability):
candidate_nodes = {}
for node in self.tosca_template.nodetemplates:
if node.type.startswith('tosca.nodes'):
tosca_helper.get_all_ancestors_types()
return capable_nodes
werkzeug==1.0.0
PyYAML
wheel==0.33.6
connexion == 2.4.0
python-dateutil == 2.8.0
typing == 3.7.4.1
swagger-ui-bundle == 0.0.5
tinydb == 3.15.1
tosca-parser ==1.6.1
wheel==0.34.2
connexion==2.6.0
python-dateutil==2.8.1
typing==3.7.4.1
swagger-ui-bundle==0.0.6
# tinydb==3.15.1
tosca-parser ==1.7.0
......@@ -4,7 +4,7 @@ import sys
from setuptools import setup, find_packages
NAME = "sure_tosca"
VERSION = "1.0.0"
VERSION = "1.2.0"
# To install the library, run the following
#
......
#!/usr/bin/env python
#!/usr/bin/env python3
import connexion
......
import connexion
import six
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501
from sure_tosca.models.topology_template import TopologyTemplateModel # noqa: E501
from sure_tosca.models.tosca_template import ToscaTemplateModel # noqa: E501
from sure_tosca import util
from sure_tosca.service import tosca_template_service
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_all_ancestor_properties(id, node_name)
if res:
return res
return 'Not Found', 404
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[str]
"""
res = tosca_template_service.get_all_ancestor_types(id, node_name)
if res:
return res
return 'Not Found', 404
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_all_ancestors_requirements(id, node_name)
if res:
return res
return 'Not Found', 404
def get_default_interface(id, interface_type, instance_name, operation_name): # noqa: E501
"""
returns an interface instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param interface_type: type to instantiate
:type interface_type: str
:param instance_name: the name of the instance to retrun
:type instance_name: str
:param operation_name: the name of operation
:type operation_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_default_interface(id, interface_type, instance_name, operation_name)
if res:
return res
return 'Not Found', 404
def get_default_node_type(id, node_type, instance_name): # noqa: E501
"""
returns an node templaye instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_type: type to instantiate
:type node_type: str
:param instance_name: the name of tghe instance to retrun
:type instance_name: str
:rtype: NodeTemplateMap
"""
return 'do some magic!'
def get_dsl_definitions(id, anchors=None, derived_from=None): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param anchors: the anchors the definition is for
:type anchors: List[str]
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).dsl_definitions
if res:
return res
return 'Not Found', 404
def get_imports(id): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).imports
if res:
return res
return 'Not Found', 404
def get_node_outputs(id, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_outputs(id, node_name)
if res:
return res
return 'Not Found', 404
def get_node_properties(id, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_properties(id, node_name)
if res:
return res
return 'Not Found', 404
def get_node_requirements(id, node_name): # noqa: E501
"""get_node_requirements
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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_requirements(id, node_name)
if res:
return res
return 'Not Found', 404
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): # noqa: E501
"""get_node_templates
returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The type
:type type_name: str
:param node_name: the name
:type node_name: str
:param has_interfaces: filter if has interfaces
:type has_interfaces: bool
:param has_properties: filter if has properties
:type has_properties: bool
:param has_attributes: filter if has attributes
:type has_attributes: bool
:param has_requirements: filter if has requirements
:type has_requirements: bool
:param has_capabilities: filter if has capabilities
:type has_capabilities: bool
:param has_artifacts: filter if has artifacts
:type has_artifacts: bool
:rtype: List[NodeTemplateMap]
"""
res = tosca_template_service.get_node_templates(id, type_name=type_name, node_name=node_name,
has_interfaces=has_interfaces, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts)
if res:
return res
return 'Not Found', 404
def get_node_type_name(id, node_name): # noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res = tosca_template_service.get_node_type_name(id, node_name)
if res:
return res
return 'Not Found', 404
def get_parent_type_name(id, node_name): # noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res = tosca_template_service.get_parent_type_name(id, node_name)
if res:
return res
return 'Not Found', 404
def get_related_nodes(id, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[NodeTemplateMap]
"""
res = tosca_template_service.get_related_nodes(id, node_name)
if res:
return res
return 'Not Found', 404
def get_relationship_templates(id, type_name=None, derived_from=None): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The relationship type
:type type_name: str
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_relationship_templates(id, type_name=type_name, derived_from=derived_from)
if res:
return res
return 'Not Found', 404
def get_topology_template(id): # noqa: E501
"""get_topology_template
r # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: TopologyTemplateModel
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).topology_template
if res:
return res
return 'Not Found', 404
def get_tosca_template(id): # noqa: E501
"""get_tosca_template
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: ToscaTemplateModel
"""
res = tosca_template_service.get_tosca_template_model_by_id(id)
if res:
return res
return 'Not Found', 404
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
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param kind_of_type: the type we are looking for e.g. capability_types, artifact_types. etc.
:type kind_of_type: str
:param has_interfaces: filter if has interfaces
:type has_interfaces: bool
:param type_name: The relationship type
:type type_name: str
:param has_properties: filter if has properties
:type has_properties: bool
:param has_attributes: filter if has attributes
:type has_attributes: bool
:param has_requirements: filter if has requirements
:type has_requirements: bool
:param has_capabilities: filter if has capabilities
:type has_capabilities: bool
:param has_artifacts: filter if has artifacts
:type has_artifacts: bool
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_types(id, kind_of_type=kind_of_type, has_interfaces=has_interfaces,
type_name=type_name, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts,
derived_from=derived_from)
if res:
return res
return 'Not Found', 404
def set_node_properties(id, properties, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: NodeTemplateModel
"""
res = tosca_template_service.set_node_properties(id, properties, node_name)
if res:
return res
return 'Not Found', 404
def upload_tosca_template(file): # noqa: E501
"""upload a tosca template description file
upload and validate a tosca template description file # noqa: E501
:param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage
:rtype: str
"""
res = tosca_template_service.save(file)
if res:
return res
return 'Bad Request', 400
def set_node_attributes(id, properties, node_name): # noqa: E501
"""set_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: str
"""
return 'do some magic!'
def get_node_attributes(id, node_name): # noqa: E501
"""get_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_attributes(id, node_name)
if res:
return res
return 'Not Found', 404
......@@ -2,320 +2,37 @@ import connexion
import six
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501
from sure_tosca.models.topology_template import TopologyTemplateModel # noqa: E501
from sure_tosca.models.node_template_map import NodeTemplateMapModel # noqa: E501
from sure_tosca.models.tosca_template import ToscaTemplateModel # noqa: E501
from sure_tosca import util
from sure_tosca.service import tosca_template_service
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_all_ancestor_properties(id, node_name)
if res:
return res
return 'Not Found', 404
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[str]
"""
res = tosca_template_service.get_all_ancestor_types(id, node_name)
if res:
return res
return 'Not Found', 404
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
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_all_ancestors_requirements(id, node_name)
if res:
return res
return 'Not Found', 404
def get_default_interface(id, interface_type, instance_name, operation_name): # noqa: E501
"""
returns an interface instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param interface_type: type to instantiate
:type interface_type: str
:param instance_name: the name of the instance to retrun
:type instance_name: str
:param operation_name: the name of operation
:type operation_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_default_interface(id, interface_type, instance_name, operation_name)
if res:
return res
return 'Not Found', 404
def get_default_node_type(id, node_type, instance_name): # noqa: E501
"""
returns an node templaye instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_type: type to instantiate
:type node_type: str
:param instance_name: the name of tghe instance to retrun
:type instance_name: str
:rtype: NodeTemplateMap
"""
return 'do some magic!'
def get_dsl_definitions(id, anchors=None, derived_from=None): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param anchors: the anchors the definition is for
:type anchors: List[str]
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).dsl_definitions
if res:
return res
return 'Not Found', 404
def get_imports(id): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).imports
if res:
return res
return 'Not Found', 404
def get_node_outputs(id, node_name): # noqa: E501
def add_type_definition(definition_map): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_outputs(id, node_name)
if res:
return res
return 'Not Found', 404
:param definition_map:
:type definition_map:
def get_node_properties(id, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_properties(id, node_name)
if res:
return res
return 'Not Found', 404
def get_node_requirements(id, node_name): # noqa: E501
"""get_node_requirements
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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
:rtype: str
"""
res = tosca_template_service.get_node_requirements(id, node_name)
if res:
return res
return 'Not Found', 404
return 'do some magic!'
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): # noqa: E501
def get_node_templates(id, query=None): # noqa: E501
"""get_node_templates
returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The type
:type type_name: str
:param node_name: the name
:type node_name: str
:param has_interfaces: filter if has interfaces
:type has_interfaces: bool
:param has_properties: filter if has properties
:type has_properties: bool
:param has_attributes: filter if has attributes
:type has_attributes: bool
:param has_requirements: filter if has requirements
:type has_requirements: bool
:param has_capabilities: filter if has capabilities
:type has_capabilities: bool
:param has_artifacts: filter if has artifacts
:type has_artifacts: bool
:param query: The the query
:type query: str
:rtype: List[NodeTemplateMap]
"""
res = tosca_template_service.get_node_templates(id, type_name=type_name, node_name=node_name,
has_interfaces=has_interfaces, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts)
if res:
return res
return 'Not Found', 404
def get_node_type_name(id, node_name): # noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res = tosca_template_service.get_node_type_name(id, node_name)
if res:
return res
return 'Not Found', 404
def get_parent_type_name(id, node_name): # noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res = tosca_template_service.get_parent_type_name(id, node_name)
if res:
return res
return 'Not Found', 404
def get_related_nodes(id, node_name): # noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[NodeTemplateMap]
"""
res = tosca_template_service.get_related_nodes(id, node_name)
if res:
return res
return 'Not Found', 404
def get_relationship_templates(id, type_name=None, derived_from=None): # noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The relationship type
:type type_name: str
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_relationship_templates(id, type_name=type_name, derived_from=derived_from)
if res:
return res
return 'Not Found', 404
def get_topology_template(id): # noqa: E501
"""get_topology_template
r # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: TopologyTemplateModel
"""
res = tosca_template_service.get_tosca_template_model_by_id(id).topology_template
if res:
return res
return 'Not Found', 404
return 'do some magic!'
def get_tosca_template(id): # noqa: E501
......@@ -326,72 +43,23 @@ def get_tosca_template(id): # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: ToscaTemplateModel
"""
res = tosca_template_service.get_tosca_template_model_by_id(id)
if res:
return res
return 'Not Found', 404
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
:rtype: ToscaTemplate
"""
return 'do some magic!'
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param kind_of_type: the type we are looking for e.g. capability_types, artifact_types. etc.
:type kind_of_type: str
:param has_interfaces: filter if has interfaces
:type has_interfaces: bool
:param type_name: The relationship type
:type type_name: str
:param has_properties: filter if has properties
:type has_properties: bool
:param has_attributes: filter if has attributes
:type has_attributes: bool
:param has_requirements: filter if has requirements
:type has_requirements: bool
:param has_capabilities: filter if has capabilities
:type has_capabilities: bool
:param has_artifacts: filter if has artifacts
:type has_artifacts: bool
:param derived_from: derived from
:type derived_from: str
def get_type_definition(query=None): # noqa: E501
"""get_type_definition
:rtype: List[Dict[str, object]]
"""
res = tosca_template_service.get_types(id, kind_of_type=kind_of_type, has_interfaces=has_interfaces,
type_name=type_name, has_properties=has_properties,
has_attributes=has_attributes, has_requirements=has_requirements,
has_capabilities=has_capabilities, has_artifacts=has_artifacts,
derived_from=derived_from)
if res:
return res
return 'Not Found', 404
returns types # noqa: E501
:param query: the query to run on the DB
:type query: str
def set_node_properties(id, properties, node_name): # noqa: E501
:rtype: List[NodeTemplate]
"""
return 'do some magic!'
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: NodeTemplateModel
"""
res = tosca_template_service.set_node_properties(id, properties, node_name)
if res:
return res
return 'Not Found', 404
k
def upload_tosca_template(file): # noqa: E501
"""upload a tosca template description file
......@@ -401,44 +69,6 @@ def upload_tosca_template(file): # noqa: E501
:param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage
:rtype: str
"""
res = tosca_template_service.save(file)
if res:
return res
return 'Bad Request', 400
def set_node_attributes(id, properties, node_name): # noqa: E501
"""set_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: str
"""
return 'do some magic!'
def get_node_attributes(id, node_name): # noqa: E501
"""get_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res = tosca_template_service.get_node_attributes(id, node_name)
if res:
return res
return 'Not Found', 404
......@@ -6,4 +6,4 @@ from __future__ import absolute_import
from sure_tosca.models.node_template import NodeTemplateModel
from sure_tosca.models.node_template_map import NodeTemplateMapModel
from sure_tosca.models.topology_template import TopologyTemplateModel
from sure_tosca.models.tosca_template import ToscaTemplateModel
from sure_tosca.models.tosca_template import ToscaTemplateModel
\ No newline at end of file
......@@ -20,18 +20,6 @@ from sure_tosca.models.node_template import NodeTemplateModel as NodeTemplateMod
from sure_tosca.models.node_template_map import NodeTemplateMapModel
from sure_tosca.models.tosca_template import ToscaTemplateModel as ToscaTemplateModel
from sure_tosca.service import tosca_helper
# db = TinyDB(storage=CachingMiddleware(MemoryStorage))
db_dir_path = tempfile.gettempdir()
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(storage=CachingMiddleware(MemoryStorage))
node_template_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))
logger = logging.getLogger(__name__)
if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.INFO)
......@@ -44,27 +32,6 @@ logger.handler_set = True
root_key = 'root_key'
def query_db(queries, db=None):
if queries:
query = reduce(lambda a, b: a & b, queries)
results = db.search(query)
else:
results = db.all()
if results:
updated_results = []
for res in results:
if root_key in res:
res_copy = copy.deepcopy(res)
key = res_copy[root_key]
res_copy.pop(root_key)
node = {key: res_copy}
else:
logger.error(str(res) + ' has no ' + root_key)
updated_results.append(node)
return updated_results
return None
def get_tosca_template_model_by_id(id):
tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template_model = ToscaTemplateModel.from_dict(tosca_template_dict)
......@@ -90,24 +57,11 @@ def get_tosca_template_dict_by_id(id):
return tosca_template_dict
def purge_all_tables():
node_template_db.purge_tables()
dsl_definitions_db.purge_tables()
relationship_template_db.purge_tables()
interface_types_db.purge_tables()
node_template_db.close()
dsl_definitions_db.close()
relationship_template_db.close()
interface_types_db.close()
def save(file):
# try:
# tosca_template_file_path = os.path.join(db_dir_path, file.filename)
start = time.time()
logger.info("Got request for tosca template")
purge_all_tables()
dictionary = yaml.safe_load(file.stream)
# dictionary = yaml.load(file.stream)
logger.info("tosca template: \n" + str(yaml.dump(dictionary)))
......@@ -119,36 +73,6 @@ def save(file):
# tosca_templates_db.close()
logger.info("Returning doc_id: " + str(doc_id))
return doc_id
# except Exception as e:
# logger.error(str(e))
# return str(e), 400
def get_interface_types(id, interface_type=None):
if len(interface_types_db) <= 1:
tosca_template_model = get_tosca_template_model_by_id(id)
object_list = tosca_template_model.interface_types
if object_list is None:
object_list = {}
tosca_template = get_tosca_template(tosca_template_model.to_dict())
tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
all_custom_def = tosca_template.nodetemplates[0].custom_def
object_list.update(tosca_node_types)
object_list.update(all_custom_def)
if object_list:
for interface_type_name in object_list:
if 'tosca.interfaces' in interface_type_name:
interface = {root_key: interface_type_name}
interface.update(object_list[interface_type_name])
interface_types_db.insert(interface)
queries = []
if interface_type:
query = Query()
queries.append(query.root_key == interface_type)
return query_db(queries, db=interface_types_db)
def change_to_node_template_model(query_results):
......@@ -164,107 +88,10 @@ def change_to_node_template_model(query_results):
return res
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):
if len(node_template_db) <= 1:
tosca_template_model = get_tosca_template_model_by_id(id)
object_list = tosca_template_model.topology_template.node_templates
# tosca_template = get_tosca_template(tosca_template_model.to_dict())
# tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
# all_custom_def = tosca_template.nodetemplates[0].custom_def
# object_list.update(tosca_node_types)
# object_list.update(all_custom_def)
if object_list:
for key in object_list:
node = {root_key: key}
if isinstance(object_list[key], dict):
node.update(object_list[key])
elif isinstance(object_list[key], Model):
node.update(object_list[key].to_dict())
node_template_db.insert(node)
queries = []
if node_name:
if isinstance(node_name, list):
for n in node_name:
query = Query()
queries.append(query.root_key == n)
elif isinstance(node_name, str):
query = Query()
queries.append(query.root_key == node_name)
if type_name:
query = Query()
queries.append(query.type == type_name)
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_db(queries, db=node_template_db)
def get_node_templates(id, query=None):
return change_to_node_template_model(query_results)
def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
# interface_types_db.purge()
if len(dsl_definitions_db) <= 1:
object_list = get_tosca_template_model_by_id(id).dsl_definitions
if object_list:
for key in object_list:
node = {key: object_list[key]}
interface_types_db.insert(node)
queries = []
if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if anchors:
for anchor in anchors:
query = Query()
queries.append(query.anchor == anchor)
return query_db(queries, db=dsl_definitions_db)
def get_relationship_templates(id, type_name=None, derived_from=None):
if len(relationship_template_db) <= 1:
object_list = get_tosca_template_model_by_id(id).relationship_templates
if object_list:
for key in object_list:
node = {key: object_list[key]}
relationship_template_db.insert(node)
queries = []
if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if type_name:
query = Query()
queries.append(query.type == type_name)
return query_db(queries, db=relationship_template_db)
def node_dict_2_node_template(id, node_name):
tosca_template_dict = get_tosca_template_dict_by_id(id)
if tosca_template_dict is None:
......@@ -282,13 +109,7 @@ def node_dict_2_node_template(id, node_name):
return the_node, all_node_types, all_custom_def
def get_all_ancestors_requirements(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 None
parent_requirements = tosca_helper.get_all_ancestors_requirements(the_node, all_node_types, all_custom_def)
return parent_requirements
def get_all_ancestor_properties(id, node_root_key):
......@@ -363,119 +184,4 @@ def get_node_attributes(id, node_name):
attributes = node_template_map.node_template.attributes
if attributes:
return attributes
return None
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_map = get_node_templates(id, node_name=node_name)[0]
type_name = node_template_map.node_template.type
if type_name:
return type_name
return None
def update(id, tosca_template_dict):
tosca_template = get_tosca_template(tosca_template_dict)
tosca_template_model = ToscaTemplateModel.from_dict(tosca_template_dict)
doc_id = tosca_templates_db.update(tosca_template_dict, doc_ids=[int(id)])
return doc_id
def set_node_properties(id, properties, node_name):
properties = properties['properties']
tosca_template_model = get_tosca_template_model_by_id(id)
node_template_model = tosca_template_model.topology_template.node_templates[node_name]
if node_template_model:
if node_template_model.properties:
node_template_model.properties.update(properties)
else:
node_template_model.properties = properties
tosca_template_model.topology_template.node_templates[node_name] = node_template_model
return update(id, tosca_template_model.to_dict())
return None
def get_types(id, kind_of_type, has_interfaces, type_name, has_properties, has_attributes, has_requirements,
has_capabilities, has_artifacts, derived_from):
if kind_of_type == 'interface_types':
return get_interface_types(id, interface_type=type_name)
return None
def get_default_entry_value(entry):
if 'default' in entry and 'required' in entry and entry['required']:
return entry['default']
return None
def get_all_interface_types(id, interface_type, parent_interfaces=None):
if parent_interfaces is None:
parent_interfaces = []
interface = get_interface_types(id, interface_type=interface_type)[0]
parent_interfaces.append(interface)
if 'derived_from' in interface[interface_type]:
return get_all_interface_types(id, interface[interface_type]['derived_from'], parent_interfaces)
else:
return parent_interfaces
def merge_interfaces(id, interface_type):
all_interfaces = get_all_interface_types(id, interface_type=interface_type)
if all_interfaces is None:
return None
all_inputs = {}
all_operations = {}
for interface in all_interfaces:
interface = interface[next(iter(interface))]
if 'inputs' in interface:
all_inputs.update(interface['inputs'])
for op in interface:
if op != 'description' and op != 'derived_from' and op != 'inputs':
all_operations[op] = interface[op]
the_interface = {interface_type: all_operations}
the_interface[interface_type]['inputs'] = all_inputs
return the_interface
def get_default_interface(id, interface_type, instance_name, operation_name):
the_interface = merge_interfaces(id, interface_type)
if the_interface is None:
return None
interface = the_interface[next(iter(the_interface))]
if operation_name not in interface:
raise Exception(
'Operation: ' + operation_name + ' not in interface: ' + interface_type + ' definition: ' + str(
the_interface))
inputs = interface['inputs']
instance_inputs_list = []
for key in inputs:
default_value = get_default_entry_value(inputs[key])
default_entry = {key: default_value}
instance_inputs_list.append(default_entry)
instance_inputs = {'inputs': instance_inputs_list}
operation = {operation_name: instance_inputs}
instance = {instance_name: operation}
return instance
return None
\ No newline at end of file
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501
from sure_tosca.models.node_template_map import NodeTemplateMapModel # noqa: E501
from sure_tosca.models.tosca_template import ToscaTemplateModel # noqa: E501
def add_type_definition(definition_map):
return None
def get_types(query):
return None
\ No newline at end of file
......@@ -2,579 +2,29 @@
swagger: "2.0"
info:
description: "TOSCA Simple qUeRy sErvice (SURE). "
version: "1.0.0"
version: "1.2.0"
title: "tosca-sure"
contact:
email: "S.Koulouzis@uva.nl"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
basePath: "/tosca-sure/1.0.0"
basePath: "/tosca-sure/1.2.0"
schemes:
- "https"
- "http"
paths:
/tosca_template:
post:
summary: "upload a tosca template description file"
description: "upload and validate a tosca template description file"
operationId: "upload_tosca_template"
consumes:
- "multipart/form-data"
parameters:
- name: "file"
in: "formData"
description: "tosca Template description"
required: true
type: "file"
responses:
"200":
description: "successful operation"
schema:
type: "string"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}:
get:
description: ""
operationId: "get_tosca_template"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
$ref: "#/definitions/ToscaTemplate"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/imports:
get:
summary: ""
description: "returns the interface types"
operationId: "get_imports"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/dsl_definitions:
get:
summary: ""
description: "returns the interface types"
operationId: "get_dsl_definitions"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "anchors"
in: "query"
description: "the anchors the definition is for"
required: false
type: "array"
items:
type: "string"
collectionFormat: "multi"
- name: "derived_from"
in: "query"
description: "derived from"
required: false
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/interface/{interface_type}/default:
get:
summary: ""
description: "returns an interface instance with the default required values."
operationId: "get_default_interface"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "interface_type"
in: "path"
description: "type to instantiate"
required: true
type: "string"
- name: "instance_name"
in: "query"
description: "the name of the instance to retrun"
required: true
type: "string"
- name: "operation_name"
in: "query"
description: "the name of operation"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/node_types/{node_type}/default:
get:
summary: ""
description: "returns an node templaye instance with the default required values."
operationId: "get_default_node_type"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_type"
in: "path"
description: "type to instantiate"
required: true
type: "string"
- name: "instance_name"
in: "query"
description: "the name of tghe instance to retrun"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
$ref: "#/definitions/NodeTemplateMap"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/types:
get:
summary: ""
description: "returns the interface types"
operationId: "get_types"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "kind_of_type"
in: "query"
description: "the type we are looking for e.g. capability_types, artifact_types.\
\ etc."
required: false
type: "string"
enum:
- "node_types"
- "relationship_types"
- "capability_types"
- "artifact_types"
- "data_types"
- "interface_types"
- "policy_types"
- "group_types"
- name: "has_interfaces"
in: "query"
description: "filter if has interfaces"
required: false
type: "boolean"
- name: "type_name"
in: "query"
description: "The type_name"
required: false
type: "string"
- name: "has_properties"
in: "query"
description: "filter if has properties"
required: false
type: "boolean"
- name: "has_attributes"
in: "query"
description: "filter if has attributes"
required: false
type: "boolean"
- name: "has_requirements"
in: "query"
description: "filter if has requirements"
required: false
type: "boolean"
- name: "has_capabilities"
in: "query"
description: "filter if has capabilities"
required: false
type: "boolean"
- name: "has_artifacts"
in: "query"
description: "filter if has artifacts"
required: false
type: "boolean"
- name: "derived_from"
in: "query"
description: "derived from"
required: false
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/relationship_templates:
get:
summary: ""
description: "returns the interface types"
operationId: "get_relationship_templates"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "type_name"
in: "query"
description: "The relationship type"
required: false
type: "string"
- name: "derived_from"
in: "query"
description: "derived from"
required: false
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template:
get:
description: "r"
operationId: "get_topology_template"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
$ref: "#/definitions/TopologyTemplate"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates:
get:
description: "returns nodes templates in topology"
operationId: "get_node_templates"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "type_name"
in: "query"
description: "The type"
required: false
type: "string"
- name: "node_name"
in: "query"
description: "the name"
required: false
type: "string"
- name: "has_interfaces"
in: "query"
description: "filter if has interfaces"
required: false
type: "boolean"
- name: "has_properties"
in: "query"
description: "filter if has properties"
required: false
type: "boolean"
- name: "has_attributes"
in: "query"
description: "filter if has attributes"
required: false
type: "boolean"
- name: "has_requirements"
in: "query"
description: "filter if has requirements"
required: false
type: "boolean"
- name: "has_capabilities"
in: "query"
description: "filter if has capabilities"
required: false
type: "boolean"
- name: "has_artifacts"
in: "query"
description: "filter if has artifacts"
required: false
type: "boolean"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/NodeTemplateMap"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name:
get:
summary: ""
description: ""
operationId: "get_node_type_name"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "string"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements:
get:
description: "Returns the requirements for an input node as described in the\
\ template not in the node's definition "
operationId: "get_node_requirements"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from:
get:
summary: ""
description: ""
operationId: "get_parent_type_name"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "string"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements:
get:
summary: ""
description: "Recursively get all requirements all the way to the ROOT including\
\ the input node's"
operationId: "get_ancestors_requirements"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types:
get:
summary: ""
description: "Recursively get all requirements all the way to the ROOT including\
\ the input node's"
operationId: "get_all_ancestor_types"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "string"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties:
/tosca_types:
get:
summary: ""
description: "Recursively get all requirements all the way to the ROOT including\
\ the input node's"
operationId: "get_all_ancestor_properties"
description: "returns types"
operationId: "get_type_definition"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
- name: "query"
in: "query"
description: "the query to run on the DB"
required: false
type: "string"
responses:
"200":
......@@ -582,119 +32,65 @@ paths:
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/properties:
get:
summary: ""
description: "s"
operationId: "get_node_properties"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "object"
properties: {}
$ref: "#/definitions/NodeTemplate"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
put:
post:
summary: ""
description: "s"
operationId: "set_node_properties"
operationId: "add_type_definition"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- in: "body"
name: "properties"
name: "definition_map"
required: true
schema:
type: "object"
example:
nodes: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/nodes.yaml"
data: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml"
capabilities: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/capabilities.yaml"
policies: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/policies.yaml"
interfaces: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/interfaces.yml"
additionalProperties:
type: "object"
properties: {}
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "string"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs:
get:
summary: ""
description: "s"
operationId: "get_node_outputs"
produces:
- "application/json"
/tosca_template:
post:
summary: "upload a tosca template description file"
description: "upload and validate a tosca template description file"
operationId: "upload_tosca_template"
consumes:
- "multipart/form-data"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
- name: "file"
in: "formData"
description: "tosca Template description"
required: true
type: "string"
type: "file"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
description: "Not found"
type: "string"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/related:
/tosca_template/{id}:
get:
summary: ""
description: "s"
operationId: "get_related_nodes"
description: ""
operationId: "get_tosca_template"
produces:
- "application/json"
parameters:
......@@ -703,26 +99,20 @@ paths:
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/NodeTemplateMap"
$ref: "#/definitions/ToscaTemplate"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/{node_name}/attributes:
/tosca_template/{id}/topology_template/node_templates:
get:
operationId: "get_node_attributes"
description: "returns nodes templates in topology"
operationId: "get_node_templates"
produces:
- "application/json"
parameters:
......@@ -731,58 +121,89 @@ paths:
description: "ID of topolog template uplodaed"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
- name: "query"
in: "query"
description: "The the query"
required: false
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "object"
additionalProperties:
type: "object"
properties: {}
type: "array"
items:
$ref: "#/definitions/NodeTemplateMap"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
put:
operationId: "set_node_attributes"
produces:
- "application/json"
parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
definitions:
NodeTemplate:
type: "object"
properties:
derived_from:
type: "string"
- in: "body"
name: "properties"
required: true
schema:
properties:
type: "object"
additionalProperties:
type: "object"
properties: {}
requirements:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
- name: "node_name"
in: "path"
description: "node_name"
required: true
interfaces:
type: "object"
additionalProperties:
type: "object"
properties: {}
capabilities:
type: "object"
additionalProperties:
type: "object"
properties: {}
type:
type: "string"
responses:
"200":
description: "successful operation"
schema:
type: "string"
"404":
description: "Not found"
"405":
description: "Invalid input"
x-swagger-router-controller: "sure_tosca.controllers.default_controller"
definitions:
description:
type: "string"
directives:
type: "array"
items:
type: "string"
attributes:
type: "object"
additionalProperties:
type: "object"
properties: {}
artifacts:
type: "object"
additionalProperties:
type: "object"
properties: {}
example:
requirements:
- key: "{}"
- key: "{}"
interfaces:
key: "{}"
capabilities:
key: "{}"
directives:
- "directives"
- "directives"
derived_from: "derived_from"
description: "description"
attributes:
key: "{}"
type: "type"
properties:
key: "{}"
artifacts:
key: "{}"
ToscaTemplate:
type: "object"
properties:
......@@ -1006,71 +427,6 @@ definitions:
key: "{}"
relationship_templates:
key: "{}"
NodeTemplate:
type: "object"
properties:
derived_from:
type: "string"
properties:
type: "object"
additionalProperties:
type: "object"
properties: {}
requirements:
type: "array"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
interfaces:
type: "object"
additionalProperties:
type: "object"
properties: {}
capabilities:
type: "object"
additionalProperties:
type: "object"
properties: {}
type:
type: "string"
description:
type: "string"
directives:
type: "array"
items:
type: "string"
attributes:
type: "object"
additionalProperties:
type: "object"
properties: {}
artifacts:
type: "object"
additionalProperties:
type: "object"
properties: {}
example:
requirements:
- key: "{}"
- key: "{}"
interfaces:
key: "{}"
capabilities:
key: "{}"
directives:
- "directives"
- "directives"
derived_from: "derived_from"
description: "description"
attributes:
key: "{}"
type: "type"
properties:
key: "{}"
artifacts:
key: "{}"
NodeTemplateMap:
type: "object"
properties:
......
......@@ -4,401 +4,85 @@ from __future__ import absolute_import
from flask import json
from six import BytesIO
import os
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501
from sure_tosca.models.topology_template import TopologyTemplateModel # noqa: E501
from sure_tosca.models.node_template_map import NodeTemplateMapModel # noqa: E501
from sure_tosca.models.tosca_template import ToscaTemplateModel # noqa: E501
from sure_tosca.test import BaseTestCase
import werkzeug
werkzeug.cached_property = werkzeug.utils.cached_property
class TestDefaultController(BaseTestCase):
"""DefaultController integration test stubs"""
def test_get_all_ancestor_properties(self):
"""Test case for get_all_ancestor_properties
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_properties'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertEqual(response.status_code, 200)
self.assertTrue(response.is_json)
self.assertIsInstance(response.json, list)
def test_get_all_ancestor_types(self):
"""Test case for get_all_ancestor_types
def test_add_type_definition(self):
"""Test case for add_type_definition
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_types'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertEqual(response.status_code, 200)
self.assertTrue(response.is_json)
self.assertIsInstance(response.json, list)
def test_get_ancestors_requirements(self):
"""Test case for get_ancestors_requirements
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/ancestors_requirements'.format(
id=id_example, node_name='kubernetes'),
method='GET')
self.assertEqual(response.status_code, 200)
self.assertTrue(response.is_json)
self.assertIsInstance(response.json, list)
def test_get_dsl_definitions(self):
"""Test case for get_dsl_definitions
"""
# query_string = [('anchors', 'anchors_example'), ('derived_from', 'derived_from_example')]
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/dsl_definitions'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
def test_get_imports(self):
"""Test case for get_imports
"""
id_example = self.upload_2_topologies_file()
definition_map = None
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/imports'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
def test_get_node_outputs(self):
"""Test case for get_node_outputs
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/outputs'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_node_properties(self):
"""Test case for get_node_properties
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_node_requirements(self):
"""Test case for get_node_requirements
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/requirements'.format(
id=id_example, node_name='kubernetes'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
'/tosca-sure/1.2.0/tosca_types',
method='POST',
data=json.dumps(definition_map),
content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_node_templates(self):
"""Test case for get_node_templates
"""
id_example = self.upload_2_topologies_file()
query_string = [('type_name', None),
('node_name', 'compute'),
('has_interfaces', True),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('type_name', None),
('node_name', None),
('has_interfaces', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('type_name', 'tosca.nodes.ARTICONF.Container.Application.Docker'),
('node_name', None),
('has_interfaces', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_get_node_type_name(self):
"""Test case for get_node_type_name
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/type_name'.format(
id=id_example, node_name='compute'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, str)
def test_get_parent_type_name(self):
"""Test case for get_parent_type_name
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/derived_from'.format(
id=id_example, node_name='kubernetes'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, str)
def test_get_related_nodes(self):
"""Test case for get_related_nodes
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/related'.format(
id=id_example, node_name='mysql'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_get_relationship_templates(self):
"""Test case for get_relationship_templates
"""
id_example = self.upload_2_topologies_file()
query_string = [('type_name', None),
('derived_from', None)]
query_string = [('query', 'query_example')]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/relationship_templates'.format(id=id_example),
'/tosca-sure/1.2.0/tosca_template/{id}/topology_template/node_templates'.format(id='id_example'),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
def test_get_topology_template(self):
"""Test case for get_topology_template
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template'.format(id=id_example),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_tosca_template(self):
"""Test case for get_tosca_template
"""
id_example = self.upload_2_topologies_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}'.format(id=id_example),
'/tosca-sure/1.2.0/tosca_template/{id}'.format(id='id_example'),
method='GET')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
def test_get_types(self):
"""Test case for get_types
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_type_definition(self):
"""Test case for get_type_definition
"""
id_example = self.upload_2_topologies_file()
query_string = [('kind_of_type', 'interface_types'),
('has_interfaces', None),
('type_name', 'tosca.interfaces.ARTICONF.CloudsStorm'),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None),
('derived_from', None)]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/types'.format(id=id_example),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
query_string = [('kind_of_type', 'interface_types'),
('has_interfaces', None),
('type_name', None),
('has_properties', None),
('has_attributes', None),
('has_requirements', None),
('has_capabilities', None),
('has_artifacts', None),
('derived_from', 'tosca.interfaces.node.lifecycle.Standard')]
query_string = [('query', 'query_example')]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/types'.format(id=id_example),
'/tosca-sure/1.2.0/tosca_types',
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def test_set_node_properties(self):
"""Test case for set_node_properties
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_upload_tosca_template(self):
"""Test case for upload_tosca_template
upload a tosca template description file
"""
id_example = self.upload_2_topologies_file()
properties = {'properties': {'cpu_frequency': '2 GHz'}}
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_name}/properties'.format(
id=id_example, node_name='compute'),
method='PUT',
data=json.dumps(properties),
content_type='application/json')
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
def upload_2_topologies_file(self):
tosca_path = "../../../TOSCA/"
file_name = 'application_example_2_topologies.yaml' # 'application_example_updated.yaml' # 'application_example_2_topologies.yaml'
input_tosca_file_path = tosca_path + '/' + file_name
if not os.path.exists(input_tosca_file_path):
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
dir_path = os.path.dirname(os.path.realpath(__file__))
self.assertEqual(True, os.path.exists(input_tosca_file_path),
'Starting from: ' + dir_path + ' Input TOSCA file: ' + input_tosca_file_path + ' not found')
with open(input_tosca_file_path, 'r') as file:
contents = file.read()
byte_contents = bytes(contents, 'utf8')
data = dict(file=(BytesIO(byte_contents), input_tosca_file_path))
data = dict(file=(BytesIO(b'some file data'), 'file.txt'))
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template',
'/tosca-sure/1.2.0/tosca_template',
method='POST',
data=data,
content_type='multipart/form-data')
file_id = response.data.decode('utf-8').replace('\n', '')
return file_id
def upload_application_example_file(self):
tosca_path = "../../../TOSCA/"
file_name = 'application_example_updated.yaml' # 'application_example_updated.yaml' # 'application_example_2_topologies.yaml'
input_tosca_file_path = tosca_path + '/' + file_name
if not os.path.exists(input_tosca_file_path):
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
dir_path = os.path.dirname(os.path.realpath(__file__))
self.assertEqual(True, os.path.exists(input_tosca_file_path),
'Starting from: ' + dir_path + ' Input TOSCA file: ' + input_tosca_file_path + ' not found')
with open(input_tosca_file_path, 'r') as file:
contents = file.read()
byte_contents = bytes(contents, 'utf8')
data = dict(file=(BytesIO(byte_contents), input_tosca_file_path))
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template',
method='POST',
data=data,
content_type='multipart/form-data')
file_id = response.data.decode('utf-8').replace('\n', '')
return file_id
def test_get_node_templates2(self):
"""Test case for get_node_templates
"""
id_example = self.upload_application_example_file()
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'.format(id=id_example),
method='GET',
query_string=None)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, list)
self.assertTrue(response.json)
def test_get_default_interface(self):
"""Test case for get_default_interface
"""
id_example = self.upload_2_topologies_file()
query_string = [('instance_name', 'instance_name_example'),
('operation_name', 'provision')]
response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/interface/{interface_type}/default'.format(id=id_example,
interface_type='tosca.interfaces.ARTICONF.CloudsStorm'),
method='GET',
query_string=query_string)
self.assertTrue(response.is_json)
self.assertEqual(response.status_code, 200)
self.assertIsInstance(response.json, dict)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
if __name__ == '__main__':
import unittest
unittest.main()
......@@ -4,4 +4,4 @@ coverage==5.0.3
nose>=1.3.7
pluggy>=0.13.1
randomize>=0.14
Werkzeug==0.16.1
\ No newline at end of file
werkzeug==1.0.0
\ 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