From 9e0f7983c2792e0bbc031b22b31896ce2b81f9da Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanino Date: Wed, 1 Feb 2017 12:41:32 -0500 Subject: [PATCH] Add --metadata option to API v2 cinder list command again In the commit I90a2b713556e91db69270a03ef6b798e08f93f90, --metadata option of do_list() in v2/shell.py was unexpectedly removed and --image_metadata option was added instead of --metadata option. This is wrong fix because --image_metadata option requires API version >= "3.4" and is not supported at API v2. On the other hands, --metadata option of do_list() is supported from API v1. We should remove --image_metadata option and then add --metadata option to do_list() again. Also comment on API v3 cinder list --metadata should be fixed because this doesn't require API >=3.4. Co-Authored-By: Masaki Kimura Change-Id: Ic7d5cfa2acb47fbf73776e034d958ad8fb9119a8 Closes-Bug: #1661045 --- cinderclient/tests/unit/v2/test_shell.py | 6 ------ cinderclient/v2/shell.py | 7 +++---- cinderclient/v3/shell.py | 8 ++++---- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py index ad1986858..5053e785d 100644 --- a/cinderclient/tests/unit/v2/test_shell.py +++ b/cinderclient/tests/unit/v2/test_shell.py @@ -189,12 +189,6 @@ class ShellTest(utils.TestCase): self.run_command('list --name=1234') self.assert_called('GET', '/volumes/detail?name=1234') - def test_list_filter_image_metadata(self): - self.run_command('list --image_metadata image_name=1234') - url = ('/volumes/detail?%s' % - parse.urlencode([('glance_metadata', {"image_name": "1234"})])) - self.assert_called('GET', url) - def test_list_all_tenants(self): self.run_command('list --all-tenants=1') self.assert_called('GET', '/volumes/detail?all_tenants=1') diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 73fbbe6dc..aa9262cb4 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -65,7 +65,7 @@ from cinderclient.v2 import availability_zones default=None, help='Filters results by a migration status. Default=None. ' 'Admin only.') -@utils.arg('--image_metadata', +@utils.arg('--metadata', type=str, nargs='*', metavar='', @@ -125,9 +125,8 @@ def do_list(cs, args): 'status': args.status, 'bootable': args.bootable, 'migration_status': args.migration_status, - 'glance_metadata': shell_utils.extract_metadata(args, - type='image_metadata') - if args.image_metadata else None, + 'metadata': (shell_utils.extract_metadata(args) if args.metadata + else None), } # If unavailable/non-existent fields are specified, these fields will diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index aabe1bc4f..2c8852a91 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -75,15 +75,15 @@ from cinderclient.v2.shell import * # flake8: noqa nargs='*', metavar='', default=None, - help='Filters results by a metadata key and value pair. Require ' - 'volume api version >=3.4. Default=None.') + help='Filters results by a metadata key and value pair. ' + 'Default=None.') @utils.arg('--image_metadata', type=str, nargs='*', metavar='', default=None, - help='Filters results by a image metadata key and value pair. ' - 'Default=None.') + help='Filters results by a image metadata key and value pair. Require ' + 'volume api version >=3.4. Default=None.') @utils.arg('--marker', metavar='', default=None,