]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use default_notification_level when notification
authorAkihiro MOTOKI <motoki@da.jp.nec.com>
Tue, 8 Jan 2013 07:57:23 +0000 (16:57 +0900)
committerAkihiro MOTOKI <motoki@da.jp.nec.com>
Sat, 12 Jan 2013 16:53:11 +0000 (01:53 +0900)
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
quantum/tests/unit/test_api_v2.py

index 117a3bc449082840581603d4e47089961febbaae..a31b5f9677f60ff382888c7722ab30bb715eb195 100644 (file)
@@ -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
 
index 5389434b5363c61288e429263c28b1fa04da11ed..38dfca658f3b8d810cb18f995c4f92f8e3cbe001 100644 (file)
@@ -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):