diff options
author | Hans Lindgren <hanlind@kth.se> | 2013-03-12 10:52:27 +0100 |
---|---|---|
committer | Hans Lindgren <hanlind@kth.se> | 2013-03-12 11:08:47 +0100 |
commit | b94fbf59a2899cf08116c6f1e4eb3c4cec8666df (patch) | |
tree | eb21747d1848ab3d26afb2e7ae2a46035594819e | |
parent | f294635c16cbf56ee90647de4fb2a35c171174a1 (diff) | |
download | python-novaclient-b94fbf59a2899cf08116c6f1e4eb3c4cec8666df.tar.gz |
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
-rw-r--r-- | novaclient/v1_1/shell.py | 20 | ||||
-rw-r--r-- | tests/v1_1/fakes.py | 10 | ||||
-rw-r--r-- | tests/v1_1/test_services.py | 6 | ||||
-rw-r--r-- | tests/v1_1/test_shell.py | 8 |
4 files changed, 22 insertions, 22 deletions
diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index e0392c56..e4e4b941 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -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.') diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py index ec1a0ceb..58f70724 100644 --- a/tests/v1_1/fakes.py +++ b/tests/v1_1/fakes.py @@ -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 diff --git a/tests/v1_1/test_services.py b/tests/v1_1/test_services.py index d6d58837..25759e27 100644 --- a/tests/v1_1/test_services.py +++ b/tests/v1_1/test_services.py @@ -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') diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py index fd028b38..74453cdf 100644 --- a/tests/v1_1/test_shell.py +++ b/tests/v1_1/test_shell.py @@ -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): |