Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
1e62a63b
Commit
1e62a63b
authored
Oct 30, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved some properties to attributes
new tosca example file
parent
e9c010de
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1244 additions
and
475 deletions
+1244
-475
application_example_2_topologies.yaml
TOSCA/application_example_2_topologies.yaml
+162
-0
application_example_output.yaml
TOSCA/application_example_output.yaml
+83
-22
application_example_updated.yaml
TOSCA/application_example_updated.yaml
+9
-0
nodes.yaml
TOSCA/types/nodes.yaml
+32
-26
workspace.xml
drip_planner2/.idea/workspace.xml
+21
-23
tosca.cpython-36.pyc
drip_planner2/src/utils/__pycache__/tosca.cpython-36.pyc
+0
-0
tosca_helper.cpython-36.pyc
...lanner2/src/utils/__pycache__/tosca_helper.cpython-36.pyc
+0
-0
tosca_helper.py
drip_planner2/src/utils/tosca_helper.py
+268
-0
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+146
-120
base_model_.py
sure_tosca-flask-server/sure_tosca/models/base_model_.py
+0
-9
node_template.py
sure_tosca-flask-server/sure_tosca/models/node_template.py
+1
-2
topology_template.py
...tosca-flask-server/sure_tosca/models/topology_template.py
+0
-5
tosca_template.py
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
+1
-10
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+168
-47
swagger.yaml
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
+273
-134
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+80
-77
No files found.
TOSCA/application_example_2_topologies.yaml
0 → 100644
View file @
1e62a63b
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
]
}
TOSCA/application_example_output.yaml
View file @
1e62a63b
...
@@ -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
...
@@ -44,7 +90,7 @@ topology_template:
...
@@ -44,7 +90,7 @@ topology_template:
os
:
ubuntu 16
os
:
ubuntu 16
role
:
worker
role
:
worker
user_name
:
vm_user
user_name
:
vm_user
type
:
tosca.nodes.ARTICONF.VM.Compute
type
:
tosca.nodes.ARTICONF.VM.Compute
kubernetes
:
kubernetes
:
interfaces
:
interfaces
:
Standard
:
Standard
:
...
@@ -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,31 +128,50 @@ topology_template:
...
@@ -86,31 +128,50 @@ 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
relationship
:
tosca.relationships.DependsOn
type
:
tosca.nodes.ARTICONF.VM.topology
-
vm
:
capability
:
tosca.capabilities.ARTICONF.VM
node
:
compute
relationship
:
tosca.relationships.DependsOn
type
:
tosca.nodes.ARTICONF.VM.topology
wordpress
:
wordpress
:
artifacts
:
artifacts
:
image
:
image
:
...
...
TOSCA/application_example_updated.yaml
View file @
1e62a63b
...
@@ -11,6 +11,15 @@ repositories:
...
@@ -11,6 +11,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
:
...
...
TOSCA/types/nodes.yaml
View file @
1e62a63b
...
@@ -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
properti
es
:
attribut
es
:
masters_num
:
masters_num
:
type
:
integer
type
:
integer
required
:
true
required
:
true
...
@@ -94,27 +94,28 @@ node_types:
...
@@ -94,27 +94,28 @@ 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
default
:
"
UvA
(Amsterdam,
The
Netherlands)
XO
Rack"
default
:
"
UvA
(Amsterdam,
The
Netherlands)
XO
Rack"
description
:
the domain of this topology e.g. California, UvA, etc
description
:
the domain of this topology e.g. California, UvA, etc
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,22 +154,35 @@ node_types:
...
@@ -161,22 +154,35 @@ 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
description
:
the role of the VM in the topology
description
:
the role of the VM in the topology
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
...
...
drip_planner2/.idea/workspace.xml
View file @
1e62a63b
...
@@ -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>
10
6
</line>
<line>
10
5
</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=
"3
05
"
/>
<option
name=
"timeStamp"
value=
"3
11
"
/>
</line-breakpoint>
</line-breakpoint>
</breakpoints>
</breakpoints>
<default-breakpoints>
<default-breakpoints>
...
...
drip_planner2/src/utils/__pycache__/tosca.cpython-36.pyc
deleted
100644 → 0
View file @
e9c010de
File deleted
drip_planner2/src/utils/__pycache__/tosca_helper.cpython-36.pyc
0 → 100644
View file @
1e62a63b
File added
drip_planner2/src/utils/tosca_helper.py
0 → 100644
View file @
1e62a63b
import
copy
from
itertools
import
chain
from
toscaparser
import
tosca_template
from
toscaparser.elements.nodetype
import
NodeType
from
toscaparser.nodetemplate
import
NodeTemplate
import
yaml
import
logging
# TOSCA template key names
SECTIONS
=
(
DEFINITION_VERSION
,
DEFAULT_NAMESPACE
,
TEMPLATE_NAME
,
TOPOLOGY_TEMPLATE
,
TEMPLATE_AUTHOR
,
TEMPLATE_VERSION
,
DESCRIPTION
,
IMPORTS
,
DSL_DEFINITIONS
,
NODE_TYPES
,
RELATIONSHIP_TYPES
,
RELATIONSHIP_TEMPLATES
,
CAPABILITY_TYPES
,
ARTIFACT_TYPES
,
DATA_TYPES
,
INTERFACE_TYPES
,
POLICY_TYPES
,
GROUP_TYPES
,
REPOSITORIES
,
INPUTS
,
NODE_TEMPLATES
,
OUTPUTS
,
GROUPS
,
SUBSTITUION_MAPPINGS
,
POLICIES
,
TYPE
,
REQUIREMENTS
,
ARTIFACTS
,
PROPERTIES
,
INTERFACES
)
=
\
(
'tosca_definitions_version'
,
'tosca_default_namespace'
,
'template_name'
,
'tosca_template'
,
'template_author'
,
'template_version'
,
'description'
,
'imports'
,
'dsl_definitions'
,
'node_types'
,
'relationship_types'
,
'relationship_templates'
,
'capability_types'
,
'artifact_types'
,
'data_types'
,
'interface_types'
,
'policy_types'
,
'group_types'
,
'repositories'
,
'inputs'
,
'node_templates'
,
'outputs'
,
'groups'
,
'substitution_mappings'
,
'policies'
,
'type'
,
'requirements'
,
'artifacts'
,
'properties'
,
'interfaces'
)
node_type_key_names_to_remove
=
[
'capabilities'
,
'derived_from'
]
def
get_node_type_name
(
node
):
"""Returns the node's type name as string"""
if
isinstance
(
node
,
NodeTemplate
):
if
node
.
type
:
if
node
.
type
and
isinstance
(
node
.
type
,
str
):
node_type
=
node
.
type
elif
isinstance
(
node
.
type
,
NodeTemplate
):
node_type
=
node
.
type
.
type
else
:
node_type
=
None
elif
isinstance
(
node
,
dict
):
node_type
=
next
(
iter
(
node
))
return
node_type
def
get_node_requirements
(
node
):
if
isinstance
(
node
,
NodeTemplate
):
node_requirements
=
node
.
requirements
elif
isinstance
(
node
,
dict
):
node_type_name
=
get_node_type_name
(
node
)
if
'requirements'
not
in
node
[
node_type_name
]:
node
[
node_type_name
][
'requirements'
]
=
{}
node_requirements
=
node
[
node_type_name
][
'requirements'
]
return
node_requirements
def
get_parent_type
(
node
):
if
isinstance
(
node
,
NodeTemplate
):
if
node
.
parent_type
:
parent_type
=
node
.
parent_type
.
type
else
:
parent_type
=
None
elif
isinstance
(
node
,
dict
):
parent_type
=
node
[
next
(
iter
(
node
))][
'derived_from'
]
return
parent_type
def
get_node_type_requirements
(
type_name
,
all_nodes
):
"""Returns the requirements for an input node as described in the template not in the node's definition """
def_type
=
all_nodes
[
type_name
]
if
'requirements'
in
def_type
.
keys
():
return
def_type
[
'requirements'
]
return
None
def
get_ancestors_requirements
(
node
,
all_nodes
,
all_custom_def
,
parent_requirements
=
None
):
"""Recursively get all requirements all the way to the ROOT including the input node's"""
if
not
parent_requirements
:
parent_requirements
=
[]
if
isinstance
(
node
,
NodeTemplate
):
# If node has parent and parent has requirements add them
if
node
.
parent_type
and
node
.
parent_type
.
requirements
:
if
isinstance
(
node
.
parent_type
.
requirements
,
dict
):
parent_requirements
.
append
(
node
.
parent_type
.
requirements
)
elif
isinstance
(
node
.
parent_type
.
requirements
,
list
):
parent_requirements
.
extend
(
node
.
parent_type
.
requirements
)
# Make parent type to NodeTemplate to continue
if
node
.
parent_type
.
type
:
parent_template
=
node_type_2_node_template
({
'name'
:
all_nodes
[
node
.
parent_type
.
type
]},
all_custom_def
)
if
parent_template
:
get_ancestors_requirements
(
parent_template
,
all_nodes
,
parent_requirements
)
elif
isinstance
(
node
,
dict
):
node_type_name
=
get_node_type_name
(
node
)
node_template
=
node_type_2_node_template
({
'name'
:
all_nodes
[
node_type_name
]},
all_custom_def
)
return
get_ancestors_requirements
(
node_template
,
all_nodes
,
all_custom_def
,
parent_requirements
)
return
parent_requirements
def
get_node_types_with_interface
(
nodes
):
node_types_with_interface
=
[]
for
node_name
in
nodes
:
if
'interfaces'
in
nodes
[
node_name
]
.
keys
()
and
'tosca.nodes.Root'
!=
node_name
:
node_types_with_interface
.
append
(
node_name
)
return
node_types_with_interface
def
node_type_2_node_template
(
node_type
,
all_custom_def
):
node_template_dict
=
{}
type_name
=
next
(
iter
(
node_type
))
node_type_array
=
type_name
.
split
(
"."
)
name
=
node_type_array
[
len
(
node_type_array
)
-
1
]
.
lower
()
node_template_dict
[
name
]
=
node_type
[
next
(
iter
(
node_type
))]
.
copy
()
node_template_dict
[
name
][
'type'
]
=
type_name
for
name_to_remove
in
node_type_key_names_to_remove
:
if
name_to_remove
in
node_template_dict
[
name
]:
node_template_dict
[
name
]
.
pop
(
name_to_remove
)
if
'type'
in
node_type
[
next
(
iter
(
node_type
))]:
node_type
[
next
(
iter
(
node_type
))]
.
pop
(
'type'
)
node_template
=
NodeTemplate
(
name
,
node_template_dict
,
node_type
)
# For some reason the tosca.nodes.ARTICONF.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.ARTICONF.Orchestrator"
# is not a valid type.'
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
for
def_key
in
all_custom_def
:
if
isinstance
(
def_key
,
dict
):
node_template
.
custom_def
.
update
(
def_key
)
else
:
node_template
.
custom_def
[
def_key
]
=
all_custom_def
[
def_key
]
return
node_template
def
get_tosca_template_2_topology_template_dictionary
(
template
):
yaml_str
=
tosca_template2_yaml
(
template
)
tosca_template_dict
=
yaml
.
load
(
yaml_str
,
Loader
=
yaml
.
FullLoader
)
this_tosca_template
=
tosca_template_dict
[
'tosca_template'
]
tosca_template_dict
.
pop
(
'tosca_template'
)
tosca_template_dict
[
'topology_template'
]
=
this_tosca_template
if
template
.
policies
and
'policies'
not
in
tosca_template_dict
[
'topology_template'
]:
policies_list
=
[]
for
policy
in
template
.
policies
:
policy_dict
=
{
policy
.
name
:
policy
.
entity_tpl
}
policies_list
.
append
(
policy_dict
)
tosca_template_dict
[
'topology_template'
][
'policies'
]
=
policies_list
return
tosca_template_dict
def
contains_node_type
(
node_types_list
,
node_type_name
):
if
node_types_list
is
None
:
return
False
for
node_type
in
node_types_list
:
if
isinstance
(
node_type
,
NodeTemplate
):
type_name
=
node_type
.
type
elif
isinstance
(
node_type
,
dict
):
type_name
=
next
(
iter
(
node_type
))
if
type_name
==
node_type_name
:
return
True
return
False
def
get_node_properties
(
node
):
node_type_name
=
get_node_type_name
(
node
)
return
node
[
node_type_name
][
'properties'
]
def
set_node_properties
(
node
,
properties
):
node_type_name
=
get_node_type_name
(
node
)
node
[
node_type_name
][
'properties'
]
=
properties
return
node
def
get_nodes_by_type
(
node_type
,
nodes
,
all_node_types
,
all_custom_def
):
nodes_by_type
=
[]
for
node
in
nodes
:
if
node
.
type
==
node_type
:
nodes_by_type
.
append
(
node
)
break
elif
node_type
in
get_all_ancestors_types
(
node
,
all_node_types
,
all_custom_def
):
nodes_by_type
.
append
(
node
)
return
nodes_by_type
def
get_all_ancestors_types
(
child_node
,
all_node_types
,
all_custom_def
,
ancestors_types
=
None
):
if
not
ancestors_types
:
ancestors_types
=
[
get_node_type_name
(
child_node
)]
parent_type
=
get_parent_type
(
child_node
)
if
parent_type
:
ancestors_types
.
append
(
parent_type
)
parent_type
=
node_type_2_node_template
({
'name'
:
all_node_types
[
parent_type
]},
all_custom_def
)
get_all_ancestors_types
(
parent_type
,
all_node_types
,
all_custom_def
,
ancestors_types
)
return
ancestors_types
def
get_all_ancestors_properties
(
node
,
all_nodes
,
all_custom_def
,
ancestors_properties
=
None
,
ancestors_types
=
None
):
if
not
ancestors_properties
:
ancestors_properties
=
[]
ancestors_properties_names
=
[]
node_prop_names
=
[]
if
node
.
get_properties_objects
():
for
node_prop
in
node
.
get_properties_objects
():
node_prop_names
.
append
(
node_prop
.
name
)
ancestors_properties
.
append
(
node_prop
)
if
not
ancestors_types
:
ancestors_types
=
get_all_ancestors_types
(
node
,
all_nodes
,
all_custom_def
)
for
ancestors_type
in
ancestors_types
:
ancestor
=
node_type_2_node_template
({
'name'
:
all_nodes
[
ancestors_type
]},
all_custom_def
)
if
ancestor
.
get_properties_objects
():
for
ancestor_prop
in
ancestor
.
get_properties_objects
():
if
ancestor_prop
.
name
not
in
ancestors_properties_names
and
ancestor_prop
.
name
not
in
node_prop_names
:
ancestors_properties_names
.
append
(
ancestor_prop
.
name
)
ancestors_properties
.
append
(
ancestor_prop
)
return
ancestors_properties
def
get_nodes_with_occurrences_in_requirements
(
topology_nodes
):
nodes_with_occurrences_in_requirement
=
[]
for
node
in
topology_nodes
:
for
requirement
in
node
.
requirements
:
requirement_dict
=
requirement
[
next
(
iter
(
requirement
))]
if
'occurrences'
in
requirement_dict
:
nodes_with_occurrences_in_requirement
.
append
(
node
)
break
return
nodes_with_occurrences_in_requirement
def
tosca_template2_yaml
(
tosca_template
):
topology_dict
=
{
DEFINITION_VERSION
:
tosca_template
.
version
,
IMPORTS
:
tosca_template
.
_tpl_imports
(),
DESCRIPTION
:
tosca_template
.
description
,
TOPOLOGY_TEMPLATE
:
{}}
topology_dict
[
TOPOLOGY_TEMPLATE
][
NODE_TEMPLATES
]
=
{}
node_templates
=
tosca_template
.
nodetemplates
for
node_template
in
node_templates
:
node_template_dict
=
get_node_template_dict
(
node_template
)
topology_dict
[
TOPOLOGY_TEMPLATE
][
NODE_TEMPLATES
][
node_template
.
name
]
=
node_template_dict
# If we don't add this then dump uses references for the same dictionary entries i.e. '&id001'
yaml
.
Dumper
.
ignore_aliases
=
lambda
*
args
:
True
return
yaml
.
dump
(
topology_dict
,
default_flow_style
=
False
)
def
get_node_template_dict
(
node_template
):
node_template_dict
=
{
TYPE
:
node_template
.
type
}
# node_template_dict[REQUIREMENTS] = {}
if
node_template
.
requirements
:
node_template_dict
[
REQUIREMENTS
]
=
node_template
.
requirements
# if node_template.interfaces:
# interfaces = {}
# for interface in node_template.interfaces:
# interfaces[interface.type] = {}
# interfaces[interface.type][interface.name] = interface.implementation
# print( node_template.templates[node_template.name] )
if
ARTIFACTS
in
node_template
.
templates
[
node_template
.
name
]
.
keys
():
node_template_dict
[
ARTIFACTS
]
=
node_template
.
templates
[
node_template
.
name
][
ARTIFACTS
]
if
PROPERTIES
in
node_template
.
templates
[
node_template
.
name
]
.
keys
():
node_template_dict
[
PROPERTIES
]
=
node_template
.
templates
[
node_template
.
name
][
PROPERTIES
]
if
INTERFACES
in
node_template
.
templates
[
node_template
.
name
]
.
keys
():
node_template_dict
[
INTERFACES
]
=
node_template
.
templates
[
node_template
.
name
][
INTERFACES
]
# print(dir(node_template))
# print(node_template.templates)
return
node_template_dict
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
View file @
1e62a63b
from
toscaparser.topology_template
import
TopologyTemplate
from
toscaparser.tosca_template
import
ToscaTemplate
from
sure_tosca.service
import
tosca_template_service
from
sure_tosca.service.tosca_template_service
import
*
import
connexion
import
connexion
import
six
import
six
...
@@ -11,213 +5,226 @@ from sure_tosca.models.node_template import NodeTemplate # noqa: E501
...
@@ -11,213 +5,226 @@ from sure_tosca.models.node_template import NodeTemplate # noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplate
# noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplate
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplate
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplate
# 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
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_all_ancestor_properties
(
id
,
node_root_key
):
# noqa: E501
"""
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: List[Dict[str, object]]
:rtype: List[Dict[str, object]]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_all_ancestor_properties
(
id
,
node_root_key
)
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_all_ancestor_types
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_all_ancestor_types
(
id
,
node_root_key
):
# noqa: E501
"""
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: List[str]
:rtype: List[str]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_all_ancestor_types
(
id
,
node_root_key
)
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_ancestors_requirements
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_ancestors_requirements
(
id
,
node_root_key
):
# noqa: E501
"""
"""
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
Recursively get all requirements all the way to the ROOT including the input node's # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_all_ancestors_requirements
(
id
,
node_root_key
)
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
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]]
"""
return
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
dsl_definitions
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]]
"""
return
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
imports
def
get_node_outputs
(
id
,
node
Template
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_outputs
(
id
,
node
_root_key
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param nodeTemplate:
:param node_root_key: node_root_key
:type nodeTemplate: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_node_outputs
(
id
,
name_key
=
node_root_key
)
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_properties
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_properties
(
id
,
node_root_key
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_node_templates
(
id
,
name_key
=
node_root_key
)[
0
]
.
properties
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_requirements
(
id
,
body
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_requirements
(
id
,
node_root_key
):
# noqa: E501
"""get_node_requirements
"""get_node_requirements
Returns the requirements for an input node as described in the template not in the node's definition # noqa: E501
Returns the requirements for an input node as described in the template not in the node's definition # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: Dict[str, object]
:rtype: Dict[str, object]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_node_templates
(
id
,
name_key
=
node_root_key
)[
0
]
.
requirements
body
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_node_templates
(
id
,
node_name
=
None
,
node_type
=
None
,
has_interface
=
None
):
# noqa: E501
def
get_node_templates
(
id
,
type_name
=
None
,
name_key
=
None
,
has_interfaces
=
None
,
has_properties
=
None
,
has_attributes
=
None
,
has_requirements
=
None
,
has_capabilities
=
None
,
has_artifacts
=
None
,
derived_from
=
None
):
# noqa: E501
"""get_node_templates
"""get_node_templates
returns nodes templates in topology # noqa: E501
returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param node_name: filter by node name
:param type_name: The type
:type node_name: str
:type type_name: str
:param node_type: filter by node type
:param name_key: the name key
:type node_type: str
:type name_key: str
:param has_interface: filter if node has interface
:param has_interfaces: filter if has interfaces
:type has_interface: bool
:type has_interfaces: bool
:param has_properties: filter if has properties
:type has_properties: bool
:param has_attributes: filter if has attributes
:type has_attributes: bool
:param has_requirements: filter if has requirements
:type has_requirements: bool
:param has_capabilities: filter if has capabilities
:type has_capabilities: bool
:param has_artifacts: filter if has artifacts
:type has_artifacts: bool
:param derived_from: derived from
:type derived_from: str
:rtype: List[NodeTemplate]
:rtype: List[NodeTemplate]
"""
"""
return
tosca_template_service
.
get_node_templates
(
id
,
name
=
node_name
,
node_type
=
node_type
,
has_interface
=
has_interface
)
return
tosca_template_service
.
get_node_templates
(
id
,
type_name
=
type_name
,
name_key
=
name_key
,
has_interfaces
=
has_interfaces
,
has_properties
=
has_properties
,
has_attributes
=
has_attributes
,
has_requirements
=
has_requirements
,
has_capabilities
=
has_capabilities
,
has_artifacts
=
has_artifacts
,
derived_from
=
derived_from
)
def
get_node_type_name
(
id
,
node
Template
=
None
,
node_name
=
None
):
# noqa: E501
def
get_node_type_name
(
id
,
node
_root_key
):
# noqa: E501
"""
"""
# noqa: E501
# noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param nodeTemplate: the NodeTemplate
:param node_root_key: node_root_key
:type nodeTemplate: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: str
:rtype: str
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_node_type_name
(
id
,
node_root_key
)
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_parent_type_name
(
id
,
node
Template
=
None
,
node_name
=
None
):
# noqa: E501
def
get_parent_type_name
(
id
,
node
_root_key
):
# noqa: E501
"""
"""
# noqa: E501
# noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param body:
:param node_root_key: node_root_key
:type body: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: str
:rtype: str
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_parent_type_name
(
id
,
node_root_key
)
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_related_node
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
def
get_related_node
s
(
id
,
node_root_key
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param nodeTemplate:
:param node_root_key: node_root_key
:type nodeTemplate: dict | bytes
:type node_root_key: str
:param node_name: The node name
:type node_name: str
:rtype: List[NodeTemplate]
:rtype: List[NodeTemplate]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
get_related_nodes
(
id
,
node_root_key
)
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
set_node_properties
(
id
,
properties
,
node_nam
e
):
# noqa: E501
def
get_relationship_templates
(
id
,
type_name
=
None
,
derived_from
=
Non
e
):
# noqa: E501
"""
"""
s # noqa: E501
returns the interface type
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param
properties:
:param
type_name: The relationship type
:type
properties:
:type
type_name: str
:param
node_name: The node name
:param
derived_from: derived from
:type
node_name
: str
:type
derived_from
: str
:rtype:
Dict[str, object
]
:rtype:
List[Dict[str, object]
]
"""
"""
return
'do some magic!'
return
tosca_template_service
.
get_relationship_templates
(
id
,
type_name
=
type_name
,
derived_from
=
derived_from
)
def
get_topology_template
(
id
):
# noqa: E501
def
get_topology_template
(
id
):
# noqa: E501
...
@@ -230,7 +237,7 @@ def get_topology_template(id): # noqa: E501
...
@@ -230,7 +237,7 @@ def get_topology_template(id): # noqa: E501
:rtype: TopologyTemplate
:rtype: TopologyTemplate
"""
"""
return
tosca_template_service
.
get_tosca_template_
model_by_id
(
id
)
.
topology_template
return
tosca_template_service
.
get_tosca_template_
dict_by_id
(
id
)
def
get_tosca_template
(
id
):
# noqa: E501
def
get_tosca_template
(
id
):
# noqa: E501
...
@@ -246,48 +253,67 @@ def get_tosca_template(id): # noqa: E501
...
@@ -246,48 +253,67 @@ def get_tosca_template(id): # noqa: E501
return
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
return
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
def
upload_tosca_template
(
file
):
# noqa: E501
def
get_types
(
id
,
kind_of_type
=
None
,
has_interfaces
=
None
,
type_name
=
None
,
has_properties
=
None
,
has_attributes
=
None
,
"""upload a tosca template description file
has_requirements
=
None
,
has_capabilities
=
None
,
has_artifacts
=
None
,
derived_from
=
None
):
# noqa: E501
"""
upload and validate a tosca template description file
# noqa: E501
returns the interface types
# noqa: E501
:param file: tosca Template description
:param id: ID of topolog template uplodaed
:type file: werkzeug.datastructures.FileStorage
: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:
str
:rtype:
List[Dict[str, object]]
"""
"""
return
tosca_template_service
.
save
(
file
)
return
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
)
def
get_related_nodes
(
id
,
nodeTemplate
=
None
,
node_name
=
None
):
# noqa: E501
def
set_node_properties
(
id
,
properties
,
node_root_key
):
# noqa: E501
"""
"""
s # noqa: E501
s # noqa: E501
:param id: ID of topolog template uplodaed
:param id: ID of topolog template uplodaed
:type id: str
:type id: str
:param
nodeTemplate:
:param
properties:
:type
nodeTemplate: dict | bytes
:type
properties:
:param node_
name: The node name
:param node_
root_key: node_root_key
:type node_
name
: str
:type node_
root_key
: str
:rtype:
List[NodeTemplate
]
:rtype:
Dict[str, object
]
"""
"""
if
connexion
.
request
.
is_json
:
return
tosca_template_service
.
set_node_properties
(
id
,
properties
,
node_root_key
)
nodeTemplate
=
NodeTemplate
.
from_dict
(
connexion
.
request
.
get_json
())
# noqa: E501
return
'do some magic!'
def
get_interface_types
(
id
,
interface_type
=
Non
e
):
# noqa: E501
def
upload_tosca_template
(
fil
e
):
# noqa: E501
"""
"""
upload a tosca template description file
returns the interface types
# noqa: E501
upload and validate a tosca template description file
# noqa: E501
:param id: ID of topolog template uplodaed
:param file: tosca Template description
:type id: str
:type file: werkzeug.datastructures.FileStorage
:param interface_type: The interface type
:type interface_type: str
:rtype:
List[Dict[str, object]]
:rtype:
str
"""
"""
return
tosca_template_service
.
get_interface_types
(
id
,
interface_type
=
interface_typ
e
)
return
tosca_template_service
.
save
(
fil
e
)
sure_tosca-flask-server/sure_tosca/models/base_model_.py
View file @
1e62a63b
...
@@ -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
sure_tosca-flask-server/sure_tosca/models/node_template.py
View file @
1e62a63b
...
@@ -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
...
...
sure_tosca-flask-server/sure_tosca/models/topology_template.py
View file @
1e62a63b
...
@@ -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
sure_tosca-flask-server/sure_tosca/models/tosca_template.py
View file @
1e62a63b
...
@@ -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
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
1e62a63b
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
:
if
interface_type
:
for
interface_type_name
in
interface_types
:
filtered_interface_types
=
[]
interface
=
{
root_key
:
interface_type_name
}
for
interface
in
interface_types
:
interface
.
update
(
interface_types
[
interface_type_name
])
type_name
=
next
(
iter
(
interface
))
queries
=
[]
if
type_name
==
interface_type
:
if
interface_type
:
filtered_interface_types
.
append
({
type_name
:
interface
})
query
=
Query
()
return
filtered_interface_types
queries
.
append
(
query
.
_name_key
==
interface_type
)
return
'Not Found'
,
404
return
query_tmp_db
(
queries
)
def
get_node_templates
(
id
,
name
=
None
,
node_type
=
None
,
has_interface
=
None
):
node_templates_db
.
purge
()
def
get_node_templates
(
id
,
type_name
=
None
,
name_key
=
None
,
has_interfaces
=
None
,
has_properties
=
None
,
has_attributes
=
None
,
node_templates
=
get_tosca_template_model_by_id
(
id
)
.
topology_template
.
node_templates
has_requirements
=
None
,
has_capabilities
=
None
,
has_artifacts
=
None
,
derived_from
=
None
):
if
node_templates
:
tmp_db
.
purge
()
for
node_template_name
in
node_templates
:
object_list
=
get_tosca_template_model_by_id
(
id
)
.
topology_template
.
node_templates
node
=
{
'name'
:
node_template_name
}
if
object_list
:
node
.
update
(
node_templates
[
node_template_name
]
.
to_dict
())
for
key
in
object_list
:
node_templates_db
.
insert
(
node
)
node
=
{
root_key
:
key
}
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
()
prop
=
None
queries
.
append
(
query
.
interfaces
!=
prop
)
if
has_attributes
:
query
=
Query
()
query
=
Query
()
queries
.
append
(
query
.
name
==
name
)
prop
=
None
if
node_type
:
queries
.
append
(
query
.
attributes
!=
prop
)
if
has_requirements
:
query
=
Query
()
query
=
Query
()
queries
.
append
(
query
.
type
==
node_type
)
prop
=
None
if
has_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_results
=
query_tmp_db
(
queries
)
return
query_results
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
tmp_db
.
purge
()
object_list
=
get_tosca_template_model_by_id
(
id
)
.
dsl_definitions
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
anchors
:
for
anchor
in
anchors
:
query
=
Query
()
query
=
Query
()
interface
=
None
queries
.
append
(
query
.
interfaces
!=
interface
)
query
=
reduce
(
lambda
a
,
b
:
a
&
b
,
queries
)
return
query_tmp_db
(
queries
)
query_results
=
node_templates_db
.
search
(
query
)
if
not
query_results
:
return
'Not Found'
,
404
def
get_relationship_templates
(
id
,
type_name
,
derived_from
):
results
=
[]
tmp_db
.
purge
()
for
res
in
query_results
:
object_list
=
get_tosca_template_model_by_id
(
id
)
.
relationship_templates
name
=
res
.
pop
(
'name'
)
if
object_list
:
node
=
{
name
:
res
}
for
key
in
object_list
:
if
has_interface
and
'interfaces'
in
res
and
res
[
'interfaces'
]
is
not
None
:
node
=
{
key
:
object_list
[
key
]}
results
.
append
(
node
)
tmp_db
.
insert
(
node
)
elif
not
has_interface
:
results
.
append
(
node
)
queries
=
[]
return
results
if
derived_from
:
return
'Not Found'
,
404
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
sure_tosca-flask-server/sure_tosca/swagger/swagger.yaml
View file @
1e62a63b
...
@@ -57,6 +57,196 @@ paths:
...
@@ -57,6 +57,196 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/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}/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
relationship
type"
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
:
/tosca_template/{id}/topology_template
:
get
:
get
:
description
:
"
r"
description
:
"
r"
...
@@ -91,21 +281,51 @@ paths:
...
@@ -91,21 +281,51 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
name
:
"
nod
e_name"
-
name
:
"
typ
e_name"
in
:
"
query"
in
:
"
query"
description
:
"
filter
by
node
nam
e"
description
:
"
The
typ
e"
required
:
false
required
:
false
type
:
"
string"
type
:
"
string"
-
name
:
"
n
ode_type
"
-
name
:
"
n
ame_key
"
in
:
"
query"
in
:
"
query"
description
:
"
filter
by
node
type
"
description
:
"
the
name
key
"
required
:
false
required
:
false
type
:
"
string"
type
:
"
string"
-
name
:
"
has_interface"
-
name
:
"
has_interface
s
"
in
:
"
query"
in
:
"
query"
description
:
"
filter
if
node
has
interface
"
description
:
"
filter
if
has
interfaces
"
required
:
false
required
:
false
type
:
"
boolean"
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"
-
name
:
"
derived_from"
in
:
"
query"
description
:
"
derived
from"
required
:
false
type
:
"
string"
responses
:
responses
:
200
:
200
:
description
:
"
successful
operation"
description
:
"
successful
operation"
...
@@ -118,7 +338,7 @@ paths:
...
@@ -118,7 +338,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/type_name
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
type_name
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
"
description
:
"
"
...
@@ -131,16 +351,10 @@ paths:
...
@@ -131,16 +351,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
description
:
"
the
NodeTemplate"
description
:
"
node_root_key"
required
:
false
required
:
true
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -152,7 +366,7 @@ paths:
...
@@ -152,7 +366,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/requirements
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
requirements
:
get
:
get
:
description
:
"
Returns
the
requirements
for
an
input
node
as
described
in
the
\
description
:
"
Returns
the
requirements
for
an
input
node
as
described
in
the
\
\
template
not
in
the
node's
definition
"
\
template
not
in
the
node's
definition
"
...
@@ -165,16 +379,10 @@ paths:
...
@@ -165,16 +379,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
description
:
"
"
description
:
"
node_root_key"
required
:
false
required
:
true
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -189,7 +397,7 @@ paths:
...
@@ -189,7 +397,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/
parent_type_name
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/derived_from
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
"
description
:
"
"
...
@@ -202,16 +410,10 @@ paths:
...
@@ -202,16 +410,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
description
:
"
"
description
:
"
node_root_key"
required
:
false
required
:
true
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -223,7 +425,7 @@ paths:
...
@@ -223,7 +425,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_requirements
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
ancestors_requirements
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
...
@@ -237,15 +439,10 @@ paths:
...
@@ -237,15 +439,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
required
:
false
description
:
"
node_root_key"
schema
:
required
:
true
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -260,7 +457,7 @@ paths:
...
@@ -260,7 +457,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_types
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
ancestors_types
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
...
@@ -274,15 +471,10 @@ paths:
...
@@ -274,15 +471,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
required
:
false
description
:
"
node_root_key"
schema
:
required
:
true
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -296,7 +488,7 @@ paths:
...
@@ -296,7 +488,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/ancestors_properties
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
ancestors_properties
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
description
:
"
Recursively
get
all
requirements
all
the
way
to
the
ROOT
including
\
...
@@ -310,15 +502,10 @@ paths:
...
@@ -310,15 +502,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
required
:
false
description
:
"
node_root_key"
schema
:
required
:
true
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -335,7 +522,7 @@ paths:
...
@@ -335,7 +522,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/properties
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
properties
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
s"
description
:
"
s"
...
@@ -348,15 +535,10 @@ paths:
...
@@ -348,15 +535,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
required
:
false
description
:
"
node_root_key"
schema
:
required
:
true
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -390,9 +572,9 @@ paths:
...
@@ -390,9 +572,9 @@ paths:
type
:
"
object"
type
:
"
object"
additionalProperties
:
additionalProperties
:
type
:
"
string"
type
:
"
string"
-
name
:
"
node_
name
"
-
name
:
"
node_
root_key
"
in
:
"
query
"
in
:
"
path
"
description
:
"
The
node
name
"
description
:
"
node_root_key
"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
responses
:
responses
:
...
@@ -408,7 +590,7 @@ paths:
...
@@ -408,7 +590,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/outputs
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
outputs
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
s"
description
:
"
s"
...
@@ -421,15 +603,10 @@ paths:
...
@@ -421,15 +603,10 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
in
:
"
path"
required
:
false
description
:
"
node_root_key"
schema
:
required
:
true
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
type
:
"
string"
responses
:
responses
:
200
:
200
:
...
@@ -444,7 +621,7 @@ paths:
...
@@ -444,7 +621,7 @@ paths:
405
:
405
:
description
:
"
Invalid
input"
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/topology_template/node_templates/related
:
/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/
related
:
get
:
get
:
summary
:
"
"
summary
:
"
"
description
:
"
s"
description
:
"
s"
...
@@ -457,56 +634,18 @@ paths:
...
@@ -457,56 +634,18 @@ paths:
description
:
"
ID
of
topolog
template
uplodaed"
description
:
"
ID
of
topolog
template
uplodaed"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
in
:
"
body"
-
name
:
"
node_root_key"
name
:
"
nodeTemplate"
required
:
false
schema
:
$ref
:
"
#/definitions/NodeTemplate"
-
name
:
"
node_name"
in
:
"
query"
description
:
"
The
node
name"
required
:
false
type
:
"
string"
responses
:
200
:
description
:
"
successful
operation"
schema
:
type
:
"
array"
items
:
$ref
:
"
#/definitions/NodeTemplate"
404
:
description
:
"
Not
found"
405
:
description
:
"
Invalid
input"
x-swagger-router-controller
:
"
sure_tosca.controllers.default_controller"
/tosca_template/{id}/interface_types
:
get
:
summary
:
"
"
description
:
"
returns
the
interface
types"
operationId
:
"
get_interface_types"
produces
:
-
"
application/json"
parameters
:
-
name
:
"
id"
in
:
"
path"
in
:
"
path"
description
:
"
ID
of
topolog
template
uplodaed
"
description
:
"
node_root_key
"
required
:
true
required
:
true
type
:
"
string"
type
:
"
string"
-
name
:
"
interface_type"
in
:
"
query"
description
:
"
The
interface
type"
required
:
false
type
:
"
string"
responses
:
responses
:
200
:
200
:
description
:
"
successful
operation"
description
:
"
successful
operation"
schema
:
schema
:
type
:
"
array"
type
:
"
array"
items
:
items
:
type
:
"
object"
$ref
:
"
#/definitions/NodeTemplate"
additionalProperties
:
type
:
"
object"
properties
:
{}
404
:
404
:
description
:
"
Not
found"
description
:
"
Not
found"
405
:
405
:
...
...
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
View file @
1e62a63b
...
@@ -19,14 +19,9 @@ class TestDefaultController(BaseTestCase):
...
@@ -19,14 +19,9 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_properties'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_properties'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -35,14 +30,9 @@ class TestDefaultController(BaseTestCase):
...
@@ -35,14 +30,9 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_types'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_types'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -51,46 +41,45 @@ class TestDefaultController(BaseTestCase):
...
@@ -51,46 +41,45 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/ancestors_requirements'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/ancestors_requirements'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_
interface_type
s
(
self
):
def
test_get_
dsl_definition
s
(
self
):
"""Test case for get_
interface_type
s
"""Test case for get_
dsl_definition
s
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'anchors'
,
'anchors_example'
),
query_string
=
[(
'interface_type'
,
'interface_type
_example'
)]
(
'derived_from'
,
'derived_from
_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/
interface_type
s'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/
dsl_definition
s'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_imports
(
self
):
"""Test case for get_imports
"""
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/imports'
.
format
(
id
=
'id_example'
),
method
=
'GET'
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_node_outputs
(
self
):
def
test_get_node_outputs
(
self
):
"""Test case for get_node_outputs
"""Test case for get_node_outputs
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/outputs'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/outputs'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -99,14 +88,9 @@ class TestDefaultController(BaseTestCase):
...
@@ -99,14 +88,9 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/properties'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/properties'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -115,14 +99,9 @@ class TestDefaultController(BaseTestCase):
...
@@ -115,14 +99,9 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/requirements'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/requirements'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -131,9 +110,15 @@ class TestDefaultController(BaseTestCase):
...
@@ -131,9 +110,15 @@ class TestDefaultController(BaseTestCase):
"""
"""
query_string
=
[(
'node_name'
,
'node_name_example'
),
query_string
=
[(
'type_name'
,
'type_name_example'
),
(
'node_type'
,
'node_type_example'
),
(
'name_key'
,
'name_key_example'
),
(
'has_interface'
,
true
)]
(
'has_interfaces'
,
true
),
(
'has_properties'
,
true
),
(
'has_attributes'
,
true
),
(
'has_requirements'
,
true
),
(
'has_capabilities'
,
true
),
(
'has_artifacts'
,
true
),
(
'derived_from'
,
'derived_from_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
method
=
'GET'
,
...
@@ -146,14 +131,9 @@ class TestDefaultController(BaseTestCase):
...
@@ -146,14 +131,9 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/type_name'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/type_name'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -162,29 +142,33 @@ class TestDefaultController(BaseTestCase):
...
@@ -162,29 +142,33 @@ class TestDefaultController(BaseTestCase):
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/parent_type_name'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/derived_from'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
,
method
=
'GET'
)
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_related_node
(
self
):
def
test_get_related_node
s
(
self
):
"""Test case for get_related_node
"""Test case for get_related_node
s
"""
"""
body
=
NodeTemplate
()
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/related'
.
format
(
id
=
'id_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/{node_root_key}/related'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key_example'
),
method
=
'GET'
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_relationship_templates
(
self
):
"""Test case for get_relationship_templates
"""
query_string
=
[(
'type_name'
,
'type_name_example'
),
(
'derived_from'
,
'derived_from_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/relationship_templates'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
method
=
'GET'
,
data
=
json
.
dumps
(
body
),
content_type
=
'application/json'
,
query_string
=
query_string
)
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
@@ -211,19 +195,38 @@ class TestDefaultController(BaseTestCase):
...
@@ -211,19 +195,38 @@ class TestDefaultController(BaseTestCase):
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_get_types
(
self
):
"""Test case for get_types
"""
query_string
=
[(
'kind_of_type'
,
'kind_of_type_example'
),
(
'has_interfaces'
,
true
),
(
'type_name'
,
'type_name_example'
),
(
'has_properties'
,
true
),
(
'has_attributes'
,
true
),
(
'has_requirements'
,
true
),
(
'has_capabilities'
,
true
),
(
'has_artifacts'
,
true
),
(
'derived_from'
,
'derived_from_example'
)]
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/types'
.
format
(
id
=
'id_example'
),
method
=
'GET'
,
query_string
=
query_string
)
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
def
test_set_node_properties
(
self
):
def
test_set_node_properties
(
self
):
"""Test case for set_node_properties
"""Test case for set_node_properties
"""
"""
properties
=
None
properties
=
None
query_string
=
[(
'node_name'
,
'node_name_example'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/
properties'
.
format
(
id
=
'id
_example'
),
'/tosca-sure/1.0.0/tosca_template/{id}/topology_template/node_templates/
{node_root_key}/properties'
.
format
(
id
=
'id_example'
,
node_root_key
=
'node_root_key
_example'
),
method
=
'PUT'
,
method
=
'PUT'
,
data
=
json
.
dumps
(
properties
),
data
=
json
.
dumps
(
properties
),
content_type
=
'application/json'
,
content_type
=
'application/json'
)
query_string
=
query_string
)
self
.
assert200
(
response
,
self
.
assert200
(
response
,
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
'Response body is : '
+
response
.
data
.
decode
(
'utf-8'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment