Add service-delete subcommand to delete a service

In nova https://review.openstack.org/#/c/39998/ expose an API to delete
a service. Both in V1.1 and V3.

This patch make novaclient support it.

Change-Id: I4aaabc866b464c046b46eda68734f37223c6d6a0
Implements: blueprint support-delete-service
This commit is contained in:
gtt116 2014-02-26 06:57:11 +00:00
parent 465919953d
commit 91caad97d3
6 changed files with 27 additions and 0 deletions

View File

@ -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
#

View File

@ -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")

View File

@ -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')

View File

@ -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)

View File

@ -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."""

View File

@ -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."""