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:
Ian Cordasco
2017-03-01 08:25:36 -06:00
parent 4ae51367ff
commit 92133f2901
4 changed files with 28 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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(

View File

@@ -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.