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
09b88064
Commit
09b88064
authored
5 years ago
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get capabilities
parent
483595ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
__main__.py
tosca_service/src/__main__.py
+31
-1
service.py
tosca_service/src/winery/service.py
+10
-1
No files found.
tosca_service/src/__main__.py
View file @
09b88064
...
@@ -26,16 +26,46 @@ if __name__ == "__main__":
...
@@ -26,16 +26,46 @@ if __name__ == "__main__":
parents
=
repo
.
get_parents
(
node_templates
[
1
])
parents
=
repo
.
get_parents
(
node_templates
[
1
])
requrements
=
[]
requrements
=
[]
requrements_types
=
set
()
requrements_types
=
set
()
node_type
=
repo
.
get_object
(
node_templates
[
1
][
'type'
])[
'serviceTemplateOrNodeTypeOrNodeTypeImplementation'
][
0
]
child_requrements
=
repo
.
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
:
for
parent
in
parents
:
parent_requrements
=
repo
.
get_requirements
(
parent
)
parent_requrements
=
repo
.
get_requirements
(
parent
)
for
p_req
in
parent_requrements
:
for
p_req
in
parent_requrements
:
if
not
p_req
[
'requirementType'
]
in
requrements_types
:
if
not
p_req
[
'requirementType'
]
in
requrements_types
:
requrements
.
append
(
p_req
)
requrements
.
append
(
p_req
)
requrements_types
.
add
(
p_req
[
'requirementType'
])
requrements_types
.
add
(
p_req
[
'requirementType'
])
print
(
requrements
)
# print(requrements)
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
:
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
)
This diff is collapsed.
Click to expand it.
tosca_service/src/winery/service.py
View file @
09b88064
...
@@ -12,6 +12,7 @@ class Service:
...
@@ -12,6 +12,7 @@ class Service:
topology_template_names
=
[
'topologyTemplate'
]
topology_template_names
=
[
'topologyTemplate'
]
node_template_names
=
[
'nodeTemplates'
]
node_template_names
=
[
'nodeTemplates'
]
requirement_deff_names
=
[
'requirementDefinitions'
]
requirement_deff_names
=
[
'requirementDefinitions'
]
capability_deff_names
=
[
'capabilityDefinitions'
]
type_names
=
[
'type'
]
type_names
=
[
'type'
]
relationships_names
=
[
'relationshipTemplates'
]
relationships_names
=
[
'relationshipTemplates'
]
service_templates
=
None
service_templates
=
None
...
@@ -61,8 +62,16 @@ class Service:
...
@@ -61,8 +62,16 @@ class Service:
def
get_requirements
(
self
,
node_type
):
def
get_requirements
(
self
,
node_type
):
requirements
=
self
.
find
(
node_type
,
self
.
requirement_deff_names
)
requirements
=
self
.
find
(
node_type
,
self
.
requirement_deff_names
)
if
requirements
:
return
requirements
[
'requirementDefinition'
]
return
requirements
[
'requirementDefinition'
]
def
get_capabilities
(
self
,
node_type
):
requirements
=
self
.
find
(
node_type
,
self
.
capability_deff_names
)
if
requirements
:
return
requirements
[
'capabilityDefinition'
]
def
get_object
(
self
,
type_str
):
def
get_object
(
self
,
type_str
):
regex
=
r"\{(.*?)\}"
regex
=
r"\{(.*?)\}"
matches
=
re
.
finditer
(
regex
,
type_str
,
re
.
MULTILINE
|
re
.
DOTALL
)
matches
=
re
.
finditer
(
regex
,
type_str
,
re
.
MULTILINE
|
re
.
DOTALL
)
...
...
This diff is collapsed.
Click to expand it.
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