diff --git a/magnumclient/tests/test_shell_args.py b/magnumclient/tests/test_shell_args.py index 29dca312..1b9186e3 100644 --- a/magnumclient/tests/test_shell_args.py +++ b/magnumclient/tests/test_shell_args.py @@ -446,12 +446,12 @@ class TestCommandLineArgument(utils.TestCase): @mock.patch('magnumclient.v1.pods.PodManager.list') def test_pod_list_success(self, mock_list): - self._test_arg_success('pod-list') + self._test_arg_success('pod-list bay_ident') self.assertTrue(mock_list.called) @mock.patch('magnumclient.v1.pods.PodManager.list') def test_pod_list_failure(self, mock_list): - self._test_arg_failure('pod-list --wrong', + self._test_arg_failure('pod-list bay_ident --wrong', self._unrecognized_arg_error) self.assertFalse(mock_list.called) @@ -523,13 +523,13 @@ class TestCommandLineArgument(utils.TestCase): @mock.patch('magnumclient.v1.replicationcontrollers.' 'ReplicationControllerManager.list') def test_rc_list_success(self, mock_list): - self._test_arg_success('rc-list') + self._test_arg_success('rc-list bay_ident') self.assertTrue(mock_list.called) @mock.patch('magnumclient.v1.replicationcontrollers.' 'ReplicationControllerManager.list') def test_rc_list_failure(self, mock_list): - self._test_arg_failure('rc-list --wrong', + self._test_arg_failure('rc-list bay_ident --wrong', self._unrecognized_arg_error) self.assertFalse(mock_list.called) @@ -609,12 +609,12 @@ class TestCommandLineArgument(utils.TestCase): @mock.patch('magnumclient.v1.services.ServiceManager.list') def test_coe_service_list_success(self, mock_list): - self._test_arg_success('coe-service-list') + self._test_arg_success('coe-service-list bay_ident') self.assertTrue(mock_list.called) @mock.patch('magnumclient.v1.services.ServiceManager.list') def test_coe_service_list_failure(self, mock_list): - self._test_arg_failure('coe-service-list --wrong', + self._test_arg_failure('coe-service-list bay_ident --wrong', self._unrecognized_arg_error) self.assertFalse(mock_list.called) diff --git a/magnumclient/tests/v1/test_pods.py b/magnumclient/tests/v1/test_pods.py index 6ce9622e..75af2099 100644 --- a/magnumclient/tests/v1/test_pods.py +++ b/magnumclient/tests/v1/test_pods.py @@ -98,7 +98,7 @@ class PodManagerTest(testtools.TestCase): self.mgr = pods.PodManager(self.api) def test_pod_list(self): - pods = self.mgr.list() + pods = self.mgr.list(POD1['bay_uuid']) expect = [ ('GET', '/v1/pods', {}, None), ] diff --git a/magnumclient/tests/v1/test_replicationcontrollers.py b/magnumclient/tests/v1/test_replicationcontrollers.py index 75b1d07a..1696b32d 100644 --- a/magnumclient/tests/v1/test_replicationcontrollers.py +++ b/magnumclient/tests/v1/test_replicationcontrollers.py @@ -96,7 +96,7 @@ class RCManagerTest(testtools.TestCase): self.mgr = rcs.ReplicationControllerManager(self.api) def test_rc_list(self): - rcs = self.mgr.list() + rcs = self.mgr.list(RC1['bay_uuid']) expect = [ ('GET', '/v1/rcs', {}, None), ] diff --git a/magnumclient/tests/v1/test_services.py b/magnumclient/tests/v1/test_services.py index 5a392154..cd73a51b 100644 --- a/magnumclient/tests/v1/test_services.py +++ b/magnumclient/tests/v1/test_services.py @@ -98,7 +98,7 @@ class ServiceManagerTest(testtools.TestCase): self.mgr = services.ServiceManager(self.api) def test_coe_service_list(self): - services = self.mgr.list() + services = self.mgr.list(SERVICE1['bay_uuid']) expect = [ ('GET', '/v1/services', {}, None), ] diff --git a/magnumclient/tests/v1/test_shell.py b/magnumclient/tests/v1/test_shell.py index c446f93b..283eeed1 100644 --- a/magnumclient/tests/v1/test_shell.py +++ b/magnumclient/tests/v1/test_shell.py @@ -389,9 +389,11 @@ class ShellTest(base.TestCase): def test_do_pod_list(self): client_mock = mock.MagicMock() args = mock.MagicMock() + bay = 'id' + args.bay = bay shell.do_pod_list(client_mock, args) - client_mock.pods.list.assert_called_once_with() + client_mock.pods.list.assert_called_once_with(bay) def test_do_pod_create(self): client_mock = mock.MagicMock() @@ -474,9 +476,11 @@ class ShellTest(base.TestCase): def test_do_rc_list(self): client_mock = mock.MagicMock() args = mock.MagicMock() + bay = 'id' + args.bay = bay shell.do_rc_list(client_mock, args) - client_mock.rcs.list.assert_called_once_with() + client_mock.rcs.list.assert_called_once_with(bay) def test_do_rc_create(self): client_mock = mock.MagicMock() @@ -560,9 +564,11 @@ class ShellTest(base.TestCase): def test_do_coe_service_list(self): client_mock = mock.MagicMock() args = mock.MagicMock() + bay = 'id' + args.bay = bay shell.do_coe_service_list(client_mock, args) - client_mock.services.list.assert_called_once_with() + client_mock.services.list.assert_called_once_with(bay) def test_do_coe_service_create(self): client_mock = mock.MagicMock() diff --git a/magnumclient/v1/pods.py b/magnumclient/v1/pods.py index 84da1578..65c7c146 100644 --- a/magnumclient/v1/pods.py +++ b/magnumclient/v1/pods.py @@ -35,13 +35,14 @@ class PodManager(base.Manager): else: return '/v1/pods' - def list(self, limit=None, marker=None, sort_key=None, + def list(self, bay_ident, limit=None, marker=None, sort_key=None, sort_dir=None, detail=False): - """Retrieve a list of port. + """Retrieve a list of pods. - :param marker: Optional, the UUID of a port, eg the last - port from a previous result set. Return - the next result set. + :param bay_ident: UUID or Name of the Bay. + :param marker: Optional, the UUID or Name of a pod, e.g. the last + pod from a previous result set. Return the next + result set. :param limit: The maximum number of results to return per request, if: @@ -66,6 +67,7 @@ class PodManager(base.Manager): limit = int(limit) filters = utils.common_filters(marker, limit, sort_key, sort_dir) + filters.append('bay_ident=%s' % bay_ident) path = '' if detail: diff --git a/magnumclient/v1/replicationcontrollers.py b/magnumclient/v1/replicationcontrollers.py index 7a8f08d3..e4f91c0a 100644 --- a/magnumclient/v1/replicationcontrollers.py +++ b/magnumclient/v1/replicationcontrollers.py @@ -35,12 +35,13 @@ class ReplicationControllerManager(base.Manager): else: return '/v1/rcs' - def list(self, limit=None, marker=None, sort_key=None, + def list(self, bay_ident, limit=None, marker=None, sort_key=None, sort_dir=None, detail=False): """Retrieve a list of ReplicationControllers. - :param marker: Optional, the UUID of a rc, eg the last - port from a previous result set. Return + :param bay_ident: UUID or Name of the Bay. + :param marker: Optional, the UUID or Name of a rc, e.g. the last + rc from a previous result set. Return the next result set. :param limit: The maximum number of results to return per request, if: @@ -66,6 +67,7 @@ class ReplicationControllerManager(base.Manager): limit = int(limit) filters = utils.common_filters(marker, limit, sort_key, sort_dir) + filters.append('bay_ident=%s' % bay_ident) path = '' if detail: diff --git a/magnumclient/v1/services.py b/magnumclient/v1/services.py index 45244512..104e6a3c 100644 --- a/magnumclient/v1/services.py +++ b/magnumclient/v1/services.py @@ -34,12 +34,13 @@ class ServiceManager(base.Manager): else: return '/v1/services' - def list(self, marker=None, limit=None, sort_key=None, + def list(self, bay_ident, marker=None, limit=None, sort_key=None, sort_dir=None, detail=False): """Retrieve a list of services. - :param marker: Optional, the UUID of a services, eg the last - services from a previous result set. Return + :param bay_ident: UUID or Name of the Bay. + :param marker: Optional, the UUID or Name of a service, e.g. the + last service from a previous result set. Return the next result set. :param limit: The maximum number of results to return per request, if: @@ -65,6 +66,7 @@ class ServiceManager(base.Manager): limit = int(limit) filters = utils.common_filters(marker, limit, sort_key, sort_dir) + filters.append('bay_ident=%s' % bay_ident) path = '' if detail: diff --git a/magnumclient/v1/shell.py b/magnumclient/v1/shell.py index 1659ed13..76e7adce 100644 --- a/magnumclient/v1/shell.py +++ b/magnumclient/v1/shell.py @@ -372,9 +372,10 @@ def do_node_create(cs, args): _show_node(node) +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_pod_list(cs, args): """Print a list of registered pods.""" - pods = cs.pods.list() + pods = cs.pods.list(args.bay) columns = ('uuid', 'name') utils.print_list(pods, columns, {'versions': _print_list_field('versions')}) @@ -412,7 +413,7 @@ def do_pod_create(cs, args): @utils.arg('pod', metavar='', help="UUID or name of pod") -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") @utils.arg( 'op', metavar='', @@ -442,7 +443,7 @@ def do_pod_update(cs, args): metavar='', nargs='+', help='ID or name of the (pod)s to delete.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_pod_delete(cs, args): """Delete specified pod.""" for pod in args.pods: @@ -457,16 +458,17 @@ def do_pod_delete(cs, args): @utils.arg('pod', metavar='', help='ID or name of the pod to show.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_pod_show(cs, args): """Show details about the given pod.""" pod = cs.pods.get(args.pod, args.bay) _show_pod(pod) +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_rc_list(cs, args): """Print a list of registered replication controllers.""" - rcs = cs.rcs.list() + rcs = cs.rcs.list(args.bay) columns = ('uuid', 'name') utils.print_list(rcs, columns, {'versions': _print_list_field('versions')}) @@ -507,7 +509,7 @@ def do_rc_create(cs, args): @utils.arg('rc', metavar='', help="UUID or name of replication controller") -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") @utils.arg( 'op', metavar='', @@ -537,7 +539,7 @@ def do_rc_update(cs, args): metavar='', nargs='+', help='ID or name of the replication (controller)s to delete.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_rc_delete(cs, args): """Delete specified replication controller.""" for rc in args.rcs: @@ -551,16 +553,17 @@ def do_rc_delete(cs, args): @utils.arg('rc', metavar='', help='ID or name of the replication controller to show.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_rc_show(cs, args): """Show details about the given replication controller.""" rc = cs.rcs.get(args.rc, args.bay) _show_rc(rc) +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_coe_service_list(cs, args): """Print a list of coe services.""" - services = cs.services.list() + services = cs.services.list(args.bay) columns = ('uuid', 'name', 'bay_uuid') utils.print_list(services, columns, {'versions': _print_list_field('versions')}) @@ -606,7 +609,7 @@ def do_coe_service_create(cs, args): @utils.arg('service', metavar='', help="UUID or name of service") -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") @utils.arg( 'op', metavar='', @@ -636,7 +639,7 @@ def do_coe_service_update(cs, args): metavar='', nargs='+', help='ID or name of the (service)s to delete.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_coe_service_delete(cs, args): """Delete specified coe service(s).""" for service in args.services: @@ -650,7 +653,7 @@ def do_coe_service_delete(cs, args): @utils.arg('service', metavar='', help='ID or name of the service to show.') -@utils.arg('bay', metavar='', help="UUID of Bay") +@utils.arg('bay', metavar='', help="UUID or Name of Bay") def do_coe_service_show(cs, args): """Show details about the given coe service.""" service = cs.services.get(args.service, args.bay)