Commit 1e62a63b authored by Spiros Koulouzis's avatar Spiros Koulouzis

moved some properties to attributes

new tosca example file 
parent e9c010de
tosca_definitions_version: tosca_simple_yaml_1_0
description: TOSCA example
imports:
- nodes: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
- capabilities: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
- policies: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
- interfaces: https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
repositories:
docker_hub: https://hub.docker.com/
topology_template:
node_templates:
compute:
interfaces:
Standard:
create: dumy.yaml
properties:
disk_size: 50000 MB
host_name: vm
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
role: master
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
compute_1:
interfaces:
Standard:
create: dumy.yaml
properties:
disk_size: 50000 MB
host_name: vm
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
role: worker
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
compute_2:
interfaces:
Standard:
create: dumy.yaml
properties:
disk_size: 50000 MB
host_name: vm
mem_size: 6000 MB
num_cores: 2
os: ubuntu 16
role: worker
user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute
kubernetes:
interfaces:
Standard:
create: interfaces/playbooks/kubernetes_install.yaml
requirements:
- host:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology
relationship: tosca.relationships.HostedOn
- host:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology_1
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
mysql:
artifacts:
image:
file: mysql:5.7
repository: docker_hub
type: tosca.artifacts.Deployment.Image.Container.Docker
properties:
environment:
MYSQL_DATABASE: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_USER: wordpress
ports:
- 3306:3306
volumes:
- db_data:/var/lib/mysql
requirements:
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
topology:
interfaces:
Standard:
create: dumy.yaml
properties:
domain: UvA (Amsterdam, The Netherlands) XO Rack
provider: ExoGeni
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_1
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology
topology:
interfaces:
Standard:
create: dumy.yaml
properties:
domain: Some other Rack
provider: ExoGeni
requirements:
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_2
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology
wordpress:
artifacts:
image:
file: wordpress:latest
repository: docker_hub
type: tosca.artifacts.Deployment.Image.Container.Docker
properties:
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_USER: wordpress
ports:
- 8000:80
requirements:
- service:
node: mysql
relationship:
type: tosca.relationships.DependsOn
- host:
capability: tosca.capabilities.ARTICONF.Orchestrator
node: kubernetes
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Container.Application.Docker
policies:
- scalability:
properties:
fault_tolerance_level: 0
targets:
- mysql
type: tosca.policies.ARTICONF.FaultTolerance
outputs:
private_ip_compute:
description: The private IP address of the application’s first tier.
value: { get_attribute: [compute, private_address] }
private_ip_compute_1:
description: The private IP address of the application’s second tier.
value: { get_attribute: [compute_1, private_address] }
private_ip_compute_2:
description: The private IP address of the application’s second tier.
value: { get_attribute: [compute_2, private_address] }
...@@ -11,13 +11,59 @@ topology_template: ...@@ -11,13 +11,59 @@ topology_template:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
properties: properties:
disk_size: 50000 MB cpu_frequency:
host_name: vm constraints:
mem_size: 6000 MB - greater_or_equal: 0.5 GHz
num_cores: 2 required: false
os: ubuntu 16 type: scalar-unit.frequency
role: master disk_size:
user_name: vm_user constraints:
- greater_or_equal: 15000 MB
default: 50000 MB
required: true
type: scalar-unit.size
host_name:
default: vm
required: true
type: string
mem_size:
constraints:
- greater_or_equal: 500 MB
default: 6000 MB
required: true
type: scalar-unit.size
node_type:
description: the type of VM depending on the provider. e.g. XOSmall, t.medium
etc. It has to match the mem_size, num_cores etc.
required: false
type: string
num_cores:
constraints:
- greater_or_equal: 1
default: 2
required: true
type: integer
os:
default: ubuntu 16
required: true
type: string
private_ip:
description: The private IP of the VM e.g. 192.168.10.10
required: false
type: string
role:
constraints:
- valid_values:
- master
- worker
default: master
description: the role of the VM in the topology
required: true
type: string
user_name:
default: vm_user
required: true
type: string
type: tosca.nodes.ARTICONF.VM.Compute type: tosca.nodes.ARTICONF.VM.Compute
compute_1: compute_1:
interfaces: interfaces:
...@@ -32,7 +78,7 @@ topology_template: ...@@ -32,7 +78,7 @@ topology_template:
role: worker role: worker
user_name: vm_user user_name: vm_user
type: tosca.nodes.ARTICONF.VM.Compute type: tosca.nodes.ARTICONF.VM.Compute
compute_3: compute_2:
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
...@@ -54,10 +100,6 @@ topology_template: ...@@ -54,10 +100,6 @@ topology_template:
capability: tosca.capabilities.ARTICONF.VM.topology capability: tosca.capabilities.ARTICONF.VM.topology
node: topology node: topology
relationship: tosca.relationships.HostedOn relationship: tosca.relationships.HostedOn
- host:
capability: tosca.capabilities.ARTICONF.VM.topology
node: topology_1
relationship: tosca.relationships.HostedOn
type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
mysql: mysql:
artifacts: artifacts:
...@@ -86,29 +128,48 @@ topology_template: ...@@ -86,29 +128,48 @@ topology_template:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
properties: properties:
domain: UvA (Amsterdam, The Netherlands) XO Rack credential:
provider: ExoGeni required: false
type: tosca.datatypes.Credential
domain:
default: UvA (Amsterdam, The Netherlands) XO Rack
description: the domain of this topology e.g. California, UvA, etc
required: true
type: string
name:
description: the name of this topology
required: false
type: string
provider:
default: ExoGeni
description: The name of the provider e.g. EC2, ExoGeni etc.
required: true
type: string
subnet:
description: The subnet of the VMs this topology e.g. 192.168.10.10/24
required: false
type: string
requirements: requirements:
- vm: - vm:
capability: tosca.capabilities.ARTICONF.VM capability: tosca.capabilities.ARTICONF.VM
node: compute node: compute
relationship: tosca.relationships.DependsOn relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute_1
relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology type: tosca.nodes.ARTICONF.VM.topology
topology_1: topology_1:
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
properties: properties:
domain: NICTA (Sydney, Australia) XO Rack domain: Some other Rack
provider: ExoGeni provider: ExoGeni
requirements: requirements:
- vm: - vm:
capability: tosca.capabilities.ARTICONF.VM capability: tosca.capabilities.ARTICONF.VM
node: compute_3 node: compute_2
relationship: tosca.relationships.DependsOn
- vm:
capability: tosca.capabilities.ARTICONF.VM
node: compute
relationship: tosca.relationships.DependsOn relationship: tosca.relationships.DependsOn
type: tosca.nodes.ARTICONF.VM.topology type: tosca.nodes.ARTICONF.VM.topology
wordpress: wordpress:
......
...@@ -12,6 +12,15 @@ repositories: ...@@ -12,6 +12,15 @@ repositories:
description: > description: >
TOSCA example TOSCA example
interface_types:
tosca.interfaces.TEST.test:
description: test
derived_from: tosca.interfaces.node.lifecycle.Standard
create:
description: creates
configure:
description: configures
topology_template: topology_template:
node_templates: node_templates:
......
...@@ -50,7 +50,7 @@ node_types: ...@@ -50,7 +50,7 @@ node_types:
type: tosca.capabilities.Container.Docker type: tosca.capabilities.Container.Docker
container: container:
type: tosca.capabilities.Container type: tosca.capabilities.Container
properties: attributes:
masters_num: masters_num:
type: integer type: integer
required: true required: true
...@@ -94,15 +94,15 @@ node_types: ...@@ -94,15 +94,15 @@ node_types:
topology: topology:
type: tosca.capabilities.ARTICONF.VM.topology type: tosca.capabilities.ARTICONF.VM.topology
properties: properties:
provider:
type: string
required: true
default: "ExoGeni"
description: The name of the provider e.g. EC2, ExoGeni etc.
name: name:
type: string type: string
required: false required: false
description: the name of this topology description: the name of this topology
subnet:
type: string
required: false
description: The subnet of the VMs this topology e.g. 192.168.10.10/24
attributes:
domain: domain:
type: string type: string
required: true required: true
...@@ -111,10 +111,11 @@ node_types: ...@@ -111,10 +111,11 @@ node_types:
credential: credential:
type: tosca.datatypes.Credential type: tosca.datatypes.Credential
required: false required: false
subnet: provider:
type: string type: string
required: false required: true
description: The subnet of the VMs this topology e.g. 192.168.10.10/24 default: "ExoGeni"
description: The name of the provider e.g. EC2, ExoGeni etc.
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
...@@ -126,14 +127,6 @@ node_types: ...@@ -126,14 +127,6 @@ node_types:
compute: compute:
type: tosca.capabilities.ARTICONF.VM type: tosca.capabilities.ARTICONF.VM
properties: properties:
user_name:
type: string
required: true
default: "vm_user"
host_name:
type: string
required: true
default: "vm"
num_cores: num_cores:
type: integer type: integer
required: true required: true
...@@ -161,6 +154,16 @@ node_types: ...@@ -161,6 +154,16 @@ node_types:
type: string type: string
required: true required: true
default: "ubuntu 16" default: "ubuntu 16"
# outputs for this node
attributes:
private_ip:
type: string
required: false
description: The private IP of the VM e.g. 192.168.10.10
public_ip:
type: string
required: false
description: The public IP
role: role:
type: string type: string
required: true required: true
...@@ -168,15 +171,18 @@ node_types: ...@@ -168,15 +171,18 @@ node_types:
default: "master" default: "master"
constraints: constraints:
- valid_values: [ "master","worker" ] - valid_values: [ "master","worker" ]
private_ip:
type: string
required: false
description: The private IP of the VM e.g. 192.168.10.10
node_type: node_type:
type: string type: string
required: false required: false
description: the type of VM depending on the provider. e.g. XOSmall, t.medium etc. It has to match the mem_size, num_cores etc. description: the type of VM depending on the provider. e.g. XOSmall, t.medium etc. It has to match the mem_size, num_cores etc.
user_name:
type: string
required: true
default: "vm_user"
host_name:
type: string
required: true
default: "vm"
interfaces: interfaces:
Standard: Standard:
create: dumy.yaml create: dumy.yaml
......
...@@ -2,28 +2,18 @@ ...@@ -2,28 +2,18 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment=""> <list default="true" id="462ede19-adfe-472b-975e-fefefa973fe0" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_output.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/application_example_updated.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../TOSCA/types/nodes.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/requirements.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/controllers/default_controller.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/controllers/default_controller.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/controllers/default_controller.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/controllers/default_controller.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/base_model_.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/base_model_.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/node_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/node_template.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/node_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/node_template.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/topology_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/topology_template.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/topology_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/topology_template.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/tosca_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/tosca_template.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/tosca_template.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/models/tosca_template.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/chardetect" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/chardetect" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/test/test_default_controller.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/sure_tosca/test/test_default_controller.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/connexion" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/connexion" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/flask" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/flask" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/jsonschema" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/jsonschema" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/openapi-spec-validator" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/openapi-spec-validator" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/pbr" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/pbr" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/pybabel" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/pybabel" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/tosca-parser" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/bin/tosca-parser" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/attr/converters.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/attr/converters.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/attr/filters.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/attr/filters.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/find_package.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/find_package.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/pbr_json.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/pbr_json.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/tests/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/tests/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/tests/testpackage/pbr_testpackage/wsgi.py" beforeDir="false" afterPath="$PROJECT_DIR$/../sure_tosca-flask-server/venv/lib/python3.6/site-packages/pbr/tests/testpackage/pbr_testpackage/wsgi.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
...@@ -113,7 +103,7 @@ ...@@ -113,7 +103,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/src/rpc_server.py" />
<option name="PARAMETERS" value="localhost planner" /> <option name="PARAMETERS" value="test_local" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" /> <option name="MODULE_MODE" value="false" />
...@@ -302,7 +292,14 @@ ...@@ -302,7 +292,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1571760668434</updated> <updated>1571760668434</updated>
</task> </task>
<option name="localTasksCounter" value="19" /> <task id="LOCAL-00019" summary="we have a bug with setting default properties">
<created>1572451502431</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1572451502431</updated>
</task>
<option name="localTasksCounter" value="20" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
...@@ -336,7 +333,8 @@ ...@@ -336,7 +333,8 @@
<MESSAGE value="fixed policies error" /> <MESSAGE value="fixed policies error" />
<MESSAGE value="added test" /> <MESSAGE value="added test" />
<MESSAGE value="check if topology node has properties" /> <MESSAGE value="check if topology node has properties" />
<option name="LAST_COMMIT_MESSAGE" value="check if topology node has properties" /> <MESSAGE value="we have a bug with setting default properties" />
<option name="LAST_COMMIT_MESSAGE" value="we have a bug with setting default properties" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
...@@ -348,13 +346,13 @@ ...@@ -348,13 +346,13 @@
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url> <url>file://$PROJECT_DIR$/src/rpc_server.py</url>
<line>106</line> <line>105</line>
<option name="timeStamp" value="302" /> <option name="timeStamp" value="302" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/src/rpc_server.py</url> <url>file://$PROJECT_DIR$/venv/lib/python3.6/site-packages/toscaparser/elements/scalarunit.py</url>
<line>138</line> <line>71</line>
<option name="timeStamp" value="305" /> <option name="timeStamp" value="311" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
......
This diff is collapsed.
...@@ -64,12 +64,3 @@ class Model(object): ...@@ -64,12 +64,3 @@ class Model(object):
def __ne__(self, other): def __ne__(self, other):
"""Returns true if both objects are not equal""" """Returns true if both objects are not equal"""
return not self == other return not self == other
# def __hash__(self):
# return hash(self.__dict__.keys())
def __key(self):
return tuple(sorted(self.to_dict()))
def __hash__(self):
return hash(self.__key())
\ No newline at end of file
...@@ -15,8 +15,7 @@ class NodeTemplate(Model): ...@@ -15,8 +15,7 @@ class NodeTemplate(Model):
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
"""NodeTemplate - a model defined in Swagger """NodeTemplate - a model defined in Swagger
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501 :param derived_from: The derived_from of this NodeTemplate. # noqa: E501
......
...@@ -245,8 +245,3 @@ class TopologyTemplate(Model): ...@@ -245,8 +245,3 @@ class TopologyTemplate(Model):
""" """
self._policies = policies self._policies = policies
def __eq__(self, other):
if isinstance(other, TopologyTemplate):
return self.__key() == other.__key()
return NotImplemented
\ No newline at end of file
...@@ -16,11 +16,7 @@ class ToscaTemplate(Model): ...@@ -16,11 +16,7 @@ class ToscaTemplate(Model):
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, topology_template=None, template_author=None, template_version=None, description=None, imports=None, dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None, capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None, group_types=None, repositories=None): # noqa: E501
topology_template=None, template_author=None, template_version=None, description=None, imports=None,
dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None,
capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None,
group_types=None, repositories=None): # noqa: E501
"""ToscaTemplate - a model defined in Swagger """ToscaTemplate - a model defined in Swagger
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501 :param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
...@@ -535,8 +531,3 @@ class ToscaTemplate(Model): ...@@ -535,8 +531,3 @@ class ToscaTemplate(Model):
""" """
self._repositories = repositories self._repositories = repositories
def __eq__(self, other):
if isinstance(other, ToscaTemplate):
return self.__key() == other.__key()
return NotImplemented
import os import os
import uuid import uuid
import connexion
import six
import yaml import yaml
from tinydb.middlewares import CachingMiddleware from tinydb.middlewares import CachingMiddleware
from typing import re
from sure_tosca.models.node_template import NodeTemplate as NodeTemplateModel from sure_tosca.models.node_template import NodeTemplate as NodeTemplateModel
from sure_tosca.models.topology_template import TopologyTemplate as TopologyTemplateModel from sure_tosca.models.topology_template import TopologyTemplate as TopologyTemplateModel
...@@ -16,29 +15,47 @@ from toscaparser.nodetemplate import NodeTemplate ...@@ -16,29 +15,47 @@ from toscaparser.nodetemplate import NodeTemplate
from toscaparser.tosca_template import ToscaTemplate from toscaparser.tosca_template import ToscaTemplate
from toscaparser.topology_template import TopologyTemplate from toscaparser.topology_template import TopologyTemplate
from tinydb.storages import MemoryStorage from tinydb.storages import MemoryStorage
from operator import and_, or_
from functools import reduce from functools import reduce
from tinydb import where from sure_tosca.service import tosca_helper
# db = TinyDB(storage=CachingMiddleware(MemoryStorage)) # db = TinyDB(storage=CachingMiddleware(MemoryStorage))
db_dir_path = tempfile.gettempdir() db_dir_path = tempfile.gettempdir()
tosca_templates_db_file_path = os.path.join(db_dir_path, "tosca_templates.json") tosca_templates_db_file_path = os.path.join(db_dir_path, "tosca_templates.json")
tosca_templates_db = TinyDB(tosca_templates_db_file_path, cache_size=30) tosca_templates_db = TinyDB(tosca_templates_db_file_path)
# tosca_templates_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
node_templates_db = TinyDB(storage=CachingMiddleware(MemoryStorage)) tmp_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
# interface_types_db = TinyDB(storage=CachingMiddleware(MemoryStorage))
model_id_names = ['id'] model_id_names = ['id']
root_key = 'root_key'
def query_tmp_db(queries):
if queries:
query = reduce(lambda a, b: a & b, queries)
results = tmp_db.search(query)
else:
results = tmp_db.all()
if results:
updated_results = []
for res in results:
key = res.pop(root_key)
node = {key: res}
updated_results.append(node)
return updated_results
return 'Not Found', 404
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)
if tosca_template_dict: if tosca_template_dict:
get_tosca_template_by_id(tosca_template_dict) get_tosca_template(tosca_template_dict)
return ToscaTemplateModel.from_dict(tosca_template_dict) return ToscaTemplateModel.from_dict(tosca_template_dict)
return 'Not Found', 404 return 'Not Found', 404
def get_tosca_template_by_id(tosca_template_dict): def get_tosca_template(tosca_template_dict):
return ToscaTemplate(yaml_dict_tpl=tosca_template_dict) return ToscaTemplate(yaml_dict_tpl=tosca_template_dict)
...@@ -72,49 +89,153 @@ def save(file): ...@@ -72,49 +89,153 @@ def save(file):
def get_interface_types(id, interface_type=None): def get_interface_types(id, interface_type=None):
interface_types = get_tosca_template_model_by_id(id).interface_types interface_types = get_tosca_template_model_by_id(id).interface_types
tmp_db.purge()
if interface_types: if interface_types:
for interface_type_name in interface_types:
interface = {root_key: interface_type_name}
interface.update(interface_types[interface_type_name])
queries = []
if interface_type: if interface_type:
filtered_interface_types = [] query = Query()
for interface in interface_types: queries.append(query._name_key == interface_type)
type_name = next(iter(interface))
if type_name == interface_type: return query_tmp_db(queries)
filtered_interface_types.append({type_name: interface})
return filtered_interface_types
return 'Not Found', 404
def get_node_templates(id, name=None, node_type=None, has_interface=None): def get_node_templates(id, type_name=None, name_key=None, has_interfaces=None, has_properties=None, has_attributes=None,
node_templates_db.purge() has_requirements=None, has_capabilities=None, has_artifacts=None, derived_from=None):
node_templates = get_tosca_template_model_by_id(id).topology_template.node_templates tmp_db.purge()
if node_templates: object_list = get_tosca_template_model_by_id(id).topology_template.node_templates
for node_template_name in node_templates: if object_list:
node = {'name': node_template_name} for key in object_list:
node.update(node_templates[node_template_name].to_dict()) node = {root_key: key}
node_templates_db.insert(node) node.update(object_list[key].to_dict())
tmp_db.insert(node)
queries = [] queries = []
if name: if name_key:
query = Query()
queries.append(query.root_key == name_key)
if type_name:
query = Query()
queries.append(query.type == type_name)
if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if has_properties:
query = Query()
prop = None
queries.append(query.properties != prop)
if has_interfaces:
query = Query() query = Query()
queries.append(query.name == name) prop = None
if node_type: queries.append(query.interfaces != prop)
if has_attributes:
query = Query() query = Query()
queries.append(query.type == node_type) prop = None
if has_interface: queries.append(query.attributes != prop)
if has_requirements:
query = Query() query = Query()
interface = None prop = None
queries.append(query.interfaces != interface) 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 = reduce(lambda a, b: a & b, queries) query_results = query_tmp_db(queries)
query_results = node_templates_db.search(query) return query_results
if not query_results:
return 'Not Found', 404
results = [] def get_tosca_template_get_dsl_definitions(id, anchors, derived_from):
for res in query_results: tmp_db.purge()
name = res.pop('name') object_list = get_tosca_template_model_by_id(id).dsl_definitions
node = {name: res} if object_list:
if has_interface and 'interfaces' in res and res['interfaces'] is not None: for key in object_list:
results.append(node) node = {key: object_list[key]}
elif not has_interface: tmp_db.insert(node)
results.append(node)
return results queries = []
return 'Not Found', 404 if derived_from:
query = Query()
queries.append(query.derived_from == derived_from)
if anchors:
for anchor in anchors:
query = Query()
return query_tmp_db(queries)
def get_relationship_templates(id, type_name, derived_from):
tmp_db.purge()
object_list = get_tosca_template_model_by_id(id).relationship_templates
if object_list:
for key in object_list:
node = {key: object_list[key]}
tmp_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_tmp_db(queries)
def find_node_template(id, node_root_key):
tosca_template_dict = get_tosca_template_dict_by_id(id)
tosca_template = get_tosca_template(tosca_template_dict)
tosca_node_types = tosca_template.nodetemplates[0].type_definition.TOSCA_DEF
all_custom_def = tosca_template.nodetemplates[0].custom_def
all_node_types = {}
all_node_types.update(tosca_node_types.items())
all_node_types.update(all_custom_def.items())
the_node = None
for node in tosca_template.nodetemplates:
if node.name == node_root_key:
the_node = node
break
if not the_node:
template = all_node_types[node_root_key]
the_node = tosca_helper.node_type_2_node_template({node_root_key: template}, all_custom_def)
return the_node, all_node_types, all_custom_def
def get_all_ancestors_requirements(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key)
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):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key)
properties = tosca_helper.get_all_ancestors_properties(the_node, all_node_types, all_custom_def)
properties_list = []
for prop in properties:
prop_dict = {prop.name: prop.value}
properties_list.append(prop_dict)
return properties_list
def get_all_ancestor_types(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key)
all_ancestor_types = tosca_helper.get_all_ancestors_types(the_node, all_node_types, all_custom_def)
return all_ancestor_types
def get_parent_type_name(id, node_root_key):
the_node, all_node_types, all_custom_def = find_node_template(id, node_root_key)
return tosca_helper.get_parent_type(the_node)
def get_node_outputs(id, name_key):
outputs = get_tosca_template_model_by_id(id).topology_template.outputs
return None
\ 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