Relax requirement of region-id for hosts and cells
When listing hosts and cells, there is no need to require the user to provide a region-id. The API previously required region IDs to be present in the query string to list hosts and cells, but relaxed this constraint. The craton CLI encoded this constraint in its parameters but now needs to relax this as well. Change-Id: I973176a150c5d10de2144501dcc39cd6cfacbf9a Closes-bug: #1659428
This commit is contained in:
@@ -32,7 +32,6 @@ def do_cell_show(cc, args):
|
||||
@cliutils.arg('-r', '--region',
|
||||
metavar='<region>',
|
||||
type=int,
|
||||
required=True,
|
||||
help='ID of the region that the cell belongs to.')
|
||||
@cliutils.arg('--cloud',
|
||||
metavar='<cloud>',
|
||||
@@ -110,8 +109,10 @@ def do_cell_list(cc, args):
|
||||
)
|
||||
)
|
||||
params['sort_key'] = sort_key
|
||||
if args.region is not None:
|
||||
params['region_id'] = args.region
|
||||
|
||||
params['sort_dir'] = args.sort_dir
|
||||
params['region_id'] = args.region
|
||||
params['marker'] = args.marker
|
||||
params['autopaginate'] = args.all
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ def do_host_show(cc, args):
|
||||
@cliutils.arg('-r', '--region',
|
||||
metavar='<region>',
|
||||
type=int,
|
||||
required=True,
|
||||
help='ID of the region that the host belongs to.')
|
||||
@cliutils.arg('--cloud',
|
||||
metavar='<cloud>',
|
||||
@@ -116,8 +115,10 @@ def do_host_list(cc, args):
|
||||
)
|
||||
)
|
||||
params['sort_key'] = sort_key
|
||||
if args.region is not None:
|
||||
params['region_id'] = args.region
|
||||
|
||||
params['sort_dir'] = args.sort_dir
|
||||
params['region_id'] = args.region
|
||||
params['marker'] = args.marker
|
||||
params['autopaginate'] = args.all
|
||||
|
||||
|
||||
@@ -163,6 +163,17 @@ class TestCellsShell(base.ShellTestCase):
|
||||
marker=None,
|
||||
)
|
||||
|
||||
@mock.patch('cratonclient.v1.cells.CellManager.list')
|
||||
def test_cell_list_does_not_require_region_id(self, cell_list):
|
||||
"""Verify -r/--region are not required to list cells."""
|
||||
self.shell('cell-list --limit 10')
|
||||
cell_list.assert_called_once_with(
|
||||
sort_dir='asc',
|
||||
autopaginate=False,
|
||||
limit=10,
|
||||
marker=None,
|
||||
)
|
||||
|
||||
def test_cell_list_sort_dir_invalid_value(self):
|
||||
"""Verify --sort-dir with invalid args, fails with Command Error."""
|
||||
(_, error) = self.shell(
|
||||
|
||||
@@ -93,6 +93,17 @@ class TestHostsShell(base.ShellTestCase):
|
||||
autopaginate=False,
|
||||
)
|
||||
|
||||
@mock.patch('cratonclient.v1.hosts.HostManager.list')
|
||||
def test_host_list_does_not_require_region(self, host_list):
|
||||
"""Verify -r/--region is not required to list hosts."""
|
||||
self.shell('host-list --limit 10')
|
||||
host_list.assert_called_once_with(
|
||||
limit=10,
|
||||
sort_dir='asc',
|
||||
marker=None,
|
||||
autopaginate=False,
|
||||
)
|
||||
|
||||
def test_host_list_limit_negative_num_failure(self):
|
||||
"""Verify --limit X, where X is a negative integer, fails.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user