Merge "cinder show with attachments is a mess"
This commit is contained in:
@@ -17,7 +17,8 @@ from cinderclient.tests.functional import base
|
||||
class CinderVolumeTests(base.ClientTestBase):
|
||||
"""Check of base cinder volume commands."""
|
||||
|
||||
VOLUME_PROPERTY = ('attachments', 'availability_zone', 'bootable',
|
||||
VOLUME_PROPERTY = ('attachment_ids', 'attached_servers',
|
||||
'availability_zone', 'bootable',
|
||||
'created_at', 'description', 'encrypted', 'id',
|
||||
'metadata', 'name', 'size', 'status',
|
||||
'user_id', 'volume_type')
|
||||
|
@@ -28,7 +28,8 @@ REQUEST_ID = 'req-test-request-id'
|
||||
def _stub_volume(*args, **kwargs):
|
||||
volume = {
|
||||
"migration_status": None,
|
||||
"attachments": [{u'server_id': u'1234'}],
|
||||
"attachments": [{u'server_id': u'1234', u'id':
|
||||
u'3f88836f-adde-4296-9f6b-2c59a0bcda9a'}],
|
||||
"links": [
|
||||
{
|
||||
"href": "http://localhost/v2/fake/volumes/1234",
|
||||
|
@@ -32,6 +32,18 @@ from cinderclient import utils
|
||||
from cinderclient.v2 import availability_zones
|
||||
|
||||
|
||||
def _translate_attachments(info):
|
||||
attachments = []
|
||||
attached_servers = []
|
||||
for attachment in info['attachments']:
|
||||
attachments.append(attachment['id'])
|
||||
attached_servers.append(attachment['server_id'])
|
||||
info.pop('attachments', None)
|
||||
info['attachment_ids'] = attachments
|
||||
info['attached_servers'] = attached_servers
|
||||
return info
|
||||
|
||||
|
||||
@utils.arg('--all-tenants',
|
||||
dest='all_tenants',
|
||||
metavar='<0|1>',
|
||||
@@ -188,9 +200,10 @@ def do_show(cs, args):
|
||||
info['readonly'] = info['metadata']['readonly']
|
||||
|
||||
info.pop('links', None)
|
||||
info = _translate_attachments(info)
|
||||
utils.print_dict(info,
|
||||
formatters=['metadata', 'volume_image_metadata',
|
||||
'attachments'])
|
||||
'attachment_ids', 'attached_servers'])
|
||||
|
||||
|
||||
class CheckSizeArgForCreate(argparse.Action):
|
||||
@@ -340,6 +353,7 @@ def do_create(cs, args):
|
||||
info['readonly'] = info['metadata']['readonly']
|
||||
|
||||
info.pop('links', None)
|
||||
info = _translate_attachments(info)
|
||||
utils.print_dict(info)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user