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
|
# Segment not allocated
|
||||||
LOG.debug("%(type)s segment %(segment)s allocate "
|
LOG.debug("%(type)s segment %(segment)s allocate "
|
||||||
"started ",
|
"started ",
|
||||||
type=network_type, segment=raw_segment)
|
{"type": network_type,
|
||||||
|
"segment": raw_segment})
|
||||||
count = (session.query(self.model).
|
count = (session.query(self.model).
|
||||||
filter_by(allocated=False, **raw_segment).
|
filter_by(allocated=False, **raw_segment).
|
||||||
update({"allocated": True}))
|
update({"allocated": True}))
|
||||||
if count:
|
if count:
|
||||||
LOG.debug("%(type)s segment %(segment)s allocate "
|
LOG.debug("%(type)s segment %(segment)s allocate "
|
||||||
"done ",
|
"done ",
|
||||||
type=network_type, segment=raw_segment)
|
{"type": network_type,
|
||||||
|
"segment": raw_segment})
|
||||||
return alloc
|
return alloc
|
||||||
|
|
||||||
# Segment allocated or deleted since select
|
# Segment allocated or deleted since select
|
||||||
LOG.debug("%(type)s segment %(segment)s allocate "
|
LOG.debug("%(type)s segment %(segment)s allocate "
|
||||||
"failed: segment has been allocated or "
|
"failed: segment has been allocated or "
|
||||||
"deleted",
|
"deleted",
|
||||||
type=network_type, segment=raw_segment)
|
{"type": network_type,
|
||||||
|
"segment": raw_segment})
|
||||||
|
|
||||||
# Segment to create or already allocated
|
# Segment to create or already allocated
|
||||||
LOG.debug("%(type)s segment %(segment)s create started",
|
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 = self.model(allocated=True, **raw_segment)
|
||||||
alloc.save(session)
|
alloc.save(session)
|
||||||
LOG.debug("%(type)s segment %(segment)s create done",
|
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:
|
except db_exc.DBDuplicateEntry:
|
||||||
# Segment already allocated (insert failure)
|
# Segment already allocated (insert failure)
|
||||||
alloc = None
|
alloc = None
|
||||||
LOG.debug("%(type)s segment %(segment)s create failed",
|
LOG.debug("%(type)s segment %(segment)s create failed",
|
||||||
type=network_type, segment=raw_segment)
|
{"type": network_type, "segment": raw_segment})
|
||||||
|
|
||||||
return alloc
|
return alloc
|
||||||
|
|
||||||
@ -115,24 +118,24 @@ class TypeDriverHelper(api.TypeDriver):
|
|||||||
raw_segment = dict((k, alloc[k]) for k in self.primary_keys)
|
raw_segment = dict((k, alloc[k]) for k in self.primary_keys)
|
||||||
LOG.debug("%(type)s segment allocate from pool, attempt "
|
LOG.debug("%(type)s segment allocate from pool, attempt "
|
||||||
"%(attempt)s started with %(segment)s ",
|
"%(attempt)s started with %(segment)s ",
|
||||||
type=network_type, attempt=attempt,
|
{"type": network_type, "attempt": attempt,
|
||||||
segment=raw_segment)
|
"segment": raw_segment})
|
||||||
count = (session.query(self.model).
|
count = (session.query(self.model).
|
||||||
filter_by(allocated=False, **raw_segment).
|
filter_by(allocated=False, **raw_segment).
|
||||||
update({"allocated": True}))
|
update({"allocated": True}))
|
||||||
if count:
|
if count:
|
||||||
LOG.debug("%(type)s segment allocate from pool, attempt "
|
LOG.debug("%(type)s segment allocate from pool, attempt "
|
||||||
"%(attempt)s success with %(segment)s ",
|
"%(attempt)s success with %(segment)s ",
|
||||||
type=network_type, attempt=attempt,
|
{"type": network_type, "attempt": attempt,
|
||||||
segment=raw_segment)
|
"segment": raw_segment})
|
||||||
return alloc
|
return alloc
|
||||||
|
|
||||||
# Segment allocated since select
|
# Segment allocated since select
|
||||||
LOG.debug("Allocate %(type)s segment from pool, "
|
LOG.debug("Allocate %(type)s segment from pool, "
|
||||||
"attempt %(attempt)s failed with segment "
|
"attempt %(attempt)s failed with segment "
|
||||||
"%(segment)s",
|
"%(segment)s",
|
||||||
type=network_type, attempt=attempt,
|
{"type": network_type, "attempt": attempt,
|
||||||
segment=raw_segment)
|
"segment": raw_segment})
|
||||||
|
|
||||||
LOG.warning(_("Allocate %(type)s segment from pool failed "
|
LOG.warning(_("Allocate %(type)s segment from pool failed "
|
||||||
"after %(number)s failed attempts"),
|
"after %(number)s failed attempts"),
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import fixtures
|
||||||
|
import logging
|
||||||
import mock
|
import mock
|
||||||
from sqlalchemy.orm import query
|
from sqlalchemy.orm import query
|
||||||
|
|
||||||
@ -42,6 +44,12 @@ class HelpersTest(base.BaseTestCase):
|
|||||||
self.driver._sync_vlan_allocations()
|
self.driver._sync_vlan_allocations()
|
||||||
self.session = db.get_session()
|
self.session = db.get_session()
|
||||||
self.addCleanup(db.clear_db)
|
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):
|
def check_raw_segment(self, expected, observed):
|
||||||
for key, value in expected.items():
|
for key, value in expected.items():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user