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
632a6a56
Commit
632a6a56
authored
Mar 04, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more tests
parent
6321c6f2
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
332 additions
and
160 deletions
+332
-160
application_example_provisioned.yaml
TOSCA/application_example_provisioned.yaml
+3
-3
compute.yaml
TOSCA/compute.yaml
+24
-0
kubernetes.yaml
TOSCA/kubernetes.yaml
+29
-0
lifeWatch_vre1.yaml
TOSCA/lifeWatch_vre1.yaml
+64
-33
topology.yaml
TOSCA/topology.yaml
+21
-0
__main__.py
planner/__main__.py
+2
-2
planner.py
planner/planner/planner.py
+79
-33
simple_spec_alayzer.py
planner/service/simple_spec_alayzer.py
+82
-80
test_planner.py
planner/test/test_planner.py
+28
-9
No files found.
TOSCA/application_example_provisioned.yaml
View file @
632a6a56
...
@@ -17,7 +17,7 @@ topology_template:
...
@@ -17,7 +17,7 @@ topology_template:
protocol
:
"
ssh"
protocol
:
"
ssh"
keys
:
keys
:
public_key
:
"
c3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFBZ1FDV3l6VEoxS1pycDVvVHVBVm15dmxKL2prMnRNdktZSlAvSWtHZ1JKeTVFNUgrbjl0eU1QRXdyUDN4c0lUMVZzRjlVNVhLTkkvVDVpZDgxNko5RmxjbEhOSHVrbE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Rdzhac1JNdXd3NUxDUzZpMENnem5RMlJ3WmIKU2dqSlVrLy81VVF2Z2x2YkFEMXJpUlJ1TzR5N0cwTFZpa2Y4b3UvM0pBM21iQUVDUVFESm1VY2dBQjJONmpSYQpydWxhNklnYzFYYjdTUGl0TEpFQjFNZytyUW5EZDZWWXZqcVVGaW9zWVdhYlJSdGtPQ1VPdWt5cklLY1puZ3Q4CjdrdHN6T1c1QWtFQXYzeEFHYUdyWkk1KzdjSTF4Si9NaWVRa1pkaFFWTEpEUnpwT3FJVjVKaFIzbCt2R3N2R2MKWWhwUG9IL1VoN3hsV3NLUVF2Q3Y2azhyaVh1dmZ6aTMyUUpBQTJDb0NtYzJGNHlXOS9YNlB1V3FjaUU1YnhoWAo0ajdlNXhMemorbENRcDRjalJJUzFTeFI1SkIxTWFERXhyY1NGOThUTGNMTVNlZVY5YS9nWDZCSE1RSkFadHNVCkIzQ2JBdW16N255cXF4SjNLUDUrT3FLbUM4aXhjTm8yRkRtVjZNbUhyL2c3QkRYYUhhd3FaM2tpclVLYVl0VXQKN25jZzEwaHRoMjBEeU4rcmlRSkFRMHVvNW
f
9HaUxJSHNEQUR5Nkw1azdrNTZjVUlhZnhpeVRHdzlWQ2tUY3puVQpPS1liYXFVM3lyaDRqbzRYTHlGd3JYcHJOdkNsb29pY1JIMTdSUkMxUHc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="
public_ip
:
"
192.125.18.246"
public_ip
:
"
192.125.18.246"
role
:
"
master"
role
:
"
master"
node_type
:
"
t2.medium"
node_type
:
"
t2.medium"
...
@@ -82,7 +82,7 @@ topology_template:
...
@@ -82,7 +82,7 @@ topology_template:
-
"
/var/run/docker.sock:/var/run/docker.sock"
-
"
/var/run/docker.sock:/var/run/docker.sock"
requirements
:
requirements
:
-
host
:
-
host
:
capability
:
"
tosca.capabilities.ARTICONF.Orchestrator"
capability
:
"
tosca.capabilities.ARTICONF.
docker.
Orchestrator"
node
:
"
kubernetes"
node
:
"
kubernetes"
relationship
:
"
tosca.relationships.HostedOn"
relationship
:
"
tosca.relationships.HostedOn"
type
:
"
tosca.nodes.ARTICONF.Container.Application.Docker"
type
:
"
tosca.nodes.ARTICONF.Container.Application.Docker"
...
@@ -104,7 +104,7 @@ topology_template:
...
@@ -104,7 +104,7 @@ topology_template:
-
"
db_data:/var/lib/mysql"
-
"
db_data:/var/lib/mysql"
requirements
:
requirements
:
-
host
:
-
host
:
capability
:
"
tosca.capabilities.ARTICONF.Orchestrator"
capability
:
"
tosca.capabilities.ARTICONF.
docker.
Orchestrator"
node
:
"
kubernetes"
node
:
"
kubernetes"
relationship
:
"
tosca.relationships.HostedOn"
relationship
:
"
tosca.relationships.HostedOn"
type
:
"
tosca.nodes.ARTICONF.Container.Application.Docker"
type
:
"
tosca.nodes.ARTICONF.Container.Application.Docker"
...
...
TOSCA/compute.yaml
0 → 100644
View file @
632a6a56
description
:
TOSCA example
imports
:
-
nodes
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
-
data
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
-
capabilities
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
-
policies
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
-
interfaces
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template
:
node_templates
:
compute
:
interfaces
:
Standard
:
create
:
dumy.yaml
properties
:
disk_size
:
50000 MB
mem_size
:
6000 MB
num_cores
:
2
os
:
Ubuntu 18.04
user_name
:
vm_user
type
:
tosca.nodes.ARTICONF.VM.Compute
tosca_definitions_version
:
tosca_simple_yaml_1_0
TOSCA/kubernetes.yaml
0 → 100644
View file @
632a6a56
description
:
TOSCA example
imports
:
-
nodes
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
-
data
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
-
capabilities
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
-
policies
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
-
interfaces
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template
:
node_templates
:
kubernetes
:
interfaces
:
Kubernetes
:
configure
:
inputs
:
playbook
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/dashboard.yaml
create
:
inputs
:
playbook
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml
install
:
inputs
:
playbook
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml
properties
:
min_masters_num
:
1
min_workers_num
:
1
type
:
tosca.nodes.ARTICONF.docker.Orchestrator.Kubernetes
tosca_definitions_version
:
tosca_simple_yaml_1_0
TOSCA/lifeWatch_vre1.yaml
View file @
632a6a56
tosca_definitions_version
:
tosca_simple_yaml_1_0
tosca_definitions_version
:
"
tosca_simple_yaml_1_0"
description
:
"
TOSCA
example"
imports
:
imports
:
-
nodes
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
-
nodes
:
"
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml"
-
data
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
-
data
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml"
-
capabilities
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
-
capabilities
:
"
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml"
-
policies
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
-
policies
:
"
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml"
-
interfaces
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
-
interfaces
:
"
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml"
topology_template
:
node_templates
:
repositories
:
kubernetes
:
docker_hub
:
https://hub.docker.com/
properties
:
min_masters_num
:
1
min_workers_num
:
1
#requirements:
#- host:
#capability: "tosca.capabilities.ARTICONF.VM.topology"
#node: "topology"
#relationship: "tosca.relationships.HostedOn"
interfaces
:
Kubernetes
:
create
:
inputs
:
playbook
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/create_k8s.yml"
install
:
inputs
:
playbook
:
"
https://raw.githubusercontent.com/skoulouzis/CONF/develop/ansible_playbooks/install_k8s.yml"
type
:
"
tosca.nodes.ARTICONF.Orchestrator.Kubernetes"
description
:
>
#mysql:
TOSCA example
#type: "tosca.nodes.ARTICONF.Container.Application.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.docker.Orchestrator"
#node: "kubernetes"
#relationship: "tosca.relationships.HostedOn"
#artifacts:
#image:
#file: "mysql:5.7"
#repository: "docker_hub"
#type: "tosca.artifacts.Deployment.Image.Container.Docker"
#topology:
#properties:
#domain: "Frankfurt"
#provider: "EC2"
#interfaces:
#CloudsStorm:
#provision:
#inputs:
#code_type: "SEQ"
#object_type: "SubTopology"
#type: "tosca.nodes.ARTICONF.VM.topology"
topology_template
:
node_templates
:
mongo
:
type
:
tosca.nodes.ARTICONF.Container.Application.Docker
properties
:
ports
:
-
"
30001:27017"
volumes
:
-
db-data:/data/db
environment
:
ROOT_PASSWORD
:
root_passwd
DATABASE
:
db
USER
:
user
PASSWORD
:
passwd
artifacts
:
image
:
type
:
tosca.artifacts.Deployment.Image.Container.Docker
file
:
mongo:3
repository
:
docker_hub
TOSCA/topology.yaml
0 → 100644
View file @
632a6a56
description
:
TOSCA example
imports
:
-
nodes
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/nodes.yaml
-
data
:
https://raw.githubusercontent.com/skoulouzis/CONF/develop/TOSCA/types/data.yml
-
capabilities
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/capabilities.yaml
-
policies
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/policies.yaml
-
interfaces
:
https://raw.githubusercontent.com/skoulouzis/DRIP/develop/TOSCA/types/interfaces.yml
topology_template
:
node_templates
:
topology
:
interfaces
:
CloudsStorm
:
provision
:
inputs
:
code_type
:
SEQ
object_type
:
SubTopology
properties
:
domain
:
Frankfurt
provider
:
EC2
type
:
tosca.nodes.ARTICONF.VM.topology
tosca_definitions_version
:
tosca_simple_yaml_1_0
planner/__main__.py
View file @
632a6a56
...
@@ -104,7 +104,7 @@ def handle_delivery(message, sys=None):
...
@@ -104,7 +104,7 @@ def handle_delivery(message, sys=None):
spec_service
=
SpecService
(
conf
)
spec_service
=
SpecService
(
conf
)
test_planner
=
Planner
(
tosca_path
=
input_tosca_file_path
,
spec_service
=
spec_service
)
test_planner
=
Planner
(
tosca_path
=
input_tosca_file_path
,
spec_service
=
spec_service
)
tosca_template
=
test_planner
.
resolve_requirements
()
tosca_template
=
test_planner
.
resolve_requirements
()
tosca_template
=
test_planner
.
set_
infrastructure_specification
s
()
tosca_template
=
test_planner
.
set_
node_templates_propertie
s
()
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
tosca_template
)
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
tosca_template
)
Planner
(
yaml_dict_tpl
=
template_dict
,
spec_service
=
spec_service
)
Planner
(
yaml_dict_tpl
=
template_dict
,
spec_service
=
spec_service
)
...
@@ -135,7 +135,7 @@ if __name__ == "__main__":
...
@@ -135,7 +135,7 @@ if __name__ == "__main__":
spec_service
=
SpecService
(
conf
)
spec_service
=
SpecService
(
conf
)
test_planner
=
Planner
(
input_tosca_file_path
,
spec_service
)
test_planner
=
Planner
(
input_tosca_file_path
,
spec_service
)
test_tosca_template
=
test_planner
.
resolve_requirements
()
test_tosca_template
=
test_planner
.
resolve_requirements
()
test_tosca_template
=
test_planner
.
set_
infrastructure_specification
s
()
test_tosca_template
=
test_planner
.
set_
node_templates_propertie
s
()
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
logger
.
info
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
logger
.
info
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
...
...
planner/planner/planner.py
View file @
632a6a56
This diff is collapsed.
Click to expand it.
planner/service/simple_spec_alayzer.py
View file @
632a6a56
...
@@ -33,7 +33,9 @@ class SimpleAnalyzer(SpecificationAnalyzer):
...
@@ -33,7 +33,9 @@ class SimpleAnalyzer(SpecificationAnalyzer):
orchestrator_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.docker.Orchestrator'
,
orchestrator_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.docker.Orchestrator'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
all_custom_def
)
min_masters_num
=
1
workers_num
=
0
if
orchestrator_nodes
:
if
'properties'
in
orchestrator_nodes
[
0
]
.
entity_tpl
:
if
'properties'
in
orchestrator_nodes
[
0
]
.
entity_tpl
:
if
'min_masters_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
]:
if
'min_masters_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
]:
min_masters_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
][
'min_masters_num'
]
min_masters_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
][
'min_masters_num'
]
...
@@ -46,7 +48,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
...
@@ -46,7 +48,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
topology_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.topology'
,
topology_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.topology'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
all_custom_def
)
if
topology_nodes
:
vm_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.Compute'
,
vm_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.Compute'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
all_custom_def
)
...
@@ -97,32 +99,32 @@ class SimpleAnalyzer(SpecificationAnalyzer):
...
@@ -97,32 +99,32 @@ class SimpleAnalyzer(SpecificationAnalyzer):
nodes
.
append
(
self
.
set_default_node_properties
(
node_template
))
nodes
.
append
(
self
.
set_default_node_properties
(
node_template
))
return
nodes
return
nodes
def
set_default_node_properties
(
self
,
affected_
node
):
# def set_default_node_properties(self,
node):
logging
.
info
(
'Setting properties for: '
+
str
(
affected_
node
.
type
))
# logging.info('Setting properties for: ' + str(
node.type))
ancestors_properties
=
tosca_helper
.
get_all_ancestors_properties
(
affected_
node
,
self
.
all_node_types
,
# ancestors_properties = tosca_helper.get_all_ancestors_properties(
node, self.all_node_types,
self
.
all_custom_def
)
#
self.all_custom_def)
default_properties
=
{}
#
default_properties = {}
for
ancestors_property
in
ancestors_properties
:
#
for ancestors_property in ancestors_properties:
default_property
=
get_default_value
(
ancestors_property
)
#
default_property = get_default_value(ancestors_property)
if
default_property
:
#
if default_property:
default_properties
[
next
(
iter
(
default_property
))]
=
default_property
[
next
(
iter
(
default_property
))]
#
default_properties[next(iter(default_property))] = default_property[next(iter(default_property))]
#
if
default_properties
:
#
if default_properties:
for
default_property
in
default_properties
:
#
for default_property in default_properties:
affected_
node
.
get_properties_objects
()
.
append
(
default_property
)
#
node.get_properties_objects().append(default_property)
node_name
=
next
(
iter
(
affected_
node
.
templates
))
# node_name = next(iter(
node.templates))
if
'properties'
in
affected_
node
.
templates
[
node_name
]:
# if 'properties' in
node.templates[node_name]:
for
prop_name
in
affected_
node
.
templates
[
node_name
][
'properties'
]:
# for prop_name in
node.templates[node_name]['properties']:
if
isinstance
(
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
],
dict
)
or
\
# if isinstance(
node.templates[node_name]['properties'][prop_name], dict) or \
isinstance
(
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
],
str
):
# isinstance(
node.templates[node_name]['properties'][prop_name], str):
if
'required'
in
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
]
and
\
# if 'required' in
node.templates[node_name]['properties'][prop_name] and \
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
][
'required'
]
and
\
#
node.templates[node_name]['properties'][prop_name]['required'] and \
'default'
in
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
]
and
\
# 'default' in
node.templates[node_name]['properties'][prop_name] and \
prop_name
not
in
default_properties
:
#
prop_name not in default_properties:
default_properties
[
prop_name
]
=
affected_
node
.
templates
[
node_name
][
'properties'
][
prop_name
][
# default_properties[prop_name] =
node.templates[node_name]['properties'][prop_name][
'default'
]
#
'default']
#
logging
.
info
(
#
logging.info(
'Adding to : '
+
str
(
affected_
node
.
templates
[
node_name
])
+
' properties: '
+
str
(
default_properties
))
# 'Adding to : ' + str(
node.templates[node_name]) + ' properties: ' + str(default_properties))
affected_
node
.
templates
[
node_name
][
'properties'
]
=
default_properties
#
node.templates[node_name]['properties'] = default_properties
return
affected_
node
# return
node
planner/test/test_planner.py
View file @
632a6a56
...
@@ -15,20 +15,38 @@ from service.spec_service import SpecService
...
@@ -15,20 +15,38 @@ from service.spec_service import SpecService
from
util
import
tosca_helper
from
util
import
tosca_helper
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
logger
.
setLevel
(
logging
.
DEBUG
)
class
MyTestCase
(
unittest
.
TestCase
):
class
MyTestCase
(
unittest
.
TestCase
):
# def test_only_docker_node
(self):
def
test_docker
(
self
):
#
file_name = 'application_example_updated.yaml'
file_name
=
'application_example_updated.yaml'
#
input_tosca_file_path = self.get_input_tosca_file_path(file_name)
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
#
self.run_test(input_tosca_file_path)
self
.
run_test
(
input_tosca_file_path
)
def
test_
with_existing_nod
es
(
self
):
def
test_
kubernet
es
(
self
):
file_name
=
'
lifeWatch_vre1
.yaml'
file_name
=
'
kubernetes
.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
self
.
run_test
(
input_tosca_file_path
)
def
test_topology
(
self
):
file_name
=
'topology.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
def
test_compute
(
self
):
file_name
=
'compute.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
# def test_lifeWatch(self):
# file_name = 'lifeWatch_vre1.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
def
get_input_tosca_file_path
(
self
,
file_name
):
def
get_input_tosca_file_path
(
self
,
file_name
):
tosca_path
=
"../../TOSCA/"
tosca_path
=
"../../TOSCA/"
input_tosca_file_path
=
tosca_path
+
file_name
input_tosca_file_path
=
tosca_path
+
file_name
...
@@ -46,10 +64,11 @@ class MyTestCase(unittest.TestCase):
...
@@ -46,10 +64,11 @@ class MyTestCase(unittest.TestCase):
test_planner
=
Planner
(
input_tosca_file_path
,
spec_service
)
test_planner
=
Planner
(
input_tosca_file_path
,
spec_service
)
test_tosca_template
=
test_planner
.
resolve_requirements
()
test_tosca_template
=
test_planner
.
resolve_requirements
()
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
test_tosca_template
=
test_planner
.
set_infrastructure_specifications
()
test_tosca_template
=
test_planner
.
set_node_templates_properties
()
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
template_dict
=
tosca_helper
.
get_tosca_template_2_topology_template_dictionary
(
test_tosca_template
)
logger
.
info
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
logger
.
info
(
"template ----:
\n
"
+
yaml
.
dump
(
template_dict
))
print
(
yaml
.
dump
(
template_dict
))
ToscaTemplate
(
yaml_dict_tpl
=
copy
.
deepcopy
(
template_dict
))
ToscaTemplate
(
yaml_dict_tpl
=
copy
.
deepcopy
(
template_dict
))
test_response
=
{
'toscaTemplate'
:
template_dict
}
test_response
=
{
'toscaTemplate'
:
template_dict
}
...
@@ -58,5 +77,5 @@ class MyTestCase(unittest.TestCase):
...
@@ -58,5 +77,5 @@ class MyTestCase(unittest.TestCase):
output_current_milli_time
=
int
(
round
(
time
.
time
()
*
1000
))
output_current_milli_time
=
int
(
round
(
time
.
time
()
*
1000
))
response
[
"creationDate"
]
=
output_current_milli_time
response
[
"creationDate"
]
=
output_current_milli_time
response
[
"parameters"
]
=
[]
response
[
"parameters"
]
=
[]
print
(
"Output message:"
+
json
.
dumps
(
response
))
#
print("Output message:" + json.dumps(response))
self
.
assertEqual
(
True
,
True
)
self
.
assertEqual
(
True
,
True
)
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