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
493da3df
Commit
493da3df
authored
Jul 09, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds missing nodes. But we miss on node (wordpress) from the initial template
parent
69b3d53d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
39 deletions
+81
-39
application_example.yaml
TOSCA/application_example.yaml
+1
-7
basic_planner.py
drip_planner2/src/planner/basic_planner.py
+77
-31
rpc_server.py
drip_planner2/src/rpc_server.py
+2
-0
TOSCA_parser.py
drip_planner2/src/utils/TOSCA_parser.py
+1
-1
No files found.
TOSCA/application_example.yaml
View file @
493da3df
...
...
@@ -47,13 +47,7 @@ topology_template:
type
:
tosca.artifacts.Deployment.Image.Container.Docker
file
:
mysql:5.7
repository
:
docker_hub
#guillermo_kubernetes:
#type: tosca.nodes.ARTICONF.Orchestrator.Kubernetes
#cluster:
#type: tosca.nodes.Compute
...
...
drip_planner2/src/planner/basic_planner.py
View file @
493da3df
...
...
@@ -14,6 +14,7 @@ import pdb
import
names
import
yaml
from
utils.TOSCA_parser
import
*
import
logging
...
...
@@ -29,53 +30,63 @@ class BasicPlanner:
self
.
all_nodes
.
update
(
self
.
all_custom_def
.
items
())
node_templates
=
[]
capable_node_name
=
''
#
capable_node_name = ''
for
node
in
self
.
template
.
nodetemplates
:
missing_requirements
=
self
.
get_missing_requirements
(
node
)
for
req
in
missing_requirements
:
for
key
in
req
:
capable_node
=
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
])
capable_node_type
=
next
(
iter
(
capable_node
))
if
self
.
node_requered_once
(
capable_node
)
and
not
self
.
contains_node_type
(
node_templates
,
capable_node_type
):
capable_node_template
=
self
.
node_type_2_node_template
(
capable_node
)
capable_node_name
=
capable_node_template
.
name
node_templates
.
append
(
capable_node_template
)
req
[
next
(
iter
(
req
))][
'node'
]
=
capable_node_name
node
.
requirements
.
append
(
req
)
node_templates
.
append
(
node
)
node_templates
=
self
.
add_reqired_nods
(
node
,
None
)
# missing_requirements = self.get_missing_requirements(node)
# for req in missing_requirements:
# for key in req:
# capable_node = self.get_node_types_by_capability(req[key]['capability'])
# capable_node_type = next(iter(capable_node))
#
# if self.node_requered_once(capable_node) and not self.contains_node_type(node_templates,capable_node_type):
# capable_node_template = self.node_type_2_node_template(capable_node)
# capable_node_name = capable_node_template.name
# node_templates.append(capable_node_template)
#
# req[next(iter(req))]['node'] = capable_node_name
# node.requirements.append(req)
# node_templates.append(node)
self
.
template
.
nodetemplates
=
node_templates
t
=
self
.
template
if
node_templates
:
self
.
template
.
nodetemplates
=
node_templates
else
:
logging
.
info
(
'The TOSCA template in: '
+
path
+
' has no requirements'
)
tp
=
TOSCAParser
()
tp
.
tosca_template2_yaml
(
t
)
yaml_str
=
tp
.
tosca_template2_yaml
(
self
.
template
)
print
(
'------------------'
)
#
print(node.get_capabilities().keys
)
logging
.
info
(
'TOSCA template:
\n
'
+
yaml_str
)
#
print(yaml_str
)
def
get_missing_requirements
(
self
,
node
):
logging
.
info
(
'Looking for requirements for node: '
+
node
.
name
)
def_type
=
self
.
all_nodes
[
node
.
type
]
def_requirements
=
def_type
[
'requirements'
]
def_requirements
=
[]
if
'requirements'
in
def_type
.
keys
():
def_requirements
=
def_type
[
'requirements'
]
logging
.
info
(
'Found requirements: '
+
str
(
def_requirements
)
+
' for node: '
+
node
.
name
)
missing_requirements
=
[]
if
not
node
.
requirements
:
missing_requirements
=
def_requirements
el
se
:
el
if
def_requirements
:
for
def_requirement
in
def_requirements
:
for
key
in
def_requirement
:
for
node_req
in
node
.
requirements
:
if
key
not
in
(
node_req
)
:
if
key
not
in
node_req
:
missing_requirements
.
append
(
def_requirement
)
break
if
node
.
parent_type
:
#Make sure we have the deffinition. Otherwise we get an error in the recursion
if
'derived_from'
in
def_type
.
keys
()
and
not
def_type
[
'derived_from'
]
in
node
.
custom_def
.
keys
():
node
.
custom_def
[
def_type
[
'derived_from'
]]
=
self
.
all_custom_def
[
def_type
[
'derived_from'
]]
if
node
.
parent_type
and
node
.
parent_type
.
requirements
:
logging
.
info
(
'Adding to : '
+
str
(
node
.
name
)
+
' parent requirements from: '
+
str
(
node
.
parent_type
.
type
))
missing_requirements
=
missing_requirements
+
node
.
parent_type
.
requirements
return
missing_requirements
...
...
@@ -129,6 +140,8 @@ class BasicPlanner:
def
contains_node_type
(
self
,
capable_node_types_list
,
node_type
):
if
capable_node_types_list
==
None
:
return
False
for
capable_node_type
in
capable_node_types_list
:
if
isinstance
(
capable_node_type
,
NodeTemplate
):
type_name
=
capable_node_type
.
type
...
...
@@ -166,4 +179,37 @@ class BasicPlanner:
for
cap
in
capabilities
:
if
self
.
has_capability_max_one_occurrence
(
capabilities
[
cap
]):
return
True
return
False
\ No newline at end of file
return
False
def
add_reqired_nods
(
self
,
node
,
node_templates
):
if
not
node_templates
:
node_templates
=
[]
missing_requirements
=
self
.
get_missing_requirements
(
node
)
if
not
missing_requirements
:
logging
.
info
(
'Node: '
+
node
.
name
+
' of type: '
+
node
.
type
+
' has no requirements'
)
# return node_templates
capable_node_name
=
''
for
req
in
missing_requirements
:
for
key
in
req
:
logging
.
info
(
'Looking for capability: '
+
req
[
key
][
'capability'
]
+
' for node: '
+
node
.
name
)
capable_node
=
self
.
get_node_types_by_capability
(
req
[
key
][
'capability'
])
if
capable_node
:
capable_node_type
=
next
(
iter
(
capable_node
))
logging
.
info
(
'Found : '
+
str
(
capable_node_type
))
else
:
logging
.
error
(
'Did not find node with reuired capability: '
+
str
(
req
[
key
][
'capability'
]))
if
self
.
node_requered_once
(
capable_node
)
and
not
self
.
contains_node_type
(
node_templates
,
capable_node_type
):
capable_node_template
=
self
.
node_type_2_node_template
(
capable_node
)
capable_node_name
=
capable_node_template
.
name
node_templates
.
append
(
capable_node_template
)
#recursively fulfill all requirements
self
.
add_reqired_nods
(
capable_node_template
,
node_templates
)
req
[
next
(
iter
(
req
))][
'node'
]
=
capable_node_name
node
.
requirements
.
append
(
req
)
if
not
self
.
contains_node_type
(
node_templates
,
node
):
node_templates
.
append
(
node
)
return
node_templates
\ No newline at end of file
drip_planner2/src/rpc_server.py
View file @
493da3df
...
...
@@ -13,6 +13,7 @@ from planner.basic_planner import *
import
sys
import
tempfile
import
time
import
logging
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -111,6 +112,7 @@ def handle_delivery(message):
return
json
.
dumps
(
response
)
if
__name__
==
"__main__"
:
logging
.
basicConfig
(
level
=
logging
.
INFO
)
if
(
sys
.
argv
[
1
]
==
"test_local"
):
# home = expanduser("~")
# tosca_reposetory_api_base_url = "http://localhost:8080/winery"
...
...
drip_planner2/src/utils/TOSCA_parser.py
View file @
493da3df
...
...
@@ -49,7 +49,7 @@ class TOSCAParser:
# If we don't add this then dump uses references for the same dictionary entries i.e. '&id001'
yaml
.
Dumper
.
ignore_aliases
=
lambda
*
args
:
True
print
(
yaml
.
dump
(
topology_dict
,
default_flow_style
=
False
))
return
(
yaml
.
dump
(
topology_dict
,
default_flow_style
=
False
))
def
get_node_template_dict
(
self
,
node_template
):
...
...
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