From 4ed71182b37d05e83d30440e4dbdf38771f4d36a Mon Sep 17 00:00:00 2001 From: TommyLike Date: Mon, 27 Mar 2017 09:17:31 +0800 Subject: [PATCH] [BugFix] Add 'all_tenants', 'project_id' in attachment-list There are some issues around new attach/detach API/CLI, fix them step by step. This patch adds 'all_tenants' and 'tenant' support in cinder-client. Change-Id: I6e360987a8d8bd6dfbeb34ea88f4964813f620b2 Depends-On: 8eac3b071cb7cca8f8b11952c95476fa57daffc0 Depends-On: bae8bd017e30425295e03d13b39202a81e923c3e Closes-Bug: #1675974 --- cinderclient/tests/unit/v3/test_shell.py | 7 ++++++- cinderclient/v3/shell.py | 6 ++++-- releasenotes/notes/bug-1675974-34edd5g9870e65b2.yaml | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/bug-1675974-34edd5g9870e65b2.yaml diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py index 80fd0fe..d2c12dd 100644 --- a/cinderclient/tests/unit/v3/test_shell.py +++ b/cinderclient/tests/unit/v3/test_shell.py @@ -133,7 +133,12 @@ class ShellTest(utils.TestCase): {'cmd': '--all-tenants 1', 'expected': '?all_tenants=1'}, {'cmd': '--all-tenants 1 --volume-id 12345', - 'expected': '?all_tenants=1&volume_id=12345'} + 'expected': '?all_tenants=1&volume_id=12345'}, + {'cmd': '--all-tenants 1 --tenant 12345', + 'expected': '?all_tenants=1&project_id=12345'}, + {'cmd': '--tenant 12345', + 'expected': '?all_tenants=1&project_id=12345'} + ) @ddt.unpack def test_attachment_list(self, cmd, expected): diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index 1e8c156..a4e402f 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -1303,6 +1303,7 @@ def do_snapshot_list(cs, args): ['ID', 'Volume ID', 'Status', 'Name', 'Size'], sortby_index=sortby_index) + @api_versions.wraps('3.27') @utils.arg('--all-tenants', dest='all_tenants', @@ -1310,7 +1311,7 @@ def do_snapshot_list(cs, args): nargs='?', type=int, const=1, - default=0, + default=utils.env('ALL_TENANTS', default=0), help='Shows details for all tenants. Admin only.') @utils.arg('--volume-id', metavar='', @@ -1346,7 +1347,8 @@ def do_snapshot_list(cs, args): def do_attachment_list(cs, args): """Lists all attachments.""" search_opts = { - 'all_tenants': args.all_tenants, + 'all_tenants': 1 if args.tenant else args.all_tenants, + 'project_id': args.tenant, 'status': args.status, 'volume_id': args.volume_id, } diff --git a/releasenotes/notes/bug-1675974-34edd5g9870e65b2.yaml b/releasenotes/notes/bug-1675974-34edd5g9870e65b2.yaml new file mode 100644 index 0000000..14ef33c --- /dev/null +++ b/releasenotes/notes/bug-1675974-34edd5g9870e65b2.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - The 'tenant' argument was ignored when listing attachments, + and now has been fixed. + [Bug `1675974 `_]