Merge "Make os-services API extensions consistent with Nova"

This commit is contained in:
Jenkins 2013-03-20 21:00:00 +00:00 committed by Gerrit Code Review
commit 22b8856815
4 changed files with 22 additions and 22 deletions

@ -2392,29 +2392,29 @@ def do_reset_network(cs, args):
@utils.arg('--host', metavar='<hostname>', default=None,
help='Name of host.')
@utils.arg('--servicename', metavar='<servicename>', default=None,
help='Name of service.')
@utils.arg('--binary', metavar='<binary>', default=None,
help='Service binary.')
def do_service_list(cs, args):
"""Show a list of all running services. Filter by host & service name."""
result = cs.services.list(args.host, args.servicename)
"""Show a list of all running services. Filter by host & binary."""
result = cs.services.list(host=args.host, binary=args.binary)
columns = ["Binary", "Host", "Zone", "Status", "State", "Updated_at"]
utils.print_list(result, columns)
@utils.arg('host', metavar='<hostname>', help='Name of host.')
@utils.arg('service', metavar='<servicename>', help='Name of service.')
@utils.arg('binary', metavar='<binary>', help='Service binary.')
def do_service_enable(cs, args):
"""Enable the service"""
result = cs.services.enable(args.host, args.service)
utils.print_list([result], ['Host', 'Service', 'Disabled'])
result = cs.services.enable(args.host, args.binary)
utils.print_list([result], ['Host', 'Binary', 'Status'])
@utils.arg('host', metavar='<hostname>', help='Name of host.')
@utils.arg('service', metavar='<servicename>', help='Name of service.')
@utils.arg('binary', metavar='<binary>', help='Service binary.')
def do_service_disable(cs, args):
"""Enable the service"""
result = cs.services.disable(args.host, args.service)
utils.print_list([result], ['Host', 'Service', 'Disabled'])
result = cs.services.disable(args.host, args.binary)
utils.print_list([result], ['Host', 'Binary', 'Status'])
@utils.arg('fixed_ip', metavar='<fixed_ip>', help='Fixed IP Address.')

@ -1318,15 +1318,15 @@ class FakeHTTPClient(base_client.HTTPClient):
#
def get_os_services(self, **kw):
host = kw.get('host', 'host1')
service = kw.get('binary', 'nova-compute')
binary = kw.get('binary', 'nova-compute')
return (200, {}, {'services':
[{'binary': service,
[{'binary': binary,
'host': host,
'zone': 'nova',
'status': 'enabled',
'state': 'up',
'updated_at': datetime(2012, 10, 29, 13, 42, 2)},
{'binary': service,
{'binary': binary,
'host': host,
'zone': 'nova',
'status': 'disabled',
@ -1337,12 +1337,12 @@ class FakeHTTPClient(base_client.HTTPClient):
def put_os_services_enable(self, body, **kw):
return (200, {}, {'service': {'host': body['host'],
'binary': body['binary'],
'disabled': False}})
'status': 'enabled'}})
def put_os_services_disable(self, body, **kw):
return (200, {}, {'service': {'host': body['host'],
'binary': body['binary'],
'disabled': True}})
'status': 'disabled'}})
#
# Fixed IPs

@ -47,7 +47,7 @@ class ServicesTest(utils.TestCase):
[self.assertEqual(s.host, 'host1') for s in svs]
def test_list_services_with_host_binary(self):
svs = cs.services.list('host2', 'nova-cert')
svs = cs.services.list(host='host2', binary='nova-cert')
cs.assert_called('GET', '/os-services?host=host2&binary=nova-cert')
[self.assertTrue(isinstance(s, services.Service)) for s in svs]
[self.assertEqual(s.binary, 'nova-cert') for s in svs]
@ -58,11 +58,11 @@ class ServicesTest(utils.TestCase):
values = {"host": "host1", 'binary': 'nova-cert'}
cs.assert_called('PUT', '/os-services/enable', values)
self.assertTrue(isinstance(service, services.Service))
self.assertFalse(service.disabled)
self.assertEqual(service.status, 'enabled')
def test_services_disable(self):
service = cs.services.disable('host1', 'nova-cert')
values = {"host": "host1", 'binary': 'nova-cert'}
cs.assert_called('PUT', '/os-services/disable', values)
self.assertTrue(isinstance(service, services.Service))
self.assertTrue(service.disabled)
self.assertEqual(service.status, 'disabled')

@ -864,12 +864,12 @@ class ShellTest(utils.TestCase):
self.run_command('service-list --host host1')
self.assert_called('GET', '/os-services?host=host1')
def test_services_list_with_servicename(self):
self.run_command('service-list --servicename nova-cert')
def test_services_list_with_binary(self):
self.run_command('service-list --binary nova-cert')
self.assert_called('GET', '/os-services?binary=nova-cert')
def test_services_list_with_host_servicename(self):
self.run_command('service-list --host host1 --servicename nova-cert')
def test_services_list_with_host_binary(self):
self.run_command('service-list --host host1 --binary nova-cert')
self.assert_called('GET', '/os-services?host=host1&binary=nova-cert')
def test_services_enable(self):