From 20df1cb7a7a76ad7171eecf288f73a08b7afc71e Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanino Date: Thu, 2 Oct 2014 15:24:01 -0400 Subject: [PATCH] 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 --- cinderclient/tests/v2/test_volumes.py | 12 ++++++++++++ cinderclient/v2/shell.py | 9 ++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/cinderclient/tests/v2/test_volumes.py b/cinderclient/tests/v2/test_volumes.py index 165742d4e..aeceff460 100644 --- a/cinderclient/tests/v2/test_volumes.py +++ b/cinderclient/tests/v2/test_volumes.py @@ -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}) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 82d6c4ffd..be3340941 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -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='', @@ -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='', @@ -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',