summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangxiyuan <wangxiyuan@huawei.com>2016-12-13 15:07:09 +0800
committerwangxiyuan <wangxiyuan@huawei.com>2017-01-25 11:04:33 +0800
commitaaffe41e3161ff5684eb87202780680f2a006fbe (patch)
treeee5818a34f389ed6a8b1deb406b689174bcecb41
parent5408aae94f149016309dd0979e0343718bee135b (diff)
downloadpython-cinderclient-aaffe41e3161ff5684eb87202780680f2a006fbe.tar.gz
Support filter volumes by group_id
After v3.10, cinder support filter volumes by group_id, this patch support this feature for client side. Change-Id: Ie7df4d8b81789fd36ca6f91d96a477c88e8d5a52 Partial-Implements: blueprint improvement-to-query-consistency-group-detail
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py12
-rw-r--r--cinderclient/v3/shell.py6
2 files changed, 18 insertions, 0 deletions
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index dc3dd68..bafc847 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -71,6 +71,18 @@ class ShellTest(utils.TestCase):
# NOTE(jdg): we default to detail currently
self.assert_called('GET', '/volumes/detail')
+ def test_list_with_group_id_before_3_10(self):
+ self.assertRaises(exceptions.UnsupportedAttribute,
+ self.run_command,
+ 'list --group_id fake_id')
+
+ @ddt.data("3.10", "3.11")
+ def test_list_with_group_id_after_3_10(self, version):
+ command = ('--os-volume-api-version %s list --group_id fake_id' %
+ version)
+ self.run_command(command)
+ self.assert_called('GET', '/volumes/detail?group_id=fake_id')
+
def test_list_availability_zone(self):
self.run_command('availability-zone-list')
self.assert_called('GET', '/os-availability-zone')
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index cf3e425..13cba23 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -31,6 +31,11 @@ from cinderclient import utils
from cinderclient.v2.shell import * # flake8: noqa
+@utils.arg('--group_id',
+ metavar='<group_id>',
+ default=None,
+ help='Filters results by a group_id. Default=None.',
+ start_version='3.10')
@utils.arg('--all-tenants',
dest='all_tenants',
metavar='<0|1>',
@@ -137,6 +142,7 @@ def do_list(cs, args):
'glance_metadata': shell_utils.extract_metadata(args,
type='image_metadata')
if args.image_metadata else None,
+ 'group_id': getattr(args, 'group_id', None),
}
# If unavailable/non-existent fields are specified, these fields will