Add some notes

This commit is contained in:
Mark McLoughlin 2013-06-23 13:22:24 +01:00
parent 7c087f23d2
commit 39f57dab59
2 changed files with 58 additions and 12 deletions

View File

@ -4,31 +4,30 @@ Projects will need to do e.g.
-- nova.config:
from nova.openstack.common.messaging import transport
from oslo import messaging
TRANSPORT_DRIVER = None
def parse_args(argv, ...):
transport.set_defaults(control_exchange='nova')
messaging.set_transport_defaults(control_exchange='nova')
cfg.CONF(...)
TRANSPORT_DRIVER = transport.get_transport(cfg.CONF)
-- nova.scheduler.rpcapi:
from oslo.config import cfg
from oslo import messaging
from nova import config
from nova.openstack.common.messaging.rpc import client
from nova.openstack.common.messaging import target
CONF = cfg.CONF
class SchedulerAPI(client.RPCClient):
class SchedulerAPI(messaging.RPCClient):
def __init__(self):
target = target.Target(topic=CONF.scheduler_topic, version='2.0')
target = messaging.Target(topic=CONF.scheduler_topic, version='2.0')
super(SchedulerAPI, self).__init__(config.TRANSPORT_DRIVER, target)
....
@ -42,20 +41,21 @@ Projects will need to do e.g.
-- nova.service:
from oslo import messaging
from nova import baserpc
from nova import config
from nova.openstack.common.messaging import eventlet
from nova.openstack.common.messaging import target
def start(self):
...
target = target.Target(topic=self.topic, self.server)
target = messaging.Target(topic=self.topic, self.server)
base_rpc = baserpc.BaseRPCAPI(self.service_name, backdoor_port)
self.rpcserver = eventlet.EventletRPCServer(config.TRANSPORT_DRIVER,
target,
[self.manager, base_rpc])
self.rpcserver = messaging.get_rpc_server(config.TRANSPORT_DRIVER,
target,
[self.manager, base_rpc],
executor='eventlet')
LOG.debug(_("Starting RPC server for %(topic)s on %(server)s") %
dict(topic=self.topic, host=self.server))
@ -65,3 +65,41 @@ Projects will need to do e.g.
...
self.rpcserver.stop()
self.rpcserver.wait()
== notifier ==
Will need e.g.
from oslo import messaging
from nova import config
def get_notifier(host=None):
global _NOTIFIER
if _NOTIFIER is None:
_NOTIFIER = messaging.Notifier(cfg.CONF,
'compute.%s' % (host or cfg.host,
transport=config.TRANSPORT_DRIVER)
return _NOTIFIER
def notify_about_instance_usage(context, instance, event, ..., host=None):
usage_info = notifications.info_from_instance(context, instance, ...)
notifier = get_notifier(host)
notify = notifier.error if event.endswith("error") else notifier.info
notify(context, 'compute.instance.%s' % event, usage_info)
Misc changes vs openstack.common.notifier.api:
- jsonutil.to_primitive(payload, convert_instances=True) is no longer called,
I'm figuring that you should supply a serializer instead
- need to construct a Notifier object, there is no global notifier state
- you'll need a Notifier object per-service, since publisher_id is an object
attribute
- publisher_id() has been removed, so you do 'service.host' manually
- the log levels aren't exposed by the API, instead use the info() etc.
methods on the Notifier class
- notifiy_decorator has been removed, see:
https://github.com/markmc/oslo-incubator/tree/oslo-messaging-notify-decorator

View File

@ -1,6 +1,14 @@
TODO:
- apps need to be able to register backwards compat aliases for
entry point names
get_transport(conf, driver_aliases={
'nova.openstack.common.rpc.impl_kombu': 'rabbit',
'nova.openstack.common.rpc.impl_qpid: 'qpid',
'nova.openstack.common.rpc.impl_zmq: 'zmq'})
- we need some way for the dispatcher to take the incoming
context dict and instantiate a user-supplied request context
object with it