From 09d87a665611af3538dc6d6dd71d522dcb8f370e Mon Sep 17 00:00:00 2001 From: Brant Knudson Date: Fri, 16 Jan 2015 18:00:53 -0600 Subject: [PATCH] Change oslo.messaging to oslo_messaging The oslo libraries are moving away from namespace packages. A hacking check is added to enforce use of the new location. bp drop-namespace-packages Change-Id: Ic96f3273284c6197d9f8aecdc49cbdca42886385 --- keystone/common/config.py | 4 ++-- keystone/hacking/checks.py | 4 ++-- keystone/notifications.py | 7 ++++--- keystone/tests/ksfixtures/hacking.py | 12 ++++++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/keystone/common/config.py b/keystone/common/config.py index 121f32f435..380c677580 100644 --- a/keystone/common/config.py +++ b/keystone/common/config.py @@ -13,7 +13,7 @@ # under the License. from oslo.config import cfg -from oslo import messaging +import oslo_messaging _DEFAULT_AUTH_METHODS = ['external', 'password', 'token'] @@ -957,7 +957,7 @@ FILE_OPTIONS = { CONF = cfg.CONF -messaging.set_transport_defaults(control_exchange='keystone') +oslo_messaging.set_transport_defaults(control_exchange='keystone') def _register_auth_plugin_opt(conf, option): diff --git a/keystone/hacking/checks.py b/keystone/hacking/checks.py index 3b856060d2..0ddf219c32 100644 --- a/keystone/hacking/checks.py +++ b/keystone/hacking/checks.py @@ -399,8 +399,8 @@ class CheckForLoggingIssues(BaseASTChecker): def check_oslo_namespace_imports(logical_line, blank_before, filename): oslo_namespace_imports = re.compile( - r"(((from)|(import))\s+oslo\.((serialization)|(utils)))|" - "(from\s+oslo\s+import\s+((serialization)|(utils)))") + r"(((from)|(import))\s+oslo\.((messaging)|(serialization)|(utils)))|" + "(from\s+oslo\s+import\s+((messaging)|(serialization)|(utils)))") if re.match(oslo_namespace_imports, logical_line): msg = ("K333: '%s' must be used instead of '%s'.") % ( diff --git a/keystone/notifications.py b/keystone/notifications.py index 8725ca49b3..7fa2d1f6b8 100644 --- a/keystone/notifications.py +++ b/keystone/notifications.py @@ -20,7 +20,7 @@ import logging import socket from oslo.config import cfg -from oslo import messaging +import oslo_messaging import pycadf from pycadf import cadftaxonomy as taxonomy from pycadf import cadftype @@ -198,8 +198,9 @@ def _get_notifier(): if _notifier is None: host = CONF.default_publisher_id or socket.gethostname() try: - transport = messaging.get_transport(CONF) - _notifier = messaging.Notifier(transport, "identity.%s" % host) + transport = oslo_messaging.get_transport(CONF) + _notifier = oslo_messaging.Notifier(transport, + "identity.%s" % host) except Exception: LOG.exception(_LE("Failed to construct notifier")) _notifier = False diff --git a/keystone/tests/ksfixtures/hacking.py b/keystone/tests/ksfixtures/hacking.py index d7203699a0..5450f7d01d 100644 --- a/keystone/tests/ksfixtures/hacking.py +++ b/keystone/tests/ksfixtures/hacking.py @@ -196,6 +196,14 @@ class HackingCode(fixtures.Fixture): from oslo import serialization from oslo.serialization import jsonutils from oslo_serialization import jsonutils + + import oslo.messaging + import oslo_messaging + import oslo.messaging.conffixture + import oslo_messaging.conffixture + from oslo import messaging + from oslo.messaging import conffixture + from oslo_messaging import conffixture """, 'expected_errors': [ (1, 0, 'K333'), @@ -206,6 +214,10 @@ class HackingCode(fixtures.Fixture): (11, 0, 'K333'), (13, 0, 'K333'), (14, 0, 'K333'), + (17, 0, 'K333'), + (19, 0, 'K333'), + (21, 0, 'K333'), + (22, 0, 'K333'), ], }