diff options
author | Steven Kaufer <kaufer@us.ibm.com> | 2014-12-19 02:56:53 +0000 |
---|---|---|
committer | Steven Kaufer <kaufer@us.ibm.com> | 2015-01-22 14:52:25 +0000 |
commit | 0560f7883353ea74fd31bf52535883cc18adecf5 (patch) | |
tree | f6499c22981eca7c4ff05239a9e2a2bec620eb15 /cinderclient/v2/volumes.py | |
parent | e109e894813016898bed9878620af25ffb025d11 (diff) | |
download | python-cinderclient-0560f7883353ea74fd31bf52535883cc18adecf5.tar.gz |
cinder list fails with 'name' sort key
The client restricts the sort keys that the user can supply. The
'name' key is allowed but is not the correct key for sorting by name,
it should be 'display_name'.
If 'name' is used then the client returns with the error 500
Internal Server Error.
This patch will add support for mapping client sort keys (eg, 'name')
to server sort keys (eg, 'display_name'), allowing the user to supply
the 'name' key to sort by name.
This patch also adds UT for the sort key and direction error cases
when an invalid value is supplied.
Change-Id: I0bdad6d61da83a3924a6b18678afe4722b5778d6
Closes-Bug: 1404020
Diffstat (limited to 'cinderclient/v2/volumes.py')
-rw-r--r-- | cinderclient/v2/volumes.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py index 7fc1267..c726c2a 100644 --- a/cinderclient/v2/volumes.py +++ b/cinderclient/v2/volumes.py @@ -24,9 +24,12 @@ except ImportError: from cinderclient import base +# Valid sort directions and client sort keys SORT_DIR_VALUES = ('asc', 'desc') SORT_KEY_VALUES = ('id', 'status', 'size', 'availability_zone', 'name', 'bootable', 'created_at') +# Mapping of client keys to actual sort keys +SORT_KEY_MAPPINGS = {'name': 'display_name'} class Volume(base.Resource): @@ -260,7 +263,7 @@ class VolumeManager(base.ManagerWithFind): if sort_key is not None: if sort_key in SORT_KEY_VALUES: - qparams['sort_key'] = sort_key + qparams['sort_key'] = SORT_KEY_MAPPINGS.get(sort_key, sort_key) else: raise ValueError('sort_key must be one of the following: %s.' % ', '.join(SORT_KEY_VALUES)) |