From cd9850b715e2f6fd46bacbe2d864387ce7a4e5f4 Mon Sep 17 00:00:00 2001 From: Cao Shufeng Date: Fri, 19 Aug 2016 02:26:04 -0400 Subject: [PATCH] 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 Change-Id: I63b6049a417293534079012dc6ee2a5b25e176be Closes-Bug: #1554538 --- cinderclient/tests/unit/v2/test_shell.py | 4 ++++ cinderclient/v3/shell.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py index d7e556bac..3ed441cd5 100644 --- a/cinderclient/tests/unit/v2/test_shell.py +++ b/cinderclient/tests/unit/v2/test_shell.py @@ -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') diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py index d0ed94c8e..9c456a6cf 100644 --- a/cinderclient/v3/shell.py +++ b/cinderclient/v3/shell.py @@ -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,