Merge "Add tenant uuid when running cinder list --all-tenants"
This commit is contained in:
@@ -95,6 +95,16 @@ class ShellTest(utils.TestCase):
|
||||
args = Arguments(metadata=input[0])
|
||||
self.assertEqual(shell_v1._extract_metadata(args), input[1])
|
||||
|
||||
def test_translate_volume_keys(self):
|
||||
cs = fakes.FakeClient()
|
||||
v = cs.volumes.list()[0]
|
||||
setattr(v, 'os-vol-tenant-attr:tenant_id', 'fake_tenant')
|
||||
setattr(v, '_info', {'attachments': [{'server_id': 1234}],
|
||||
'id': 1234, 'name': 'sample-volume',
|
||||
'os-vol-tenant-attr:tenant_id': 'fake_tenant'})
|
||||
shell_v1._translate_volume_keys([v])
|
||||
self.assertEqual(v.tenant_id, 'fake_tenant')
|
||||
|
||||
@httpretty.activate
|
||||
def test_list(self):
|
||||
self.register_keystone_auth_fixture()
|
||||
|
@@ -101,7 +101,8 @@ def _translate_keys(collection, convert):
|
||||
|
||||
|
||||
def _translate_volume_keys(collection):
|
||||
convert = [('displayName', 'display_name'), ('volumeType', 'volume_type')]
|
||||
convert = [('displayName', 'display_name'), ('volumeType', 'volume_type'),
|
||||
('os-vol-tenant-attr:tenant_id', 'tenant_id')]
|
||||
_translate_keys(collection, convert)
|
||||
|
||||
|
||||
@@ -179,8 +180,13 @@ def do_list(cs, args):
|
||||
for vol in volumes:
|
||||
servers = [s.get('server_id') for s in vol.attachments]
|
||||
setattr(vol, 'attached_to', ','.join(map(str, servers)))
|
||||
utils.print_list(volumes, ['ID', 'Status', 'Display Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to'])
|
||||
if all_tenants:
|
||||
key_list = ['ID', 'Tenant ID', 'Status', 'Display Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to']
|
||||
else:
|
||||
key_list = ['ID', 'Status', 'Display Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to']
|
||||
utils.print_list(volumes, key_list)
|
||||
|
||||
|
||||
@utils.arg('volume', metavar='<volume>', help='Volume name or ID.')
|
||||
|
@@ -97,7 +97,8 @@ def _translate_keys(collection, convert):
|
||||
|
||||
|
||||
def _translate_volume_keys(collection):
|
||||
convert = [('volumeType', 'volume_type')]
|
||||
convert = [('volumeType', 'volume_type'),
|
||||
('os-vol-tenant-attr:tenant_id', 'tenant_id')]
|
||||
_translate_keys(collection, convert)
|
||||
|
||||
|
||||
@@ -177,8 +178,13 @@ def do_list(cs, args):
|
||||
servers = [s.get('server_id') for s in vol.attachments]
|
||||
setattr(vol, 'attached_to', ','.join(map(str, servers)))
|
||||
|
||||
utils.print_list(volumes, ['ID', 'Status', 'Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to'])
|
||||
if all_tenants:
|
||||
key_list = ['ID', 'Tenant ID', 'Status', 'Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to']
|
||||
else:
|
||||
key_list = ['ID', 'Status', 'Name',
|
||||
'Size', 'Volume Type', 'Bootable', 'Attached to']
|
||||
utils.print_list(volumes, key_list)
|
||||
|
||||
|
||||
@utils.arg('volume',
|
||||
|
Reference in New Issue
Block a user