Permalink
Browse files

Make os-services API extensions consistent with Nova

Updates the os-services API extensions to match the Nova changes
proposed in I932160d64fdd3aaeb2ed90a092ecc7a36dcc9665.

Resolves bug 1147746.

Change-Id: Ib0f24dea8e937a8e1a1604b1cbf19d96bcdbcd8f
  • Loading branch information...
1 parent f294635 commit b94fbf59a2899cf08116c6f1e4eb3c4cec8666df @hanlind hanlind committed Mar 12, 2013
Showing with 22 additions and 22 deletions.
  1. +10 −10 novaclient/v1_1/shell.py
  2. +5 −5 tests/v1_1/fakes.py
  3. +3 −3 tests/v1_1/test_services.py
  4. +4 −4 tests/v1_1/test_shell.py
View
@@ -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.')
View
@@ -1318,15 +1318,15 @@ def delete_os_aggregates_1(self, **kw):
#
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 @@ def get_os_services(self, **kw):
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 @@ def test_list_services_with_binary(self):
[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 @@ def test_services_enable(self):
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')
View
@@ -864,12 +864,12 @@ def test_services_list_with_host(self):
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):

0 comments on commit b94fbf5

Please sign in to comment.