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
c8cbab19
Commit
c8cbab19
authored
Oct 06, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use parser
parent
a9d4ea29
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
46 deletions
+78
-46
.rpc_server.py.kate-swp
drip-deployer/.rpc_server.py.kate-swp
+0
-0
rpc_server.py
drip-deployer/rpc_server.py
+2
-1
__init__.py
drip_planner2/src/planner/__init__.py
+0
-0
__init__.pyc
drip_planner2/src/planner/__init__.pyc
+0
-0
dump_planner.py
drip_planner2/src/planner/dump_planner.py
+45
-0
dump_planner.pyc
drip_planner2/src/planner/dump_planner.pyc
+0
-0
rpc_server.py
drip_planner2/src/rpc_server.py
+31
-45
No files found.
drip-deployer/.rpc_server.py.kate-swp
deleted
100644 → 0
View file @
a9d4ea29
File deleted
drip-deployer/rpc_server.py
View file @
c8cbab19
...
...
@@ -98,7 +98,8 @@ def handleDelivery(message):
number_of_containers
=
param
[
"attributes"
][
"number_of_containers"
]
elif
name
==
"swarm_info"
:
name_of_deployment
=
param
[
"value"
]
name_of_service
=
param
[
"attributes"
][
"service"
]
name_of_service
=
param
[
"attributes"
][
"service"
]
compose_name
=
param
[
"attributes"
][
"name"
]
if
manager_type
==
"kubernetes"
:
...
...
drip_planner2/src/planner/__init__.py
0 → 100644
View file @
c8cbab19
drip_planner2/src/planner/__init__.pyc
0 → 100644
View file @
c8cbab19
File added
drip_planner2/src/planner/dump_planner.py
0 → 100644
View file @
c8cbab19
from
toscaparser
import
*
from
toscaparser.tosca_template
import
ToscaTemplate
import
json
import
time
class
DumpPlanner
:
def
__init__
(
self
,
tosca
):
self
.
tosca
=
tosca
self
.
tt
=
ToscaTemplate
()
def
plan
(
self
):
self
.
tt
# topology_template = parsed_json_value['topology_template']
# node_templates = topology_template["node_templates"]
#
# response = {}
# current_milli_time = lambda: int(round(time.time() * 1000))
# response["creationDate"] = current_milli_time()
# response["parameters"] = []
#
# for nodes in node_templates:
# if "Switch.nodes.Application.Container.Docker." in node_templates[nodes]['type']:
# node_keys = node_templates[nodes].keys()
# if 'artifacts' in node_keys:
# artifact_key = next(iter(node_templates[nodes]['artifacts']))
# artifact_keys = node_templates[nodes]['artifacts'][artifact_key].keys()
# if 'file' in artifact_keys:
# docker = node_templates[nodes]['artifacts'][artifact_key]['file']
# elif 'docker_image' in artifact_keys:
# docker = node_templates[nodes]['artifacts']['docker_image']['file']
# result = {}
# parameter = {}
# result['name'] = nodes
# result['size'] = 'Medium'
# result['docker'] = docker
# parameter['value'] = str(json.dumps(result))
# parameter['attributes'] = 'null'
# parameter["url"] = "null"
# parameter["encoding"] = "UTF-8"
# response["parameters"].append(parameter)
# print ("Output message: %s" % json.dumps(response))
# return json.dumps(response)
\ No newline at end of file
drip_planner2/src/planner/dump_planner.pyc
0 → 100644
View file @
c8cbab19
File added
drip_planner2/src/rpc_server.py
View file @
c8cbab19
...
...
@@ -2,26 +2,18 @@
# To change this template file, choose Tools | Templates
# and open the template in the editor.
import
argparse
import
getopt
import
json
import
networkx
as
nx
import
numpy
as
np
import
operator
import
os
import
pika
import
random
import
re
from
planner.dump_planner
import
*
import
sys
import
time
from
toscaparser
import
*
from
toscaparser.tosca_template
import
ToscaTemplate
from
toscaparser.elements.entity_type
import
EntityType
def
init_chanel
(
args
):
if
len
(
args
)
>
1
:
rabbitmq_host
=
args
[
1
]
#sys.argv[1]
rabbitmq_host
=
args
[
1
]
else
:
rabbitmq_host
=
'127.0.0.1'
...
...
@@ -55,42 +47,36 @@ def handle_delivery(message):
value
=
param
[
"value"
]
parsed_json_value
=
json
.
loads
(
value
)
topology_template
=
parsed_json_value
[
'topology_template'
]
node_templates
=
topology_template
[
"node_templates"
]
response
=
{}
current_milli_time
=
lambda
:
int
(
round
(
time
.
time
()
*
1000
))
response
[
"creationDate"
]
=
current_milli_time
()
response
[
"parameters"
]
=
[]
for
nodes
in
node_templates
:
if
"Switch.nodes.Application.Container.Docker."
in
node_templates
[
nodes
][
'type'
]:
node_keys
=
node_templates
[
nodes
]
.
keys
()
if
'artifacts'
in
node_keys
:
artifact_key
=
next
(
iter
(
node_templates
[
nodes
][
'artifacts'
]))
artifact_keys
=
node_templates
[
nodes
][
'artifacts'
][
artifact_key
]
.
keys
()
if
'file'
in
artifact_keys
:
docker
=
node_templates
[
nodes
][
'artifacts'
][
artifact_key
][
'file'
]
elif
'docker_image'
in
artifact_keys
:
docker
=
node_templates
[
nodes
][
'artifacts'
][
'docker_image'
][
'file'
]
result
=
{}
parameter
=
{}
result
[
'name'
]
=
nodes
result
[
'size'
]
=
'Medium'
result
[
'docker'
]
=
docker
parameter
[
'value'
]
=
str
(
json
.
dumps
(
result
))
parameter
[
'attributes'
]
=
'null'
parameter
[
"url"
]
=
"null"
parameter
[
"encoding"
]
=
"UTF-8"
response
[
"parameters"
]
.
append
(
parameter
)
print
(
"Output message:
%
s"
%
json
.
dumps
(
response
))
return
json
.
dumps
(
response
)
planner
=
DumpPlanner
();
response
=
planner
.
plan
(
parsed_json_value
);
return
response
if
__name__
==
"__main__"
:
print
sys
.
argv
channel
=
init_chanel
(
sys
.
argv
)
start
(
channel
)
# print sys.argv
# channel = init_chanel(sys.argv)
# start(channel)
tosca
=
ToscaTemplate
(
'/home/alogo/workspace/DRIP/docs/input_tosca_files/tosca_MOG_input.yaml'
)
# for node in tosca.nodetemplates:
# print "Name %s Type: %s " %(node.name,node.type)
#
# for input in tosca.inputs:
# print input.name
# for node in tosca.nodetemplates:
# for relationship, trgt in node.relationships.items():
# rel_template = trgt.get_relationship_template()
# for rel in rel_template:
# print "source %s Relationship: %s target: %s" %(rel.source.type,rel.type,rel.target.type)
# print dir(rel)
for
node
in
tosca
.
nodetemplates
:
for
relationship
,
trgt
in
node
.
relationships
.
items
():
# print EntityType.HOSTEDON
# print type(EntityType.HOSTEDON)
# print relationship.type
# print type(relationship.type)
if
relationship
.
type
==
EntityType
.
HOSTEDON
:
print
relationship
.
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