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
f1c6b279
Commit
f1c6b279
authored
Nov 06, 2017
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added environment for getting environment vars
parent
67f39af4
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
802 additions
and
23 deletions
+802
-23
Matej.BEIA.yml
docs/input_tosca_files/Matej.BEIA.yml
+762
-0
rpc_server.py
drip_parser/src/rpc_server.py
+1
-1
__init__.pyc
drip_parser/src/transformer/__init__.pyc
+0
-0
docker_compose_transformer.py
drip_parser/src/transformer/docker_compose_transformer.py
+39
-22
docker_compose_transformer.pyc
drip_parser/src/transformer/docker_compose_transformer.pyc
+0
-0
No files found.
docs/input_tosca_files/Matej.BEIA.yml
0 → 100644
View file @
f1c6b279
This diff is collapsed.
Click to expand it.
drip_parser/src/rpc_server.py
View file @
f1c6b279
...
@@ -82,7 +82,7 @@ def handle_delivery(message):
...
@@ -82,7 +82,7 @@ def handle_delivery(message):
def
test_local
():
def
test_local
():
home
=
expanduser
(
"~"
)
home
=
expanduser
(
"~"
)
transformer
=
DockerComposeTransformer
(
home
+
"/workspace/DRIP/docs/input_tosca_files/BEIA.yml"
)
transformer
=
DockerComposeTransformer
(
home
+
"/workspace/DRIP/docs/input_tosca_files/
Matej.
BEIA.yml"
)
compose
=
transformer
.
getnerate_compose
()
compose
=
transformer
.
getnerate_compose
()
print
yaml
.
dump
(
compose
)
print
yaml
.
dump
(
compose
)
response
=
{}
response
=
{}
...
...
drip_parser/src/transformer/__init__.pyc
View file @
f1c6b279
No preview for this file type
drip_parser/src/transformer/docker_compose_transformer.py
View file @
f1c6b279
...
@@ -3,6 +3,17 @@ from toscaparser import *
...
@@ -3,6 +3,17 @@ from toscaparser import *
from
toscaparser.tosca_template
import
ToscaTemplate
from
toscaparser.tosca_template
import
ToscaTemplate
import
toscaparser.utils.yamlparser
import
toscaparser.utils.yamlparser
import
yaml
import
yaml
import
logging
logger
=
logging
.
getLogger
(
__name__
)
if
not
getattr
(
logger
,
'handler_set'
,
None
):
logger
.
setLevel
(
logging
.
INFO
)
h
=
logging
.
StreamHandler
()
formatter
=
logging
.
Formatter
(
'
%(asctime)
s -
%(name)
s -
%(levelname)
s -
%(message)
s'
)
h
.
setFormatter
(
formatter
)
logger
.
addHandler
(
h
)
logger
.
handler_set
=
True
class
DockerComposeTransformer
:
class
DockerComposeTransformer
:
...
@@ -50,7 +61,7 @@ class DockerComposeTransformer:
...
@@ -50,7 +61,7 @@ class DockerComposeTransformer:
def
get_enviroment_vars
(
self
,
properties
):
def
get_enviroment_vars
(
self
,
properties
):
environments
=
[]
environments
=
[]
for
prop
in
properties
:
for
prop
in
properties
:
if
prop
==
'Environment_variables'
or
prop
==
'Live_variables'
:
if
prop
==
'Environment_variables'
or
prop
==
'Live_variables'
or
prop
==
'Environment'
:
for
var
in
properties
[
prop
]:
for
var
in
properties
[
prop
]:
environment
=
{}
environment
=
{}
environment
[
var
]
=
properties
[
prop
][
var
]
environment
[
var
]
=
properties
[
prop
][
var
]
...
@@ -68,12 +79,12 @@ class DockerComposeTransformer:
...
@@ -68,12 +79,12 @@ class DockerComposeTransformer:
for
port_map_key
in
ports_mappings
:
for
port_map_key
in
ports_mappings
:
port_map
=
{}
port_map
=
{}
host_port
=
ports_mappings
[
port_map_key
][
'host_port'
]
host_port
=
ports_mappings
[
port_map_key
][
'host_port'
]
if
not
isinstance
(
host_port
,
(
int
,
long
,
float
,
complex
)):
if
not
isinstance
(
host_port
,
(
int
,
long
,
float
,
complex
))
and
'$'
in
host_port
:
host_port_var
=
host_port
.
replace
(
'${'
,
''
)
.
replace
(
'}'
,
''
)
host_port_var
=
host_port
.
replace
(
'${'
,
''
)
.
replace
(
'}'
,
''
)
host_port
=
properties
[
host_port_var
]
host_port
=
properties
[
host_port_var
]
container_port
=
ports_mappings
[
port_map_key
][
'container_port'
]
container_port
=
ports_mappings
[
port_map_key
][
'container_port'
]
if
not
isinstance
(
container_port
,
(
int
,
long
,
float
,
complex
)):
if
not
isinstance
(
container_port
,
(
int
,
long
,
float
,
complex
))
and
'$'
in
container_port
:
container_port_var
=
container_port
.
replace
(
'${'
,
''
)
.
replace
(
'}'
,
''
)
container_port_var
=
container_port
.
replace
(
'${'
,
''
)
.
replace
(
'}'
,
''
)
container_port
=
properties
[
container_port_var
]
container_port
=
properties
[
container_port_var
]
port_map
[
host_port
]
=
container_port
port_map
[
host_port
]
=
container_port
...
@@ -82,12 +93,16 @@ class DockerComposeTransformer:
...
@@ -82,12 +93,16 @@ class DockerComposeTransformer:
ports_mappings
=
properties
[
'in_ports'
]
ports_mappings
=
properties
[
'in_ports'
]
for
port_map_key
in
ports_mappings
:
for
port_map_key
in
ports_mappings
:
port_map
=
{}
port_map
=
{}
if
'host_port'
in
ports_mappings
[
port_map_key
]:
host_port
=
ports_mappings
[
port_map_key
][
'host_port'
]
host_port
=
ports_mappings
[
port_map_key
][
'host_port'
]
container_port
=
None
if
'container_port'
in
ports_mappings
[
port_map_key
]:
container_port
=
ports_mappings
[
port_map_key
][
'container_port'
]
container_port
=
ports_mappings
[
port_map_key
][
'container_port'
]
if
'protocol'
in
ports_mappings
[
port_map_key
]:
if
'protocol'
in
ports_mappings
[
port_map_key
]:
protocol
=
ports_mappings
[
port_map_key
][
'protocol'
]
protocol
=
ports_mappings
[
port_map_key
][
'protocol'
]
if
protocol
:
if
protocol
:
container_port
=
container_port
+
'/'
+
protocol
container_port
=
container_port
+
'/'
+
protocol
if
container_port
:
port_map
[
host_port
]
=
container_port
port_map
[
host_port
]
=
container_port
port_maps
.
append
(
port_map
)
port_maps
.
append
(
port_map
)
if
'out_ports'
in
properties
:
if
'out_ports'
in
properties
:
...
@@ -110,6 +125,7 @@ class DockerComposeTransformer:
...
@@ -110,6 +125,7 @@ class DockerComposeTransformer:
return
node
[
'requirements'
]
return
node
[
'requirements'
]
def
get_volumes
(
self
,
requirements
):
def
get_volumes
(
self
,
requirements
):
if
requirements
:
volumes
=
[]
volumes
=
[]
for
req
in
requirements
:
for
req
in
requirements
:
if
'volume'
in
req
:
if
'volume'
in
req
:
...
@@ -145,6 +161,7 @@ class DockerComposeTransformer:
...
@@ -145,6 +161,7 @@ class DockerComposeTransformer:
properties
=
self
.
get_properties
(
node_templates
[
node_template_key
])
properties
=
self
.
get_properties
(
node_templates
[
node_template_key
])
environment
=
self
.
get_enviroment_vars
(
properties
)
environment
=
self
.
get_enviroment_vars
(
properties
)
if
environment
:
service
[
'environment'
]
=
environment
service
[
'environment'
]
=
environment
port_maps
=
self
.
get_port_map
(
properties
)
port_maps
=
self
.
get_port_map
(
properties
)
...
...
drip_parser/src/transformer/docker_compose_transformer.pyc
View file @
f1c6b279
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