Commit 59e4b88d authored by Spiros Koulouzis's avatar Spiros Koulouzis

resolve conflicts

parents c24f404d ab6a1a17
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA example
imports:
<<<<<<< HEAD
- 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
repositories:
docker_hub: https://hub.docker.com/
description: >
TOSCA example
topology_template:
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:
ports:
- "30001:8080"
artifacts:
image:
type: tosca.artifacts.Deployment.Image.Container.Docker
file: alogo53/ws-pema-lifewatch
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
interfaces:
Kubernetes:
create:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml"
install:
inputs:
playbook: "https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml"
#topology:
#type: tosca.nodes.ARTICONF.VM.topology
#properties:
#domain: "UvA (Amsterdam, The Netherlands) XO Rack"
#provider: "ExoGENI"
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: "SEQ"
#object_type: "SubTopology"
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
artifacts: artifacts:
type: object type: object
additionalProperties: additionalProperties:
type: object type: object
......
werkzeug==1.0.0
PyYAML PyYAML
wheel==0.33.6 wheel==0.34.2
connexion == 2.4.0 connexion==2.6.0
python-dateutil == 2.8.0 python-dateutil==2.8.1
typing == 3.7.4.1 typing==3.7.4.1
swagger-ui-bundle == 0.0.5 swagger-ui-bundle==0.0.6
tinydb == 3.15.1 # tinydb==3.15.1
tosca-parser ==1.6.1 tosca-parser ==1.7.0
...@@ -4,7 +4,7 @@ import sys ...@@ -4,7 +4,7 @@ import sys
from setuptools import setup, find_packages from setuptools import setup, find_packages
NAME = "sure_tosca" NAME = "sure_tosca"
VERSION = "1.0.0" VERSION = "1.2.0"
# To install the library, run the following # To install the library, run the following
# #
......
#!/usr/bin/env python #!/usr/bin/env python3
import connexion 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&#39;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&#39;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&#39;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&#39;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 ...@@ -2,320 +2,37 @@ import connexion
import six import six
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501 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.models.tosca_template import ToscaTemplateModel # noqa: E501
from sure_tosca import util from sure_tosca import util
from sure_tosca.service import tosca_template_service
def get_all_ancestor_properties(id, node_name): # noqa: E501 def add_type_definition(definition_map): # noqa: E501
"""
Recursively get all requirements all the way to the ROOT including the input node&#39;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&#39;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&#39;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 s # noqa: E501
:param id: ID of topolog template uplodaed :param definition_map:
:type id: str :type definition_map:
: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 :rtype: str
"""
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&#39;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) return 'do some magic!'
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, def get_node_templates(id, query=None): # noqa: E501
has_attributes=None, has_requirements=None, has_capabilities=None,
has_artifacts=None): # noqa: E501
"""get_node_templates """get_node_templates
returns nodes templates in topology # noqa: E501 returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed :param id: ID of topolog template uplodaed
:type id: str :type id: str
:param type_name: The type :param query: The the query
:type type_name: str :type query: 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] :rtype: List[NodeTemplateMap]
""" """
res = tosca_template_service.get_node_templates(id, type_name=type_name, node_name=node_name, return 'do some magic!'
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 def get_tosca_template(id): # noqa: E501
...@@ -326,72 +43,23 @@ 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 :param id: ID of topolog template uplodaed
:type id: str :type id: str
:rtype: ToscaTemplateModel :rtype: ToscaTemplate
"""
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
""" """
return 'do some magic!'
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed def get_type_definition(query=None): # noqa: E501
:type id: str """get_type_definition
: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]] returns types # noqa: E501
"""
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
: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 def upload_tosca_template(file): # noqa: E501
"""upload a tosca template description file """upload a tosca template description file
...@@ -401,44 +69,6 @@ def upload_tosca_template(file): # noqa: E501 ...@@ -401,44 +69,6 @@ def upload_tosca_template(file): # noqa: E501
:param file: tosca Template description :param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage :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 :rtype: str
""" """
return 'do some magic!' 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 ...@@ -6,4 +6,4 @@ from __future__ import absolute_import
from sure_tosca.models.node_template import NodeTemplateModel from sure_tosca.models.node_template import NodeTemplateModel
from sure_tosca.models.node_template_map import NodeTemplateMapModel from sure_tosca.models.node_template_map import NodeTemplateMapModel
from sure_tosca.models.topology_template import TopologyTemplateModel 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 ...@@ -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.node_template_map import NodeTemplateMapModel
from sure_tosca.models.tosca_template import ToscaTemplateModel as ToscaTemplateModel 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__) logger = logging.getLogger(__name__)
if not getattr(logger, 'handler_set', None): if not getattr(logger, 'handler_set', None):
logger.setLevel(logging.INFO) logger.setLevel(logging.INFO)
...@@ -44,27 +32,6 @@ logger.handler_set = True ...@@ -44,27 +32,6 @@ logger.handler_set = True
root_key = 'root_key' 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): def get_tosca_template_model_by_id(id):
tosca_template_dict = get_tosca_template_dict_by_id(id) tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template_model = ToscaTemplateModel.from_dict(tosca_template_dict) tosca_template_model = ToscaTemplateModel.from_dict(tosca_template_dict)
...@@ -90,24 +57,11 @@ def get_tosca_template_dict_by_id(id): ...@@ -90,24 +57,11 @@ def get_tosca_template_dict_by_id(id):
return tosca_template_dict 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): 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)
start = time.time() start = time.time()
logger.info("Got request for tosca template") logger.info("Got request for tosca template")
purge_all_tables()
dictionary = yaml.safe_load(file.stream) dictionary = yaml.safe_load(file.stream)
# dictionary = yaml.load(file.stream) # dictionary = yaml.load(file.stream)
logger.info("tosca template: \n" + str(yaml.dump(dictionary))) logger.info("tosca template: \n" + str(yaml.dump(dictionary)))
...@@ -119,36 +73,6 @@ def save(file): ...@@ -119,36 +73,6 @@ def save(file):
# tosca_templates_db.close() # tosca_templates_db.close()
logger.info("Returning doc_id: " + str(doc_id)) logger.info("Returning doc_id: " + str(doc_id))
return 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): def change_to_node_template_model(query_results):
...@@ -164,107 +88,10 @@ def change_to_node_template_model(query_results): ...@@ -164,107 +88,10 @@ def change_to_node_template_model(query_results):
return res return res
def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, has_properties=None, def get_node_templates(id, query=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)
return change_to_node_template_model(query_results) 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): 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)
if tosca_template_dict is None: if tosca_template_dict is None:
...@@ -282,13 +109,7 @@ def node_dict_2_node_template(id, node_name): ...@@ -282,13 +109,7 @@ def node_dict_2_node_template(id, node_name):
return the_node, all_node_types, all_custom_def 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): def get_all_ancestor_properties(id, node_root_key):
...@@ -363,119 +184,4 @@ def get_node_attributes(id, node_name): ...@@ -363,119 +184,4 @@ def get_node_attributes(id, node_name):
attributes = node_template_map.node_template.attributes attributes = node_template_map.node_template.attributes
if attributes: if attributes:
return attributes return attributes
return None return None
\ No newline at end of file
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
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 @@ ...@@ -2,579 +2,29 @@
swagger: "2.0" swagger: "2.0"
info: info:
description: "TOSCA Simple qUeRy sErvice (SURE). " description: "TOSCA Simple qUeRy sErvice (SURE). "
version: "1.0.0" version: "1.2.0"
title: "tosca-sure" title: "tosca-sure"
contact: contact:
email: "S.Koulouzis@uva.nl" email: "S.Koulouzis@uva.nl"
license: license:
name: "Apache 2.0" name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
basePath: "/tosca-sure/1.0.0" basePath: "/tosca-sure/1.2.0"
schemes: schemes:
- "https" - "https"
- "http" - "http"
paths: paths:
/tosca_template: /tosca_types:
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:
get: get:
summary: "" description: "returns types"
description: "Recursively get all requirements all the way to the ROOT including\ operationId: "get_type_definition"
\ the input node's"
operationId: "get_all_ancestor_properties"
produces: produces:
- "application/json" - "application/json"
parameters: parameters:
- name: "id" - name: "query"
in: "path" in: "query"
description: "ID of topolog template uplodaed" description: "the query to run on the DB"
required: true required: false
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string" type: "string"
responses: responses:
"200": "200":
...@@ -582,119 +32,65 @@ paths: ...@@ -582,119 +32,65 @@ paths:
schema: schema:
type: "array" type: "array"
items: items:
type: "object" $ref: "#/definitions/NodeTemplate"
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: {}
"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"
put: post:
summary: "" summary: ""
description: "s" description: "s"
operationId: "set_node_properties" operationId: "add_type_definition"
produces: produces:
- "application/json" - "application/json"
parameters: parameters:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string"
- in: "body" - in: "body"
name: "properties" name: "definition_map"
required: true required: true
schema: schema:
type: "object" 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: additionalProperties:
type: "object" type: "string"
properties: {}
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses: responses:
"200": "200":
description: "successful operation" description: "successful operation"
schema: schema:
type: "string" type: "string"
"404":
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_name}/outputs: /tosca_template:
get: post:
summary: "" summary: "upload a tosca template description file"
description: "s" description: "upload and validate a tosca template description file"
operationId: "get_node_outputs" operationId: "upload_tosca_template"
produces: consumes:
- "application/json" - "multipart/form-data"
parameters: parameters:
- name: "id" - name: "file"
in: "path" in: "formData"
description: "ID of topolog template uplodaed" description: "tosca Template description"
required: true
type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true required: true
type: "string" type: "file"
responses: responses:
"200": "200":
description: "successful operation" description: "successful operation"
schema: schema:
type: "array" type: "string"
items:
type: "object"
additionalProperties:
type: "object"
properties: {}
"404":
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_name}/related: /tosca_template/{id}:
get: get:
summary: "" description: ""
description: "s" operationId: "get_tosca_template"
operationId: "get_related_nodes"
produces: produces:
- "application/json" - "application/json"
parameters: parameters:
...@@ -703,26 +99,20 @@ paths: ...@@ -703,26 +99,20 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_name"
in: "path"
description: "node_name"
required: true
type: "string"
responses: responses:
"200": "200":
description: "successful operation" description: "successful operation"
schema: schema:
type: "array" $ref: "#/definitions/ToscaTemplate"
items:
$ref: "#/definitions/NodeTemplateMap"
"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_name}/attributes: /tosca_template/{id}/topology_template/node_templates:
get: get:
operationId: "get_node_attributes" description: "returns nodes templates in topology"
operationId: "get_node_templates"
produces: produces:
- "application/json" - "application/json"
parameters: parameters:
...@@ -731,58 +121,89 @@ paths: ...@@ -731,58 +121,89 @@ paths:
description: "ID of topolog template uplodaed" description: "ID of topolog template uplodaed"
required: true required: true
type: "string" type: "string"
- name: "node_name" - name: "query"
in: "path" in: "query"
description: "node_name" description: "The the query"
required: true required: false
type: "string" type: "string"
responses: responses:
"200": "200":
description: "successful operation" description: "successful operation"
schema: schema:
type: "object" type: "array"
additionalProperties: items:
type: "object" $ref: "#/definitions/NodeTemplateMap"
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"
put: definitions:
operationId: "set_node_attributes" NodeTemplate:
produces: type: "object"
- "application/json" properties:
parameters: derived_from:
- name: "id"
in: "path"
description: "ID of topolog template uplodaed"
required: true
type: "string" type: "string"
- in: "body" properties:
name: "properties" type: "object"
required: true additionalProperties:
schema: type: "object"
properties: {}
requirements:
type: "array"
items:
type: "object" type: "object"
additionalProperties: additionalProperties:
type: "object" type: "object"
properties: {} properties: {}
- name: "node_name" interfaces:
in: "path" type: "object"
description: "node_name" additionalProperties:
required: true type: "object"
properties: {}
capabilities:
type: "object"
additionalProperties:
type: "object"
properties: {}
type:
type: "string" type: "string"
responses: description:
"200": type: "string"
description: "successful operation" directives:
schema: type: "array"
type: "string" items:
"404": type: "string"
description: "Not found" attributes:
"405": type: "object"
description: "Invalid input" additionalProperties:
x-swagger-router-controller: "sure_tosca.controllers.default_controller" type: "object"
definitions: 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: ToscaTemplate:
type: "object" type: "object"
properties: properties:
...@@ -1006,71 +427,6 @@ definitions: ...@@ -1006,71 +427,6 @@ definitions:
key: "{}" key: "{}"
relationship_templates: relationship_templates:
key: "{}" 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: NodeTemplateMap:
type: "object" type: "object"
properties: properties:
......
...@@ -4,401 +4,85 @@ from __future__ import absolute_import ...@@ -4,401 +4,85 @@ from __future__ import absolute_import
from flask import json from flask import json
from six import BytesIO from six import BytesIO
import os
from sure_tosca.models.node_template import NodeTemplateModel # noqa: E501 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.models.tosca_template import ToscaTemplateModel # noqa: E501
from sure_tosca.test import BaseTestCase from sure_tosca.test import BaseTestCase
import werkzeug
werkzeug.cached_property = werkzeug.utils.cached_property
class TestDefaultController(BaseTestCase): class TestDefaultController(BaseTestCase):
"""DefaultController integration test stubs""" """DefaultController integration test stubs"""
def test_get_all_ancestor_properties(self): def test_add_type_definition(self):
"""Test case for get_all_ancestor_properties """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_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
""" """
id_example = self.upload_2_topologies_file() definition_map = None
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()
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template/{id}/imports'.format(id=id_example), '/tosca-sure/1.2.0/tosca_types',
method='GET') method='POST',
self.assertTrue(response.is_json) data=json.dumps(definition_map),
content_type='application/json')
def test_get_node_outputs(self): self.assert200(response,
"""Test case for get_node_outputs 'Response body is : ' + response.data.decode('utf-8'))
"""
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)
def test_get_node_templates(self): def test_get_node_templates(self):
"""Test case for get_node_templates """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 = [('query', 'query_example')]
query_string = [('type_name', None),
('derived_from', None)]
response = self.client.open( 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', method='GET',
query_string=query_string) query_string=query_string)
self.assertTrue(response.is_json) self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
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)
def test_get_tosca_template(self): def test_get_tosca_template(self):
"""Test case for get_tosca_template """Test case for get_tosca_template
""" """
id_example = self.upload_2_topologies_file()
response = self.client.open( 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') method='GET')
self.assertTrue(response.is_json) self.assert200(response,
self.assertEqual(response.status_code, 200) 'Response body is : ' + response.data.decode('utf-8'))
self.assertIsInstance(response.json, dict)
def test_get_types(self):
"""Test case for get_types
def test_get_type_definition(self):
"""Test case for get_type_definition
""" """
id_example = self.upload_2_topologies_file() query_string = [('query', 'query_example')]
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')]
response = self.client.open( 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', method='GET',
query_string=query_string) query_string=query_string)
self.assertTrue(response.is_json) self.assert200(response,
self.assertEqual(response.status_code, 200) 'Response body is : ' + response.data.decode('utf-8'))
self.assertIsInstance(response.json, list)
def test_set_node_properties(self):
"""Test case for set_node_properties
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() data = dict(file=(BytesIO(b'some file data'), 'file.txt'))
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))
response = self.client.open( response = self.client.open(
'/tosca-sure/1.0.0/tosca_template', '/tosca-sure/1.2.0/tosca_template',
method='POST', method='POST',
data=data, data=data,
content_type='multipart/form-data') content_type='multipart/form-data')
file_id = response.data.decode('utf-8').replace('\n', '') self.assert200(response,
return file_id 'Response body is : ' + response.data.decode('utf-8'))
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)
if __name__ == '__main__': if __name__ == '__main__':
import unittest import unittest
unittest.main() unittest.main()
...@@ -4,4 +4,4 @@ coverage==5.0.3 ...@@ -4,4 +4,4 @@ coverage==5.0.3
nose>=1.3.7 nose>=1.3.7
pluggy>=0.13.1 pluggy>=0.13.1
randomize>=0.14 randomize>=0.14
Werkzeug==0.16.1 werkzeug==1.0.0
\ No newline at end of file \ 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