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
9e9ab47b
Commit
9e9ab47b
authored
Nov 01, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemeted update and set (update) properties
parent
cbb1cec7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
23 deletions
+18
-23
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+18
-23
No files found.
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
9e9ab47b
...
@@ -70,26 +70,6 @@ def get_tosca_template_dict_by_id(id):
...
@@ -70,26 +70,6 @@ def get_tosca_template_dict_by_id(id):
return
tosca_template_dict
return
tosca_template_dict
# def deTOSCAfy_topology_template(dictionary):
# # outputs out of nowhere is instantiated as GetAttribute or str
# if 'outputs' in dictionary['topology_template']:
# outputs = dictionary['topology_template']['outputs']
# if isinstance(outputs, str):
# json_acceptable_string = outputs.replace("'", "\"")
# d = json.loads(json_acceptable_string)
# outputs = d
# if not isinstance(outputs, dict):
# for output_name in outputs:
# output = outputs[output_name]
# if isinstance(output['value'], GetAttribute):
# args = output['value'].args
# assert isinstance(args, list)
# output['value'] = {'get_attribute': args}
# dictionary['topology_template']['outputs'] = outputs
#
# return dictionary
def
save
(
file
):
def
save
(
file
):
try
:
try
:
# tosca_template_file_path = os.path.join(db_dir_path, file.filename)
# tosca_template_file_path = os.path.join(db_dir_path, file.filename)
...
@@ -352,8 +332,23 @@ def get_node_type_name(id, node_name):
...
@@ -352,8 +332,23 @@ def get_node_type_name(id, node_name):
return
None
return
None
def
update
(
id
,
tosca_template_dict
):
tosca_template
=
ToscaTemplate
(
yaml_dict_tpl
=
copy
.
deepcopy
(
tosca_template_dict
))
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
doc_id
=
tosca_templates_db
.
update
(
tosca_template_dict
,
doc_ids
=
[
int
(
id
)])
return
doc_id
def
set_node_properties
(
id
,
properties
,
node_name
):
def
set_node_properties
(
id
,
properties
,
node_name
):
node_template_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
properties
=
properties
[
'properties'
]
if
node_name
in
node_template_dict
:
tosca_template_model
=
get_tosca_template_model_by_id
(
id
)
node_template_dict
=
node_template_dict
[
node_name
]
node_template_model
=
tosca_template_model
.
topology_template
.
node_templates
[
node_name
]
if
node_template_model
:
if
node_template_model
.
properties
:
node_template_model
.
properties
.
update
(
properties
)
else
:
node_template_model
.
properties
=
properties
tosca_template_model
.
topology_template
.
node_templates
[
node_name
]
=
node_template_model
return
update
(
id
,
tosca_template_model
.
to_dict
())
return
None
return
None
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