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
11d83af3
Commit
11d83af3
authored
Mar 10, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed error with deserialize_model. from_dict was not creating correct model
parent
bde03643
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
469 deletions
+55
-469
docker-compose.yml
docker-compose.yml
+16
-8
default_controller-1.py
...ask-server/sure_tosca/controllers/default_controller-1.py
+0
-444
default_controller.py
...flask-server/sure_tosca/controllers/default_controller.py
+2
-2
tosca_helper.py
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
+1
-4
tosca_template_service.py
...flask-server/sure_tosca/service/tosca_template_service.py
+3
-1
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+1
-2
util.py
sure_tosca-flask-server/sure_tosca/util.py
+29
-5
test-requirements.txt
sure_tosca-flask-server/test-requirements.txt
+3
-3
No files found.
docker-compose.yml
View file @
11d83af3
...
@@ -117,14 +117,22 @@ services:
...
@@ -117,14 +117,22 @@ services:
environment
:
environment
:
RABBITMQ_HOST
:
rabbit
RABBITMQ_HOST
:
rabbit
#provisioner:
provisioner
:
#depends_on:
depends_on
:
#- rabbit
-
rabbit
#- sure-tosca
-
sure-tosca
#image: alogo53/provisioner:3.0.0
image
:
alogo53/provisioner:3.0.0
#environment:
environment
:
#RABBITMQ_HOST: rabbit
RABBITMQ_HOST
:
rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
SURE_TOSCA_BASE_PATH
:
http://sure-tosca:8081/tosca-sure/1.0.0
deployer
:
depends_on
:
-
rabbit
-
sure-tosca
image
:
alogo53/deployer:3.0.0
environment
:
RABBITMQ_HOST
:
rabbit
#volumes:
#volumes:
...
...
sure_tosca-flask-server/sure_tosca/controllers/default_controller-1.py
deleted
100644 → 0
View file @
bde03643
import
connexion
import
six
from
sure_tosca.models.node_template
import
NodeTemplateModel
# noqa: E501
from
sure_tosca.models.topology_template
import
TopologyTemplateModel
# noqa: E501
from
sure_tosca.models.tosca_template
import
ToscaTemplateModel
# noqa: E501
from
sure_tosca
import
util
from
sure_tosca.service
import
tosca_template_service
def
get_all_ancestor_properties
(
id
,
node_name
):
# 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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[Dict[str, object]]
"""
res
=
tosca_template_service
.
get_all_ancestor_properties
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_all_ancestor_types
(
id
,
node_name
):
# 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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[str]
"""
res
=
tosca_template_service
.
get_all_ancestor_types
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_ancestors_requirements
(
id
,
node_name
):
# 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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_all_ancestors_requirements
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_default_interface
(
id
,
interface_type
,
instance_name
,
operation_name
):
# noqa: E501
"""
returns an interface instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param interface_type: type to instantiate
:type interface_type: str
:param instance_name: the name of the instance to retrun
:type instance_name: str
:param operation_name: the name of operation
:type operation_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_default_interface
(
id
,
interface_type
,
instance_name
,
operation_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_default_node_type
(
id
,
node_type
,
instance_name
):
# noqa: E501
"""
returns an node templaye instance with the default required values. # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_type: type to instantiate
:type node_type: str
:param instance_name: the name of tghe instance to retrun
:type instance_name: str
:rtype: NodeTemplateMap
"""
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]]
"""
res
=
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
dsl_definitions
if
res
:
return
res
return
'Not Found'
,
404
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]]
"""
res
=
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
imports
if
res
:
return
res
return
'Not Found'
,
404
def
get_node_outputs
(
id
,
node_name
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_node_outputs
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_node_properties
(
id
,
node_name
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_node_properties
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_node_requirements
(
id
,
node_name
):
# noqa: E501
"""get_node_requirements
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
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_node_requirements
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_node_templates
(
id
,
type_name
=
None
,
node_name
=
None
,
has_interfaces
=
None
,
has_properties
=
None
,
has_attributes
=
None
,
has_requirements
=
None
,
has_capabilities
=
None
,
has_artifacts
=
None
):
# noqa: E501
"""get_node_templates
returns nodes templates in topology # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The type
:type type_name: str
:param node_name: the name
:type node_name: str
:param has_interfaces: filter if has interfaces
: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
:rtype: List[NodeTemplateMap]
"""
res
=
tosca_template_service
.
get_node_templates
(
id
,
type_name
=
type_name
,
node_name
=
node_name
,
has_interfaces
=
has_interfaces
,
has_properties
=
has_properties
,
has_attributes
=
has_attributes
,
has_requirements
=
has_requirements
,
has_capabilities
=
has_capabilities
,
has_artifacts
=
has_artifacts
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_node_type_name
(
id
,
node_name
):
# noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res
=
tosca_template_service
.
get_node_type_name
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_parent_type_name
(
id
,
node_name
):
# noqa: E501
"""
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: str
"""
res
=
tosca_template_service
.
get_parent_type_name
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_related_nodes
(
id
,
node_name
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: List[NodeTemplateMap]
"""
res
=
tosca_template_service
.
get_related_nodes
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_relationship_templates
(
id
,
type_name
=
None
,
derived_from
=
None
):
# noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param type_name: The relationship type
:type type_name: str
:param derived_from: derived from
:type derived_from: str
:rtype: List[Dict[str, object]]
"""
res
=
tosca_template_service
.
get_relationship_templates
(
id
,
type_name
=
type_name
,
derived_from
=
derived_from
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_topology_template
(
id
):
# noqa: E501
"""get_topology_template
r # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: TopologyTemplateModel
"""
res
=
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
.
topology_template
if
res
:
return
res
return
'Not Found'
,
404
def
get_tosca_template
(
id
):
# noqa: E501
"""get_tosca_template
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:rtype: ToscaTemplateModel
"""
res
=
tosca_template_service
.
get_tosca_template_model_by_id
(
id
)
if
res
:
return
res
return
'Not Found'
,
404
def
get_types
(
id
,
kind_of_type
=
None
,
has_interfaces
=
None
,
type_name
=
None
,
has_properties
=
None
,
has_attributes
=
None
,
has_requirements
=
None
,
has_capabilities
=
None
,
has_artifacts
=
None
,
derived_from
=
None
):
# noqa: E501
"""
returns the interface types # noqa: E501
:param id: ID of topolog template uplodaed
: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: List[Dict[str, object]]
"""
res
=
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
)
if
res
:
return
res
return
'Not Found'
,
404
def
set_node_properties
(
id
,
properties
,
node_name
):
# noqa: E501
"""
s # noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: NodeTemplateModel
"""
res
=
tosca_template_service
.
set_node_properties
(
id
,
properties
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
def
upload_tosca_template
(
file
):
# noqa: E501
"""upload a tosca template description file
upload and validate a tosca template description file # noqa: E501
:param file: tosca Template description
:type file: werkzeug.datastructures.FileStorage
:rtype: str
"""
res
=
tosca_template_service
.
save
(
file
)
if
res
:
return
res
return
'Bad Request'
,
400
def
set_node_attributes
(
id
,
properties
,
node_name
):
# noqa: E501
"""set_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param properties:
:type properties:
:param node_name: node_name
:type node_name: str
:rtype: str
"""
return
'do some magic!'
def
get_node_attributes
(
id
,
node_name
):
# noqa: E501
"""get_node_attributes
# noqa: E501
:param id: ID of topolog template uplodaed
:type id: str
:param node_name: node_name
:type node_name: str
:rtype: Dict[str, object]
"""
res
=
tosca_template_service
.
get_node_attributes
(
id
,
node_name
)
if
res
:
return
res
return
'Not Found'
,
404
sure_tosca-flask-server/sure_tosca/controllers/default_controller.py
View file @
11d83af3
...
@@ -391,7 +391,7 @@ def set_node_properties(id, properties, node_name): # noqa: E501
...
@@ -391,7 +391,7 @@ def set_node_properties(id, properties, node_name): # noqa: E501
if
res
:
if
res
:
return
res
return
res
return
'Not Found'
,
404
return
'Not Found'
,
404
k
def
upload_tosca_template
(
file
):
# noqa: E501
def
upload_tosca_template
(
file
):
# noqa: E501
"""upload a tosca template description file
"""upload a tosca template description file
...
@@ -441,4 +441,4 @@ def get_node_attributes(id, node_name): # noqa: E501
...
@@ -441,4 +441,4 @@ def get_node_attributes(id, node_name): # noqa: E501
res
=
tosca_template_service
.
get_node_attributes
(
id
,
node_name
)
res
=
tosca_template_service
.
get_node_attributes
(
id
,
node_name
)
if
res
:
if
res
:
return
res
return
res
return
'Not Found'
,
404
return
'Not Found'
,
404
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
View file @
11d83af3
...
@@ -293,7 +293,4 @@ def get_node_template_dict(node_template):
...
@@ -293,7 +293,4 @@ def get_node_template_dict(node_template):
# print(dir(node_template))
# print(dir(node_template))
# print(node_template.templates)
# print(node_template.templates)
return
node_template_dict
return
node_template_dict
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/service/tosca_template_service.py
View file @
11d83af3
...
@@ -45,6 +45,7 @@ root_key = 'root_key'
...
@@ -45,6 +45,7 @@ root_key = 'root_key'
def
query_db
(
queries
,
db
=
None
):
def
query_db
(
queries
,
db
=
None
):
results
=
db
.
all
()
if
queries
:
if
queries
:
query
=
reduce
(
lambda
a
,
b
:
a
&
b
,
queries
)
query
=
reduce
(
lambda
a
,
b
:
a
&
b
,
queries
)
results
=
db
.
search
(
query
)
results
=
db
.
search
(
query
)
...
@@ -221,6 +222,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
...
@@ -221,6 +222,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
prop
=
None
prop
=
None
queries
.
append
(
query
.
artifacts
!=
prop
)
queries
.
append
(
query
.
artifacts
!=
prop
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
query_results
=
query_db
(
queries
,
db
=
node_template_db
)
return
change_to_node_template_model
(
query_results
)
return
change_to_node_template_model
(
query_results
)
...
@@ -478,4 +480,4 @@ def get_default_interface(id, interface_type, instance_name, operation_name):
...
@@ -478,4 +480,4 @@ def get_default_interface(id, interface_type, instance_name, operation_name):
instance_inputs
=
{
'inputs'
:
instance_inputs_list
}
instance_inputs
=
{
'inputs'
:
instance_inputs_list
}
operation
=
{
operation_name
:
instance_inputs
}
operation
=
{
operation_name
:
instance_inputs
}
instance
=
{
instance_name
:
operation
}
instance
=
{
instance_name
:
operation
}
return
instance
return
instance
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
View file @
11d83af3
...
@@ -30,7 +30,6 @@ class TestDefaultController(BaseTestCase):
...
@@ -30,7 +30,6 @@ class TestDefaultController(BaseTestCase):
self
.
assertTrue
(
response
.
is_json
)
self
.
assertTrue
(
response
.
is_json
)
self
.
assertIsInstance
(
response
.
json
,
list
)
self
.
assertIsInstance
(
response
.
json
,
list
)
def
test_get_all_ancestor_types
(
self
):
def
test_get_all_ancestor_types
(
self
):
"""Test case for get_all_ancestor_types
"""Test case for get_all_ancestor_types
...
@@ -402,4 +401,4 @@ class TestDefaultController(BaseTestCase):
...
@@ -402,4 +401,4 @@ class TestDefaultController(BaseTestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
unittest
import
unittest
unittest
.
main
()
unittest
.
main
()
\ No newline at end of file
sure_tosca-flask-server/sure_tosca/util.py
View file @
11d83af3
...
@@ -89,7 +89,6 @@ def deserialize_datetime(string):
...
@@ -89,7 +89,6 @@ def deserialize_datetime(string):
except
ImportError
:
except
ImportError
:
return
string
return
string
def
deserialize_model
(
data
,
klass
):
def
deserialize_model
(
data
,
klass
):
"""Deserializes list or dict to model.
"""Deserializes list or dict to model.
...
@@ -104,14 +103,39 @@ def deserialize_model(data, klass):
...
@@ -104,14 +103,39 @@ def deserialize_model(data, klass):
return
data
return
data
for
attr
,
attr_type
in
six
.
iteritems
(
instance
.
swagger_types
):
for
attr
,
attr_type
in
six
.
iteritems
(
instance
.
swagger_types
):
if
data
is
not
None
\
if
data
is
not
None
and
isinstance
(
data
,
(
list
,
dict
)):
and
instance
.
attribute_map
[
attr
]
in
data
\
value
=
None
and
isinstance
(
data
,
(
list
,
dict
)):
if
instance
.
attribute_map
[
attr
]
in
data
:
value
=
data
[
instance
.
attribute_map
[
attr
]]
value
=
data
[
instance
.
attribute_map
[
attr
]]
elif
attr
in
data
:
value
=
data
[
attr
]
setattr
(
instance
,
attr
,
_deserialize
(
value
,
attr_type
))
setattr
(
instance
,
attr
,
_deserialize
(
value
,
attr_type
))
return
instance
return
instance
# def deserialize_model(data, klass):
# """Deserializes list or dict to model.
#
# :param data: dict, list.
# :type data: dict | list
# :param klass: class literal.
# :return: model object.
# """
# instance = klass()
#
# if not instance.swagger_types:
# return data
#
# for attr, attr_type in six.iteritems(instance.swagger_types):
# if data is not None \
# and instance.attribute_map[attr] in data \
# and isinstance(data, (list, dict)):
# value = data[instance.attribute_map[attr]]
# setattr(instance, attr, _deserialize(value, attr_type))
#
# return instance
def
_deserialize_list
(
data
,
boxed_type
):
def
_deserialize_list
(
data
,
boxed_type
):
"""Deserializes a list and its elements.
"""Deserializes a list and its elements.
...
...
sure_tosca-flask-server/test-requirements.txt
View file @
11d83af3
wheel==0.3
3.6
wheel==0.3
4.2
flask-testing==0.
7.1
flask-testing==0.
8.0
coverage==5.0.3
coverage==5.0.3
nose>=1.3.7
nose>=1.3.7
pluggy>=0.13.1
pluggy>=0.13.1
randomize>=0.14
randomize>=0.14
Werkzeug==0.16.1
Werkzeug==1.0.0
\ No newline at end of file
\ No newline at end of file
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