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
7e75bf9e
Commit
7e75bf9e
authored
Oct 31, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed serialization problem: outputs was loaded as str
parent
1a5b5b27
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
10 deletions
+21
-10
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+21
-10
No files found.
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
7e75bf9e
import
json
import
os
import
sys
import
uuid
from
collections
import
defaultdict
import
yaml
from
tinydb.database
import
Document
...
...
@@ -60,9 +62,11 @@ def query_db(queries, db=None):
def
get_tosca_template_model_by_id
(
id
):
tosca_template_dict
=
get_tosca_template_dict_by_id
(
id
)
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
tosca_template_dict
=
deTOSCAfy_topology_template
(
tosca_template_dict
)
if
tosca_template_dict
:
get_tosca_template
(
tosca_template_dict
)
return
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
return
tosca_template_model
return
'Not Found'
,
404
...
...
@@ -79,7 +83,7 @@ def get_tosca_template_dict_by_id(id):
if
id_name
in
tosca_template_dict
:
tosca_template_dict
.
pop
(
id_name
)
break
return
tosca_template_dict
return
deTOSCAfy_topology_template
(
tosca_template_dict
)
return
'Not Found'
,
404
...
...
@@ -87,12 +91,19 @@ def deTOSCAfy_topology_template(dictionary):
# outputs out of nowhere is instantiated as GetAttribute
if
'outputs'
in
dictionary
[
'topology_template'
]:
outputs
=
dictionary
[
'topology_template'
][
'outputs'
]
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
}
if
isinstance
(
outputs
,
str
):
json_acceptable_string
=
outputs
.
replace
(
"'"
,
"
\"
"
)
d
=
json
.
loads
(
json_acceptable_string
)
outputs
=
d
elif
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
...
...
@@ -300,8 +311,8 @@ def get_node_outputs(id, node_nme):
if
node_nme
==
output
.
value
.
node_template_name
:
matching_output_names
.
append
(
output
.
name
)
tosca_template_
model
=
ToscaTemplateModel
.
from_dict
(
deTOSCAfy_topology_template
(
tosca_template_dict
)
)
tosca_template_
dict
=
deTOSCAfy_topology_template
(
tosca_template_dict
)
tosca_template_model
=
ToscaTemplateModel
.
from_dict
(
tosca_template_dict
)
for
matching_output_name
in
matching_output_names
:
matching_outputs
[
matching_output_name
]
=
tosca_template_model
.
topology_template
.
outputs
[
matching_output_name
]
...
...
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