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
968191a4
Commit
968191a4
authored
Jul 02, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to get one node type
parent
a910170f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
10 deletions
+41
-10
application_example.yaml
TOSCA/application_example.yaml
+1
-1
nodes.yaml
TOSCA/types/nodes.yaml
+1
-1
basic_planner.py
drip_planner2/src/planner/basic_planner.py
+39
-8
No files found.
TOSCA/application_example.yaml
View file @
968191a4
...
...
@@ -46,7 +46,7 @@ topology_template:
image
:
type
:
tosca.artifacts.Deployment.Image.Container.Docker
file
:
mysql:5.7
repository
:
docker_hub
repository
:
docker_hub
...
...
TOSCA/types/nodes.yaml
View file @
968191a4
...
...
@@ -70,6 +70,6 @@ node_types:
implementation
:
playbooks/kubernetes_install.yaml
inputs
:
kubernetes_master_ip
:
{
get_property
:
[
SELF
,
kubernetes_master_ip
]
}
kubernetes_worker_ips
:
{
get_property
:
[
SELF
,
kubernetes_worker_ips
]
}
kubernetes_worker_ips
:
{
get_property
:
[
SELF
,
kubernetes_worker_ips
]
}
drip_planner2/src/planner/basic_planner.py
View file @
968191a4
...
...
@@ -24,15 +24,38 @@ class BasicPlanner:
self
.
all_nodes
=
{}
self
.
all_nodes
.
update
(
self
.
tosca_node_types
.
items
())
self
.
all_nodes
.
update
(
self
.
all_custom_def
.
items
())
capable_node_types
=
[]
for
node
in
self
.
template
.
nodetemplates
:
capable_nodes
=
[]
missing_requirements
=
self
.
get_missing_requirements
(
node
)
for
req
in
missing_requirements
:
for
key
in
req
:
capable_nodes
.
append
(
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
]))
capable_nodes
=
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
])
capable_node_types
.
append
(
capable_nodes
)
for
node_type
in
capable_nodes
:
capable_node
=
capable_nodes
[
node_type
]
for
cap
in
capable_node
[
'capabilities'
]:
capability_type
=
capable_node
[
'capabilities'
][
cap
][
'type'
]
if
capability_type
==
req
[
key
][
'capability'
]
and
self
.
has_capability_max_one_occurrence
(
capable_node
[
'capabilities'
][
cap
]):
for
capable_node_type
in
capable_node_types
:
print
(
capable_node_type
)
# print(req[key]['capability'])
# print(capable_nodes[node_type]['capabilities'])
# if self.has_capability_max_one_occurrence(capable_nodes[node_type]['capabilities']):
# capable_nodes_dict[node_type] = capable_nodes[node_type]
# for capable_node in capable_nodes:
# print(capable_node)
# capable_nodes.append(capable_nodes)
node
.
requirements
.
append
(
req
)
print
(
capable_nodes
)
# print(node.requirements)
# print(capable_node_types)
print
(
'------------------'
)
# print(node.get_capabilities().keys)
...
...
@@ -73,25 +96,26 @@ class BasicPlanner:
for
candidate_node_name
in
candidate_nodes
:
if
candidate_child_node
[
'derived_from'
]
==
candidate_node_name
:
candidate_child_nodes
[
tosca_node_type
]
=
self
.
all_nodes
[
tosca_node_type
]
candidate_child_nodes
[
tosca_node_type
]
=
self
.
inherit
_capabilities_with_one_occurrences
(
candidate_nodes
[
candidate_node_name
][
'capabilities'
],
candidate_child_node
)
candidate_child_nodes
[
tosca_node_type
]
=
self
.
copy
_capabilities_with_one_occurrences
(
candidate_nodes
[
candidate_node_name
][
'capabilities'
],
candidate_child_node
)
candidate_nodes
.
update
(
candidate_child_nodes
)
capable_nodes
=
{}
#Only return the nodes that have interfaces. This means that they are not "abstract"
for
candidate_node_name
in
candidate_nodes
:
if
'interfaces'
in
candidate_nodes
[
candidate_node_name
]
.
keys
():
capable_nodes
[
candidate_node_name
]
=
candidate_nodes
[
candidate_node_name
]
return
capable_nodes
def
inherit
_capabilities_with_one_occurrences
(
self
,
parent_capabilities
,
candidate_child_node
):
def
copy
_capabilities_with_one_occurrences
(
self
,
parent_capabilities
,
candidate_child_node
):
inherited_capabilities
=
[]
if
not
'capabilities'
in
candidate_child_node
.
keys
():
candidate_child_node
[
'capabilities'
]
=
{}
for
capability
in
parent_capabilities
:
inherited_capability
=
parent_capabilities
[
capability
]
if
'occurrences'
in
inherited_capability
and
inherited_capability
[
'occurrences'
][
1
]
==
1
:
if
self
.
has_capability_max_one_occurrence
(
inherited_capability
)
:
inherited_capabilities
.
append
(
parent_capabilities
)
for
key
in
parent_capabilities
:
candidate_child_node
[
'capabilities'
][
key
]
=
parent_capabilities
[
key
]
...
...
@@ -104,4 +128,11 @@ class BasicPlanner:
# for key in inherited_capability:
# candidate_child_node['capabilities'][key] = inherited_capability[key]
return
candidate_child_node
\ No newline at end of file
return
candidate_child_node
def
has_capability_max_one_occurrence
(
self
,
capability
):
if
'occurrences'
in
capability
and
capability
[
'occurrences'
][
1
]
==
1
:
return
True
else
:
return
False
\ 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