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
37e7927d
Commit
37e7927d
authored
Jul 02, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to generate NodeTemplate from NodeType dictionary
parent
968191a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
36 deletions
+41
-36
nodes.yaml
TOSCA/types/nodes.yaml
+0
-3
basic_planner.py
drip_planner2/src/planner/basic_planner.py
+41
-33
No files found.
TOSCA/types/nodes.yaml
View file @
37e7927d
...
@@ -68,8 +68,5 @@ node_types:
...
@@ -68,8 +68,5 @@ node_types:
Standard
:
Standard
:
configure
:
configure
:
implementation
:
playbooks/kubernetes_install.yaml
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 @
37e7927d
...
@@ -6,11 +6,12 @@ from toscaparser.tosca_template import ToscaTemplate
...
@@ -6,11 +6,12 @@ from toscaparser.tosca_template import ToscaTemplate
from
toscaparser.topology_template
import
TopologyTemplate
from
toscaparser.topology_template
import
TopologyTemplate
from
toscaparser.elements.nodetype
import
NodeType
from
toscaparser.elements.nodetype
import
NodeType
from
toscaparser.nodetemplate
import
NodeTemplate
from
toscaparser.nodetemplate
import
NodeTemplate
import
toscaparser.utils.
yamlparser
from
toscaparser.utils
import
yamlparser
import
urllib
import
urllib
import
urllib.parse
import
urllib.parse
import
sys
import
sys
import
pdb
import
pdb
import
names
...
@@ -26,37 +27,45 @@ class BasicPlanner:
...
@@ -26,37 +27,45 @@ class BasicPlanner:
self
.
all_nodes
.
update
(
self
.
all_custom_def
.
items
())
self
.
all_nodes
.
update
(
self
.
all_custom_def
.
items
())
capable_node_types
=
[]
capable_node_types
=
[]
node_templates
=
[]
for
node
in
self
.
template
.
nodetemplates
:
for
node
in
self
.
template
.
nodetemplates
:
missing_requirements
=
self
.
get_missing_requirements
(
node
)
missing_requirements
=
self
.
get_missing_requirements
(
node
)
for
req
in
missing_requirements
:
for
req
in
missing_requirements
:
for
key
in
req
:
for
key
in
req
:
capable_nodes
=
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
:
for
node_type
in
capable_nodes
:
capable_node
=
capable_nodes
[
node_type
]
capable_node
=
capable_nodes
[
node_type
]
for
cap
in
capable_node
[
'capabilities'
]:
for
cap
in
capable_node
[
'capabilities'
]:
capability_type
=
capable_node
[
'capabilities'
][
cap
][
'type'
]
capability_type
=
capable_node
[
'capabilities'
][
cap
][
'type'
]
if
capability_type
==
req
[
key
][
'capability'
]
and
self
.
has_capability_max_one_occurrence
(
capable_node
[
'capabilities'
][
cap
]):
if
capability_type
==
req
[
key
][
'capability'
]
and
self
.
has_capability_max_one_occurrence
(
capable_node
[
'capabilities'
][
cap
])
and
not
self
.
contains_node_type
(
capable_node_types
,
node_type
):
for
capable_node_type
in
capable_node_types
:
capable_node_types
.
append
(
capable_nodes
)
print
(
capable_node_type
)
break
elif
capability_type
==
req
[
key
][
'capability'
]
and
not
self
.
has_capability_max_one_occurrence
(
capable_node
[
'capabilities'
][
cap
]):
# print(req[key]['capability'])
capable_node_types
.
append
(
capable_nodes
)
# print(capable_nodes[node_type]['capabilities'])
break
# 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
)
node
.
requirements
.
append
(
req
)
# print(node.requirements)
node_templates
.
append
(
node
)
# print(capable_node_types)
print
(
'------------------'
)
for
node_type
in
capable_nodes
:
capable_node
=
capable_nodes
[
node_type
]
nodetemplate
=
{}
nodetemplate
[
names
.
get_first_name
()
.
lower
()]
=
node_type
print
(
nodetemplate
)
self
.
template
.
nodetemplates
=
node_templates
tpl_snippet
=
'''
server:
type: tosca.my.nodes.Compute
properties:
cpu_frequency: 0.05 GHz
disk_size: 500 MB
mem_size: 1 MB
'''
nodetemplates
=
yamlparser
.
simple_parse
(
tpl_snippet
)
# print(type(nodetemplates))
# nodetemplate = NodeTemplate('server', nodetemplates)
print
(
'------------------'
)
# print(node.get_capabilities().keys)
# print(node.get_capabilities().keys)
...
@@ -118,16 +127,7 @@ class BasicPlanner:
...
@@ -118,16 +127,7 @@ class BasicPlanner:
if
self
.
has_capability_max_one_occurrence
(
inherited_capability
):
if
self
.
has_capability_max_one_occurrence
(
inherited_capability
):
inherited_capabilities
.
append
(
parent_capabilities
)
inherited_capabilities
.
append
(
parent_capabilities
)
for
key
in
parent_capabilities
:
for
key
in
parent_capabilities
:
candidate_child_node
[
'capabilities'
][
key
]
=
parent_capabilities
[
key
]
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
return
candidate_child_node
...
@@ -135,4 +135,12 @@ class BasicPlanner:
...
@@ -135,4 +135,12 @@ class BasicPlanner:
if
'occurrences'
in
capability
and
capability
[
'occurrences'
][
1
]
==
1
:
if
'occurrences'
in
capability
and
capability
[
'occurrences'
][
1
]
==
1
:
return
True
return
True
else
:
else
:
return
False
return
False
\ No newline at end of file
def
contains_node_type
(
self
,
capable_node_types_list
,
node_type
):
for
capable_node_type
in
capable_node_types_list
:
type_name
=
next
(
iter
(
capable_node_type
))
if
type_name
==
node_type
:
return
True
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