From: Zack Cerza Date: Mon, 18 Jan 2016 21:18:16 +0000 (-0700) Subject: nuke: Expect json output from openstack commands X-Git-Tag: 1.1.0~696^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F771%2Fhead;p=teuthology.git nuke: Expect json output from openstack commands Signed-off-by: Zack Cerza --- diff --git a/teuthology/nuke.py b/teuthology/nuke.py index 3452c96c..9b3791cc 100644 --- a/teuthology/nuke.py +++ b/teuthology/nuke.py @@ -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() diff --git a/teuthology/test/test_nuke.py b/teuthology/test/test_nuke.py index a77e2b54..a11ad728 100644 --- a/teuthology/test/test_nuke.py +++ b/teuthology/test/test_nuke.py @@ -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,