diff options
author | Julien Danjou <julien@danjou.info> | 2013-06-20 16:05:40 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2013-07-08 12:58:59 +0200 |
commit | 54fcea25407d6958cfd189f19e0e3c1ed12df91c (patch) | |
tree | 4bc187747d443eeda1cba9476e50f0cf037322c2 /openstack | |
parent | abfd8ca6ca13b8ad1d42f081aaf29ec639a4032c (diff) | |
download | oslo-54fcea25407d6958cfd189f19e0e3c1ed12df91c.tar.gz oslo-54fcea25407d6958cfd189f19e0e3c1ed12df91c.tar.xz oslo-54fcea25407d6958cfd189f19e0e3c1ed12df91c.zip |
notifier: do not rely on CONF.host
There's nothing in Oslo declaring an 'host' configuration option, so
relying on it isn't a good practice. Let's use the same default value as
intended, but make it work in any case.
Change-Id: I9c898647e68e35435d1a58f920b6e610f217e4e8
Signed-off-by: Julien Danjou <julien@danjou.info>
Diffstat (limited to 'openstack')
-rw-r--r-- | openstack/common/notifier/api.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/openstack/common/notifier/api.py b/openstack/common/notifier/api.py index 7c4dbd1..dc4f578 100644 --- a/openstack/common/notifier/api.py +++ b/openstack/common/notifier/api.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import socket import uuid from oslo.config import cfg @@ -35,7 +36,7 @@ notifier_opts = [ default='INFO', help='Default notification level for outgoing notifications'), cfg.StrOpt('default_publisher_id', - default='$host', + default=None, help='Default publisher_id for outgoing notifications'), ] @@ -74,7 +75,7 @@ def notify_decorator(name, fn): ctxt = context.get_context_from_function_and_args(fn, args, kwarg) notify(ctxt, - CONF.default_publisher_id, + CONF.default_publisher_id or socket.gethostname(), name, CONF.default_notification_level, body) @@ -84,7 +85,10 @@ def notify_decorator(name, fn): def publisher_id(service, host=None): if not host: - host = CONF.host + try: + host = CONF.host + except AttributeError: + host = CONF.default_publisher_id or socket.gethostname() return "%s.%s" % (service, host) |