Pass rpc connection to pre_start_hook.

The pre_start_hook allows a manager to perform some additional service
setup before the service starts reading messages from message queues.
This patch moves the hook just a bit so that it's after creating the rpc
connection, but before creating the default queues, and most importantly
still before the service starts reading from the queues.

The pre_start_hook now gets the rpc_connection as an argument.  That
will allow this hook to set up some additional queues beyond the ones
that are set up by default in the base service code.

Change-Id: I5bf7795fca21627566ef4f688d45dc83bb953d1b
This commit is contained in:
Russell Bryant
2012-11-19 16:17:30 -05:00
parent c1d7dd7af8
commit 3349417edf
4 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -407,7 +407,7 @@ class ComputeManager(manager.SchedulerDependentManager):
self._report_driver_status(context)
self.publish_service_capabilities(context)
def pre_start_hook(self):
def pre_start_hook(self, **kwargs):
"""After the service is initialized, but before we fully bring
the service up by listening on RPC queues, make sure to update
our available resources.
+1 -1
View File
@@ -189,7 +189,7 @@ class Manager(base.Base):
"""
pass
def pre_start_hook(self):
def pre_start_hook(self, **kwargs):
"""Hook to provide the manager the ability to do additional
start-up work before any RPC queues/consumers are created. This is
called after other initialization has succeeded and a service
+2 -2
View File
@@ -400,8 +400,6 @@ class Service(object):
except exception.NotFound:
self._create_service_ref(ctxt)
self.manager.pre_start_hook()
if self.backdoor_port is not None:
self.manager.backdoor_port = self.backdoor_port
@@ -409,6 +407,8 @@ class Service(object):
LOG.debug(_("Creating Consumer connection for Service %s") %
self.topic)
self.manager.pre_start_hook(rpc_connection=self.conn)
rpc_dispatcher = self.manager.create_rpc_dispatcher()
# Share this same connection for these Consumers
+1 -1
View File
@@ -159,7 +159,7 @@ class ServiceTestCase(test.TestCase):
self._service_start_mocks()
# pre_start_hook is called after service record is created,
# but before RPC consumer is created
self.manager_mock.pre_start_hook()
self.manager_mock.pre_start_hook(rpc_connection=mox.IgnoreArg())
self.manager_mock.create_rpc_dispatcher()
# post_start_hook is called after RPC consumer is created.
self.manager_mock.post_start_hook()