Pass bay_ident to k8s objects methods
Pass bay_ident to k8s objects (pod, service, replication controllers) list method. Doing so returns a list of k8s objects based on the specified bay identifier. A Bay identifier can be an UUID or a logical name of the Bay. magnum rc-list => magnum rc-list <bay_ident> magnum service-list => magnum service-list <bay_ident> magnum pod-list => magnum pod-list <bay_ident> Change-Id: Ia1ec5376d728a4eaacf344cbda5c60d80fbb0495 Closes-Bug: #1503066
This commit is contained in:
parent
6ee3293270
commit
01373e979a
|
@ -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)
|
||||
|
||||
|
|
|
@ -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),
|
||||
]
|
||||
|
|
|
@ -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),
|
||||
]
|
||||
|
|
|
@ -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),
|
||||
]
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -372,9 +372,10 @@ def do_node_create(cs, args):
|
|||
_show_node(node)
|
||||
|
||||
|
||||
@utils.arg('bay', metavar='<bay>', 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='<pod-id>', help="UUID or name of pod")
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', help="UUID or Name of Bay")
|
||||
@utils.arg(
|
||||
'op',
|
||||
metavar='<op>',
|
||||
|
@ -442,7 +443,7 @@ def do_pod_update(cs, args):
|
|||
metavar='<pods>',
|
||||
nargs='+',
|
||||
help='ID or name of the (pod)s to delete.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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='<pod>',
|
||||
help='ID or name of the pod to show.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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='<bay>', 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='<rc>', help="UUID or name of replication controller")
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', help="UUID or Name of Bay")
|
||||
@utils.arg(
|
||||
'op',
|
||||
metavar='<op>',
|
||||
|
@ -537,7 +539,7 @@ def do_rc_update(cs, args):
|
|||
metavar='<rcs>',
|
||||
nargs='+',
|
||||
help='ID or name of the replication (controller)s to delete.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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='<rc>',
|
||||
help='ID or name of the replication controller to show.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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='<bay>', 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='<service>', help="UUID or name of service")
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', help="UUID or Name of Bay")
|
||||
@utils.arg(
|
||||
'op',
|
||||
metavar='<op>',
|
||||
|
@ -636,7 +639,7 @@ def do_coe_service_update(cs, args):
|
|||
metavar='<services>',
|
||||
nargs='+',
|
||||
help='ID or name of the (service)s to delete.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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='<service>',
|
||||
help='ID or name of the service to show.')
|
||||
@utils.arg('bay', metavar='<bay-uuid>', help="UUID of Bay")
|
||||
@utils.arg('bay', metavar='<bay>', 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)
|
||||
|
|
Loading…
Reference in New Issue