Parse filter item "name" correctly for snapshot-list

Cinderclient will parse filter item "name" to "display_name"
when get snapshot list via v2/v3 api.
This works for admin user. However for non-admin user,
cinder-api[1] removes "display_name" as an invalid filter item
and return the full snapshot list.
This change use "name" as filter of snapshots rather than
"display_name".

[1]: https://github.com/openstack/cinder/blob/master/cinder/api/v2/snapshots.py#L87-#L93

Co-Authored-By: cheneydc <dongc@neunn.com>

Change-Id: I63b6049a417293534079012dc6ee2a5b25e176be
Closes-Bug: #1554538
This commit is contained in:
Cao Shufeng
2016-08-19 02:26:04 -04:00
committed by Cao ShuFeng
parent ce2c1daee5
commit cd9850b715
2 changed files with 5 additions and 1 deletions

View File

@@ -505,6 +505,10 @@ class ShellTest(utils.TestCase):
self.assert_called('GET', '/snapshots/detail?'
'status=available&volume_id=1234')
def test_snapshot_list_filter_name(self):
self.run_command('snapshot-list --name abc')
self.assert_called('GET', '/snapshots/detail?name=abc')
@mock.patch("cinderclient.utils.print_list")
def test_snapshot_list_sort(self, mock_print_list):
self.run_command('snapshot-list --sort id')

View File

@@ -732,7 +732,7 @@ def do_snapshot_list(cs, args):
search_opts = {
'all_tenants': all_tenants,
'display_name': args.name,
'name': args.name,
'status': args.status,
'volume_id': args.volume_id,
'project_id': args.tenant,