Support different format of fuel task info 83/22783/1
authorMichal Skalski <mskalski@mirantis.com>
Tue, 27 Sep 2016 21:31:52 +0000 (23:31 +0200)
committerMichal Skalski <mskalski@mirantis.com>
Fri, 7 Oct 2016 09:24:21 +0000 (09:24 +0000)
As described in this bug: https://bugs.launchpad.net/fuel/+bug/1625518
json output of the task can be in different format: single dict or list
of dicts. During tests of https://gerrit.opnfv.org/gerrit/21807 only the
later one was visible, try to support both types of output.

Change-Id: I7d3e12270c8246b03bdc6c73d3be77a039df469f
Signed-off-by: Michal Skalski <mskalski@mirantis.com>
(cherry picked from commit b2a63bfe5746729b4731a14d98c50fb7f59d875e)

deploy/cloud/deployment.py

index 75bd4ef..ecccc24 100644 (file)
@@ -179,8 +179,13 @@ class Deployment(object):
             out, _ = exec_cmd('fuel2 task show {} -f json'.format(id), False)
             task_info = json.loads(out)
             properties = {}
-            for d in task_info:
-                    properties.update({d['Field']: d['Value']})
+            # for 9.0 this can be list of dicts or dict
+            # see https://bugs.launchpad.net/fuel/+bug/1625518
+            if isinstance(task_info, list):
+                for d in task_info:
+                        properties.update({d['Field']: d['Value']})
+            else:
+                return task_info
             return properties
         except ValueError as e:
             err('Unable to fetch task info: {}'.format(e))