]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Correct LOG.debug use
authorCedric Brandily <zzelle@gmail.com>
Mon, 21 Jul 2014 14:45:38 +0000 (16:45 +0200)
committerCedric Brandily <zzelle@gmail.com>
Mon, 21 Jul 2014 15:26:32 +0000 (17:26 +0200)
The commit b3202c3283597de031572e0ede082237487d8110 used:

  LOG.debug("...%(key1)s...", key1=value1)

which  is not supported, this change ues instead:

  LOG.debug("...%(key1)s...", {"key1": value1})

Change-Id: I9bd63c27ca8acf89284399fda8cd74c82906113b

neutron/plugins/ml2/drivers/helpers.py
neutron/tests/unit/ml2/test_helpers.py

index 9e73a8b6cfdf44c721aa06c32baf8b214265d68f..5ab0e7f2d17817403789cdb457ae91ca5601890c 100644 (file)
@@ -60,35 +60,38 @@ class TypeDriverHelper(api.TypeDriver):
                         # Segment not allocated
                         LOG.debug("%(type)s segment %(segment)s allocate "
                                   "started ",
-                                  type=network_type, segment=raw_segment)
+                                  {"type": network_type,
+                                   "segment": raw_segment})
                         count = (session.query(self.model).
                                  filter_by(allocated=False, **raw_segment).
                                  update({"allocated": True}))
                         if count:
                             LOG.debug("%(type)s segment %(segment)s allocate "
                                       "done ",
-                                      type=network_type, segment=raw_segment)
+                                  {"type": network_type,
+                                   "segment": raw_segment})
                             return alloc
 
                         # Segment allocated or deleted since select
                         LOG.debug("%(type)s segment %(segment)s allocate "
                                   "failed: segment has been allocated or "
                                   "deleted",
-                                  type=network_type, segment=raw_segment)
+                                  {"type": network_type,
+                                   "segment": raw_segment})
 
                 # Segment to create or already allocated
                 LOG.debug("%(type)s segment %(segment)s create started",
-                          type=network_type, segment=raw_segment)
+                          {"type": network_type, "segment": raw_segment})
                 alloc = self.model(allocated=True, **raw_segment)
                 alloc.save(session)
                 LOG.debug("%(type)s segment %(segment)s create done",
-                          type=network_type, segment=raw_segment)
+                          {"type": network_type, "segment": raw_segment})
 
         except db_exc.DBDuplicateEntry:
             # Segment already allocated (insert failure)
             alloc = None
             LOG.debug("%(type)s segment %(segment)s create failed",
-                      type=network_type, segment=raw_segment)
+                      {"type": network_type, "segment": raw_segment})
 
         return alloc
 
@@ -115,24 +118,24 @@ class TypeDriverHelper(api.TypeDriver):
                 raw_segment = dict((k, alloc[k]) for k in self.primary_keys)
                 LOG.debug("%(type)s segment allocate from pool, attempt "
                           "%(attempt)s started with %(segment)s ",
-                          type=network_type, attempt=attempt,
-                          segment=raw_segment)
+                          {"type": network_type, "attempt": attempt,
+                           "segment": raw_segment})
                 count = (session.query(self.model).
                          filter_by(allocated=False, **raw_segment).
                          update({"allocated": True}))
                 if count:
                     LOG.debug("%(type)s segment allocate from pool, attempt "
                               "%(attempt)s success with %(segment)s ",
-                              type=network_type, attempt=attempt,
-                              segment=raw_segment)
+                              {"type": network_type, "attempt": attempt,
+                               "segment": raw_segment})
                     return alloc
 
                 # Segment allocated since select
                 LOG.debug("Allocate %(type)s segment from pool, "
                           "attempt %(attempt)s failed with segment "
                           "%(segment)s",
-                          type=network_type, attempt=attempt,
-                          segment=raw_segment)
+                          {"type": network_type, "attempt": attempt,
+                           "segment": raw_segment})
 
         LOG.warning(_("Allocate %(type)s segment from pool failed "
                       "after %(number)s failed attempts"),
index 24f8eea4e1a0acd6a5e40abbef361387044f71bb..b1543261a8c7a7dc595d4f98b1f710eadc1201bb 100644 (file)
@@ -13,6 +13,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import fixtures
+import logging
 import mock
 from sqlalchemy.orm import query
 
@@ -42,6 +44,12 @@ class HelpersTest(base.BaseTestCase):
         self.driver._sync_vlan_allocations()
         self.session = db.get_session()
         self.addCleanup(db.clear_db)
+        self.useFixture(
+            fixtures.FakeLogger(
+                name=helpers.__name__,
+                format=base.LOG_FORMAT,
+                level=logging.DEBUG
+            ))
 
     def check_raw_segment(self, expected, observed):
         for key, value in expected.items():