[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
This commit is contained in:
TommyLike 2017-03-27 09:17:31 +08:00
parent 48d7e3540f
commit 4ed71182b3
3 changed files with 15 additions and 3 deletions

View File

@ -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):

View File

@ -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='<volume-id>',
@ -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,
}

View File

@ -0,0 +1,5 @@
---
fixes:
- The 'tenant' argument was ignored when listing attachments,
and now has been fixed.
[Bug `1675974 <https://bugs.launchpad.net/bugs/1675974>`_]