diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index 89a1d60fb..983357619 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -1446,6 +1446,9 @@ class FakeHTTPClient(base_client.HTTPClient): 'status': 'disabled', 'disabled_reason': body['disabled_reason']}}) + def delete_os_services_1(self, **kw): + return (204, {}, None) + # # Fixed IPs # diff --git a/novaclient/tests/v1_1/test_services.py b/novaclient/tests/v1_1/test_services.py index d66a11107..5ee33432e 100644 --- a/novaclient/tests/v1_1/test_services.py +++ b/novaclient/tests/v1_1/test_services.py @@ -78,6 +78,10 @@ class ServicesTest(utils.TestCase): self.assertIsInstance(service, self._get_service_type()) self.assertEqual(service.status, 'enabled') + def test_services_delete(self): + service = self.cs.services.delete('1') + self.cs.assert_called('DELETE', '/os-services/1') + def test_services_disable(self): service = self.cs.services.disable('host1', 'nova-cert') values = self._update_body("host1", "nova-cert") diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index d86180267..44538f252 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1286,6 +1286,10 @@ class ShellTest(utils.TestCase): 'disabled_reason': 'no_reason'} self.assert_called('PUT', '/os-services/disable-log-reason', body) + def test_services_delete(self): + self.run_command('service-delete 1') + self.assert_called('DELETE', '/os-services/1') + def test_fixed_ips_get(self): self.run_command('fixed-ip-get 192.168.1.1') self.assert_called('GET', '/os-fixed-ips/192.168.1.1') diff --git a/novaclient/v1_1/services.py b/novaclient/v1_1/services.py index f2588eaa1..d51fa3ebf 100644 --- a/novaclient/v1_1/services.py +++ b/novaclient/v1_1/services.py @@ -69,3 +69,7 @@ class ServiceManager(base.ManagerWithFind): """Disable the service with reason.""" body = self._update_body(host, binary, reason) return self._update("/os-services/disable-log-reason", body, "service") + + def delete(self, service_id): + """Delete a service.""" + return self._delete("/os-services/%s" % service_id) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 1c6b28c21..74a3f7c77 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -2880,6 +2880,12 @@ def do_service_disable(cs, args): utils.print_list([result], ['Host', 'Binary', 'Status']) +@utils.arg('id', metavar='<id>', help=_('Id of service.')) +def do_service_delete(cs, args): + """Delete the service.""" + cs.services.delete(args.id) + + @utils.arg('fixed_ip', metavar='<fixed_ip>', help=_('Fixed IP Address.')) def do_fixed_ip_get(cs, args): """Retrieve info on a fixed ip.""" diff --git a/novaclient/v3/shell.py b/novaclient/v3/shell.py index b9a03ba4f..aade7489e 100644 --- a/novaclient/v3/shell.py +++ b/novaclient/v3/shell.py @@ -2390,6 +2390,12 @@ def do_service_disable(cs, args): utils.print_list([result], ['Host', 'Binary', 'Status']) +@utils.arg('id', metavar='<id>', help='Id of service.') +def do_service_delete(cs, args): + """Delete the service.""" + cs.services.delete(args.id) + + @utils.arg('fixed_ip', metavar='<fixed_ip>', help='Fixed IP Address.') def do_fixed_ip_get(cs, args): """Retrieve info on a fixed ip."""