From 1a71f30a8ec93f733accf4eed0a696d1f9ef787f Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 18 Jan 2016 14:18:16 -0700 Subject: [PATCH] nuke: Expect json output from openstack commands Signed-off-by: Zack Cerza --- teuthology/nuke.py | 4 ++-- teuthology/test/test_nuke.py | 20 +++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/teuthology/nuke.py b/teuthology/nuke.py index 3452c96c4e..9b3791cc2f 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 a77e2b54b9..a11ad7283e 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, -- 2.39.5