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
a9d61f92
Commit
a9d61f92
authored
Dec 20, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed errors from using NodeTemplateMap
parent
6df3b431
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
38 deletions
+124
-38
sure_tosca-1.0.0-swagger.yaml
openAPI/API/sure_tosca-1.0.0-swagger.yaml
+9
-4
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+2
-4
node_template_map.py
...tosca-flask-server/sure_tosca/models/node_template_map.py
+91
-0
tosca_helper.py
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
+3
-2
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+19
-28
No files found.
openAPI/API/sure_tosca-1.0.0-swagger.yaml
View file @
a9d61f92
...
...
@@ -319,7 +319,7 @@ paths:
schema
:
type
:
array
items
:
$ref
:
'
#/definitions/NodeTemplate'
$ref
:
'
#/definitions/NodeTemplate
Map
'
"
404"
:
description
:
Not found
"
405"
:
...
...
@@ -618,7 +618,7 @@ paths:
schema
:
type
:
array
items
:
$ref
:
'
#/definitions/NodeTemplate'
$ref
:
'
#/definitions/NodeTemplate
Map
'
"
404"
:
description
:
Not found
"
405"
:
...
...
@@ -746,8 +746,6 @@ definitions:
NodeTemplate
:
type
:
object
properties
:
name
:
type
:
string
derived_from
:
type
:
string
properties
:
...
...
@@ -790,3 +788,10 @@ definitions:
additionalProperties
:
type
:
object
properties
:
{}
NodeTemplateMap
:
type
:
object
properties
:
name
:
type
:
string
nodeTemplate
:
$ref
:
'
#/definitions/NodeTemplate'
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
View file @
a9d61f92
...
...
@@ -176,10 +176,8 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
: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
Map
]
"""
res
=
tosca_template_service
.
get_node_templates
(
id
,
type_name
=
type_name
,
node_name
=
node_name
,
has_interfaces
=
has_interfaces
,
has_properties
=
has_properties
,
...
...
@@ -236,7 +234,7 @@ def get_related_nodes(id, node_name): # noqa: E501
:param node_name: node_name
:type node_name: str
:rtype: List[NodeTemplate]
:rtype: List[NodeTemplate
Map
]
"""
res
=
tosca_template_service
.
get_related_nodes
(
id
,
node_name
)
if
res
:
...
...
sure_tosca-flask-server/sure_tosca/models/node_template_map.py
0 → 100644
View file @
a9d61f92
# coding: utf-8
from
__future__
import
absolute_import
from
datetime
import
date
,
datetime
# noqa: F401
from
typing
import
List
,
Dict
# noqa: F401
from
sure_tosca.models
import
NodeTemplateModel
from
sure_tosca.models.base_model_
import
Model
from
sure_tosca
import
util
class
NodeTemplateMapModel
(
Model
):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def
__init__
(
self
,
name
=
None
,
node_template
=
None
):
# noqa: E501
"""NodeTemplateMap - a model defined in Swagger
:param name: The name of this NodeTemplateMap. # noqa: E501
:type name: str
:param node_template: The node_template of this NodeTemplateMap. # noqa: E501
:type node_template: NodeTemplate
"""
self
.
swagger_types
=
{
'name'
:
str
,
'node_template'
:
NodeTemplateModel
}
self
.
attribute_map
=
{
'name'
:
'name'
,
'node_template'
:
'nodeTemplate'
}
self
.
_name
=
name
self
.
_node_template
=
node_template
@
classmethod
def
from_dict
(
cls
,
dikt
):
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The NodeTemplateMap of this NodeTemplateMap. # noqa: E501
:rtype: NodeTemplateMapModel
"""
return
util
.
deserialize_model
(
dikt
,
cls
)
@
property
def
name
(
self
):
"""Gets the name of this NodeTemplateMap.
:return: The name of this NodeTemplateMap.
:rtype: str
"""
return
self
.
_name
@
name
.
setter
def
name
(
self
,
name
):
"""Sets the name of this NodeTemplateMap.
:param name: The name of this NodeTemplateMap.
:type name: str
"""
self
.
_name
=
name
@
property
def
node_template
(
self
):
"""Gets the node_template of this NodeTemplateMap.
:return: The node_template of this NodeTemplateMap.
:rtype: NodeTemplate
"""
return
self
.
_node_template
@
node_template
.
setter
def
node_template
(
self
,
node_template
):
"""Sets the node_template of this NodeTemplateMap.
:param node_template: The node_template of this NodeTemplateMap.
:type node_template: NodeTemplate
"""
self
.
_node_template
=
node_template
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
View file @
a9d61f92
...
...
@@ -106,8 +106,9 @@ def get_node_types_with_interface(nodes):
return
node_types_with_interface
def
node_dict_2_node_template
(
node_dict
,
all_custom_def
):
node_name
=
next
(
iter
(
node_dict
))
def
node_dict_2_node_template
(
node_name
,
node_dict
,
all_custom_def
):
node_dict
=
{
node_name
:
node_dict
}
# node_type = node_dict[node_name]['type']
# for name_to_remove in node_type_key_names_to_remove:
...
...
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
a9d61f92
...
...
@@ -16,7 +16,9 @@ from toscaparser.tosca_template import ToscaTemplate
from
sure_tosca.models.base_model_
import
Model
from
sure_tosca.models.node_template
import
NodeTemplateModel
as
NodeTemplateModel
from
sure_tosca.models.node_template_map
import
NodeTemplateMapModel
from
sure_tosca.models.tosca_template
import
ToscaTemplateModel
as
ToscaTemplateModel
from
sure_tosca.service
import
tosca_helper
# db = TinyDB(storage=CachingMiddleware(MemoryStorage))
...
...
@@ -48,7 +50,7 @@ def query_db(queries, db=None):
res_copy
.
pop
(
root_key
)
node
=
{
key
:
res_copy
}
else
:
logging
.
error
(
str
(
res
)
+
' has no '
+
root_key
)
logging
.
error
(
str
(
res
)
+
' has no '
+
root_key
)
updated_results
.
append
(
node
)
return
updated_results
return
None
...
...
@@ -120,10 +122,12 @@ def change_to_nodeTemplateModel(query_results):
res
=
[]
for
node_template
in
query_results
:
# copy.deepcopy()
node_template_map
=
NodeTemplateMapModel
()
name
=
next
(
iter
(
node_template
))
node_template_map
.
name
=
name
node_template
=
node_template
[
name
]
node_template
[
'name'
]
=
name
res
.
append
(
NodeTemplateModel
.
from_dict
(
node_template
)
)
node_template
_map
.
node_template
=
NodeTemplateModel
.
from_dict
(
node_template
)
res
.
append
(
node_template_map
)
return
res
...
...
@@ -188,7 +192,6 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
return
change_to_nodeTemplateModel
(
query_results
)
def
get_tosca_template_get_dsl_definitions
(
id
,
anchors
,
derived_from
):
# interface_types_db.purge()
if
len
(
dsl_definitions_db
)
<=
1
:
...
...
@@ -240,14 +243,10 @@ def node_dict_2_node_template(id, node_name):
all_node_types
.
update
(
tosca_node_types
.
items
())
all_node_types
.
update
(
all_custom_def
.
items
())
node_template_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
if
next
(
iter
(
node_template_dict
))
!=
node_name
:
node_template_dict
=
{
node_name
:
node_template_dict
}
if
isinstance
(
node_template_dict
,
dict
):
the_node
=
tosca_helper
.
node_dict_2_node_template
(
node_template_dict
,
all_node_types
)
return
the_node
,
all_node_types
,
all_custom_def
return
None
node_template_map_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
the_node
=
tosca_helper
.
node_dict_2_node_template
(
node_template_map_dict
.
name
,
node_template_map_dict
.
node_template
.
to_dict
(),
all_node_types
)
return
the_node
,
all_node_types
,
all_custom_def
def
get_all_ancestors_requirements
(
id
,
node_root_key
):
...
...
@@ -310,22 +309,17 @@ def get_node_outputs(id, node_name):
def
get_node_properties
(
id
,
node_name
):
node_template_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
if
node_name
in
node_template_dict
:
node_template_dict
=
node_template_dict
[
node_name
]
node_template_map
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
properties
=
NodeTemplateModel
.
from_dict
(
node_template_dict
)
.
properties
properties
=
node_template_map
.
node_template
.
properties
if
properties
:
return
properties
return
None
def
get_node_requirements
(
id
,
node_name
):
node_template_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
if
node_name
in
node_template_dict
:
node_template_dict
=
node_template_dict
[
node_name
]
requirements
=
NodeTemplateModel
.
from_dict
(
node_template_dict
)
.
requirements
node_template_map
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
requirements
=
node_template_map
.
node_template
.
requirements
if
requirements
:
return
requirements
return
None
...
...
@@ -349,11 +343,8 @@ def get_related_nodes(id, node_name):
def
get_node_type_name
(
id
,
node_name
):
node_template_dict
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
if
node_name
in
node_template_dict
:
node_template_dict
=
node_template_dict
[
node_name
]
type_name
=
NodeTemplateModel
.
from_dict
(
node_template_dict
)
.
type
node_template_map
=
get_node_templates
(
id
,
node_name
=
node_name
)[
0
]
type_name
=
node_template_map
.
node_template
.
type
if
type_name
:
return
type_name
return
None
...
...
@@ -377,7 +368,7 @@ def set_node_properties(id, properties, node_name):
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
update
(
id
,
tosca_template_model
.
to_dict
())
return
None
...
...
@@ -385,4 +376,4 @@ def get_types(id, kind_of_type, has_interfaces, type_name, has_properties, has_a
has_capabilities
,
has_artifacts
,
derived_from
):
if
kind_of_type
==
'interface_types'
:
return
get_interface_types
(
id
,
interface_type
=
type_name
)
return
None
\ No newline at end of file
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