Merge "Add start_version check for do_list() image_metadata option"

This commit is contained in:
Jenkins 2017-02-10 16:38:29 +00:00 committed by Gerrit Code Review
commit b8a3ef936e
2 changed files with 8 additions and 2 deletions

View File

@ -385,8 +385,13 @@ class ShellTest(utils.TestCase):
self.run_command('--os-volume-api-version 3.5 message-list --marker=1')
self.assert_called('GET', '/messages?marker=1')
def test_list_with_image_metadata_before_3_4(self):
self.assertRaises(exceptions.UnsupportedAttribute,
self.run_command,
'list --image_metadata image_name=1234')
def test_list_filter_image_metadata(self):
self.run_command('--os-volume-api-version 3.0 '
self.run_command('--os-volume-api-version 3.4 '
'list --image_metadata image_name=1234')
url = ('/volumes/detail?%s' %
parse.urlencode([('glance_metadata', {"image_name": "1234"})]))

View File

@ -82,6 +82,7 @@ from cinderclient.v2.shell import * # flake8: noqa
nargs='*',
metavar='<key=value>',
default=None,
start_version='3.4',
help='Filters results by a image metadata key and value pair. Require '
'volume api version >=3.4. Default=None.')
@utils.arg('--marker',
@ -141,7 +142,7 @@ def do_list(cs, args):
if args.metadata else None,
'glance_metadata': shell_utils.extract_metadata(args,
type='image_metadata')
if args.image_metadata else None,
if hasattr(args, 'image_metadata') and args.image_metadata else None,
'group_id': getattr(args, 'group_id', None),
}