From 209eebbb127db6552610c44f36bea1d5d97eadbf Mon Sep 17 00:00:00 2001 From: Mykhailo Dovgal Date: Thu, 26 Jan 2017 16:53:52 +0200 Subject: [PATCH] Fix getting metadata attr error in snapshot-list command Because of 'start_version' parameter in decorator here [0] we won't have metadata attr in args using api versions from 3.0 to 3.21. This patch changes getting metadata from args logic for compatibility with the api versions 3.0 - 3.21. [0] - https://github.com/openstack/python-cinderclient/blob/b73b3932404c4645e05aaefae5502ab2304a5334/cinderclient/v3/shell.py#L1237 Change-Id: I4aa099556c57c49e9ad74fe80e5591d738cf3aa0 Closes-Bug: #1659561 --- cinderclient/v3/shell.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index cf3e42512..e779869ac 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -1245,14 +1245,20 @@ def do_snapshot_list(cs, args): if args.display_name is not None: args.name = args.display_name + metadata = None + try: + if args.metadata: + metadata = shell_utils.extract_metadata(args) + except AttributeError: + pass + search_opts = { 'all_tenants': all_tenants, 'name': args.name, 'status': args.status, 'volume_id': args.volume_id, 'project_id': args.tenant, - 'metadata': shell_utils.extract_metadata(args) - if args.metadata else None, + 'metadata': metadata } snapshots = cs.volume_snapshots.list(search_opts=search_opts, @@ -1263,4 +1269,4 @@ def do_snapshot_list(cs, args): sortby_index = None if args.sort else 0 utils.print_list(snapshots, ['ID', 'Volume ID', 'Status', 'Name', 'Size'], - sortby_index=sortby_index) \ No newline at end of file + sortby_index=sortby_index)