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
842f448b
Commit
842f448b
authored
Oct 10, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to parse tosca
parent
3bea3c50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
19 deletions
+51
-19
docker-composerMOG.yaml
docs/composer_files/docker-composerMOG.yaml
+0
-0
rpc_server.py
drip_planner2/src/rpc_server.py
+51
-19
No files found.
docs/
input_tosca
_files/docker-composerMOG.yaml
→
docs/
composer
_files/docker-composerMOG.yaml
View file @
842f448b
File moved
drip_planner2/src/rpc_server.py
View file @
842f448b
...
...
@@ -56,27 +56,59 @@ if __name__ == "__main__":
# 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)
try
:
# tosca = ToscaTemplate('/home/alogo/workspace/DRIP/docs/input_tosca_files/tosca_MOG_input.yaml')
tosca
=
ToscaTemplate
(
'/home/alogo/workspace/DRIP/docs/input_tosca_files/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 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():
# 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)
response
=
{}
current_milli_time
=
lambda
:
int
(
round
(
time
.
time
()
*
1000
))
response
[
"creationDate"
]
=
current_milli_time
()
response
[
"parameters"
]
=
[]
compute_nodes
=
[]
for
node
in
tosca
.
nodetemplates
:
# print dir(node)
print
"Name:
%
s Type:
%
s props:
%
s"
%
(
node
.
name
,
node
.
type
,
node
.
get_properties
()
.
keys
())
for
relationship
,
trgt
in
node
.
relationships
.
items
():
if
relationship
.
type
==
EntityType
.
HOSTEDON
:
rel_template
=
trgt
.
get_relationship_template
()
for
rel
in
rel_template
:
compute_nodes
.
append
(
rel
.
target
)
for
compute_node
in
compute_nodes
:
result
=
{}
parameter
=
{}
result
[
'name'
]
=
node
.
name
result
[
'size'
]
=
'Medium'
result
[
'docker'
]
=
compute_node
.
get_properties
()[
'dockers'
]
.
value
# print dir(compute_node.get_properties()['dockers'] )
# print "dockers. Name: %s Type: %s Value: %s" % (compute_node.get_properties()['dockers'].name, compute_node.get_properties()['dockers'].type, compute_node.get_properties()['dockers'].value )
parameter
[
'value'
]
=
str
(
json
.
dumps
(
result
))
parameter
[
'attributes'
]
=
'null'
parameter
[
"url"
]
=
"null"
parameter
[
"encoding"
]
=
"UTF-8"
response
[
"parameters"
]
.
append
(
parameter
)
# print "Name: %s Type: %s properties: %s" %(compute_node.name,compute_node.type,compute_node.get_properties().keys())
print
(
"Output message:
%
s"
%
json
.
dumps
(
response
))
except
AttributeError
as
e
:
z
=
e
print
z
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