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
a910170f
Commit
a910170f
authored
Jul 02, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inherit capabilities with max occurrences 1
parent
80d57fd6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
11 deletions
+65
-11
nodes.yaml
TOSCA/types/nodes.yaml
+18
-3
basic_planner.py
drip_planner2/src/planner/basic_planner.py
+47
-8
No files found.
TOSCA/types/nodes.yaml
View file @
a910170f
...
@@ -46,15 +46,30 @@ node_types:
...
@@ -46,15 +46,30 @@ node_types:
capabilities
:
capabilities
:
host
:
host
:
type
:
tosca.capabilities.ARTICONF.Orchestrator
type
:
tosca.capabilities.ARTICONF.Orchestrator
occurrences
:
[
1
,
1
]
cap
:
type
:
tosca.capabilities.ROOT
occurrences
:
[
1
,
1
]
tosca.nodes.ARTICONF.Orchestrator.Kubernetes
:
tosca.nodes.ARTICONF.Orchestrator.Kubernetes
:
derived_from
:
tosca.nodes.ARTICONF.Orchestrator
derived_from
:
tosca.nodes.ARTICONF.Orchestrator
description
:
Kubernetes orchestrator
description
:
Kubernetes orchestrator
capabilities
:
cap_1
:
type
:
tosca.capabilities.ROOT
occurrences
:
[
1
,
100
]
requirements
:
requirements
:
-
host
:
-
host
:
capability
:
tosca.capabilities.Scalable
capability
:
tosca.capabilities.Scalable
node
:
tosca.nodes.Compute
node
:
tosca.nodes.Compute
relationship
:
tosca.relationships.HostedOn
relationship
:
tosca.relationships.HostedOn
interfaces
:
Standard
:
configure
:
implementation
:
playbooks/kubernetes_install.yaml
inputs
:
kubernetes_master_ip
:
{
get_property
:
[
SELF
,
kubernetes_master_ip
]
}
kubernetes_worker_ips
:
{
get_property
:
[
SELF
,
kubernetes_worker_ips
]
}
drip_planner2/src/planner/basic_planner.py
View file @
a910170f
...
@@ -32,7 +32,7 @@ class BasicPlanner:
...
@@ -32,7 +32,7 @@ class BasicPlanner:
for
key
in
req
:
for
key
in
req
:
capable_nodes
.
append
(
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
]))
capable_nodes
.
append
(
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
]))
node
.
requirements
.
append
(
req
)
node
.
requirements
.
append
(
req
)
# print((node.type_definition._get_node_type_by_cap('tosca.capabilities.ARTICONF.Orchestrator'))
)
print
(
capable_nodes
)
print
(
'------------------'
)
print
(
'------------------'
)
# print(node.get_capabilities().keys)
# print(node.get_capabilities().keys)
...
@@ -59,10 +59,49 @@ class BasicPlanner:
...
@@ -59,10 +59,49 @@ class BasicPlanner:
def
get_node_types_by_capability
(
self
,
cap
):
def
get_node_types_by_capability
(
self
,
cap
):
capable_nodes
=
[]
candidate_nodes
=
{}
for
tosca_node
in
self
.
all_nodes
:
for
tosca_node_type
in
self
.
all_nodes
:
if
'capabilities'
in
self
.
all_nodes
[
tosca_node
]:
if
tosca_node_type
.
startswith
(
'tosca.nodes'
)
and
'capabilities'
in
self
.
all_nodes
[
tosca_node_type
]:
for
caps
in
self
.
all_nodes
[
tosca_node
][
'capabilities'
]:
for
caps
in
self
.
all_nodes
[
tosca_node_type
][
'capabilities'
]:
if
self
.
all_nodes
[
tosca_node
][
'capabilities'
][
caps
][
'type'
]
==
cap
:
if
self
.
all_nodes
[
tosca_node_type
][
'capabilities'
][
caps
][
'type'
]
==
cap
:
capable_nodes
.
append
(
tosca_node
)
candidate_nodes
[
tosca_node_type
]
=
self
.
all_nodes
[
tosca_node_type
]
candidate_child_nodes
=
{}
for
tosca_node_type
in
self
.
all_nodes
:
if
tosca_node_type
.
startswith
(
'tosca.nodes'
)
and
'derived_from'
in
self
.
all_nodes
[
tosca_node_type
]:
candidate_child_node
=
(
self
.
all_nodes
[
tosca_node_type
])
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_nodes
.
update
(
candidate_child_nodes
)
capable_nodes
=
{}
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
return
capable_nodes
def
inherit_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
:
inherited_capabilities
.
append
(
parent_capabilities
)
for
key
in
parent_capabilities
:
candidate_child_node
[
'capabilities'
][
key
]
=
parent_capabilities
[
key
]
# candidate_child_node['capabilities'][key] = inherited_capability[key]
# print(inherited_capability)
# for inherited_capability in inherited_capabilities:
# for key in inherited_capability:
# candidate_child_node['capabilities'][key] = inherited_capability[key]
return
candidate_child_node
\ 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