Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuke: Expect json output from openstack commands #771

Merged
merged 1 commit into from Jan 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions teuthology/nuke.py
Expand Up @@ -11,7 +11,7 @@
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
Expand Down Expand Up @@ -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()
Expand Down
20 changes: 9 additions & 11 deletions teuthology/test/test_nuke.py
Expand Up @@ -28,12 +28,11 @@ def test_stale_openstack_volumes(self):
# 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
Expand All @@ -51,12 +50,11 @@ def sh(cmd):
#
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
Expand Down Expand Up @@ -147,7 +145,7 @@ def test_stale_openstack_nodes(self):
nuke.stale_openstack_nodes(ctx, {
uuid: {
'ID': uuid,
'Name': name,
'Name': name,
},
}, {
name: { 'locked_since': ancient,
Expand Down