Merge "Add marker/limit/sort-key/sort-dir features for bay-list"
This commit is contained in:
commit
1531444c5e
@ -25,6 +25,25 @@ class ShellTest(shell_test_base.TestCommandLineArgument):
|
|||||||
self._test_arg_success('bay-list')
|
self._test_arg_success('bay-list')
|
||||||
self.assertTrue(mock_list.called)
|
self.assertTrue(mock_list.called)
|
||||||
|
|
||||||
|
@mock.patch('magnumclient.v1.bays.BayManager.list')
|
||||||
|
def test_bay_list_success_with_arg(self, mock_list):
|
||||||
|
self._test_arg_success('bay-list '
|
||||||
|
'--marker some_uuid '
|
||||||
|
'--limit 1 '
|
||||||
|
'--sort-dir asc '
|
||||||
|
'--sort-key uuid')
|
||||||
|
self.assertTrue(mock_list.called)
|
||||||
|
|
||||||
|
@mock.patch('magnumclient.v1.bays.BayManager.list')
|
||||||
|
def test_bay_list_failure_invalid_arg(self, mock_list):
|
||||||
|
_error_msg = [
|
||||||
|
'.*?^usage: magnum bay-list ',
|
||||||
|
'.*?^error: argument --sort-dir: invalid choice: ',
|
||||||
|
".*?^Try 'magnum help bay-list' for more information."
|
||||||
|
]
|
||||||
|
self._test_arg_failure('bay-list --sort-dir aaa', _error_msg)
|
||||||
|
self.assertFalse(mock_list.called)
|
||||||
|
|
||||||
@mock.patch('magnumclient.v1.bays.BayManager.list')
|
@mock.patch('magnumclient.v1.bays.BayManager.list')
|
||||||
def test_bay_list_failure(self, mock_list):
|
def test_bay_list_failure(self, mock_list):
|
||||||
self._test_arg_failure('bay-list --wrong',
|
self._test_arg_failure('bay-list --wrong',
|
||||||
|
@ -21,12 +21,31 @@ def _show_bay(bay):
|
|||||||
utils.print_dict(bay._info)
|
utils.print_dict(bay._info)
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('--marker',
|
||||||
|
metavar='<marker>',
|
||||||
|
default=None,
|
||||||
|
help='The last bay UUID of the previous page; '
|
||||||
|
'displays list of bays after "marker".')
|
||||||
|
@utils.arg('--limit',
|
||||||
|
metavar='<limit>',
|
||||||
|
type=int,
|
||||||
|
help='Maximum number of bays to return.')
|
||||||
|
@utils.arg('--sort-key',
|
||||||
|
metavar='<sort-key>',
|
||||||
|
help='Column to sort results by.')
|
||||||
|
@utils.arg('--sort-dir',
|
||||||
|
metavar='<sort-dir>',
|
||||||
|
choices=['desc', 'asc'],
|
||||||
|
help='Direction to sort. "asc" or "desc".')
|
||||||
def do_bay_list(cs, args):
|
def do_bay_list(cs, args):
|
||||||
"""Print a list of available bays."""
|
"""Print a list of available bays."""
|
||||||
bays = cs.bays.list()
|
bays = cs.bays.list(marker=args.marker, limit=args.limit,
|
||||||
|
sort_key=args.sort_key,
|
||||||
|
sort_dir=args.sort_dir)
|
||||||
columns = ('uuid', 'name', 'node_count', 'master_count', 'status')
|
columns = ('uuid', 'name', 'node_count', 'master_count', 'status')
|
||||||
utils.print_list(bays, columns,
|
utils.print_list(bays, columns,
|
||||||
{'versions': magnum_utils.print_list_field('versions')})
|
{'versions': magnum_utils.print_list_field('versions')},
|
||||||
|
sortby_index=None)
|
||||||
|
|
||||||
|
|
||||||
@utils.arg('--name',
|
@utils.arg('--name',
|
||||||
|
Loading…
Reference in New Issue
Block a user