Commit Graph

37 Commits

Author SHA1 Message Date
Doug Hellmann 03265410e0 Remove oslo namespace package
Blueprint remove-namespace-packages

Depends-on: I2eeef93ee2e61a721c69f62add819f93f62f077d
for openstack/ceilometer
Depends-on: I26390dd908769be5f1a5b70be22d3b98e3a45563
for openstack/ceilometermiddleware
Depends-on: Ifa8baab33cdb3e606cf175a8c29c3a4ef6c44480
for openstack/glance
Depends-on: I029c3260051aa48cfaae428c096c1ac7b43b2bd2
for openstack/ceilometermiddleware

Change-Id: I8c5595bbafa82db33f62fa47d214f5cb756a2639
2015-07-16 17:47:16 +00:00
Doug Hellmann e55a83e832 Move files out of the namespace package
Move the public API out of oslo.messaging to oslo_messaging. Retain
the ability to import from the old namespace package for backwards
compatibility for this release cycle.

bp/drop-namespace-packages

Co-authored-by: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
Change-Id: Ia562010c152a214f1c0fed767c82022c7c2c52e7
2015-01-12 12:50:41 -05:00
Mehdi Abaakouk bcb3b23b8f Don't use oslo.cfg to set kombu in-memory driver
This removes a TODO and also fixes a issue due to the
global state of oslo.config.cfg.CONF.

Closes bug: #1397339

Change-Id: Ib366f35678f899fda93821e6f07897baf8f631b4
2014-12-02 14:42:04 +01:00
Jenkins 0b839c57b7 Merge "Notification listener pools" 2014-11-27 11:56:42 +00:00
Mehdi Abaakouk 30e0aea877 Notification listener pools
We can now set the pool name of a notification listener
to create multiple groups/pools of listeners consuming notifications
and that each group/pool only receives one copy of each notification.

The AMQP implementation of that is to set queue_name with the pool name.

Implements blueprint notification-listener-pools
Closes-bug: #1356226

Change-Id: I8dc0549f5550f684a261c78c58737b798fcdd656
2014-11-14 10:20:18 +01:00
Oleksii Zamiatin f74014a7db Documentation anomaly in TransportURL parse classmethod
The documentation for the classmethod `parse` states that

    The last parsed username and password will be propagated to the rest
    of hosts specified::
    user:pass@host1:port1,host2:port2
    [
    {"username": "user", "password": "pass", "host": "host1:port1"},
    {"username": "user", "password": "pass", "host": "host2:port2"}
    ]

However, in practice one needs to specify the usernames and passwords
individually with every host.

DocImpact: Documentation needs to be changed due anomaly in TransportURL
parse classmethod.

Change-Id: I1a9e07e0380a0d6f7d00731df93c9ba01ae20e0e
Closes-Bug: #1355684
2014-10-31 12:14:17 +02:00
Christian Berendt 5be1b6a6a9 Enabled hacking checks H305 and H307
* H305  imports not grouped correctly
* H307  like imports should be grouped together

Change-Id: I08dafc4fa150d2213b2bb002da7c9ee0ee517fac
2014-07-17 12:41:21 +02:00
Christian Berendt 59103984bb Replaced 'e.g.' with 'for example'
According to the IBM Style Guide the Latin abbreviation 'e.g.'
should be replace by 'for example'.

Change-Id: I694df5ed62213e29bdf35f781fd6f310b7df77a6
2014-07-06 20:56:11 +02:00
Mark McLoughlin da2abaaa06 Fix formatting of TransportURL.parse() docs
Change-Id: I0b2cf7b1e76bd9151957ddaaaaca8d9e11cf1ed5
2014-06-26 06:53:32 +01:00
ChangBo Guo(gcb) 821ee096a6 Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this.

Change-Id: I67cc0774a65886ef9fce0b72e52157b622248a85
Closes-Bug: #1327473
2014-06-21 11:41:36 +08:00
Mehdi Abaakouk 1ea9c35ab4 Transport reconnection retries for notification
This patch add support of reconnection retries for the
messaging notifier.

Related bug #1282639
Change-Id: Ia30331f8306ff0f6952d83ef42ff8bee6b900427
2014-06-18 18:41:33 +02:00
Mehdi Abaakouk 948c05417c Add transport reconnection retries
When a rpc client try to make a RPC call and the server is unreachable
The rpc call hang until the server come back.

In most case this is the desired behavior.

But sometimes, we can prefer that the library raise an exception after a
certain number of retries.

For example in ceilometer, when publishing a
storage.objects.incoming.bytes sample from the Swift middleware to an
AMQP topic, you might not want to block the Swift client if the AMQP broker
is unavailable - instead, you might have a queueing policy whereby
if a single reconection attempt fails we queue the sample in memory and
try again when another sample is to be published.

This patch is the oslo.messaging part that allow this.

Closes bug #1282639
Co-Authored-By: Ala Rezmerita <ala.rezmerita@cloudwatt.com>

Change-Id: I32086d0abf141c368343bf225d4b021da496c020
2014-06-13 16:21:59 +02:00
Christian Berendt c0fde47499 remove default=None for config options
In the cfg module default=None is set as the default value.

Change-Id: I5de0c1ddeeaccde8183ec130c85524f5b57f6f74
Closes-Bug: #1323975
2014-05-28 09:08:51 +02:00
Mehdi Abaakouk 78b498de23 Make the TransportUrl hashable
The amqp connection pool uses the Transport Url as key
to track the connection, but currently a different hash can be
returned for the same url.

This change fixes the hash method of the TransportUrl

Change-Id: Id701d6a80a909d6bd6dabe680c2b8e09dd721ef1
Closes-bug: #1316891
2014-05-24 12:30:21 +02:00
Eric Guo 13608437bb Remove dependent module py3kcompat
Module py3kcompat was removed from oslo-incubator, we can use
six directly.

Syncing module network_utils:
162e850 Remove import workaround of SplitResult
897aa7c urlsplit issues with IPv6 addresses in python26
35dc1d7 py3kcompat: remove

Change-Id: I71446362209c306c7e8858f4713a59b84fbcc1b2
Closes-Bug: #1280033
2014-04-25 20:31:11 +08:00
Mark McLoughlin 5bd31315c2 notification listener: add allow_requeue param
In commit d8d2ad9 we added support for notification listener endpoint
methods to return REQUEUE, but if a driver does not support this we
raise NotImplementedError when the application attempts to requeue
a message.

This requeuing behaviour might only be used by an application in
unusual, exceptional circumstances and catch users by surprise.

Instead, let's require the application to assert that it needs this
feature in advance and raise NotImplementError at that point if the
driver doesn't support it.

Change-Id: Id0bb0e57d2dcc1ec7d752e98c9b1e8e48d99f35c
2014-03-03 07:51:18 -08:00
Mehdi Abaakouk 9f58e2c3fe Implements notification listener and dispatcher
This patch allows to quickly create a listener to receive
notification messages.

Example of the api:

class Endpoint(object):
    def warn(self, ctxt, publisher_id, event_type, payload):
        do_something(payload)

target = messaging.Target(topic='notifications', exchange='cinder')
listener = notify.get_notification_listener(transport, [target],
                                            [Endpoint()],
                                            executor,
                                            serializer)

Implements blueprint notification-subscriber-server

Change-Id: I434bc487c382a2048670df726d9bebd640150bb9
2014-02-14 16:06:26 +01:00
Jenkins 4f431ea652 Merge "Fix spelling errors in comments" 2014-01-11 17:06:08 +00:00
Stanislav Kudriashev 2e59af91ba Fix spelling errors in comments
Change-Id: I9f7de85912c687d37661c3301b5898960082fc13
2014-01-10 17:02:27 +02:00
Victor Stinner 690868bc99 Minor Python 3 fixes
basestring does not exist anymore in Python 3: use six.string_types instead.

In "try: .../except Exception as err: ...", err is a local variable, it does no
more exist after the except block. Copy the exception in a new cls_error
variable to fix Python 3 support.

Extract of Python 3 documentation: "When an exception has been assigned using
as target, it is cleared at the end of the except clause. (...) Exceptions are
cleared because with the traceback attached to them, they form a reference
cycle with the stack frame, keeping all locals in that frame alive until the
next garbage collection occurs."

http://docs.python.org/3.3/reference/compound_stmts.html#try

Change-Id: I2efb14b3838f78d1ed5e09b3ccd4e796a3448aee
2014-01-07 11:29:13 +01:00
Chang Bo Guo db9e8d3c61 Unify different names between Python2 and Python3
Some modules have different names in Python2 and Python3. This patch
make them compatible with Python 3.

 * Use six.moves.filter instead of itertools.ifilter() in Python 2.
 * Use common.py3kcompat.urlutils instead of urllib and urlparse.

Change-Id: Ia27ebf6057d91d0e129fbe90f995cfdaa89efa8a
2013-12-09 02:19:52 -08:00
Mark McLoughlin 5b8fbdcad2 Add transport aliases
We need to support deprecated transport driver configurations like:

 rpc_backend = nova.rpc.impl_kombu

i.e. 'nova.rpc.impl_kombu' is a deprecated alias for 'rabbit'.

Initially, we supported this by adding the aliases to each project's
setup.cfg:

oslo.messaging.drivers =
    nova.rpc.impl_kombu = oslo.messaging._drivers.impl_rabbit:RabbitDriver

However, this means that code like this:

  url = str(TransportURL(conf))

generates a bogus URL string like:

  nova.rpc.impl_kombu://...

We need to apply these transport aliases when we load drivers, but also
when we create transport URLs from configuration containing potentially
deprecated aliases.

To enable that, add an aliases parameter to TransportURL(),
TransportURL.parse() and get_transport().

blueprint: transport-aliases
Change-Id: Ifce68ff62746c2a363c719417a2bd0a78ee025dd
2013-12-06 19:18:18 +00:00
Julien Danjou 2545a5d806 Remove hosts as property in TransportURL
There's no need to use this indirection there.

Change-Id: Ia0d247693509f14b1a0a2faffb7da8884c679170
2013-11-12 18:22:10 +01:00
Julien Danjou c65bfb7a55 Remove property on virtual_host in TransportURL
This isn't useful at all.

Change-Id: I1025da66a0f382cc3ecec15acf01890d75257a6a
2013-11-12 18:22:06 +01:00
Chang Bo Guo 0b078b6062 Fix some typos and adjust capitalization
Change-Id: I61cf108f9746fc44a08d83e11d44ed1007a6a1fa
2013-11-03 07:07:51 -08:00
Christian Strack b29a1462c2 Changes driver method for notifications
Oslo.messaging.Transport is used as an abstraction to redirect function
calls to the configured driver. _send_notification called
self._driver.send instead of self._driver.send_notification

As the test
oslo.messaging.tests.TestTransportMethodArgs.test_send_notification also
assumed that send was the correct method, this should be changed
accordingly

Change-Id: I9406d74f3dc13c44d1aaad5379aafbf1a8580137
2013-10-31 15:08:06 +01:00
Mark McLoughlin 3a2a4d9831 Make rpc_backend default to 'rabbit'
'rabbit' is the canonical name for the driver and 'kombu' is just an
alias, so let's set the default to the canonical.

Change-Id: If163ece6793d2a7d6e99d0c8df1745bbcf9a36e6
2013-10-18 14:54:26 +01:00
Mark McLoughlin 2564795108 Fix transport URL parsing bug
Handle e.g. foo://u:p@/bar. Right now we get:

 IndexError: string index out of range

from:

     if hostname[0] == '[':

Change-Id: I0bccebb14ad1d37862955e8988d160240bd1cf6d
2013-08-18 01:49:25 +01:00
Mark McLoughlin a3ffdd1b16 Fix transport URL ipv6 parsing support
Just copies code from Nova's cells code.

See I6b18f7643ab694f5ff34206b80865c40b1ec2680 for where this code was
first introduced.

Change-Id: If9b1503ed47f5910c0ab44edfbe3f42fcce9bf18
2013-08-16 06:31:03 +01:00
Mark McLoughlin c846cf35b8 Add a TransportURL class to the public API
Nova's cells/rpc_driver.py has some code which allows user of the REST
API to update elements of a cell's transport URL (say, the host name of
the message broker) stored in the database. To achieve this, it has
a parse_transport_url() method which breaks the URL into its constituent
parts and an unparse_transport_url() which re-forms it again after
updating some of its parts.

This is all fine and, since it's fairly specialized, it wouldn't be a
big deal to leave this code in Nova for now ... except the unparse
method looks at CONF.rpc_backend to know what scheme to use in the
returned URL if now backend was specified.

oslo.messaging registers the rpc_backend option, but the ability to
reference any option registered by the library should not be relied upon
by users of the library. Imagine, for instance, if we renamed the option
in future (with backwards compat for old configurations), then this
would mean API breakage.

So, long story short - an API along these lines makes some sense, but
especially since not having it would mean we'd need to add some way to
query the name of the transport driver.

In this commit, we add a simple new TransportURL class:

  >>> url = messaging.TransportURL.parse(cfg.CONF, 'foo:///')
  >>> str(url), url
  ('foo:///', <TransportURL transport='foo'>)
  >>> url.hosts.append(messaging.TransportHost(hostname='localhost'))
  >>> str(url), url
  ('foo://localhost/', <TransportURL transport='foo', hosts=[<TransportHost hostname='localhost'>]>)
  >>> url.transport = None
  >>> str(url), url
  ('kombu://localhost/', <TransportURL transport='kombu', hosts=[<TransportHost hostname='localhost'>]>)
  >>> cfg.CONF.set_override('rpc_backend', 'bar')
  >>> str(url), url
  ('bar://localhost/', <TransportURL transport='bar', hosts=[<TransportHost hostname='localhost'>]>)

The TransportURL.parse() method equates to parse_transport_url() and
TransportURL.__str__() equates to unparse_transport().

The transport drivers are also updated to take a TransportURL as a
required argument, which simplifies the handling of transport URLs in
the drivers.

Change-Id: Ic04173476329858e4a2c2d2707e9d4aeb212d127
2013-08-12 23:30:43 +01:00
Mark McLoughlin 9cc66e1e01 Kill ability to specify exchange in transport URL
My original thinking was that if you're using the exchange name to
separate two instances of the applications (so their queues don't
collide) then the exchange name is pretty key to transport
configuration. In fact, it's really a virtual host that you'd use for
this (at least in the case of rabbit and qpid).

Also, Nova's cells code has already moved ahead with the assumption that
the path specifies a virtual host, so it'd only make sense to deviate
from that if there was a really good reason to.

Change-Id: Ic8b5dc3538b6b17afec524047acc2efa76366377
2013-08-12 06:09:48 +01:00
Mark McLoughlin ac2176cde3 Add a per-transport allow_remote_exmods API
Currently we have a allowed_rpc_exception_modules configuration variable
which we use to configure a per-project list of modules which we will
allow exceptions to be instantiated from when deserializing remote
errors.

It makes no sense for this to be user configurable, instead the list of
modules should be set when you create a transport.

Closes-Bug: #1031719
Change-Id: Ib40e92cb920996ec5e8f63d6f2cbd88fd01a90f2
2013-08-07 13:11:46 +01:00
Mark McLoughlin 206c19e99e Add a driver method specifically for sending notifications
Notifications are an unusual case in that we need users to manually opt
in to new incompatible message formats by editing configuration because
there may be external consumers expecting the old format.

Add a send_notification() method to the driver interface and add a
format version paramater to the method, to make it clear that this
version selection is specifically for notifications.

In the case of the rabbit/qpid drivers, the 2.0 format is where we added
the message envelope.

Change-Id: Ib4925c308b1252503749962aa16f043281f2b429
2013-08-07 06:51:35 +01:00
Mark McLoughlin 294c99a6d2 Enforce target preconditions outside of drivers
The target preconditions (e.g. you need at least a topic to send) are
the same for all drivers, so enforce them before we ever call into a
driver.

Change-Id: Ic4e9bd94bd9f060ec0662d2bb778c699903dddc4
2013-08-07 06:51:24 +01:00
Mark McLoughlin 1f0874857c Add a transport cleanup() method
Pretty obvious that we need this.

The rabbit/qpid implementations just empty the connection pool, in the
same way their module-level cleanup() methods do now.

Change-Id: I70ba5cab3eb7a30f74cdd6cafe60087769a77b57
2013-08-02 06:47:57 +01:00
Mark McLoughlin 03aafcb49c Simplify public symbol exports
Inspired by tulip, have every module define a __all__ list and import *
from the top-level module.

Rename transport.set_defaults() since we don't want this to be a
top-level set_defaults() function as there may be multiple.

Also, rather than configuring flake8 to allow star imports, just exclude
the __init__.py files from flake8 checks.
2013-06-24 12:52:30 +01:00
Mark McLoughlin cbfb1452a4 Move files to new locations for oslo.messaging 2013-06-15 08:43:54 +01:00