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
c6a1b02d
Commit
c6a1b02d
authored
Oct 17, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed invalid type
parent
bc784604
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
42 deletions
+73
-42
workspace.xml
drip_planner2/.idea/workspace.xml
+16
-9
planner.py
drip_planner2/src/planner/planner.py
+4
-0
simple_spec_alayzer.py
drip_planner2/src/planner/simple_spec_alayzer.py
+19
-19
specification_analyzer.py
drip_planner2/src/planner/specification_analyzer.py
+2
-2
tosca.py
drip_planner2/src/utils/tosca.py
+32
-12
setuptools-40.8.0-py3.6.egg
...v/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg
+0
-0
No files found.
drip_planner2/.idea/workspace.xml
View file @
c6a1b02d
...
...
@@ -6,7 +6,6 @@
<change
beforePath=
"$PROJECT_DIR$/src/planner/planner.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/planner/planner.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/planner/simple_spec_alayzer.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/planner/simple_spec_alayzer.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/planner/specification_analyzer.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/planner/specification_analyzer.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/setup.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/setup.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/utils/tosca.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/utils/tosca.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg"
afterDir=
"false"
/>
</list>
...
...
@@ -190,7 +189,14 @@
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1571247029429
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"11"
/>
<task
id=
"LOCAL-00011"
summary=
"added libs in setup"
>
<created>
1571320780678
</created>
<option
name=
"number"
value=
"00011"
/>
<option
name=
"presentableId"
value=
"LOCAL-00011"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1571320780678
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"12"
/>
<servers
/>
</component>
<component
name=
"Vcs.Log.Tabs.Properties"
>
...
...
@@ -216,7 +222,8 @@
<MESSAGE
value=
"split methods to util and set node properties to default"
/>
<MESSAGE
value=
"slolved cap error"
/>
<MESSAGE
value=
"try to analyze policies"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"try to analyze policies"
/>
<MESSAGE
value=
"added libs in setup"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"added libs in setup"
/>
</component>
<component
name=
"XDebuggerManager"
>
<breakpoint-manager>
...
...
@@ -227,14 +234,14 @@
<option
name=
"timeStamp"
value=
"1"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/src/
utils/tosca
.py
</url>
<line>
123
</line>
<option
name=
"timeStamp"
value=
"
84
"
/>
<url>
file://$PROJECT_DIR$/src/
planner/simple_spec_alayzer
.py
</url>
<line>
39
</line>
<option
name=
"timeStamp"
value=
"
125
"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/src/
planner/specification_analyzer
.py
</url>
<line>
51
</line>
<option
name=
"timeStamp"
value=
"
8
8"
/>
<url>
file://$PROJECT_DIR$/src/
utils/tosca
.py
</url>
<line>
18
</line>
<option
name=
"timeStamp"
value=
"
12
8"
/>
</line-breakpoint>
</breakpoints>
<default-breakpoints>
...
...
drip_planner2/src/planner/planner.py
View file @
c6a1b02d
...
...
@@ -75,6 +75,10 @@ class Planner:
matching_node_type_name
=
next
(
iter
(
matching_node
))
matching_node_type_name
=
next
(
iter
(
matching_node
))
matching_node_template
=
tosca_util
.
node_type_2_node_template
(
matching_node
)
# For some reason the definitions of swarm are missing. We add them manually here
if
len
(
matching_node_template
.
custom_def
)
<
len
(
self
.
all_custom_def
):
matching_node_template
.
custom_def
.
update
(
self
.
all_custom_def
)
node
=
self
.
add_missing_requirements
(
node
,
missing_requirements
,
matching_node_template
.
name
)
if
not
tosca_util
.
contains_node_type
(
self
.
required_nodes
,
matching_node_type_name
):
logging
.
info
(
' Adding: '
+
str
(
matching_node_template
.
name
))
...
...
drip_planner2/src/planner/simple_spec_alayzer.py
View file @
c6a1b02d
...
...
@@ -10,37 +10,37 @@ class SimpleAnalyzer(SpecificationAnalyzer):
super
(
SimpleAnalyzer
,
self
)
.
__init__
(
tosca_template
,
required_nodes
)
def
set_node_specifications
(
self
):
nodes_to_implement_polic
y
=
self
.
get_nodes_to_implement_policy
()
nodes_to_implement_polic
ies
=
self
.
get_nodes_to_implement_policy
()
for
node_name
in
nodes_to_implement_polic
y
:
polic
y
=
nodes_to_implement_policy
[
node_name
]
affected_node
=
self
.
set_specs
(
node_name
,
polic
y
,
self
.
nodes_in_template
)
for
node_name
in
nodes_to_implement_polic
ies
:
polic
ies
=
nodes_to_implement_policies
[
node_name
]
affected_node
=
self
.
set_specs
(
node_name
,
polic
ies
,
self
.
nodes_in_template
)
return
self
.
required_nodes
def
get_nodes_to_implement_policy
(
self
):
nodes_to_implement_polic
y
=
{}
nodes_to_implement_polic
ies
=
{}
for
policy
in
self
.
tosca_template
.
policies
:
for
target
in
policy
.
targets
:
for
leaf
in
self
.
leaf_nodes
:
logging
.
info
(
'From: '
+
target
+
' to: '
+
str
(
leaf
))
for
affected_node_name
in
(
nx
.
shortest_path
(
self
.
g
,
source
=
target
,
target
=
leaf
)):
if
affected_node_name
not
in
nodes_to_implement_polic
y
:
if
affected_node_name
not
in
nodes_to_implement_polic
ies
:
policy_list
=
[]
nodes_to_implement_polic
y
[
affected_node_name
]
=
policy_list
policy_list
=
nodes_to_implement_polic
y
[
affected_node_name
]
policy_list
.
append
(
policy
)
nodes_to_implement_polic
y
[
affected_node_name
]
=
policy_list
return
nodes_to_implement_polic
y
def
set_node_properties_for_policy
(
self
,
affected_node
,
polic
y
):
logging
.
info
(
'Se
e
ting properties for: '
+
str
(
affected_node
.
type
))
ancestors_types
=
tosca_util
.
get_all_ancestors_types
(
affected_node
)
if
affected_node
.
type
==
'tosca.nodes.ARTICONF.Orchestrator'
:
if
policy
.
type
==
'tosca.policies.ARTICONF.Performance.CPU'
:
nodes_to_implement_polic
ies
[
affected_node_name
]
=
policy_list
policy_list
=
nodes_to_implement_polic
ies
[
affected_node_name
]
policy_list
.
append
(
policy
.
type
)
nodes_to_implement_polic
ies
[
affected_node_name
]
=
policy_list
return
nodes_to_implement_polic
ies
def
set_node_properties_for_policy
(
self
,
affected_node
,
polic
ies
):
logging
.
info
(
'Se
t
ting properties for: '
+
str
(
affected_node
.
type
))
ancestors_types
=
tosca_util
.
get_all_ancestors_types
(
affected_node
,
self
.
all_node_types
)
if
'tosca.nodes.ARTICONF.Orchestrator'
in
ancestors_types
:
logging
.
info
(
'Do Something'
)
if
'tosca.policies.ARTICONF.Performance.CPU'
in
policies
:
logging
.
info
(
'Do placement'
)
return
affected_node
...
...
drip_planner2/src/planner/specification_analyzer.py
View file @
c6a1b02d
...
...
@@ -49,8 +49,8 @@ class SpecificationAnalyzer(metaclass=ABCMeta):
relationship_type
=
req
[
req_name
][
'relationship'
]
graph
.
add_edge
(
node
.
name
,
req_node_name
,
relationship
=
relationship_type
)
#
nx.draw(graph, with_labels=True)
#
plt.savefig("/tmp/graph.png")
nx
.
draw
(
graph
,
with_labels
=
True
)
plt
.
savefig
(
"/tmp/graph.png"
)
# plt.show()
return
graph
...
...
drip_planner2/src/utils/tosca.py
View file @
c6a1b02d
from
itertools
import
chain
from
toscaparser.elements.nodetype
import
NodeType
from
toscaparser.nodetemplate
import
NodeTemplate
from
utils.TOSCA_parser
import
TOSCAParser
...
...
@@ -9,7 +12,13 @@ node_type_key_names_to_remove = ['capabilities', 'derived_from']
def
get_node_type_name
(
node
):
if
isinstance
(
node
,
NodeTemplate
):
node_type
=
node
.
type
if
node
.
type
:
if
node
.
type
and
isinstance
(
node
.
type
,
str
):
node_type
=
node
.
type
elif
isinstance
(
node
.
type
,
NodeTemplate
):
node_type
=
node
.
type
.
type
else
:
node_type
=
None
elif
isinstance
(
node
,
dict
):
node_type
=
next
(
iter
(
node
))
return
node_type
...
...
@@ -28,7 +37,10 @@ def get_node_requirements(node):
def
get_parent_type
(
node
):
if
isinstance
(
node
,
NodeTemplate
):
parent_type
=
node
.
parent_type
if
node
.
parent_type
:
parent_type
=
node
.
parent_type
.
type
else
:
parent_type
=
None
elif
isinstance
(
node
,
dict
):
parent_type
=
node
[
next
(
iter
(
node
))][
'derived_from'
]
return
parent_type
...
...
@@ -63,20 +75,20 @@ def get_node_types_with_interface(nodes):
def
node_type_2_node_template
(
node_type
):
nodetemplate_dict
=
{}
node
_
template_dict
=
{}
type_name
=
next
(
iter
(
node_type
))
node_type_array
=
type_name
.
split
(
"."
)
name
=
node_type_array
[
len
(
node_type_array
)
-
1
]
.
lower
()
nodetemplate_dict
[
name
]
=
node_type
[
next
(
iter
(
node_type
))]
.
copy
()
nodetemplate_dict
[
name
][
'type'
]
=
type_name
node
_
template_dict
[
name
]
=
node_type
[
next
(
iter
(
node_type
))]
.
copy
()
node
_
template_dict
[
name
][
'type'
]
=
type_name
for
name_to_remove
in
node_type_key_names_to_remove
:
if
name_to_remove
in
nodetemplate_dict
[
name
]:
nodetemplate_dict
[
name
]
.
pop
(
name_to_remove
)
if
name_to_remove
in
node
_
template_dict
[
name
]:
node
_
template_dict
[
name
]
.
pop
(
name_to_remove
)
if
'type'
in
node_type
[
next
(
iter
(
node_type
))]:
node_type
[
next
(
iter
(
node_type
))]
.
pop
(
'type'
)
return
NodeTemplate
(
name
,
nodetemplate_dict
,
node_type
)
return
NodeTemplate
(
name
,
node
_
template_dict
,
node_type
)
def
get_tosca_template_2_topology_template
(
template
):
...
...
@@ -119,8 +131,16 @@ def set_node_properties(node, properties):
return
node
def
get_all_ancestors_types
(
child_node
):
logging
.
info
(
'child_node: '
+
str
(
child_node
.
type
))
def
get_node_by_type
(
node_type
,
all_nodes
):
return
all_nodes
[
node_type
]
def
get_all_ancestors_types
(
child_node
,
all_nodes
,
ancestors_types
=
None
):
if
not
ancestors_types
:
ancestors_types
=
[
get_node_type_name
(
child_node
)]
parent_type
=
get_parent_type
(
child_node
)
logging
.
info
(
'child_node.parent_type: '
+
str
(
parent_type
))
return
None
if
parent_type
:
ancestors_types
.
append
(
parent_type
)
parent_type
=
node_type_2_node_template
({
'name'
:
all_nodes
[
parent_type
]})
get_all_ancestors_types
(
parent_type
,
all_nodes
,
ancestors_types
)
return
ancestors_types
drip_planner2/venv/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg
View file @
c6a1b02d
No preview for this file type
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