From 848ae6677e235778fd0b5efd500ea92c5b955096 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 23 Jan 2014 10:43:01 +0100 Subject: [PATCH] Remove rabbit_notifier (Sync notifier with oslo d6e1ba7) 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 | 14 ---- cinder/openstack/common/notifier/api.py | 2 +- cinder/openstack/common/notifier/proxy.py | 77 +++++++++++++++++++ .../common/notifier/rabbit_notifier.py | 29 ------- .../openstack/common/notifier/rpc_notifier.py | 2 +- .../common/notifier/rpc_notifier2.py | 2 +- .../common/notifier/test_notifier.py | 1 - 7 files changed, 80 insertions(+), 47 deletions(-) create mode 100644 cinder/openstack/common/notifier/proxy.py delete mode 100644 cinder/openstack/common/notifier/rabbit_notifier.py diff --git a/cinder/openstack/common/notifier/__init__.py b/cinder/openstack/common/notifier/__init__.py index 45c3b46ae..e69de29bb 100644 --- a/cinder/openstack/common/notifier/__init__.py +++ b/cinder/openstack/common/notifier/__init__.py @@ -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. diff --git a/cinder/openstack/common/notifier/api.py b/cinder/openstack/common/notifier/api.py index b9b790895..d93530d08 100644 --- a/cinder/openstack/common/notifier/api.py +++ b/cinder/openstack/common/notifier/api.py @@ -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 index 000000000..1ab404709 --- /dev/null +++ b/cinder/openstack/common/notifier/proxy.py @@ -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 index 2ffe9524e..000000000 --- a/cinder/openstack/common/notifier/rabbit_notifier.py +++ /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) diff --git a/cinder/openstack/common/notifier/rpc_notifier.py b/cinder/openstack/common/notifier/rpc_notifier.py index 83c94ed5c..6412342b2 100644 --- a/cinder/openstack/common/notifier/rpc_notifier.py +++ b/cinder/openstack/common/notifier/rpc_notifier.py @@ -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 diff --git a/cinder/openstack/common/notifier/rpc_notifier2.py b/cinder/openstack/common/notifier/rpc_notifier2.py index e264374ce..524ca9269 100644 --- a/cinder/openstack/common/notifier/rpc_notifier2.py +++ b/cinder/openstack/common/notifier/rpc_notifier2.py @@ -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 diff --git a/cinder/openstack/common/notifier/test_notifier.py b/cinder/openstack/common/notifier/test_notifier.py index 96c1746bf..11fc21fc3 100644 --- a/cinder/openstack/common/notifier/test_notifier.py +++ b/cinder/openstack/common/notifier/test_notifier.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. - NOTIFICATIONS = [] -- 2.45.2