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
0d49ba8c
Commit
0d49ba8c
authored
May 12, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed types and added glusterfs test
parent
c2921364
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
51 deletions
+70
-51
planner.py
planner/planner/planner.py
+5
-2
simple_spec_alayzer.py
planner/service/simple_spec_alayzer.py
+23
-16
test_planner.py
planner/test/test_planner.py
+37
-28
tosca_helper.py
planner/util/tosca_helper.py
+5
-5
No files found.
planner/planner/planner.py
View file @
0d49ba8c
...
...
@@ -257,8 +257,11 @@ class Planner:
number_of_matching_requirement
=
{}
# Loop requirements to find nodes per requirement
for
req
in
all_requirements
:
if
'capability'
in
req
[
next
(
iter
(
req
))]:
capability
=
req
[
next
(
iter
(
req
))][
'capability'
]
key
=
next
(
iter
(
req
))
if
not
req
[
key
]:
raise
Exception
(
'Requirement: '
+
str
(
req
)
+
' is not properly defined'
)
if
'capability'
in
req
[
key
]:
capability
=
req
[
key
][
'capability'
]
# Find all nodes in the definitions that have the capability: capability
logger
.
info
(
' Looking for nodes in node types with capability: '
+
capability
)
capable_nodes
=
self
.
get_node_types_by_capability
(
capability
)
...
...
planner/service/simple_spec_alayzer.py
View file @
0d49ba8c
...
...
@@ -30,26 +30,33 @@ class SimpleAnalyzer(SpecificationAnalyzer):
def
set_relationship_occurrences
(
self
):
return_nodes
=
[]
orchestrator_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF
.docker.Orchestrator'
,
nodes_with_min_vms
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.QC
.docker.Orchestrator'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
min_masters_num
=
1
nodes_with_min_vms
=
nodes_with_min_vms
+
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.QC.Application.GlusterFS'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
min_masters_num
=
0
workers_num
=
0
if
orchestrator_nodes
:
if
'properties'
in
orchestrator_nodes
[
0
]
.
entity_tpl
:
if
'min_masters_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
]:
min_masters_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
][
'min_masters_num'
]
if
'min_workers_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
]:
workers_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'properties'
][
'min_workers_num'
]
else
:
min_masters_num
=
orchestrator_nodes
[
0
]
.
get_property_value
(
'min_masters_num'
)
workers_num
=
orchestrator_nodes
[
0
]
.
get_property_value
(
'min_workers_num'
)
topology_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.topology'
,
if
nodes_with_min_vms
:
for
node_with_min_vms
in
nodes_with_min_vms
:
if
'properties'
in
node_with_min_vms
.
entity_tpl
:
if
'min_masters_num'
in
node_with_min_vms
.
entity_tpl
[
'properties'
]:
min_masters_num
=
min_masters_num
+
node_with_min_vms
.
entity_tpl
[
'properties'
][
'min_masters_num'
]
if
'min_workers_num'
in
node_with_min_vms
.
entity_tpl
[
'properties'
]:
workers_num
=
workers_num
+
node_with_min_vms
.
entity_tpl
[
'properties'
][
'min_workers_num'
]
else
:
min_masters_num
=
min_masters_num
+
node_with_min_vms
.
get_property_value
(
'min_masters_num'
)
workers_num
=
workers_num
+
node_with_min_vms
.
get_property_value
(
'min_workers_num'
)
if
min_masters_num
<
0
:
min_masters_num
=
1
topology_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.QC.VM.topology'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
if
topology_nodes
:
vm_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.
ARTICONF
.VM.Compute'
,
vm_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.
QC
.VM.Compute'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
if
vm_nodes
:
...
...
@@ -65,7 +72,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for
requirement
in
topology_nodes
[
0
]
.
requirements
:
requirement_key
=
next
(
iter
(
requirement
))
requirement_value
=
requirement
[
requirement_key
]
if
requirement_value
[
'capability'
]
==
'tosca.capabilities.
ARTICONF
.VM'
:
if
requirement_value
[
'capability'
]
==
'tosca.capabilities.
QC
.VM'
:
new_requirement
=
copy
.
deepcopy
(
requirement
)
new_requirement
[
requirement_key
][
'node'
]
=
new_vm
.
name
topology_nodes
[
0
]
.
requirements
.
append
(
new_requirement
)
...
...
@@ -84,7 +91,7 @@ class SimpleAnalyzer(SpecificationAnalyzer):
for
requirement
in
topology_nodes
[
0
]
.
requirements
:
requirement_key
=
next
(
iter
(
requirement
))
requirement_value
=
requirement
[
requirement_key
]
if
requirement_value
[
'capability'
]
==
'tosca.capabilities.
ARTICONF
.VM'
:
if
requirement_value
[
'capability'
]
==
'tosca.capabilities.
QC
.VM'
:
new_requirement
=
copy
.
deepcopy
(
requirement
)
new_requirement
[
requirement_key
][
'node'
]
=
new_vm
.
name
topology_nodes
[
0
]
.
requirements
.
append
(
new_requirement
)
...
...
planner/test/test_planner.py
View file @
0d49ba8c
...
...
@@ -6,7 +6,7 @@ import os.path
import
tempfile
import
time
import
unittest
import
requests
import
yaml
from
toscaparser.tosca_template
import
ToscaTemplate
...
...
@@ -20,36 +20,45 @@ logger.setLevel(logging.DEBUG)
class
MyTestCase
(
unittest
.
TestCase
):
def
test_docker
(
self
):
file_name
=
'application_example_updated.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
file_name
=
'lifeWatch_vre1.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
def
test_tic_gluster_fs
(
self
):
url
=
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.yaml'
tic_tosca
=
requests
.
get
(
url
)
input_tosca_file_path
=
os
.
path
.
join
(
tempfile
.
gettempdir
(),
'TIC.yaml'
)
open
(
input_tosca_file_path
,
'wb'
)
.
write
(
tic_tosca
.
content
)
self
.
run_test
(
input_tosca_file_path
)
def
test_kubernetes
(
self
):
file_name
=
'kubernetes.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
def
test_topology
(
self
):
file_name
=
'topology.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
def
test_compute
(
self
):
file_name
=
'compute.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
def
test_lifeWatch
(
self
):
file_name
=
'lifeWatch_vre1.yaml'
input_tosca_file_path
=
self
.
get_input_tosca_file_path
(
file_name
)
self
.
run_test
(
input_tosca_file_path
)
# def test_docker(self):
# file_name = 'application_example_updated.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# file_name = 'lifeWatch_vre1.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
#
# def test_kubernetes(self):
# file_name = 'kubernetes.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# def test_topology(self):
# file_name = 'topology.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# def test_compute(self):
# file_name = 'compute.yaml'
# input_tosca_file_path = self.get_input_tosca_file_path(file_name)
# self.run_test(input_tosca_file_path)
#
# def test_lifeWatch(self):
# url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml'
# tic_tosca = requests.get(url)
# input_tosca_file_path = os.path.join(tempfile.gettempdir(),'TIC.yaml')
# open( input_tosca_file_path, 'wb').write(tic_tosca.content)
# self.run_test(input_tosca_file_path)
def
get_input_tosca_file_path
(
self
,
file_name
):
tosca_path
=
"../../TOSCA/"
...
...
planner/util/tosca_helper.py
View file @
0d49ba8c
...
...
@@ -121,8 +121,8 @@ def node_type_2_node_template(node_type, all_custom_def):
node_type
[
next
(
iter
(
node_type
))]
.
pop
(
'type'
)
node_template
=
NodeTemplate
(
name
,
node_template_dict
,
node_type
)
# For some reason the tosca.
nodes.ARTICONF
.docker.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.
nodes.ARTICONF
.docker.Orchestrator"
# For some reason the tosca.
capabilities.QC
.docker.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.
capabilities.QC
.docker.Orchestrator"
# is not a valid type.'
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
for
def_key
in
all_custom_def
:
...
...
@@ -273,7 +273,7 @@ def get_node_template_dict(node_template):
def
get_node_type_interfaces
(
node
):
node_type_interfaces
=
node
.
type_definition
.
interfaces
node_type_interfaces
=
node
.
type_definition
.
interfaces
return
node_type_interfaces
...
...
@@ -282,6 +282,6 @@ def get_node_template_interfaces(node):
return
node_template_interfaces
def
add_interfaces
(
node
,
node_type_interfaces
):
def
add_interfaces
(
node
,
node_type_interfaces
):
# node.interfaces = node_type_interfaces
return
node
\ No newline at end of file
return
node
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