Fix sort problem in snapshot and backup list
The sort in command snapshot-list and backup-list doesn't work, and they show same results. The patch is to fix the problem, and transfer sortby_index as None in utils.print_list. Closes-Bug: #1536054 Change-Id: I00760fd4b395b04b95a8139224e18ea8d649d377
This commit is contained in:
@@ -450,6 +450,14 @@ class ShellTest(utils.TestCase):
|
||||
self.assert_called('GET', '/snapshots/detail?'
|
||||
'status=available&volume_id=1234')
|
||||
|
||||
@mock.patch("cinderclient.utils.print_list")
|
||||
def test_snapshot_list_sort(self, mock_print_list):
|
||||
self.run_command('snapshot-list --sort id')
|
||||
self.assert_called('GET', '/snapshots/detail?sort=id')
|
||||
columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size']
|
||||
mock_print_list.assert_called_once_with(mock.ANY, columns,
|
||||
sortby_index=None)
|
||||
|
||||
def test_rename(self):
|
||||
# basic rename with positional arguments
|
||||
self.run_command('rename 1234 new-name')
|
||||
@@ -1163,6 +1171,15 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('backup-list')
|
||||
self.assert_called('GET', '/backups/detail')
|
||||
|
||||
@mock.patch("cinderclient.utils.print_list")
|
||||
def test_backup_list_sort(self, mock_print_list):
|
||||
self.run_command('backup-list --sort id')
|
||||
self.assert_called('GET', '/backups/detail?sort=id')
|
||||
columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size', 'Object Count',
|
||||
'Container']
|
||||
mock_print_list.assert_called_once_with(mock.ANY, columns,
|
||||
sortby_index=None)
|
||||
|
||||
def test_get_capabilities(self):
|
||||
self.run_command('get-capabilities host')
|
||||
self.assert_called('GET', '/capabilities/host')
|
||||
|
||||
@@ -677,8 +677,14 @@ def do_snapshot_list(cs, args):
|
||||
limit=args.limit,
|
||||
sort=args.sort)
|
||||
_translate_volume_snapshot_keys(snapshots)
|
||||
if args.sort:
|
||||
sortby_index = None
|
||||
else:
|
||||
sortby_index = 0
|
||||
|
||||
utils.print_list(snapshots,
|
||||
['ID', 'Volume ID', 'Status', 'Name', 'Size'])
|
||||
['ID', 'Volume ID', 'Status', 'Name', 'Size'],
|
||||
sortby_index=sortby_index)
|
||||
|
||||
|
||||
@utils.arg('snapshot',
|
||||
@@ -1457,7 +1463,11 @@ def do_backup_list(cs, args):
|
||||
_translate_volume_snapshot_keys(backups)
|
||||
columns = ['ID', 'Volume ID', 'Status', 'Name', 'Size', 'Object Count',
|
||||
'Container']
|
||||
utils.print_list(backups, columns)
|
||||
if args.sort:
|
||||
sortby_index = None
|
||||
else:
|
||||
sortby_index = 0
|
||||
utils.print_list(backups, columns, sortby_index=sortby_index)
|
||||
|
||||
|
||||
@utils.arg('backup', metavar='<backup>',
|
||||
|
||||
Reference in New Issue
Block a user