diff --git a/nova/notifier/api.py b/nova/notifier/api.py index f5cf95d2a36f..6ef4a050e36d 100644 --- a/nova/notifier/api.py +++ b/nova/notifier/api.py @@ -25,6 +25,9 @@ FLAGS = flags.FLAGS flags.DEFINE_string('default_notification_level', 'INFO', 'Default notification level for outgoing notifications') +flags.DEFINE_string('default_publisher_id', FLAGS.host, + 'Default publisher_id for outgoing notifications') + WARN = 'WARN' INFO = 'INFO' @@ -55,9 +58,9 @@ def notify_decorator(name, fn): body['args'].append(arg) for key in kwarg: body['kwarg'][key] = kwarg[key] - notify(FLAGS.host, + notify(FLAGS.default_publisher_id, name, - DEBUG, + FLAGS.default_notification_level, body) return fn(*args, **kwarg) return wrapped_func diff --git a/nova/tests/monkey_patch_example/__init__.py b/nova/tests/monkey_patch_example/__init__.py index 1cfdf8a7e3af..25cf9ccfe68c 100644 --- a/nova/tests/monkey_patch_example/__init__.py +++ b/nova/tests/monkey_patch_example/__init__.py @@ -1,3 +1,5 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + # Copyright 2011 OpenStack LLC. # All Rights Reserved. # @@ -12,8 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Example Module for testing utils.monkey_patch() -""" +"""Example Module for testing utils.monkey_patch().""" CALLED_FUNCTION = [] @@ -21,12 +22,10 @@ CALLED_FUNCTION = [] def example_decorator(name, function): """ decorator for notify which is used from utils.monkey_patch() - Parameters: - - name - name of the function - function - object of the function - + :param name: name of the function + :param function: - object of the function + :returns: function -- decorated function """ def wrapped_func(*args, **kwarg): CALLED_FUNCTION.append(name) diff --git a/nova/tests/monkey_patch_example/example_a.py b/nova/tests/monkey_patch_example/example_a.py index 91bf048e4e42..21e79bcb0f79 100644 --- a/nova/tests/monkey_patch_example/example_a.py +++ b/nova/tests/monkey_patch_example/example_a.py @@ -1,7 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. +# Copyright 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -15,9 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - -"""Example Module A for testing utils.monkey_patch() -""" +"""Example Module A for testing utils.monkey_patch().""" def example_function_a(): diff --git a/nova/tests/monkey_patch_example/example_b.py b/nova/tests/monkey_patch_example/example_b.py index edd267c4fd55..9d8f6d339ef9 100644 --- a/nova/tests/monkey_patch_example/example_b.py +++ b/nova/tests/monkey_patch_example/example_b.py @@ -1,7 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. +# Copyright 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -16,8 +15,7 @@ # License for the specific language governing permissions and limitations # under the License. -"""Example Module B for testing utils.monkey_patch() -""" +"""Example Module B for testing utils.monkey_patch().""" def example_function_b(): diff --git a/nova/tests/test_notifier.py b/nova/tests/test_notifier.py index ab5dfb692f55..7de3a4a99832 100644 --- a/nova/tests/test_notifier.py +++ b/nova/tests/test_notifier.py @@ -141,8 +141,7 @@ class NotifierTestCase(test.TestCase): def example_api(arg1, arg2): return arg1 + arg2 - example_api =\ - nova.notifier.api.notify_decorator( + example_api = nova.notifier.api.notify_decorator( 'example_api', example_api)