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
03c9c83b
Commit
03c9c83b
authored
Nov 08, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change some attributes back to properties
parent
5b6644ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
107 deletions
+125
-107
application_example_2_topologies.yaml
TOSCA/application_example_2_topologies.yaml
+33
-45
workspace.xml
drip-planner/.idea/workspace.xml
+27
-10
__main__.py
drip-planner/__main__.py
+13
-13
simple_spec_alayzer.py
drip-planner/service/simple_spec_alayzer.py
+52
-39
No files found.
TOSCA/application_example_2_topologies.yaml
View file @
03c9c83b
tosca_definitions_version
:
tosca_simple_yaml_1_0
description
:
TOSCA example
imports
:
-
nodes
:
https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/nodes.yaml
-
capabilities
:
https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/capabilities.yaml
-
policies
:
https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/policies.yaml
-
interfaces
:
https://raw.githubusercontent.com/skoulouzis/DRIP/DRIP_3.0/TOSCA/types/interfaces.yml
repositories
:
docker_hub
:
https://hub.docker.com/
topology_template
:
node_templates
:
compute
:
...
...
@@ -19,8 +15,6 @@ topology_template:
mem_size
:
6000 MB
num_cores
:
2
os
:
ubuntu 16
attributes
:
private_ip
:
192.168.1.10
type
:
tosca.nodes.ARTICONF.VM.Compute
compute_1
:
interfaces
:
...
...
@@ -31,19 +25,7 @@ topology_template:
mem_size
:
6000 MB
num_cores
:
2
os
:
ubuntu 16
attributes
:
private_ip
:
192.168.1.11
type
:
tosca.nodes.ARTICONF.VM.Compute
compute_2
:
interfaces
:
Standard
:
create
:
dumy.yaml
properties
:
disk_size
:
50000 MB
mem_size
:
6000 MB
num_cores
:
2
os
:
ubuntu 16
type
:
tosca.nodes.ARTICONF.VM.Compute
kubernetes
:
interfaces
:
Standard
:
...
...
@@ -53,11 +35,27 @@ topology_template:
capability
:
tosca.capabilities.ARTICONF.VM.topology
node
:
topology
relationship
:
tosca.relationships.HostedOn
-
host
:
capability
:
tosca.capabilities.ARTICONF.VM.topology
node
:
topology_1
relationship
:
tosca.relationships.HostedOn
type
:
tosca.nodes.ARTICONF.Orchestrator.Kubernetes
logspout
:
artifacts
:
image
:
file
:
gliderlabs/logspout:latest
repository
:
docker_hub
type
:
tosca.artifacts.Deployment.Image.Container.Docker
properties
:
environment
:
publish
:
127.0.0.1:8000:80
ports
:
-
8000:80
volumes
:
-
/etc/hostname:/etc/host_hostname:ro
-
/var/run/docker.sock:/var/run/docker.sock
requirements
:
-
host
:
capability
:
tosca.capabilities.ARTICONF.Orchestrator
node
:
kubernetes
relationship
:
tosca.relationships.HostedOn
type
:
tosca.nodes.ARTICONF.Container.Application.Docker
mysql
:
artifacts
:
image
:
...
...
@@ -84,6 +82,9 @@ topology_template:
interfaces
:
Standard
:
create
:
dumy.yaml
properties
:
domain
:
UvA (Amsterdam, The Netherlands) XO Rack
provider
:
ExoGeni
requirements
:
-
vm
:
capability
:
tosca.capabilities.ARTICONF.VM
...
...
@@ -93,17 +94,7 @@ topology_template:
capability
:
tosca.capabilities.ARTICONF.VM
node
:
compute_1
relationship
:
tosca.relationships.DependsOn
type
:
tosca.nodes.ARTICONF.VM.topology
topology_1
:
interfaces
:
Standard
:
create
:
dumy.yaml
requirements
:
-
vm
:
capability
:
tosca.capabilities.ARTICONF.VM
node
:
compute_2
relationship
:
tosca.relationships.DependsOn
type
:
tosca.nodes.ARTICONF.VM.topology
type
:
tosca.nodes.ARTICONF.VM.topology
wordpress
:
artifacts
:
image
:
...
...
@@ -128,21 +119,18 @@ topology_template:
node
:
kubernetes
relationship
:
tosca.relationships.HostedOn
type
:
tosca.nodes.ARTICONF.Container.Application.Docker
policies
:
-
scalability
:
properties
:
fault_tolerance_level
:
0
constraint_name
:
cpu_load
max_value
:
90
targets
:
-
wordpress
type
:
tosca.policies.ARTICONF.Performance.CPU
-
faultTolerance
:
properties
:
level
:
1
targets
:
-
mysql
type
:
tosca.policies.ARTICONF.FaultTolerance
outputs
:
private_ip
:
description
:
The private IP address of the application’s first tier.
value
:
{
get_attribute
:
[
compute
,
private_ip
]
}
private_ip_1
:
description
:
The private IP address of the application’s first tier.
value
:
{
get_attribute
:
[
compute_1
,
private_ip
]
}
tosca_definitions_version
:
tosca_simple_yaml_1_0
drip-planner/.idea/workspace.xml
View file @
03c9c83b
...
...
@@ -2,13 +2,10 @@
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"e478ccae-5352-4e8e-9efb-3f5cda44e877"
name=
"Default Changelist"
comment=
"added matplotlib"
>
<change
beforePath=
"$PROJECT_DIR$/../
build.sh"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../build.sh
"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../
TOSCA/application_example_2_topologies.yaml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../TOSCA/application_example_2_topologies.yaml
"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/
requirements.txt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/requirements.txt
"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/
__main__.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/__main__.py
"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/service/simple_spec_alayzer.py"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/service/simple_spec_alayzer.py"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../jenkins_pipeline"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../jenkins_pipeline"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../sure_tosca-flask-server/test-requirements.txt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../sure_tosca-flask-server/test-requirements.txt"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/../test.sh"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../test.sh"
afterDir=
"false"
/>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
...
@@ -206,18 +203,38 @@
<breakpoints>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/service/simple_spec_alayzer.py
</url>
<line>
4
5
</line>
<line>
4
7
</line>
<option
name=
"timeStamp"
value=
"1"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/planner/planner.py
</url>
<line>
36
</line>
<option
name=
"timeStamp"
value=
"3"
/>
<line>
66
</line>
<option
name=
"timeStamp"
value=
"8"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/planner/planner.py
</url>
<line>
61
</line>
<option
name=
"timeStamp"
value=
"9"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/__main__.py
</url>
<line>
124
</line>
<option
name=
"timeStamp"
value=
"10"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/service/simple_spec_alayzer.py
</url>
<line>
25
</line>
<option
name=
"timeStamp"
value=
"20"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/service/simple_spec_alayzer.py
</url>
<line>
127
</line>
<option
name=
"timeStamp"
value=
"22"
/>
</line-breakpoint>
<line-breakpoint
enabled=
"true"
suspend=
"THREAD"
type=
"python-line"
>
<url>
file://$PROJECT_DIR$/service/simple_spec_alayzer.py
</url>
<line>
26
</line>
<option
name=
"timeStamp"
value=
"
5
"
/>
<line>
160
</line>
<option
name=
"timeStamp"
value=
"
26
"
/>
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
...
...
drip-planner/__main__.py
View file @
03c9c83b
...
...
@@ -115,7 +115,7 @@ if __name__ == "__main__":
logging
.
basicConfig
(
level
=
logging
.
INFO
)
if
sys
.
argv
[
1
]
==
"test_local"
:
tosca_path
=
"../TOSCA/"
input_tosca_file_path
=
tosca_path
+
'/application_example_
2_topologies
.yaml'
input_tosca_file_path
=
tosca_path
+
'/application_example_
updated
.yaml'
conf
=
{
'url'
:
"http://host"
}
spec_service
=
SpecService
(
conf
)
test_planner
=
Planner
(
input_tosca_file_path
,
spec_service
)
...
...
@@ -129,18 +129,18 @@ if __name__ == "__main__":
except
NameError
:
import
sys
tosca_folder_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
sys
.
argv
[
0
]))
+
os
.
path
.
join
(
tempfile
.
gettempdir
(),
tosca_path
)
tosca_file_name
=
'tosca_template'
input_tosca_file_path
=
tosca_path
+
'/application_example_2_topologies.yaml'
with
open
(
input_tosca_file_path
,
'w'
)
as
outfile
:
outfile
.
write
(
yaml
.
dump
(
template_dict
))
ToscaTemplate
(
input_tosca_file_path
)
test_response
=
{
'toscaTemplate'
:
template_dict
}
logger
.
info
(
"Output message:"
+
json
.
dumps
(
test_response
))
#
tosca_folder_path = os.path.dirname(os.path.abspath(sys.argv[0])) + os.path.join(tempfile.gettempdir(),
#
tosca_path)
#
tosca_file_name = 'tosca_template'
#
input_tosca_file_path = tosca_path + '/application_example_2_topologies.yaml'
#
#
with open(input_tosca_file_path, 'w') as outfile:
#
outfile.write(yaml.dump(template_dict))
#
#
ToscaTemplate(input_tosca_file_path)
#
#
test_response = {'toscaTemplate': template_dict}
#
logger.info("Output message:" + json.dumps(test_response))
else
:
logger
.
info
(
"Input args: "
+
sys
.
argv
[
0
]
+
' '
+
sys
.
argv
[
1
]
+
' '
+
sys
.
argv
[
2
])
channel
=
init_chanel
(
sys
.
argv
)
...
...
drip-planner/service/simple_spec_alayzer.py
View file @
03c9c83b
...
...
@@ -20,19 +20,21 @@ class SimpleAnalyzer(SpecificationAnalyzer):
# nodes_with_occurrences_in_requirements = tosca_util.get_nodes_with_occurrences_in_requirements(
# self.tosca_template.nodetemplates)
orchestrator_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.Orchestrator'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
orchestrator_nodes
[
0
]
.
type_definition
if
'attributes'
in
orchestrator_nodes
[
0
]
.
entity_tpl
:
if
'masters_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'attributes'
]:
masters_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'attributes'
][
'masters_num'
]
if
'workers_num'
in
orchestrator_nodes
[
0
]
.
entity_tpl
[
'attributes'
]:
workers_num
=
orchestrator_nodes
[
0
]
.
entity_tpl
[
'attributes'
][
'workers_num'
]
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
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'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
# for requirement in topology_nodes[0].requirements:
# requirement_dict = requirement[next(iter(requirement))]
...
...
@@ -40,10 +42,10 @@ class SimpleAnalyzer(SpecificationAnalyzer):
# requirement_dict['occurrences'] = min_num_of_vm
vm_nodes
=
tosca_helper
.
get_nodes_by_type
(
'tosca.nodes.ARTICONF.VM.Compute'
,
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
self
.
tosca_template
.
nodetemplates
,
self
.
all_node_types
,
self
.
all_custom_def
)
if
vm_nodes
:
for
i
in
range
(
len
(
vm_nodes
),
masters_num
):
for
i
in
range
(
len
(
vm_nodes
),
m
in_m
asters_num
):
old_vm_name
=
vm_nodes
[
0
]
.
name
new_vm
=
copy
.
deepcopy
(
vm_nodes
[
0
])
new_vm_name
=
new_vm
.
name
+
'_'
+
str
(
i
)
...
...
@@ -116,12 +118,12 @@ class SimpleAnalyzer(SpecificationAnalyzer):
ancestors_types
=
tosca_helper
.
get_all_ancestors_types
(
affected_node
,
self
.
all_node_types
,
self
.
all_custom_def
)
# if 'tosca.nodes.ARTICONF.Orchestrator' in ancestors_types:
# logging.info('Do Something')
properties
=
tosca_helper
.
get_all_ancestors_properties
(
affected_node
,
self
.
all_node_types
,
self
.
all_custom_def
)
ancestors_
properties
=
tosca_helper
.
get_all_ancestors_properties
(
affected_node
,
self
.
all_node_types
,
self
.
all_custom_def
)
default_properties
=
{}
for
node_property
in
properties
:
default_property
=
self
.
get_defult_value
(
node
_property
)
for
ancestors_property
in
ancestors_
properties
:
default_property
=
self
.
get_defult_value
(
ancestors
_property
)
if
default_property
:
default_properties
[
next
(
iter
(
default_property
))]
=
default_property
[
next
(
iter
(
default_property
))]
...
...
@@ -156,25 +158,36 @@ class SimpleAnalyzer(SpecificationAnalyzer):
return
affected_node
def
get_defult_value
(
self
,
node_property
):
if
isinstance
(
node_property
.
value
,
dict
)
and
'required'
in
node_property
.
value
and
'type'
in
node_property
.
value
:
if
node_property
.
value
[
'required'
]:
default_prop
=
{}
if
'default'
in
node_property
.
value
:
if
node_property
.
value
[
'type'
]
==
'integer'
:
default_prop
=
int
(
node_property
.
value
[
'default'
])
else
:
default_prop
=
str
(
node_property
.
value
[
'default'
])
elif
'constraints'
in
node_property
.
value
:
constraints
=
node_property
.
value
[
'constraints'
]
for
constraint
in
constraints
:
for
constraint_key
in
constraint
:
if
'equal'
in
constraint_key
:
if
node_property
.
value
[
'type'
]
==
'integer'
:
default_prop
=
int
(
constraint
[
constraint_key
])
else
:
default_prop
=
str
(
constraint
[
constraint_key
])
name
=
node_property
.
name
node_property
=
{
name
:
default_prop
}
return
node_property
if
node_property
and
node_property
.
required
and
isinstance
(
node_property
.
value
,
dict
)
and
'required'
in
\
node_property
.
value
and
'type'
in
node_property
.
value
:
if
node_property
.
default
:
return
{
node_property
.
name
:
node_property
.
default
}
if
node_property
.
constraints
:
for
constraint
in
node_property
.
constraints
:
print
(
constraint
)
# if isinstance(node_property.value,
# dict) and 'required' in node_property.value and 'type' in node_property.value:
# if node_property.value['required']:
# default_prop = {}
# if 'default' in node_property.value:
# if node_property.value['type'] == 'integer':
# default_prop = int(node_property.value['default'])
# else:
# default_prop = str(node_property.value['default'])
# elif 'constraints' in node_property.value:
# constraints = node_property.value['constraints']
# for constraint in constraints:
# for constraint_key in constraint:
# if 'equal' in constraint_key:
# if node_property.value['type'] == 'integer':
# default_prop = int(constraint[constraint_key])
# else:
# default_prop = str(constraint[constraint_key])
# name = node_property.name
# node_property = {name: default_prop}
# return node_property
# if node_property.value:
# name = node_property.name
# node_property = {name: node_property.value}
# return node_property
return
None
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