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):
def test_local():
home = expanduser("~")
transformer = DockerComposeTransformer(home+"/workspace/DRIP/docs/input_tosca_files/MOG/test_tosca2.yml")
transformer = DockerComposeTransformer(home+"/Downloads/tosca.yml")
vresion = '2';
compose = transformer.getnerate_compose(vresion)
print yaml.dump(compose)
......
......@@ -169,9 +169,13 @@ class DockerComposeTransformer:
for req in requirements:
if 'volume' in req:
vol = {}
name = req['volume']['name']
path = req['volume']['link']
vol[name]=path
if isinstance(req,dict):
name = req['volume']['name']
path = req['volume']['link']
vol[name]=path
else:
vol = None
return None
volumes.append(vol)
return volumes
......@@ -180,8 +184,8 @@ class DockerComposeTransformer:
networks = []
for req in requirements:
if 'networks' in req:
network = {}
networks.append(requirements[req])
for net_name in requirements[req]:
networks.append(net_name)
return networks
def analyze_yaml(self,version):
......@@ -229,10 +233,13 @@ class DockerComposeTransformer:
networks = self.get_networks(requirements)
if networks:
service['networks'] = networks
for network in networks:
network_id = {}
network_id[next(iter(network))] = None
all_networks.append(network_id)
for network in networks:
network_id = {}
if isinstance(network,dict):
network_id[next(iter(network))] = None
elif isinstance(network,str):
network_id[network] = None
all_networks.append(network_id)
services['services'][node_template_key] = service
break
......
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