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
9a3a26eb
Commit
9a3a26eb
authored
May 03, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get all capabilities / requirements
parent
09b88064
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
37 deletions
+46
-37
__main__.py
tosca_service/src/__main__.py
+4
-36
service.py
tosca_service/src/winery/service.py
+42
-1
No files found.
tosca_service/src/__main__.py
View file @
9a3a26eb
...
@@ -23,47 +23,15 @@ if __name__ == "__main__":
...
@@ -23,47 +23,15 @@ if __name__ == "__main__":
tt
=
repo
.
get_topology_template
(
servicetemplates
)
tt
=
repo
.
get_topology_template
(
servicetemplates
)
node_templates
=
repo
.
get_node_templates
(
tt
)
node_templates
=
repo
.
get_node_templates
(
tt
)
parents
=
repo
.
get_parents
(
node_templates
[
1
])
requrements
=
[]
requrements_types
=
set
()
node_type
=
repo
.
get_object
(
node_templates
[
1
][
'type'
])[
'serviceTemplateOrNodeTypeOrNodeTypeImplementation'
][
0
]
child_requrements
=
repo
.
get_requirements
(
node_type
)
requrements
=
repo
.
get_all_requirements
(
node_templates
[
1
])
if
child_requrements
:
for
c_req
in
child_requrements
:
if
not
c_req
[
'requirementType'
]
in
requrements_types
:
requrements
.
append
(
c_req
)
requrements_types
.
add
(
c_req
[
'requirementType'
])
for
parent
in
parents
:
parent_requrements
=
repo
.
get_requirements
(
parent
)
for
p_req
in
parent_requrements
:
if
not
p_req
[
'requirementType'
]
in
requrements_types
:
requrements
.
append
(
p_req
)
requrements_types
.
add
(
p_req
[
'requirementType'
])
# print(requrements)
# print(requrements)
capabilities
=
repo
.
get_all_capabilities
(
node_templates
[
1
])
capabilities
=
[]
capabilities_types
=
set
()
child_capabilities
=
repo
.
get_capabilities
(
node_type
)
if
child_capabilities
:
for
c_cap
in
child_capabilities
:
if
not
c_cap
[
'capabilityType'
]
in
capabilities_types
:
capabilities
.
append
(
c_cap
)
capabilities_types
.
add
(
c_cap
[
'capabilityType'
])
for
parent
in
parents
:
print
(
capabilities
)
parent_capabilities
=
repo
.
get_capabilities
(
parent
)
if
(
parent_capabilities
):
for
p_cap
in
parent_capabilities
:
if
not
p_cap
[
'capabilityType'
]
in
capabilities_types
:
capabilities
.
append
(
p_cap
)
capabilities_types
.
add
(
p_cap
[
'capabilityType'
])
print
(
capabilities_types
)
...
...
tosca_service/src/winery/service.py
View file @
9a3a26eb
...
@@ -65,10 +65,51 @@ class Service:
...
@@ -65,10 +65,51 @@ class Service:
if
requirements
:
if
requirements
:
return
requirements
[
'requirementDefinition'
]
return
requirements
[
'requirementDefinition'
]
def
get_all_requirements
(
self
,
node_template
):
parents
=
self
.
get_parents
(
node_template
)
node_type
=
self
.
get_object
(
node_template
[
'type'
])[
'serviceTemplateOrNodeTypeOrNodeTypeImplementation'
][
0
]
requrements
=
[]
requrements_types
=
set
()
child_requrements
=
self
.
get_requirements
(
node_type
)
if
child_requrements
:
for
c_req
in
child_requrements
:
if
not
c_req
[
'requirementType'
]
in
requrements_types
:
requrements
.
append
(
c_req
)
requrements_types
.
add
(
c_req
[
'requirementType'
])
for
parent
in
parents
:
parent_requrements
=
self
.
get_requirements
(
parent
)
for
p_req
in
parent_requrements
:
if
not
p_req
[
'requirementType'
]
in
requrements_types
:
requrements
.
append
(
p_req
)
requrements_types
.
add
(
p_req
[
'requirementType'
])
return
requrements
def
get_all_capabilities
(
self
,
node_template
):
parents
=
self
.
get_parents
(
node_template
)
node_type
=
self
.
get_object
(
node_template
[
'type'
])[
'serviceTemplateOrNodeTypeOrNodeTypeImplementation'
][
0
]
child_capabilities
=
self
.
get_capabilities
(
node_type
)
capabilities
=
[]
capabilities_types
=
set
()
if
child_capabilities
:
for
c_cap
in
child_capabilities
:
if
not
c_cap
[
'capabilityType'
]
in
capabilities_types
:
capabilities
.
append
(
c_cap
)
capabilities_types
.
add
(
c_cap
[
'capabilityType'
])
for
parent
in
parents
:
parent_capabilities
=
self
.
get_capabilities
(
parent
)
if
(
parent_capabilities
):
for
p_cap
in
parent_capabilities
:
if
not
p_cap
[
'capabilityType'
]
in
capabilities_types
:
capabilities
.
append
(
p_cap
)
capabilities_types
.
add
(
p_cap
[
'capabilityType'
])
return
capabilities
def
get_capabilities
(
self
,
node_type
):
def
get_capabilities
(
self
,
node_type
):
requirements
=
self
.
find
(
node_type
,
self
.
capability_deff_names
)
requirements
=
self
.
find
(
node_type
,
self
.
capability_deff_names
)
if
requirements
:
if
requirements
:
return
requirements
[
'capabilityDefinition'
]
return
requirements
[
'capabilityDefinition'
]
...
...
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