Commit dabe6983 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed bug: check if volumes is there or a dict

parent cd4d6930
...@@ -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/MOG/test_tosca2.yml") transformer = DockerComposeTransformer(home+"/Downloads/tosca.yml")
vresion = '2'; vresion = '2';
compose = transformer.getnerate_compose(vresion) compose = transformer.getnerate_compose(vresion)
print yaml.dump(compose) print yaml.dump(compose)
......
...@@ -169,9 +169,13 @@ class DockerComposeTransformer: ...@@ -169,9 +169,13 @@ class DockerComposeTransformer:
for req in requirements: for req in requirements:
if 'volume' in req: if 'volume' in req:
vol = {} vol = {}
if isinstance(req,dict):
name = req['volume']['name'] name = req['volume']['name']
path = req['volume']['link'] path = req['volume']['link']
vol[name]=path vol[name]=path
else:
vol = None
return None
volumes.append(vol) volumes.append(vol)
return volumes return volumes
...@@ -180,8 +184,8 @@ class DockerComposeTransformer: ...@@ -180,8 +184,8 @@ class DockerComposeTransformer:
networks = [] networks = []
for req in requirements: for req in requirements:
if 'networks' in req: if 'networks' in req:
network = {} for net_name in requirements[req]:
networks.append(requirements[req]) networks.append(net_name)
return networks return networks
def analyze_yaml(self,version): def analyze_yaml(self,version):
...@@ -231,7 +235,10 @@ class DockerComposeTransformer: ...@@ -231,7 +235,10 @@ class DockerComposeTransformer:
service['networks'] = networks service['networks'] = networks
for network in networks: for network in networks:
network_id = {} network_id = {}
if isinstance(network,dict):
network_id[next(iter(network))] = None network_id[next(iter(network))] = None
elif isinstance(network,str):
network_id[network] = None
all_networks.append(network_id) all_networks.append(network_id)
services['services'][node_template_key] = service services['services'][node_template_key] = service
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment