From faa1733ef0adfdfb3e625d60d96b08ce764ca824 Mon Sep 17 00:00:00 2001 From: Akihiro MOTOKI Date: Tue, 8 Jan 2013 16:57:23 +0900 Subject: [PATCH] Use default_notification_level when notification Fix bug 1089773 Notifications in quantum api do not honor default_notification_level in quantum.conf and always use INFO level. On the other hand dhcp-agent refers to default_notification_level. If default_notification_level is set to a value other than INFO, dhcp-agent cannot receive notification from quantum server. Change-Id: Ie3ae576d62e91651aa59b2324ec114716181107f --- quantum/api/v2/base.py | 12 ++++++------ quantum/tests/unit/test_api_v2.py | 12 +++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/quantum/api/v2/base.py b/quantum/api/v2/base.py index 117a3bc4490..a31b5f9677f 100644 --- a/quantum/api/v2/base.py +++ b/quantum/api/v2/base.py @@ -268,7 +268,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.create.start', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, body) body = Controller.prepare_request_body(request.context, body, True, self._resource, self._attr_info, @@ -313,7 +313,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.create.end', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, create_result) return create_result @@ -341,7 +341,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.delete.start', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, {self._resource + '_id': id}) action = self._plugin_handlers[self.DELETE] @@ -363,7 +363,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.delete.end', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, {self._resource + '_id': id}) def update(self, request, id, body=None, **kwargs): @@ -374,7 +374,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.update.start', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, payload) body = Controller.prepare_request_body(request.context, body, False, self._resource, self._attr_info, @@ -409,7 +409,7 @@ class Controller(object): notifier_api.notify(request.context, self._publisher_id, self._resource + '.update.end', - notifier_api.INFO, + notifier_api.CONF.default_notification_level, result) return result diff --git a/quantum/tests/unit/test_api_v2.py b/quantum/tests/unit/test_api_v2.py index 5389434b536..38dfca658f3 100644 --- a/quantum/tests/unit/test_api_v2.py +++ b/quantum/tests/unit/test_api_v2.py @@ -732,7 +732,8 @@ class V2Views(unittest.TestCase): class NotificationTest(APIv2TestBase): - def _resource_op_notifier(self, opname, resource, expected_errors=False): + def _resource_op_notifier(self, opname, resource, expected_errors=False, + notification_level='INFO'): initial_input = {resource: {'name': 'myname'}} instance = self.plugin.return_value instance.get_networks.return_value = initial_input @@ -757,12 +758,12 @@ class NotificationTest(APIv2TestBase): expected = [mock.call(mock.ANY, 'network.' + cfg.CONF.host, resource + "." + opname + ".start", - 'INFO', + notification_level, mock.ANY), mock.call(mock.ANY, 'network.' + cfg.CONF.host, resource + "." + opname + ".end", - 'INFO', + notification_level, mock.ANY)] self.assertEqual(expected, mynotifier.call_args_list) self.assertEqual(res.status_int, expected_code) @@ -776,6 +777,11 @@ class NotificationTest(APIv2TestBase): def test_network_update_notifer(self): self._resource_op_notifier('update', 'network') + def test_network_create_notifer(self): + cfg.CONF.set_override('default_notification_level', 'DEBUG') + self._resource_op_notifier('create', 'network', + notification_level='DEBUG') + class QuotaTest(APIv2TestBase): def test_create_network_quota(self):