Fix volume name support of unmanage and replication commands

Volume not found error occurs when running these commands via cinderclient
with volume name as an argument.
unmanage, replication-promote, replication-reenable

However in their help text, it is described that Name and ID are supported.
Therefore, this patch fixes volume name support to their argument.

Closes-bug: #1374211
Change-Id: I8b90523d8e79a65eb27ff4e99820e8cb3feb3120
This commit is contained in:
Mitsuhiro Tanino
2014-10-02 15:24:01 -04:00
parent 26e19ff186
commit 20df1cb7a7
2 changed files with 18 additions and 3 deletions

View File

@@ -176,3 +176,15 @@ class VolumesTest(utils.TestCase):
v = cs.volumes.get('1234')
cs.volumes.unmanage(v)
cs.assert_called('POST', '/volumes/1234/action', {'os-unmanage': None})
def test_replication_promote(self):
v = cs.volumes.get('1234')
cs.volumes.promote(v)
cs.assert_called('POST', '/volumes/1234/action',
{'os-promote-replica': None})
def test_replication_reenable(self):
v = cs.volumes.get('1234')
cs.volumes.reenable(v)
cs.assert_called('POST', '/volumes/1234/action',
{'os-reenable-replica': None})

View File

@@ -1705,7 +1705,8 @@ def do_manage(cs, args):
@utils.service_type('volumev2')
def do_unmanage(cs, args):
"""Stop managing a volume."""
utils.find_volume(cs, args.volume).unmanage(args.volume)
volume = utils.find_volume(cs, args.volume)
cs.volumes.unmanage(volume.id)
@utils.arg('volume', metavar='<volume>',
@@ -1713,7 +1714,8 @@ def do_unmanage(cs, args):
@utils.service_type('volumev2')
def do_replication_promote(cs, args):
"""Promote a secondary volume to primary for a relationship."""
utils.find_volume(cs, args.volume).promote(args.volume)
volume = utils.find_volume(cs, args.volume)
cs.volumes.promote(volume.id)
@utils.arg('volume', metavar='<volume>',
@@ -1721,7 +1723,8 @@ def do_replication_promote(cs, args):
@utils.service_type('volumev2')
def do_replication_reenable(cs, args):
"""Sync the secondary volume with primary for a relationship."""
utils.find_volume(cs, args.volume).reenable(args.volume)
volume = utils.find_volume(cs, args.volume)
cs.volumes.reenable(volume.id)
@utils.arg('--all-tenants',