Improve logging in octavia.controller

We should delegate (when possible) formatting to the logger in order to
perform formatting only when needed, by using:

 LOG.<level>(message, data)

instead of:

 LOG.<level>(message % data)

and

 try:
   ...
 except ...:
   LOG.exception("lorem ipsum")

instead of:

 try:
   ...
 except ... as e:
   LOG.error("lorem ipsum: %s:", e)

This change removes also some incorrect usages of _LW in debug logs.

Change-Id: I6c62ceffbb99d2dee76160d398c6166132f6471c
This commit is contained in:
Cedric Brandily 2015-10-01 22:11:19 +02:00
parent cc67be5e5f
commit c287c9f447
7 changed files with 88 additions and 106 deletions

View File

@ -48,12 +48,12 @@ class HealthManager(object):
if amp is None: if amp is None:
break break
failover_count += 1 failover_count += 1
LOG.info(_LI("Stale amphora's id is: %s") % LOG.info(_LI("Stale amphora's id is: %s"),
amp.amphora_id) amp.amphora_id)
executor.submit(self.cw.failover_amphora, executor.submit(self.cw.failover_amphora,
amp.amphora_id) amp.amphora_id)
if failover_count > 0: if failover_count > 0:
LOG.info(_LI("Failed over %s amphora") % LOG.info(_LI("Failed over %s amphora"),
failover_count) failover_count)
finally: finally:
executor.shutdown(wait=True) executor.shutdown(wait=True)

View File

@ -41,8 +41,8 @@ class SpareAmphora(object):
session = db_api.get_session() session = db_api.get_session()
conf_spare_cnt = CONF.house_keeping.spare_amphora_pool_size conf_spare_cnt = CONF.house_keeping.spare_amphora_pool_size
curr_spare_cnt = self.amp_repo.get_spare_amphora_count(session) curr_spare_cnt = self.amp_repo.get_spare_amphora_count(session)
LOG.debug("Required Spare Amphora count : %d" % conf_spare_cnt) LOG.debug("Required Spare Amphora count : %d", conf_spare_cnt)
LOG.debug("Current Spare Amphora count : %d" % curr_spare_cnt) LOG.debug("Current Spare Amphora count : %d", curr_spare_cnt)
diff_count = conf_spare_cnt - curr_spare_cnt diff_count = conf_spare_cnt - curr_spare_cnt
# When the current spare amphora is less than required # When the current spare amphora is less than required
@ -52,7 +52,7 @@ class SpareAmphora(object):
# Call Amphora Create Flow diff_count times # Call Amphora Create Flow diff_count times
for i in range(1, diff_count + 1): for i in range(1, diff_count + 1):
LOG.debug("Starting amphorae number %d ..." % i) LOG.debug("Starting amphorae number %d ...", i)
self.cw.create_amphora() self.cw.create_amphora()
else: else:
@ -76,6 +76,6 @@ class DatabaseCleanup(object):
for amp in amphora: for amp in amphora:
if self.amp_health_repo.check_amphora_expired(session, amp.id, if self.amp_health_repo.check_amphora_expired(session, amp.id,
exp_age): exp_age):
LOG.info(_LI('Attempting to delete Amphora id : %s') % amp.id) LOG.info(_LI('Attempting to delete Amphora id : %s'), amp.id)
self.amp_repo.delete(session, id=amp.id) self.amp_repo.delete(session, id=amp.id)
LOG.info(_LI('Deleted Amphora id : %s') % amp.id) LOG.info(_LI('Deleted Amphora id : %s'), amp.id)

View File

@ -41,53 +41,53 @@ class Endpoint(object):
).driver ).driver
def create_load_balancer(self, context, load_balancer_id): def create_load_balancer(self, context, load_balancer_id):
LOG.info(_LI('Creating load balancer \'%s\'...') % load_balancer_id) LOG.info(_LI('Creating load balancer \'%s\'...'), load_balancer_id)
self.worker.create_load_balancer(load_balancer_id) self.worker.create_load_balancer(load_balancer_id)
def update_load_balancer(self, context, load_balancer_id, def update_load_balancer(self, context, load_balancer_id,
load_balancer_updates): load_balancer_updates):
LOG.info(_LI('Updating load balancer \'%s\'...') % load_balancer_id) LOG.info(_LI('Updating load balancer \'%s\'...'), load_balancer_id)
self.worker.update_load_balancer(load_balancer_id, self.worker.update_load_balancer(load_balancer_id,
load_balancer_updates) load_balancer_updates)
def delete_load_balancer(self, context, load_balancer_id): def delete_load_balancer(self, context, load_balancer_id):
LOG.info(_LI('Deleting load balancer \'%s\'...') % load_balancer_id) LOG.info(_LI('Deleting load balancer \'%s\'...'), load_balancer_id)
self.worker.delete_load_balancer(load_balancer_id) self.worker.delete_load_balancer(load_balancer_id)
def create_listener(self, context, listener_id): def create_listener(self, context, listener_id):
LOG.info(_LI('Creating listener \'%s\'...') % listener_id) LOG.info(_LI('Creating listener \'%s\'...'), listener_id)
self.worker.create_listener(listener_id) self.worker.create_listener(listener_id)
def update_listener(self, context, listener_id, listener_updates): def update_listener(self, context, listener_id, listener_updates):
LOG.info(_LI('Updating listener \'%s\'...') % listener_id) LOG.info(_LI('Updating listener \'%s\'...'), listener_id)
self.worker.update_listener(listener_id, listener_updates) self.worker.update_listener(listener_id, listener_updates)
def delete_listener(self, context, listener_id): def delete_listener(self, context, listener_id):
LOG.info(_LI('Deleting listener \'%s\'...') % listener_id) LOG.info(_LI('Deleting listener \'%s\'...'), listener_id)
self.worker.delete_listener(listener_id) self.worker.delete_listener(listener_id)
def create_pool(self, context, pool_id): def create_pool(self, context, pool_id):
LOG.info(_LI('Creating pool \'%s\'...') % pool_id) LOG.info(_LI('Creating pool \'%s\'...'), pool_id)
self.worker.create_pool(pool_id) self.worker.create_pool(pool_id)
def update_pool(self, context, pool_id, pool_updates): def update_pool(self, context, pool_id, pool_updates):
LOG.info(_LI('Updating pool \'%s\'...') % pool_id) LOG.info(_LI('Updating pool \'%s\'...'), pool_id)
self.worker.update_pool(pool_id, pool_updates) self.worker.update_pool(pool_id, pool_updates)
def delete_pool(self, context, pool_id): def delete_pool(self, context, pool_id):
LOG.info(_LI('Deleting pool \'%s\'...') % pool_id) LOG.info(_LI('Deleting pool \'%s\'...'), pool_id)
self.worker.delete_pool(pool_id) self.worker.delete_pool(pool_id)
def create_health_monitor(self, context, pool_id): def create_health_monitor(self, context, pool_id):
LOG.info(_LI('Creating health monitor on pool \'%s\'...') % pool_id) LOG.info(_LI('Creating health monitor on pool \'%s\'...'), pool_id)
self.worker.create_health_monitor(pool_id) self.worker.create_health_monitor(pool_id)
def update_health_monitor(self, context, pool_id, health_monitor_updates): def update_health_monitor(self, context, pool_id, health_monitor_updates):
LOG.info(_LI('Updating health monitor on pool \'%s\'...') % pool_id) LOG.info(_LI('Updating health monitor on pool \'%s\'...'), pool_id)
self.worker.update_health_monitor(pool_id, health_monitor_updates) self.worker.update_health_monitor(pool_id, health_monitor_updates)
def delete_health_monitor(self, context, pool_id): def delete_health_monitor(self, context, pool_id):
LOG.info(_LI('Deleting health monitor on pool \'%s\'...') % pool_id) LOG.info(_LI('Deleting health monitor on pool \'%s\'...'), pool_id)
self.worker.delete_health_monitor(pool_id) self.worker.delete_health_monitor(pool_id)
def create_member(self, context, member_id): def create_member(self, context, member_id):

View File

@ -190,8 +190,8 @@ class AmphoraPostNetworkPlug(BaseAmphoraTask):
for port in ports: for port in ports:
self.amphora_driver.post_network_plug(amphora, port) self.amphora_driver.post_network_plug(amphora, port)
LOG.debug("post_network_plug called on compute instance " LOG.debug("post_network_plug called on compute instance "
"{compute_id} for port {port_id}".format( "%(compute_id)s for port %(port_id)s",
compute_id=amphora.compute_id, port_id=port.id)) {"compute_id": amphora.compute_id, "port_id": port.id})
def revert(self, result, amphora, *args, **kwargs): def revert(self, result, amphora, *args, **kwargs):
"""Handle a failed post network plug.""" """Handle a failed post network plug."""

View File

@ -54,8 +54,7 @@ class ComputeCreate(BaseComputeTask):
""" """
ports = ports or [] ports = ports or []
config_drive_files = config_drive_files or {} config_drive_files = config_drive_files or {}
LOG.debug("Compute create execute for amphora with id %s" LOG.debug("Compute create execute for amphora with id %s", amphora_id)
% amphora_id)
try: try:
agent_cfg = agent_jinja_cfg.AgentJinjaTemplater() agent_cfg = agent_jinja_cfg.AgentJinjaTemplater()
@ -71,15 +70,14 @@ class ComputeCreate(BaseComputeTask):
port_ids=[port.id for port in ports], port_ids=[port.id for port in ports],
config_drive_files=config_drive_files) config_drive_files=config_drive_files)
LOG.debug("Server created with id: %s for amphora id: %s" % LOG.debug("Server created with id: %s for amphora id: %s",
(compute_id, amphora_id)) (compute_id, amphora_id))
return compute_id return compute_id
except Exception as e: except Exception:
LOG.error(_LE("Compute create for amphora id: %(amp)s " LOG.exception(_LE("Compute create for amphora id: %s failed"),
"failed: %(exp)s"), amphora_id)
{'amp': amphora_id, 'exp': e}) raise
raise e
def revert(self, result, amphora_id, *args, **kwargs): def revert(self, result, amphora_id, *args, **kwargs):
"""This method will revert the creation of the """This method will revert the creation of the
@ -94,9 +92,8 @@ class ComputeCreate(BaseComputeTask):
{'amp': amphora_id, 'comp': compute_id}) {'amp': amphora_id, 'comp': compute_id})
try: try:
self.compute.delete(compute_id) self.compute.delete(compute_id)
except Exception as e: except Exception:
LOG.error(_LE("Reverting compute create failed" LOG.exception(_LE("Reverting compute create failed"))
" with exception %s"), e)
class CertComputeCreate(ComputeCreate): class CertComputeCreate(ComputeCreate):
@ -126,22 +123,22 @@ class DeleteAmphoraeOnLoadBalancer(BaseComputeTask):
for amp in loadbalancer.amphorae: for amp in loadbalancer.amphorae:
try: try:
self.compute.delete(amp.compute_id) self.compute.delete(amp.compute_id)
except Exception as e: except Exception:
LOG.error(_LE("Compute delete for amphora id: %(amp)s failed:" LOG.exception(_LE("Compute delete for amphora id: %s failed"),
"%(exp)s"), {'amp': amp.id, 'exp': e}) amp.id)
raise e raise
class ComputeDelete(BaseComputeTask): class ComputeDelete(BaseComputeTask):
def execute(self, amphora): def execute(self, amphora):
LOG.debug("Compute delete execute for amphora with id %s" % amphora.id) LOG.debug("Compute Delete execute for amphora with id %s", amphora.id)
try: try:
self.compute.delete(compute_id=amphora.compute_id) self.compute.delete(compute_id=amphora.compute_id)
except Exception as e: except Exception:
LOG.error(_LE("Compute delete for amphora id: %(amp)s failed:" LOG.exception(_LE("Compute delete for amphora id: %s failed"),
"%(exp)s"), {'amp': amphora.id, 'exp': e}) amphora.id)
raise e raise
class ComputeWait(BaseComputeTask): class ComputeWait(BaseComputeTask):

View File

@ -56,7 +56,7 @@ class CreateAmphoraInDB(BaseDatabaseTask):
id=uuidutils.generate_uuid(), id=uuidutils.generate_uuid(),
status=constants.PENDING_CREATE) status=constants.PENDING_CREATE)
LOG.info(_LI("Created Amphora in DB with id %s") % amphora.id) LOG.info(_LI("Created Amphora in DB with id %s"), amphora.id)
return amphora.id return amphora.id
def revert(self, result, *args, **kwargs): def revert(self, result, *args, **kwargs):
@ -89,7 +89,7 @@ class MarkLBAmphoraeDeletedInDB(BaseDatabaseTask):
""" """
for amp in loadbalancer.amphorae: for amp in loadbalancer.amphorae:
LOG.debug(_LW("Marking amphora %s DELETED ") % amp.id) LOG.debug("Marking amphora %s DELETED ", amp.id)
self.amphora_repo.update(db_apis.get_session(), self.amphora_repo.update(db_apis.get_session(),
id=amp.id, status=constants.DELETED) id=amp.id, status=constants.DELETED)
@ -107,7 +107,7 @@ class DeleteHealthMonitorInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("DB delete health monitor for id: %s " % pool_id) LOG.debug("DB delete health monitor for id: %s ", pool_id)
self.health_mon_repo.delete(db_apis.get_session(), pool_id=pool_id) self.health_mon_repo.delete(db_apis.get_session(), pool_id=pool_id)
def revert(self, pool_id, *args, **kwargs): def revert(self, pool_id, *args, **kwargs):
@ -136,8 +136,7 @@ class DeleteMemberInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("DB delete member for id: %s " % LOG.debug("DB delete member for id: %s ", member_id)
member_id)
self.member_repo.delete(db_apis.get_session(), id=member_id) self.member_repo.delete(db_apis.get_session(), id=member_id)
def revert(self, member_id, *args, **kwargs): def revert(self, member_id, *args, **kwargs):
@ -162,7 +161,7 @@ class DeleteListenerInDB(BaseDatabaseTask):
:param listener: The listener to delete :param listener: The listener to delete
:returns: None :returns: None
""" """
LOG.debug(_LW("Delete in DB for listener id: %s") % listener.id) LOG.debug("Delete in DB for listener id: %s", listener.id)
self.listener_repo.delete(db_apis.get_session(), id=listener.id) self.listener_repo.delete(db_apis.get_session(), id=listener.id)
def revert(self, listener_id, *args, **kwargs): def revert(self, listener_id, *args, **kwargs):
@ -189,8 +188,7 @@ class DeletePoolInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Delete in DB for pool id: %s " % LOG.debug("Delete in DB for pool id: %s ", pool.id)
pool.id)
self.pool_repo.delete(db_apis.get_session(), id=pool.id) self.pool_repo.delete(db_apis.get_session(), id=pool.id)
def revert(self, pool_id, *args, **kwargs): def revert(self, pool_id, *args, **kwargs):
@ -216,8 +214,7 @@ class ReloadAmphora(BaseDatabaseTask):
:returns: The amphora object :returns: The amphora object
""" """
LOG.debug("Get amphora from DB for amphora id: %s " % LOG.debug("Get amphora from DB for amphora id: %s ", amphora_id)
amphora_id)
return self.amphora_repo.get(db_apis.get_session(), id=amphora_id) return self.amphora_repo.get(db_apis.get_session(), id=amphora_id)
@ -231,7 +228,7 @@ class ReloadLoadBalancer(BaseDatabaseTask):
:returns: The load balancer object :returns: The load balancer object
""" """
LOG.debug("Get load balancer from DB for load balancer id: %s " % LOG.debug("Get load balancer from DB for load balancer id: %s ",
loadbalancer_id) loadbalancer_id)
return self.loadbalancer_repo.get(db_apis.get_session(), return self.loadbalancer_repo.get(db_apis.get_session(),
id=loadbalancer_id) id=loadbalancer_id)
@ -281,19 +278,20 @@ class MapLoadbalancerToAmphora(BaseDatabaseTask):
unable to allocate an Amphora unable to allocate an Amphora
""" """
LOG.debug("Allocating an Amphora for load balancer with id %s" % LOG.debug("Allocating an Amphora for load balancer with id %s",
loadbalancer_id) loadbalancer_id)
amp = self.amphora_repo.allocate_and_associate( amp = self.amphora_repo.allocate_and_associate(
db_apis.get_session(), db_apis.get_session(),
loadbalancer_id) loadbalancer_id)
if amp is None: if amp is None:
LOG.debug("No Amphora available for load balancer with id %s" % LOG.debug("No Amphora available for load balancer with id %s",
loadbalancer_id) loadbalancer_id)
raise exceptions.NoReadyAmphoraeException() raise exceptions.NoReadyAmphoraeException()
LOG.info(_LI("Allocated Amphora with id %(amp)s for load balancer " LOG.info(_LI("Allocated Amphora with id %(amp)s for load balancer "
"with id %(lb)s") % {"amp": amp.id, "lb": loadbalancer_id}) "with id %(lb)s"),
{"amp": amp.id, "lb": loadbalancer_id})
return amp.id return amp.id
@ -309,7 +307,7 @@ class MarkAmphoraAllocatedInDB(BaseDatabaseTask):
"""Mark amphora as allocated to a load balancer in DB.""" """Mark amphora as allocated to a load balancer in DB."""
LOG.info(_LI("Mark ALLOCATED in DB for amphora: %(amp)s with " LOG.info(_LI("Mark ALLOCATED in DB for amphora: %(amp)s with "
"compute id %(comp)s for load balancer: %(lb)s") % "compute id %(comp)s for load balancer: %(lb)s"),
{"amp": amphora.id, "comp": amphora.compute_id, {"amp": amphora.id, "comp": amphora.compute_id,
"lb": loadbalancer_id}) "lb": loadbalancer_id})
self.amphora_repo.update(db_apis.get_session(), amphora.id, self.amphora_repo.update(db_apis.get_session(), amphora.id,
@ -337,7 +335,7 @@ class MarkAmphoraBootingInDB(BaseDatabaseTask):
def execute(self, amphora_id, compute_id): def execute(self, amphora_id, compute_id):
"""Mark amphora booting in DB.""" """Mark amphora booting in DB."""
LOG.debug("Mark BOOTING in DB for amphora: %s with compute id %s" % LOG.debug("Mark BOOTING in DB for amphora: %s with compute id %s",
(amphora_id, compute_id)) (amphora_id, compute_id))
self.amphora_repo.update(db_apis.get_session(), amphora_id, self.amphora_repo.update(db_apis.get_session(), amphora_id,
status=constants.AMPHORA_BOOTING, status=constants.AMPHORA_BOOTING,
@ -366,8 +364,7 @@ class MarkAmphoraDeletedInDB(BaseDatabaseTask):
def execute(self, amphora): def execute(self, amphora):
"""Mark the amphora as pending delete in DB.""" """Mark the amphora as pending delete in DB."""
LOG.debug("Mark DELETED in DB for amphora: %s " LOG.debug("Mark DELETED in DB for amphora: %s with compute id %s",
"with compute id %s" %
(amphora.id, amphora.compute_id)) (amphora.id, amphora.compute_id))
self.amphora_repo.update(db_apis.get_session(), amphora.id, self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.DELETED) status=constants.DELETED)
@ -392,7 +389,7 @@ class MarkAmphoraPendingDeleteInDB(BaseDatabaseTask):
"""Mark the amphora as pending delete in DB.""" """Mark the amphora as pending delete in DB."""
LOG.debug("Mark PENDING DELETE in DB for amphora: %s " LOG.debug("Mark PENDING DELETE in DB for amphora: %s "
"with compute id %s" % "with compute id %s",
(amphora.id, amphora.compute_id)) (amphora.id, amphora.compute_id))
self.amphora_repo.update(db_apis.get_session(), amphora.id, self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.PENDING_DELETE) status=constants.PENDING_DELETE)
@ -417,7 +414,7 @@ class MarkAmphoraPendingUpdateInDB(BaseDatabaseTask):
"""Mark the amphora as pending upate in DB.""" """Mark the amphora as pending upate in DB."""
LOG.debug("Mark PENDING UPDATE in DB for amphora: %s " LOG.debug("Mark PENDING UPDATE in DB for amphora: %s "
"with compute id %s" % "with compute id %s",
(amphora.id, amphora.compute_id)) (amphora.id, amphora.compute_id))
self.amphora_repo.update(db_apis.get_session(), amphora.id, self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.PENDING_UPDATE) status=constants.PENDING_UPDATE)
@ -443,8 +440,8 @@ class MarkAmphoraReadyInDB(BaseDatabaseTask):
"""Mark amphora as ready in DB.""" """Mark amphora as ready in DB."""
LOG.info(_LI("Mark READY in DB for amphora: %(amp)s with compute " LOG.info(_LI("Mark READY in DB for amphora: %(amp)s with compute "
"id %(comp)s") % {"amp": amphora.id, "id %(comp)s"),
"comp": amphora.compute_id}) {"amp": amphora.id, "comp": amphora.compute_id})
self.amphora_repo.update(db_apis.get_session(), amphora.id, self.amphora_repo.update(db_apis.get_session(), amphora.id,
status=constants.AMPHORA_READY, status=constants.AMPHORA_READY,
compute_id=amphora.compute_id, compute_id=amphora.compute_id,
@ -486,7 +483,7 @@ class MarkLBActiveInDB(BaseDatabaseTask):
def execute(self, loadbalancer): def execute(self, loadbalancer):
"""Mark the load balancer as active in DB.""" """Mark the load balancer as active in DB."""
LOG.info(_LI("Mark ACTIVE in DB for load balancer id: %s") % LOG.info(_LI("Mark ACTIVE in DB for load balancer id: %s"),
loadbalancer.id) loadbalancer.id)
self.loadbalancer_repo.update(db_apis.get_session(), self.loadbalancer_repo.update(db_apis.get_session(),
loadbalancer.id, loadbalancer.id,
@ -511,7 +508,7 @@ class MarkLBDeletedInDB(BaseDatabaseTask):
def execute(self, loadbalancer): def execute(self, loadbalancer):
"""Mark the load balancer as deleted in DB.""" """Mark the load balancer as deleted in DB."""
LOG.debug("Mark DELETED in DB for load balancer id: %s" % LOG.debug("Mark DELETED in DB for load balancer id: %s",
loadbalancer.id) loadbalancer.id)
self.loadbalancer_repo.update(db_apis.get_session(), self.loadbalancer_repo.update(db_apis.get_session(),
loadbalancer.id, loadbalancer.id,
@ -536,7 +533,7 @@ class MarkLBPendingDeleteInDB(BaseDatabaseTask):
def execute(self, loadbalancer): def execute(self, loadbalancer):
"""Mark the load balancer as pending delete in DB.""" """Mark the load balancer as pending delete in DB."""
LOG.debug("Mark PENDING DELETE in DB for load balancer id: %s" % LOG.debug("Mark PENDING DELETE in DB for load balancer id: %s",
loadbalancer.id) loadbalancer.id)
self.loadbalancer_repo.update(db_apis.get_session(), self.loadbalancer_repo.update(db_apis.get_session(),
loadbalancer.id, loadbalancer.id,
@ -563,7 +560,7 @@ class MarkLBAndListenerActiveInDB(BaseDatabaseTask):
"""Mark the load balancer and listener as active in DB.""" """Mark the load balancer and listener as active in DB."""
LOG.debug("Mark ACTIVE in DB for load balancer id: %s " LOG.debug("Mark ACTIVE in DB for load balancer id: %s "
"and listener id: %s" % (loadbalancer.id, listener.id)) "and listener id: %s", (loadbalancer.id, listener.id))
self.loadbalancer_repo.update(db_apis.get_session(), self.loadbalancer_repo.update(db_apis.get_session(),
loadbalancer.id, loadbalancer.id,
provisioning_status=constants.ACTIVE) provisioning_status=constants.ACTIVE)
@ -598,8 +595,7 @@ class MarkListenerActiveInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Mark ACTIVE in DB for listener id: %s " % LOG.debug("Mark ACTIVE in DB for listener id: %s ", listener.id)
listener.id)
self.listener_repo.update(db_apis.get_session(), listener.id, self.listener_repo.update(db_apis.get_session(), listener.id,
provisioning_status=constants.ACTIVE) provisioning_status=constants.ACTIVE)
@ -628,8 +624,7 @@ class MarkListenerDeletedInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Mark DELETED in DB for listener id: %s " % LOG.debug("Mark DELETED in DB for listener id: %s ", listener.id)
listener.id)
self.listener_repo.update(db_apis.get_session(), listener.id, self.listener_repo.update(db_apis.get_session(), listener.id,
provisioning_status=constants.DELETED) provisioning_status=constants.DELETED)
@ -654,7 +649,7 @@ class MarkListenerPendingDeleteInDB(BaseDatabaseTask):
def execute(self, listener): def execute(self, listener):
"""Mark the listener as pending delete in DB.""" """Mark the listener as pending delete in DB."""
LOG.debug("Mark PENDING DELETE in DB for listener id: %s" % LOG.debug("Mark PENDING DELETE in DB for listener id: %s",
listener.id) listener.id)
self.listener_repo.update(db_apis.get_session(), listener.id, self.listener_repo.update(db_apis.get_session(), listener.id,
provisioning_status=constants.PENDING_DELETE) provisioning_status=constants.PENDING_DELETE)
@ -682,8 +677,7 @@ class UpdateLoadbalancerInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Update DB for listener id: %s " % LOG.debug("Update DB for listener id: %s ", loadbalancer.id)
loadbalancer.id)
self.loadbalancer_repo.update(db_apis.get_session(), loadbalancer.id, self.loadbalancer_repo.update(db_apis.get_session(), loadbalancer.id,
**update_dict) **update_dict)
@ -714,8 +708,7 @@ class UpdateHealthMonInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Update DB for health monitor id: %s " % LOG.debug("Update DB for health monitor id: %s ", health_mon.pool_id)
health_mon.pool_id)
self.health_mon_repo.update(db_apis.get_session(), health_mon.pool_id, self.health_mon_repo.update(db_apis.get_session(), health_mon.pool_id,
**update_dict) **update_dict)
@ -746,8 +739,7 @@ class UpdateListenerInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Update DB for listener id: %s " % LOG.debug("Update DB for listener id: %s ", listener.id)
listener.id)
self.listener_repo.update(db_apis.get_session(), listener.id, self.listener_repo.update(db_apis.get_session(), listener.id,
**update_dict) **update_dict)
@ -778,8 +770,7 @@ class UpdateMemberInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Update DB for member id: %s " % LOG.debug("Update DB for member id: %s ", member.id)
member.id)
self.member_repo.update(db_apis.get_session(), member.id, self.member_repo.update(db_apis.get_session(), member.id,
**update_dict) **update_dict)
@ -810,8 +801,7 @@ class UpdatePoolInDB(BaseDatabaseTask):
:returns: None :returns: None
""" """
LOG.debug("Update DB for pool id: %s " % LOG.debug("Update DB for pool id: %s ", pool.id)
pool.id)
self.pool_repo.update(db_apis.get_session(), pool.id, self.pool_repo.update(db_apis.get_session(), pool.id,
**update_dict) **update_dict)

View File

@ -50,7 +50,7 @@ class CalculateAmphoraDelta(BaseNetworkTask):
default_provides = constants.DELTA default_provides = constants.DELTA
def execute(self, loadbalancer, amphora): def execute(self, loadbalancer, amphora):
LOG.debug("Calculating network delta for amphora id: %s" % amphora.id) LOG.debug("Calculating network delta for amphora id: %s", amphora.id)
# Figure out what networks we want # Figure out what networks we want
# seed with lb network(s) # seed with lb network(s)
@ -129,7 +129,7 @@ class GetPlumbedNetworks(BaseNetworkTask):
def execute(self, amphora): def execute(self, amphora):
"""Get plumbed networks for the amphora.""" """Get plumbed networks for the amphora."""
LOG.debug("Getting plumbed networks for amphora id: %s" % amphora.id) LOG.debug("Getting plumbed networks for amphora id: %s", amphora.id)
return self.network_driver.get_plugged_networks(amphora.compute_id) return self.network_driver.get_plugged_networks(amphora.compute_id)
@ -143,10 +143,10 @@ class PlugNetworks(BaseNetworkTask):
def execute(self, amphora, delta): def execute(self, amphora, delta):
"""Update the amphora networks for the delta.""" """Update the amphora networks for the delta."""
LOG.debug("Plug or unplug networks for amphora id: %s" % amphora.id) LOG.debug("Plug or unplug networks for amphora id: %s", amphora.id)
if not delta: if not delta:
LOG.debug("No network deltas for amphora id: %s" % amphora.id) LOG.debug("No network deltas for amphora id: %s", amphora.id)
return None return None
# add nics # add nics
@ -181,20 +181,18 @@ class UnPlugNetworks(BaseNetworkTask):
LOG.debug("Unplug network for amphora") LOG.debug("Unplug network for amphora")
if not delta: if not delta:
LOG.debug("No network deltas for amphora id: %s" % amphora.id) LOG.debug("No network deltas for amphora id: %s", amphora.id)
return None return None
for nic in delta.delete_nics: for nic in delta.delete_nics:
try: try:
self.network_driver.unplug_network(amphora.compute_id, self.network_driver.unplug_network(amphora.compute_id,
nic.network_id) nic.network_id)
except base.NetworkNotFound as e: except base.NetworkNotFound:
LOG.debug("Network %d not found ", nic.network_id) LOG.debug("Network %d not found", nic.network_id)
pass pass
except Exception as e: except Exception:
LOG.error( LOG.exception(_LE("Unable to unplug network"))
_LE("Unable to unplug network - exception: %s"),
str(e))
pass # Todo(german) follow up if that makes sense pass # Todo(german) follow up if that makes sense
@ -245,9 +243,8 @@ class HandleNetworkDeltas(BaseNetworkTask):
nic.network_id) nic.network_id)
except base.NetworkNotFound: except base.NetworkNotFound:
LOG.debug("Network %d not found ", nic.network_id) LOG.debug("Network %d not found ", nic.network_id)
except Exception as e: except Exception:
LOG.error( LOG.exception(_LE("Unable to unplug network"))
_LE("Unable to unplug network - exception: %s"), e)
return added_ports return added_ports
def revert(self, result, deltas): def revert(self, result, deltas):
@ -275,7 +272,7 @@ class PlugVIP(BaseNetworkTask):
def execute(self, loadbalancer): def execute(self, loadbalancer):
"""Plumb a vip to an amphora.""" """Plumb a vip to an amphora."""
LOG.debug("Plumbing VIP for loadbalancer id: %s" % loadbalancer.id) LOG.debug("Plumbing VIP for loadbalancer id: %s", loadbalancer.id)
amps_data = self.network_driver.plug_vip(loadbalancer, amps_data = self.network_driver.plug_vip(loadbalancer,
loadbalancer.vip) loadbalancer.vip)
@ -301,10 +298,9 @@ class UnplugVIP(BaseNetworkTask):
LOG.debug("Unplug vip on amphora") LOG.debug("Unplug vip on amphora")
try: try:
self.network_driver.unplug_vip(loadbalancer, loadbalancer.vip) self.network_driver.unplug_vip(loadbalancer, loadbalancer.vip)
except Exception as e: except Exception:
LOG.error(_LE("Unable to unplug vip from load balancer" LOG.exception(_LE("Unable to unplug vip from load balancer %s"),
"{id}: exception: {ex}").format(id=loadbalancer.id, loadbalancer.id)
ex=e.message))
class AllocateVIP(BaseNetworkTask): class AllocateVIP(BaseNetworkTask):
@ -353,7 +349,7 @@ class UpdateVIP(BaseNetworkTask):
"""Task to update a VIP.""" """Task to update a VIP."""
def execute(self, loadbalancer): def execute(self, loadbalancer):
LOG.debug("Updating VIP of load_balancer %s." % loadbalancer.id) LOG.debug("Updating VIP of load_balancer %s.", loadbalancer.id)
self.network_driver.update_vip(loadbalancer) self.network_driver.update_vip(loadbalancer)
@ -368,8 +364,7 @@ class GetAmphoraeNetworkConfigs(BaseNetworkTask):
amp_net_configs = {} amp_net_configs = {}
for amp in loadbalancer.amphorae: for amp in loadbalancer.amphorae:
if amp.status != constants.DELETED: if amp.status != constants.DELETED:
LOG.debug("Retrieving network details for " LOG.debug("Retrieving network details for amphora %s", amp.id)
"amphora {0}".format(amp.id))
vrrp_port = self.network_driver.get_port(amp.vrrp_port_id) vrrp_port = self.network_driver.get_port(amp.vrrp_port_id)
vrrp_subnet = self.network_driver.get_subnet( vrrp_subnet = self.network_driver.get_subnet(
vrrp_port.get_subnet_id(amp.vrrp_ip)) vrrp_port.get_subnet_id(amp.vrrp_ip))
@ -392,7 +387,7 @@ class FailoverPreparationForAmphora(BaseNetworkTask):
"""Task to prepare an amphora for failover.""" """Task to prepare an amphora for failover."""
def execute(self, amphora): def execute(self, amphora):
LOG.debug("Prepare amphora %s for failover." % amphora.id) LOG.debug("Prepare amphora %s for failover.", amphora.id)
self.network_driver.failover_preparation(amphora) self.network_driver.failover_preparation(amphora)
@ -401,7 +396,7 @@ class RetrievePortIDsOnAmphoraExceptLBNetwork(BaseNetworkTask):
"""Task retrieving all the port ids on an amphora, except lb network.""" """Task retrieving all the port ids on an amphora, except lb network."""
def execute(self, amphora): def execute(self, amphora):
LOG.debug("Retrieve all but the lb network port id on amphora %s." % LOG.debug("Retrieve all but the lb network port id on amphora %s.",
amphora.id) amphora.id)
interfaces = self.network_driver.get_plugged_networks( interfaces = self.network_driver.get_plugged_networks(