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
Hide 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,14 +93,18 @@ class DockerComposeTransformer:
...
@@ -82,14 +93,18 @@ 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
=
{}
host_port
=
ports_mappings
[
port_map_key
][
'host_port'
]
if
'host_port'
in
ports_mappings
[
port_map_key
]:
container_port
=
ports_mappings
[
port_map_key
][
'container_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'
]
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
port_map
[
host_port
]
=
container_port
if
container_port
:
port_maps
.
append
(
port_map
)
port_map
[
host_port
]
=
container_port
port_maps
.
append
(
port_map
)
if
'out_ports'
in
properties
:
if
'out_ports'
in
properties
:
ports_mappings
=
properties
[
'out_ports'
]
ports_mappings
=
properties
[
'out_ports'
]
for
port_map_key
in
ports_mappings
:
for
port_map_key
in
ports_mappings
:
...
@@ -110,15 +125,16 @@ class DockerComposeTransformer:
...
@@ -110,15 +125,16 @@ class DockerComposeTransformer:
return
node
[
'requirements'
]
return
node
[
'requirements'
]
def
get_volumes
(
self
,
requirements
):
def
get_volumes
(
self
,
requirements
):
volumes
=
[]
if
requirements
:
for
req
in
requirements
:
volumes
=
[]
if
'volume'
in
req
:
for
req
in
requirements
:
vol
=
{}
if
'volume'
in
req
:
name
=
req
[
'volume'
][
'name'
]
vol
=
{}
path
=
req
[
'volume'
][
'link'
]
name
=
req
[
'volume'
][
'name'
]
vol
[
name
]
=
path
path
=
req
[
'volume'
][
'link'
]
volumes
.
append
(
vol
)
vol
[
name
]
=
path
return
volumes
volumes
.
append
(
vol
)
return
volumes
def
analyze_yaml
(
self
):
def
analyze_yaml
(
self
):
docker_types
=
self
.
get_docker_types
()
docker_types
=
self
.
get_docker_types
()
...
@@ -137,15 +153,16 @@ class DockerComposeTransformer:
...
@@ -137,15 +153,16 @@ class DockerComposeTransformer:
docker_file
=
artifacts
[
key
][
'file'
]
docker_file
=
artifacts
[
key
][
'file'
]
if
docker_file
:
if
docker_file
:
service
[
'image'
]
=
docker_file
service
[
'image'
]
=
docker_file
if
docker_file
and
docker_file
is
not
None
and
'/'
in
docker_file
:
if
docker_file
and
docker_file
is
not
None
and
'/'
in
docker_file
:
container_name
=
docker_file
.
split
(
"/"
)[
1
]
container_name
=
docker_file
.
split
(
"/"
)[
1
]
if
container_name
and
':'
in
container_name
:
if
container_name
and
':'
in
container_name
:
container_name
=
container_name
.
split
(
':'
)[
0
]
container_name
=
container_name
.
split
(
':'
)[
0
]
service
[
'container_name'
]
=
container_name
+
"_"
+
node_template_key
service
[
'container_name'
]
=
container_name
+
"_"
+
node_template_key
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
)
service
[
'environment'
]
=
environment
if
environment
:
service
[
'environment'
]
=
environment
port_maps
=
self
.
get_port_map
(
properties
)
port_maps
=
self
.
get_port_map
(
properties
)
if
port_maps
:
if
port_maps
:
...
...
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