Correct LOG.debug use
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
This commit is contained in:
parent
ef379f7f97
commit
c3e7192489
@ -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"),
|
||||
|
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user