Add a callback registry event for the init process - before spawning

The current PROCESS AFTER_INIT event (or AFTER_CREATE) are being called
multiple times, once for each process.
In case we want to perform an action only once after init, we would need a
callback that is called after init is done, but before spawning.

Usage examples can be:
- A plugin/driver needs to configure something at the backend after init is done
- A plugin/driver needs to create an object in one of the neutron tables
(add a network for example)

Change-Id: I249ba32dede16e61b1c757a8010dac610484da4f
This commit is contained in:
Adit Sarfaty 2016-07-04 11:38:55 +03:00
parent f75966ee5e
commit 0dbe21cc87
2 changed files with 6 additions and 1 deletions

View File

@ -31,7 +31,8 @@ AFTER_REQUEST = 'after_request'
# String literals representing events associated to process operations
BEFORE_INIT = 'before_init'
AFTER_INIT = 'after_init'
BEFORE_SPAWN = 'before_spawn' # sent per process
AFTER_INIT = 'after_init' # sent per worker
# String literals representing events associated to error conditions
ABORT_CREATE = 'abort_create'

View File

@ -27,6 +27,9 @@ from oslo_utils import excutils
from oslo_utils import importutils
from neutron._i18n import _LE, _LI
from neutron.callbacks import events
from neutron.callbacks import registry
from neutron.callbacks import resources
from neutron.common import config
from neutron.common import profiler
from neutron.common import rpc as n_rpc
@ -87,6 +90,7 @@ def serve_wsgi(cls):
LOG.exception(_LE('Unrecoverable error: please check log '
'for details.'))
registry.notify(resources.PROCESS, events.BEFORE_SPAWN, service)
return service