]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
nuke: Expect json output from openstack commands 771/head
authorZack Cerza <zack@redhat.com>
Mon, 18 Jan 2016 21:18:16 +0000 (14:18 -0700)
committerZack Cerza <zack@redhat.com>
Mon, 18 Jan 2016 23:21:56 +0000 (16:21 -0700)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/nuke.py
teuthology/test/test_nuke.py

index 3452c96c4e9b8b92974b19c40323f49c461a33e9..9b3791cc2f6430e12eb59d49498c0d61e0b4fda7 100644 (file)
@@ -11,7 +11,7 @@ from StringIO import StringIO
 import teuthology
 from . import orchestra
 import orchestra.remote
-from .openstack import OpenStack, OpenStackInstance
+from .openstack import OpenStack, OpenStackInstance, enforce_json_dictionary
 from .orchestra import run
 from .config import config, FakeNamespace
 from .lock import list_locks
@@ -435,7 +435,7 @@ def stale_openstack_volumes(ctx, volumes):
             log.debug("stale-openstack: {id} disappeared, ignored"
                       .format(id=volume['ID']))
             continue
-        volume = dict(map(lambda v: (v['Field'], v['Value']), volume))
+        enforce_json_dictionary(volume)
         created_at = datetime.datetime.strptime(
             volume['created_at'], '%Y-%m-%dT%H:%M:%S.%f')
         created = (now - created_at).total_seconds()
index a77e2b54b9405bdedbd709c1bd37020d317d5277..a11ad7283ef66d52292bc3c5835b4db9bea316b6 100644 (file)
@@ -28,12 +28,11 @@ class TestNuke(object):
         # A volume created a second ago is left untouched
         #
         volume_show = (
-            '['
-            ' {"Field": "id", "Value": "' + id + '"},'
-            ' {"Field": "created_at", "Value": "' + now + '"},'
-            ' {"Field": "display_name", "Value": "' + name + '"}'
-            ']'
+            '{"id": "' + id + '", '
+            '"created_at": "' + now + '", '
+            '"display_name": "' + name + '"}'
         )
+
         def sh(cmd):
             if 'volume show' in cmd:
                 return volume_show
@@ -51,12 +50,11 @@ class TestNuke(object):
         #
         ancient = "2000-11-02T15:43:12.000000"
         volume_show = (
-            '['
-            ' {"Field": "id", "Value": "' + id + '"},'
-            ' {"Field": "created_at", "Value": "' + ancient + '"},'
-            ' {"Field": "display_name", "Value": "' + name + '"}'
-            ']'
+            '{"id": "' + id + '", '
+            '"created_at": "' + ancient + '", '
+            '"display_name": "' + name + '"}'
         )
+
         def sh(cmd):
             if 'volume show' in cmd:
                 return volume_show
@@ -147,7 +145,7 @@ class TestNuke(object):
             nuke.stale_openstack_nodes(ctx, {
                 uuid: {
                     'ID': uuid,
-                    'Name': name, 
+                    'Name': name,
                 },
             }, {
                 name: { 'locked_since': ancient,