summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-21 21:37:14 +0000
committerGerrit Code Review <review@openstack.org>2017-06-21 21:37:14 +0000
commit9ea2e61cc1eec015efd5a17212261431ec5145ca (patch)
treeb1d98f7c2c1cc9b33e34965ac4237e6660b382e1
parent71dfec67434ab9108a5faeee094d0225a5970e0a (diff)
parent4082478986341839b1de163a37c968e580634b74 (diff)
downloadpython-cinderclient-9ea2e61cc1eec015efd5a17212261431ec5145ca.tar.gz
Merge "Enabled like filter support in client"
-rw-r--r--cinderclient/tests/unit/v3/test_shell.py28
-rw-r--r--cinderclient/v3/shell.py25
-rw-r--r--releasenotes/notes/support-like-filter-7434w23f66bf5587.yaml11
3 files changed, 57 insertions, 7 deletions
diff --git a/cinderclient/tests/unit/v3/test_shell.py b/cinderclient/tests/unit/v3/test_shell.py
index 0a52f48..0b9431b 100644
--- a/cinderclient/tests/unit/v3/test_shell.py
+++ b/cinderclient/tests/unit/v3/test_shell.py
@@ -95,6 +95,10 @@ class ShellTest(utils.TestCase):
'list --filters metadata={key1:value1}',
'expected':
'/volumes/detail?metadata=%7B%27key1%27%3A+%27value1%27%7D'},
+ {'command':
+ 'list --filters name~=456',
+ 'expected':
+ '/volumes/detail?name%7E=456'},
# testcases for list group
{'command':
'group-list --filters name=456',
@@ -104,6 +108,10 @@ class ShellTest(utils.TestCase):
'group-list --filters status=available',
'expected':
'/groups/detail?status=available'},
+ {'command':
+ 'group-list --filters name~=456',
+ 'expected':
+ '/groups/detail?name%7E=456'},
# testcases for list group-snapshot
{'command':
'group-snapshot-list --status=error --filters status=available',
@@ -113,6 +121,10 @@ class ShellTest(utils.TestCase):
'group-snapshot-list --filters availability_zone=123',
'expected':
'/group_snapshots/detail?availability_zone=123'},
+ {'command':
+ 'group-snapshot-list --filters status~=available',
+ 'expected':
+ '/group_snapshots/detail?status%7E=available'},
# testcases for list message
{'command':
'message-list --event_id=123 --filters event_id=456',
@@ -122,6 +134,10 @@ class ShellTest(utils.TestCase):
'message-list --filters request_id=123',
'expected':
'/messages?request_id=123'},
+ {'command':
+ 'message-list --filters request_id~=123',
+ 'expected':
+ '/messages?request_id%7E=123'},
# testcases for list attachment
{'command':
'attachment-list --volume-id=123 --filters volume_id=456',
@@ -131,6 +147,10 @@ class ShellTest(utils.TestCase):
'attachment-list --filters mountpoint=123',
'expected':
'/attachments?mountpoint=123'},
+ {'command':
+ 'attachment-list --filters volume_id~=456',
+ 'expected':
+ '/attachments?volume_id%7E=456'},
# testcases for list backup
{'command':
'backup-list --volume-id=123 --filters volume_id=456',
@@ -140,6 +160,10 @@ class ShellTest(utils.TestCase):
'backup-list --filters name=123',
'expected':
'/backups/detail?name=123'},
+ {'command':
+ 'backup-list --filters volume_id~=456',
+ 'expected':
+ '/backups/detail?volume_id%7E=456'},
# testcases for list snapshot
{'command':
'snapshot-list --volume-id=123 --filters volume_id=456',
@@ -149,6 +173,10 @@ class ShellTest(utils.TestCase):
'snapshot-list --filters name=123',
'expected':
'/snapshots/detail?name=123'},
+ {'command':
+ 'snapshot-list --filters volume_id~=456',
+ 'expected':
+ '/snapshots/detail?volume_id%7E=456'},
# testcases for get pools
{'command':
'get-pools --filters name=456 --detail',
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index 47635c5..6a1e3b9 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -43,6 +43,10 @@ FILTER_DEPRECATED = ("This option is deprecated and will be removed in "
default=None,
help='Show enabled filters for specified resource. Default=None.')
def do_list_filters(cs, args):
+ """List enabled filters.
+
+ Symbol '~' after filter key means it supports inexact filtering.
+ """
filters = cs.resource_filters.list(resource=args.resource)
shell_utils.print_resource_filter_list(filters)
@@ -100,7 +104,8 @@ def do_list_filters(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' for "
+ "inexact filtering if the key supports. Default=None.")
def do_backup_list(cs, args):
"""Lists all backups."""
# pylint: disable=function-redefined
@@ -274,7 +279,8 @@ RESET_STATE_RESOURCES = {'volume': utils.find_volume,
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_list(cs, args):
"""Lists all volumes."""
# pylint: disable=function-redefined
@@ -976,7 +982,8 @@ def do_manageable_list(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_group_list(cs, args):
"""Lists all groups."""
search_opts = {'all_tenants': args.all_tenants}
@@ -1191,7 +1198,8 @@ def do_group_update(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_group_snapshot_list(cs, args):
"""Lists all group snapshots."""
@@ -1416,7 +1424,8 @@ def do_api_version(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_message_list(cs, args):
"""Lists all messages."""
search_opts = {
@@ -1553,7 +1562,8 @@ def do_message_delete(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_snapshot_list(cs, args):
"""Lists all snapshots."""
# pylint: disable=function-redefined
@@ -1643,7 +1653,8 @@ def do_snapshot_list(cs, args):
metavar='<key=value>',
default=None,
help="Filter key and value pairs. Please use 'cinder list-filters' "
- "to check enabled filters from server, Default=None.")
+ "to check enabled filters from server. Use 'key~=value' "
+ "for inexact filtering if the key supports. Default=None.")
def do_attachment_list(cs, args):
"""Lists all attachments."""
search_opts = {
diff --git a/releasenotes/notes/support-like-filter-7434w23f66bf5587.yaml b/releasenotes/notes/support-like-filter-7434w23f66bf5587.yaml
new file mode 100644
index 0000000..ebc1c80
--- /dev/null
+++ b/releasenotes/notes/support-like-filter-7434w23f66bf5587.yaml
@@ -0,0 +1,11 @@
+---
+features:
+ - |
+ Enabled like filter support in these list commands.
+ - list
+ - snapshot-list
+ - backup-list
+ - group-list
+ - group-snapshot-list
+ - attachment-list
+ - message-list