Enable notification messaging pools
Use notification pools by default and use the same notification topic as ceilometer, separate notification topic is no need to add. Change-Id: Ieef1ece78e6e8d20abfeea9546e1a9170b7eeb70
This commit is contained in:
parent
e5385d4e9b
commit
5025328bc1
@ -20,13 +20,11 @@ MAX_RESOURCE_NUM = 1000
|
|||||||
RPC_ATTRS = (
|
RPC_ATTRS = (
|
||||||
ENGINE_TOPIC,
|
ENGINE_TOPIC,
|
||||||
SCHEDULER_TOPIC,
|
SCHEDULER_TOPIC,
|
||||||
NOTIFICATION_TOPICS,
|
|
||||||
ENGINE_DISPATCHER_TOPIC,
|
ENGINE_DISPATCHER_TOPIC,
|
||||||
RPC_API_VERSION,
|
RPC_API_VERSION,
|
||||||
) = (
|
) = (
|
||||||
'bilean-engine',
|
'bilean-engine',
|
||||||
'bilean-scheduler',
|
'bilean-scheduler',
|
||||||
'billing_notifications',
|
|
||||||
'bilean_engine_dispatcher',
|
'bilean_engine_dispatcher',
|
||||||
'1.0',
|
'1.0',
|
||||||
)
|
)
|
||||||
|
@ -24,7 +24,7 @@ from bilean.common import exception
|
|||||||
from bilean.common.i18n import _LE
|
from bilean.common.i18n import _LE
|
||||||
from bilean.engine import policy as policy_mod
|
from bilean.engine import policy as policy_mod
|
||||||
from bilean.engine import user as user_mod
|
from bilean.engine import user as user_mod
|
||||||
from bilean.plugin import base as plugin_base
|
from bilean.plugins import base as plugin_base
|
||||||
from bilean import scheduler as bilean_scheduler
|
from bilean import scheduler as bilean_scheduler
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -11,37 +11,75 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
from oslo_service import service
|
from oslo_service import service
|
||||||
|
|
||||||
from bilean.common import consts
|
from bilean.common.i18n import _LE
|
||||||
from bilean.common.i18n import _
|
|
||||||
from bilean.common import messaging as bilean_messaging
|
from bilean.common import messaging as bilean_messaging
|
||||||
|
from bilean.engine import environment
|
||||||
from bilean.notification import endpoint
|
from bilean.notification import endpoint
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
listener_opts = [
|
||||||
|
cfg.IntOpt('workers',
|
||||||
|
default=1,
|
||||||
|
min=1,
|
||||||
|
help='Number of workers for notification service. A single '
|
||||||
|
'notification agent is enabled by default.'),
|
||||||
|
cfg.StrOpt('notifications_pool',
|
||||||
|
default='bilean-listener',
|
||||||
|
help='Use an oslo.messaging pool, which can be an alternative '
|
||||||
|
'to multiple topics. ')
|
||||||
|
]
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.register_opts(listener_opts, group="listener")
|
||||||
|
|
||||||
|
|
||||||
class NotificationService(service.Service):
|
class NotificationService(service.Service):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(NotificationService, self).__init__(*args, **kwargs)
|
super(NotificationService, self).__init__(*args, **kwargs)
|
||||||
self.targets, self.listeners = [], []
|
self.listeners = []
|
||||||
self.transport = None
|
self.topics_exchanges_set = self.topics_and_exchanges()
|
||||||
self.group_id = None
|
|
||||||
self.endpoints = [endpoint.EventsNotificationEndpoint()]
|
def topics_and_exchanges(self):
|
||||||
|
topics_exchanges = set()
|
||||||
|
plugins = environment.global_env().get_plugins()
|
||||||
|
for plugin in plugins:
|
||||||
|
try:
|
||||||
|
topic_exchanges = plugin.get_notification_topics_exchanges()
|
||||||
|
for plugin_topic in topic_exchanges:
|
||||||
|
if isinstance(plugin_topic, basestring):
|
||||||
|
raise Exception(
|
||||||
|
_LE("Plugin %s should return a list of topic "
|
||||||
|
"exchange pairs") % plugin.__class__.__name__)
|
||||||
|
topics_exchanges.add(plugin_topic)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.error(_LE("Failed to retrieve notification topic(s) "
|
||||||
|
"and exchanges from bilean plugin "
|
||||||
|
"%(ext)s: %(e)s") %
|
||||||
|
{'ext': plugin.__name__, 'e': e})
|
||||||
|
|
||||||
|
return topics_exchanges
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
super(NotificationService, self).start()
|
super(NotificationService, self).start()
|
||||||
self.transport = bilean_messaging.get_transport()
|
transport = bilean_messaging.get_transport()
|
||||||
self.targets.append(
|
targets = [
|
||||||
oslo_messaging.Target(topic=consts.NOTIFICATION_TOPICS))
|
oslo_messaging.Target(topic=tp, exchange=eg)
|
||||||
listener = bilean_messaging.get_notification_listener(
|
for tp, eg in self.topics_exchanges_set
|
||||||
self.transport, self.targets, self.endpoints)
|
]
|
||||||
|
endpoints = [endpoint.EventsNotificationEndpoint()]
|
||||||
|
listener = oslo_messaging.get_notification_listener(
|
||||||
|
transport,
|
||||||
|
targets,
|
||||||
|
endpoints,
|
||||||
|
pool=CONF.listener.notifications_pool)
|
||||||
|
|
||||||
LOG.info(_("Starting listener on topic: %s"),
|
|
||||||
consts.NOTIFICATION_TOPICS)
|
|
||||||
listener.start()
|
listener.start()
|
||||||
self.listeners.append(listener)
|
self.listeners.append(listener)
|
||||||
|
|
||||||
|
@ -128,4 +128,4 @@ class ServerPlugin(base.Plugin):
|
|||||||
|
|
||||||
RuleClass = ServerRule
|
RuleClass = ServerRule
|
||||||
ResourceClass = ServerResource
|
ResourceClass = ServerResource
|
||||||
notification_exchanges = ['nova', 'neutron']
|
notification_exchanges = ['nova']
|
||||||
|
@ -22,8 +22,21 @@ Enabling Bilean in DevStack
|
|||||||
|
|
||||||
Bilean service is driven using a plugin mechanism for integrating to other
|
Bilean service is driven using a plugin mechanism for integrating to other
|
||||||
services. Each integrated service may require additional configuration
|
services. Each integrated service may require additional configuration
|
||||||
settings. For example, typically, you will need to add the
|
settings. Typically, you will need to set the notifications driver in each
|
||||||
``billing_notifications`` notification topic to each service's configuration.
|
service's configuration.
|
||||||
|
|
||||||
|
For example, to enable nova service, edit `/etc/nova/nvoa.conf` and add
|
||||||
|
following configuration::
|
||||||
|
|
||||||
|
[oslo_messaging_notifications]
|
||||||
|
driver = messaging
|
||||||
|
|
||||||
|
Or add following configurations to post config section in `local.conf` to
|
||||||
|
make devstack automaticlly configure the settings above::
|
||||||
|
|
||||||
|
[[post-config|$NOVA_CONF]]
|
||||||
|
[oslo_messaging_notifications]
|
||||||
|
driver = messaging
|
||||||
|
|
||||||
4. Then run devstack normally.
|
4. Then run devstack normally.
|
||||||
|
|
||||||
|
@ -46,8 +46,21 @@ following detailed instructions.
|
|||||||
|
|
||||||
Bilean service is driven using a plugin mechanism for integrating to other
|
Bilean service is driven using a plugin mechanism for integrating to other
|
||||||
services. Each integrated service may require additional configuration
|
services. Each integrated service may require additional configuration
|
||||||
settings. For example, typically, you will need to add the
|
settings. Typically, you will need to set the notifications driver in each
|
||||||
``billing_notifications`` notification topic to each service's configuration.
|
service's configuration.
|
||||||
|
|
||||||
|
For example, to enable nova service, edit `/etc/nova/nvoa.conf` and add
|
||||||
|
following configuration::
|
||||||
|
|
||||||
|
[oslo_messaging_notifications]
|
||||||
|
driver = messaging
|
||||||
|
|
||||||
|
Or add following configurations to post config section in `local.conf` to
|
||||||
|
make devstack automaticlly configure the settings above::
|
||||||
|
|
||||||
|
[[post-config|$NOVA_CONF]]
|
||||||
|
[oslo_messaging_notifications]
|
||||||
|
driver = messaging
|
||||||
|
|
||||||
4. Then run devstack normally.
|
4. Then run devstack normally.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user