From a2d113198c684e585c5bab9e313b4ede8a6aee4f Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 28 Aug 2013 12:24:04 +0100 Subject: [PATCH] Add zmq-receiver This is the ZeroMQ server which acts as a proxy for all messages destined to a particular host. Again, there are a bunch of FIXMEs here. This still needs work. Change-Id: I9384f486e44b0b0cbca028e219ad66f1990d5181 --- oslo/messaging/_cmd/__init__.py | 14 ++++++++++ oslo/messaging/_cmd/zmq_receiver.py | 41 +++++++++++++++++++++++++++++ oslo/messaging/_drivers/impl_zmq.py | 2 ++ setup.cfg | 3 +++ 4 files changed, 60 insertions(+) create mode 100644 oslo/messaging/_cmd/__init__.py create mode 100755 oslo/messaging/_cmd/zmq_receiver.py diff --git a/oslo/messaging/_cmd/__init__.py b/oslo/messaging/_cmd/__init__.py new file mode 100644 index 000000000..b1541fdb7 --- /dev/null +++ b/oslo/messaging/_cmd/__init__.py @@ -0,0 +1,14 @@ + +# Copyright 2013 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. diff --git a/oslo/messaging/_cmd/zmq_receiver.py b/oslo/messaging/_cmd/zmq_receiver.py new file mode 100755 index 000000000..af7f089bb --- /dev/null +++ b/oslo/messaging/_cmd/zmq_receiver.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 OpenStack Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import eventlet +eventlet.monkey_patch() + +import contextlib +import logging +import sys + +from oslo.config import cfg + +from oslo.messaging._drivers import impl_zmq +from oslo.messaging._executors import impl_eventlet # FIXME(markmc) + +CONF = cfg.CONF +CONF.register_opts(impl_zmq.zmq_opts) +CONF.register_opts(impl_eventlet._eventlet_opts) + + +def main(): + CONF(sys.argv[1:], project='oslo') + logging.basicConfig(level=logging.DEBUG) + + with contextlib.closing(impl_zmq.ZmqProxy(CONF)) as reactor: + reactor.consume_in_thread() + reactor.wait() diff --git a/oslo/messaging/_drivers/impl_zmq.py b/oslo/messaging/_drivers/impl_zmq.py index dea2cadac..71d29ea29 100644 --- a/oslo/messaging/_drivers/impl_zmq.py +++ b/oslo/messaging/_drivers/impl_zmq.py @@ -29,6 +29,7 @@ from oslo.config import cfg from oslo.messaging._drivers import base from oslo.messaging._drivers import common as rpc_common +from oslo.messaging._executors import impl_eventlet # FIXME(markmc) from oslo.messaging.openstack.common import excutils from oslo.messaging.openstack.common import importutils from oslo.messaging.openstack.common import jsonutils @@ -826,6 +827,7 @@ class ZmqDriver(base.BaseDriver): def __init__(self, conf, url, default_exchange=None, allowed_remote_exmods=[]): conf.register_opts(zmq_opts) + conf.register_opts(impl_eventlet._eventlet_opts) super(ZmqDriver, self).__init__(conf, url, default_exchange, allowed_remote_exmods) diff --git a/setup.cfg b/setup.cfg index e4dab987e..9f768208b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,9 @@ setup-hooks = pbr.hooks.setup_hook [entry_points] +console_scripts = + oslo-messaging-zmq-receiver = oslo.messaging._cmd.zmq_receiver:main + oslo.messaging.drivers = rabbit = oslo.messaging._drivers.impl_rabbit:RabbitDriver qpid = oslo.messaging._drivers.impl_qpid:QpidDriver