]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove rabbit_notifier (Sync notifier with oslo d6e1ba7)
authorDirk Mueller <dirk@dmllr.de>
Thu, 23 Jan 2014 09:43:01 +0000 (10:43 +0100)
committerDirk Mueller <dirk@dmllr.de>
Fri, 14 Feb 2014 15:47:30 +0000 (16:47 +0100)
rpc_notifier is available since grizzly, and rabbit_notifier
was printing deprecation messages since then. Remove it
for icehouse. This includes a sync to oslo-incubator, which
includes the following commits:

  aff0171 Remove "vim: tabstop=4 shiftwidth=4 softtabstop=4" from headers
  8575d87 Removed copyright from empty files
  8b2b0b7 Use hacking import_exceptions for gettextutils._
  6fa29ae Trivial: Make vertical white space after license header
          consistent
  d7ae4ff Remove deprecated Grizzly features

DocImpact: Remove all references to rabbit_notifier and replace
it with rpc_notifier.

Change-Id: I889b43dfcebe6574dfa00ea50818f85732860d98

cinder/openstack/common/notifier/__init__.py
cinder/openstack/common/notifier/api.py
cinder/openstack/common/notifier/proxy.py [new file with mode: 0644]
cinder/openstack/common/notifier/rabbit_notifier.py [deleted file]
cinder/openstack/common/notifier/rpc_notifier.py
cinder/openstack/common/notifier/rpc_notifier2.py
cinder/openstack/common/notifier/test_notifier.py

index 45c3b46ae93ba49d1f4f665a1a26dfa5aec94eed..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,14 +0,0 @@
-# Copyright 2011 OpenStack Foundation.
-# All Rights Reserved.
-#
-#    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.
index b9b790895485ff430c48bd2366d35eca302ba41e..d93530d084180fe0019cb209fd7c3fcf29bfe0b2 100644 (file)
@@ -19,7 +19,7 @@ import uuid
 from oslo.config import cfg
 
 from cinder.openstack.common import context
-from cinder.openstack.common.gettextutils import _  # noqa
+from cinder.openstack.common.gettextutils import _
 from cinder.openstack.common import importutils
 from cinder.openstack.common import jsonutils
 from cinder.openstack.common import log as logging
diff --git a/cinder/openstack/common/notifier/proxy.py b/cinder/openstack/common/notifier/proxy.py
new file mode 100644 (file)
index 0000000..1ab4047
--- /dev/null
@@ -0,0 +1,77 @@
+# 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.
+
+"""
+A temporary helper which emulates oslo.messaging.Notifier.
+
+This helper method allows us to do the tedious porting to the new Notifier API
+as a standalone commit so that the commit which switches us to oslo.messaging
+is smaller and easier to review. This file will be removed as part of that
+commit.
+"""
+
+from oslo.config import cfg
+
+from cinder.openstack.common.notifier import api as notifier_api
+
+CONF = cfg.CONF
+
+
+class Notifier(object):
+
+    def __init__(self, publisher_id):
+        super(Notifier, self).__init__()
+        self.publisher_id = publisher_id
+
+    _marker = object()
+
+    def prepare(self, publisher_id=_marker):
+        ret = self.__class__(self.publisher_id)
+        if publisher_id is not self._marker:
+            ret.publisher_id = publisher_id
+        return ret
+
+    def _notify(self, ctxt, event_type, payload, priority):
+        notifier_api.notify(ctxt,
+                            self.publisher_id,
+                            event_type,
+                            priority,
+                            payload)
+
+    def audit(self, ctxt, event_type, payload):
+        # No audit in old notifier.
+        self._notify(ctxt, event_type, payload, 'INFO')
+
+    def debug(self, ctxt, event_type, payload):
+        self._notify(ctxt, event_type, payload, 'DEBUG')
+
+    def info(self, ctxt, event_type, payload):
+        self._notify(ctxt, event_type, payload, 'INFO')
+
+    def warn(self, ctxt, event_type, payload):
+        self._notify(ctxt, event_type, payload, 'WARN')
+
+    warning = warn
+
+    def error(self, ctxt, event_type, payload):
+        self._notify(ctxt, event_type, payload, 'ERROR')
+
+    def critical(self, ctxt, event_type, payload):
+        self._notify(ctxt, event_type, payload, 'CRITICAL')
+
+
+def get_notifier(service=None, host=None, publisher_id=None):
+    if not publisher_id:
+        publisher_id = "%s.%s" % (service, host or CONF.host)
+    return Notifier(publisher_id)
diff --git a/cinder/openstack/common/notifier/rabbit_notifier.py b/cinder/openstack/common/notifier/rabbit_notifier.py
deleted file mode 100644 (file)
index 2ffe952..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2012 Red Hat, Inc.
-# All Rights Reserved.
-#
-#    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.
-
-
-from cinder.openstack.common.gettextutils import _
-from cinder.openstack.common import log as logging
-from cinder.openstack.common.notifier import rpc_notifier
-
-LOG = logging.getLogger(__name__)
-
-
-def notify(context, message):
-    """Deprecated in Grizzly. Please use rpc_notifier instead."""
-
-    LOG.deprecated(_("The rabbit_notifier is now deprecated."
-                     " Please use rpc_notifier instead."))
-    rpc_notifier.notify(context, message)
index 83c94ed5cc520cd1279903ee3e81b28b50a0c41e..6412342b2aa9c6789c29bd31f3663ff826f2597d 100644 (file)
@@ -16,7 +16,7 @@
 from oslo.config import cfg
 
 from cinder.openstack.common import context as req_context
-from cinder.openstack.common.gettextutils import _  # noqa
+from cinder.openstack.common.gettextutils import _
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import rpc
 
index e264374ce0d66c502fece7e3b43f10ff27902563..524ca926905c6262b4115927a325aeb96b22e4a1 100644 (file)
@@ -18,7 +18,7 @@
 from oslo.config import cfg
 
 from cinder.openstack.common import context as req_context
-from cinder.openstack.common.gettextutils import _  # noqa
+from cinder.openstack.common.gettextutils import _
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import rpc
 
index 96c1746bf42a175e3285a51f6751921eef7eb449..11fc21fc3118ba197be98274afab4f3193473bb0 100644 (file)
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-
 NOTIFICATIONS = []