diff --git a/cratonclient/shell/v1/cells_shell.py b/cratonclient/shell/v1/cells_shell.py index fb98cc6..66c9d56 100644 --- a/cratonclient/shell/v1/cells_shell.py +++ b/cratonclient/shell/v1/cells_shell.py @@ -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 diff --git a/cratonclient/shell/v1/hosts_shell.py b/cratonclient/shell/v1/hosts_shell.py index c906667..01f30cf 100644 --- a/cratonclient/shell/v1/hosts_shell.py +++ b/cratonclient/shell/v1/hosts_shell.py @@ -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>', @@ -140,8 +139,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 diff --git a/cratonclient/tests/integration/shell/v1/test_cells_shell.py b/cratonclient/tests/integration/shell/v1/test_cells_shell.py index 71754f9..f5ede2f 100644 --- a/cratonclient/tests/integration/shell/v1/test_cells_shell.py +++ b/cratonclient/tests/integration/shell/v1/test_cells_shell.py @@ -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( diff --git a/cratonclient/tests/integration/shell/v1/test_hosts_shell.py b/cratonclient/tests/integration/shell/v1/test_hosts_shell.py index cc9ff2f..9b932d5 100644 --- a/cratonclient/tests/integration/shell/v1/test_hosts_shell.py +++ b/cratonclient/tests/integration/shell/v1/test_hosts_shell.py @@ -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.