Merge "Added command for device to cinder volume mapping"

This commit is contained in:
Jenkins 2015-11-19 13:25:49 +00:00 committed by Gerrit Code Review
commit dada6cc91d
2 changed files with 21 additions and 0 deletions
novaclient
tests/unit/v2
v2

@ -2276,6 +2276,10 @@ class ShellTest(utils.TestCase):
pos=-1
)
def test_volume_attachments(self):
self.run_command('volume-attachments 1234')
self.assert_called('GET', '/servers/1234/os-volume_attachments')
def test_volume_create(self):
_, err = self.run_command('volume-create 2 --display-name Work')
self.assertIn('Command volume-create is deprecated', err)

@ -2053,6 +2053,12 @@ def _translate_availability_zone_keys(collection):
[('zoneName', 'name'), ('zoneState', 'status')])
def _translate_volume_attachments_keys(collection):
_translate_keys(collection,
[('serverId', 'server_id'),
('volumeId', 'volume_id')])
@cliutils.arg(
'--all-tenants',
dest='all_tenants',
@ -2225,6 +2231,17 @@ def do_volume_detach(cs, args):
args.attachment_id)
@cliutils.arg(
'server',
metavar='<server>',
help=_('Name or ID of server.'))
def do_volume_attachments(cs, args):
"""List all the volumes attached to a server"""
volumes = cs.volumes.get_server_volumes(_find_server(cs, args.server).id)
_translate_volume_attachments_keys(volumes)
utils.print_list(volumes, ['ID', 'DEVICE', 'SERVER ID', 'VOLUME ID'])
def do_volume_snapshot_list(cs, _args):
"""DEPRECATED: List all the snapshots."""
emit_volume_deprecation_warning('volume-snapshot-list')