Fix error in CLI 'manila list' with sorting key 'availability_zone'.
CLI 'manila list --sort-key availability_zone' return http 400 code, and error message 'Wrong sorting key provided'. The cause is that sortble key name in sqlAlchemy model field is 'availability_zone_id' , not 'availability_zone'. So we need a translation in CLI implement. Closes-Bug: #1920888 Change-Id: Ied983d85ca08a123b78bf8b05085fad8fe5bc2c5
This commit is contained in:
parent
89f32351db
commit
69031b558d
@ -20,7 +20,7 @@ SORT_DIR_VALUES = ('asc', 'desc')
|
||||
|
||||
SHARE_SORT_KEY_VALUES = (
|
||||
'id', 'status', 'size', 'host', 'share_proto',
|
||||
'availability_zone',
|
||||
'availability_zone_id', 'availability_zone',
|
||||
'user_id', 'project_id',
|
||||
'created_at', 'updated_at',
|
||||
'display_name', 'name',
|
||||
|
@ -332,6 +332,8 @@ class ShellTest(test_utils.TestCase):
|
||||
key = 'share_network_id' if key == 'share_network' else key
|
||||
key = 'snapshot_id' if key == 'snapshot' else key
|
||||
key = 'share_type_id' if key == 'share_type' else key
|
||||
key = ('availability_zone_id' if key == 'availability_zone'
|
||||
else key)
|
||||
self.assert_called('GET', '/shares/detail?sort_key=' + key)
|
||||
|
||||
def test_list_with_fake_sort_key(self):
|
||||
|
@ -388,6 +388,8 @@ class ShareManager(base.ManagerWithFind):
|
||||
search_opts['sort_key'] = 'snapshot_id'
|
||||
elif sort_key == 'share_network':
|
||||
search_opts['sort_key'] = 'share_network_id'
|
||||
elif sort_key == 'availability_zone':
|
||||
search_opts['sort_key'] = 'availability_zone_id'
|
||||
else:
|
||||
raise ValueError('sort_key must be one of the following: %s.'
|
||||
% ', '.join(constants.SHARE_SORT_KEY_VALUES))
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
`Launchpad bug 1920888 <https://bugs.launchpad.net/manila/+bug/1920888>`_:
|
||||
Fix the bug in CLI 'manila list' with sorting key 'availability_zone'.
|
Loading…
x
Reference in New Issue
Block a user