Added command for device to cinder volume mapping

Added new sub command volume-attachments which displays the list
of volumes attached to a server.

Change-Id: I1f56a6fa18c35f3df2bdd11b9cf83bd5c5d9e182
Closes-Bug: #1116593
This commit is contained in:
Sujitha 2015-11-10 22:41:54 +00:00
parent e77d770bd9
commit 6a18757509
2 changed files with 21 additions and 0 deletions

View File

@ -2266,6 +2266,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)

View File

@ -2032,6 +2032,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',
@ -2204,6 +2210,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')