Make service-delete work in API cells

nova service-delete is handled by HostAPI.service_delete method.
Normally, it searches for relevant Service object in DB and calls
destroy() on it. However, in API cell it is over-ridden so that
service_delete message can be routed to appropriate cell. Once the
destination cell is reached, the message processor invokes
HostAPI.service_delete to perform the actual delete. This works in
case of child cells.
However in case of API cells, since HostAPI.service_delete has been
over-ridden, when the message processor invokes HostAPI.service_delete
to perform actual delete of the service, the API cell tries to again
route the message and fails in doing so with an AttributeError (as
the message is already at the destination cell and can not be further
routed).
This patch moves the object destroy() call to a separate function and
modifies the message processor to call the new function. The original
service_delete is modified to also call the new function.

Change-Id: I9148d8ceb5cdeb858dc9741b24cf0e03487c9a62
Closes-Bug: 1361186
(cherry picked from commit b0feaba45f)
This commit is contained in:
Dheeraj Gupta 2014-10-08 09:24:18 +00:00 committed by Rajesh Tailor
parent 9ee1a0f575
commit 3212242fc3
2 changed files with 6 additions and 2 deletions

View File

@ -750,7 +750,7 @@ class _TargetedMessageMethods(_BaseMessageMethods):
def service_delete(self, message, service_id):
"""Deletes the specified service."""
self.host_api.service_delete(message.ctxt, service_id)
self.host_api._service_delete(message.ctxt, service_id)
def proxy_rpc_to_manager(self, message, host_name, rpc_message,
topic, timeout):

View File

@ -3372,9 +3372,13 @@ class HostAPI(base.Base):
service.save()
return service
def _service_delete(self, context, service_id):
"""Performs the actual Service deletion operation."""
objects.Service.get_by_id(context, service_id).destroy()
def service_delete(self, context, service_id):
"""Deletes the specified service."""
objects.Service.get_by_id(context, service_id).destroy()
self._service_delete(context, service_id)
def instance_get_all_by_host(self, context, host_name):
"""Return all instances on the given host."""