Browse Source

Stop translating log messages

This is in line with late i18n team requests, and to adopt the new N537
hacking check from neutron-lib.

Change-Id: Ieacc6d3cfcea6846054655312916d29c1bb40d43
Depends-On: I1a7fff4140e50deb0e10024dedfba45d793b20fe
changes/88/460688/4
Ihar Hrachyshka 4 years ago
parent
commit
ad6e1cebd7
  1. 12
      networking_ovn/_i18n.py
  2. 39
      networking_ovn/cmd/neutron_ovn_db_sync_util.py
  3. 52
      networking_ovn/l3/l3_ovn.py
  4. 24
      networking_ovn/ml2/mech_driver.py
  5. 3
      networking_ovn/ml2/qos_driver.py
  6. 150
      networking_ovn/ovn_db_sync.py
  7. 4
      networking_ovn/ovsdb/impl_idl_ovn.py
  8. 3
      networking_ovn/ovsdb/ovsdb_monitor.py
  9. 5
      networking_ovn/tests/functional/base.py
  10. 8
      networking_ovn/tests/unit/cmd/test_neutron_ovn_db_sync_util.py
  11. 4
      tox.ini

12
networking_ovn/_i18n.py

@ -18,7 +18,7 @@ DOMAIN = "networking_ovn"
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
# The translation function using the well-known name "_"
_ = _translators.primary
# The contextual translation function using the name "_C"
@ -27,16 +27,6 @@ _C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

39
networking_ovn/cmd/neutron_ovn_db_sync_util.py

@ -23,7 +23,6 @@ from neutron import manager
from neutron import opts as neutron_options
from neutron.plugins.ml2 import plugin as ml2_plugin
from networking_ovn._i18n import _LI, _LE
from networking_ovn.common import config as ovn_config
from networking_ovn.ml2 import mech_driver
from networking_ovn import ovn_db_sync
@ -75,16 +74,15 @@ def main():
try:
conf(project='neutron')
except TypeError:
LOG.error(_LE('Error parsing the configuration values. '
'Please verify.'))
LOG.error('Error parsing the configuration values. Please verify.')
return
logging.setup(conf, 'neutron_ovn_db_sync_util')
LOG.info(_LI('Started Neutron OVN db sync'))
LOG.info('Started Neutron OVN db sync')
mode = ovn_config.get_ovn_neutron_sync_mode()
if mode not in [ovn_db_sync.SYNC_MODE_LOG, ovn_db_sync.SYNC_MODE_REPAIR]:
LOG.error(_LE('Invalid sync mode : ["%s"]. Should be "log" or '
'"repair"'), mode)
LOG.error(
'Invalid sync mode : ["%s"]. Should be "log" or "repair"', mode)
return
# Validate and modify core plugin and ML2 mechanism drivers for syncing.
@ -93,23 +91,23 @@ def main():
cfg.CONF.core_plugin = (
'networking_ovn.cmd.neutron_ovn_db_sync_util.Ml2Plugin')
if not cfg.CONF.ml2.mechanism_drivers:
LOG.error(_LE('please use --config-file to specify '
'neutron and ml2 configuration file.'))
LOG.error('please use --config-file to specify '
'neutron and ml2 configuration file.')
return
if 'ovn' not in cfg.CONF.ml2.mechanism_drivers:
LOG.error(_LE('No "ovn" mechanism driver found : "%s".'),
LOG.error('No "ovn" mechanism driver found : "%s".',
cfg.CONF.ml2.mechanism_drivers)
return
cfg.CONF.set_override('mechanism_drivers', ['ovn-sync'], 'ml2')
conf.service_plugins = ['networking_ovn.l3.l3_ovn.OVNL3RouterPlugin']
else:
LOG.error(_LE('Invalid core plugin : ["%s"].'), cfg.CONF.core_plugin)
LOG.error('Invalid core plugin : ["%s"].', cfg.CONF.core_plugin)
return
try:
ovn_api = impl_idl_ovn.OvsdbNbOvnIdl(None)
except RuntimeError:
LOG.error(_LE('Invalid --ovn-ovn_nb_connection parameter provided.'))
LOG.error('Invalid --ovn-ovn_nb_connection parameter provided.')
return
manager.init()
@ -122,29 +120,28 @@ def main():
ctx = context.get_admin_context()
LOG.info(_LI('Syncing the networks and ports with mode : %s'), mode)
LOG.info('Syncing the networks and ports with mode : %s', mode)
try:
synchronizer.sync_address_sets(ctx)
except Exception:
LOG.exception(_LE("Error syncing the Address Sets. Check the "
"--database-connection value again"))
LOG.exception("Error syncing the Address Sets. Check the "
"--database-connection value again")
return
try:
synchronizer.sync_networks_ports_and_dhcp_opts(ctx)
except Exception:
LOG.exception(_LE("Error syncing Networks, Ports and DHCP options "
"for unknown reason please try again"))
LOG.exception("Error syncing Networks, Ports and DHCP options "
"for unknown reason please try again")
return
try:
synchronizer.sync_acls(ctx)
except Exception:
LOG.exception(_LE("Error syncing ACLs for unknown "
"reason please try again"))
LOG.exception("Error syncing ACLs for unknown reason please try again")
return
try:
synchronizer.sync_routers_and_rports(ctx)
except Exception:
LOG.exception(_LE("Error syncing Routers and Router ports "
"please try again"))
LOG.exception(
"Error syncing Routers and Router ports please try again")
return
LOG.info(_LI('Sync completed'))
LOG.info('Sync completed')

52
networking_ovn/l3/l3_ovn.py

@ -27,7 +27,6 @@ from neutron.db import common_db_mixin
from neutron.db import extraroute_db
from neutron.db import l3_gwmode_db
from networking_ovn._i18n import _LE, _LI
from networking_ovn.common import constants as ovn_const
from networking_ovn.common import extensions
from networking_ovn.common import utils
@ -52,7 +51,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
extensions.ML2_SUPPORTED_API_EXTENSIONS_OVN_L3
def __init__(self):
LOG.info(_LI("Starting OVNL3RouterPlugin"))
LOG.info("Starting OVNL3RouterPlugin")
super(OVNL3RouterPlugin, self).__init__()
self._nb_ovn_idl = None
self._sb_ovn_idl = None
@ -62,14 +61,14 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
@property
def _ovn(self):
if self._nb_ovn_idl is None:
LOG.info(_LI("Getting OvsdbNbOvnIdl"))
LOG.info("Getting OvsdbNbOvnIdl")
self._nb_ovn_idl = impl_idl_ovn.OvsdbNbOvnIdl(self)
return self._nb_ovn_idl
@property
def _sb_ovn(self):
if self._sb_ovn_idl is None:
LOG.info(_LI("Getting OvsdbSbOvnIdl"))
LOG.info("Getting OvsdbSbOvnIdl")
self._sb_ovn_idl = impl_idl_ovn.OvsdbSbOvnIdl(self)
return self._sb_ovn_idl
@ -150,8 +149,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
except Exception:
with excutils.save_and_reraise_exception():
self._delete_router_ext_gw(context, router_id, router)
LOG.error(_LE('Unable to add external router port %(id)s to'
'lrouter %(name)s'),
LOG.error('Unable to add external router port %(id)s to '
'lrouter %(name)s',
{'id': port['id'], 'name': lrouter_name})
# 2. Add default route with nexthop as ext_gw_ip
@ -161,9 +160,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
except Exception:
with excutils.save_and_reraise_exception():
self._delete_router_ext_gw(context, router_id, router)
LOG.error(_LE('Error updating routes %(route)s in lrouter '
'%(name)s'), {'route': route,
'name': lrouter_name})
LOG.error('Error updating routes %(route)s in lrouter '
'%(name)s', {'route': route, 'name': lrouter_name})
# 3. Add snat rules for tenant networks in lrouter if snat is enabled
if utils.is_snat_enabled(router):
@ -176,7 +174,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
except Exception:
with excutils.save_and_reraise_exception():
self._delete_router_ext_gw(context, router_id, router)
LOG.error(_LE('Error in updating SNAT for lrouter %s'),
LOG.error('Error in updating SNAT for lrouter %s',
lrouter_name)
def _delete_router_ext_gw(self, context, router_id, router,
@ -211,7 +209,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
except Exception:
with excutils.save_and_reraise_exception():
# Delete the logical router
LOG.error(_LE('Unable to create lrouter for %s'), router['id'])
LOG.error('Unable to create lrouter for %s', router['id'])
super(OVNL3RouterPlugin, self).delete_router(context,
router['id'])
return router
@ -284,7 +282,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
enable_snat=new_snat_state)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update lrouter for %s'), id)
LOG.error('Unable to update lrouter for %s', id)
super(OVNL3RouterPlugin, self).update_router(context, id,
revert_router)
@ -309,7 +307,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
check_error=True)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update lrouter for %s'), id)
LOG.error('Unable to update lrouter for %s', id)
super(OVNL3RouterPlugin, self).update_router(context, id,
revert_router)
@ -326,8 +324,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
self._update_lrouter_routes(context, id, added, removed)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update static routes in lrouter '
'%s'), id)
LOG.error(
'Unable to update static routes in lrouter %s', id)
super(OVNL3RouterPlugin, self).update_router(context, id,
revert_router)
@ -476,8 +474,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
utils.ovn_name(router_id)).execute(check_error=True)
super(OVNL3RouterPlugin, self).remove_router_interface(
context, router_id, router_interface_info)
LOG.error(_LE('Error updating snat for subnet %(subnet)s in '
'router %(router)s'),
LOG.error('Error updating snat for subnet %(subnet)s in '
'router %(router)s',
{'subnet': router_interface_info['subnet_id'],
'router': router_id})
@ -531,7 +529,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
with excutils.save_and_reraise_exception():
super(OVNL3RouterPlugin, self).add_router_interface(
context, router_id, interface_info)
LOG.error(_LE('Error is deleting snat'))
LOG.error('Error is deleting snat')
return router_interface_info
@ -553,8 +551,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
n_const.FLOATINGIP_STATUS_ACTIVE)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to create floating ip in gateway'
'router'))
LOG.error('Unable to create floating ip in gateway router')
return fip
def delete_floatingip(self, context, id):
@ -571,8 +568,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
associate=False)
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Error in disassociating floatingip: %s'),
id)
LOG.error('Error in disassociating floatingip: %s', id)
def update_floatingip(self, context, id, floatingip):
fip_db = self._get_floatingip(context, id)
@ -599,8 +595,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
fip_status = n_const.FLOATINGIP_STATUS_DOWN
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update floating ip in '
'gateway router'))
LOG.error('Unable to update floating ip in gateway router')
if new_port_id:
update_fip = {}
@ -614,8 +609,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
fip_status = n_const.FLOATINGIP_STATUS_ACTIVE
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update floating ip in '
'gateway router'))
LOG.error('Unable to update floating ip in gateway router')
if fip_status:
self.update_floatingip_status(context, id, fip_status)
@ -639,8 +633,8 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
self.update_floatingip_status(
context, fip['id'], n_const.FLOATINGIP_STATUS_DOWN)
except Exception as e:
LOG.error(_LE('Error in disassociating floatingip %(id)s: '
'%(error)s'), {'id': fip['id'], 'error': e})
LOG.error('Error in disassociating floatingip %(id)s: '
'%(error)s', {'id': fip['id'], 'error': e})
return router_ids
def _update_floating_ip_in_ovn(self, context, router_id, update,
@ -682,7 +676,7 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
external_ip=update['external_ip']))
except Exception:
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to update NAT rule in gateway router'))
LOG.error('Unable to update NAT rule in gateway router')
def schedule_unhosted_gateways(self):
valid_chassis_list = self._sb_ovn.get_all_chassis()

24
networking_ovn/ml2/mech_driver.py

@ -37,7 +37,7 @@ from neutron.plugins.ml2 import driver_api
from neutron.services.qos import qos_consts
from neutron.services.segments import db as segment_service_db
from networking_ovn._i18n import _, _LI, _LW
from networking_ovn._i18n import _
from networking_ovn.common import acl as ovn_acl
from networking_ovn.common import config
from networking_ovn.common import constants as ovn_const
@ -89,13 +89,13 @@ class OVNMechanismDriver(driver_api.MechanismDriver):
been initialized. No abstract methods defined below will be
called prior to this method being called.
"""
LOG.info(_LI("Starting OVNMechanismDriver"))
LOG.info("Starting OVNMechanismDriver")
self._nb_ovn = None
self._sb_ovn = None
self._plugin_property = None
self.sg_enabled = ovn_acl.is_sg_enabled()
if cfg.CONF.SECURITYGROUP.firewall_driver:
LOG.warning(_LW('Firewall driver configuration is ignored'))
LOG.warning('Firewall driver configuration is ignored')
self._setup_vif_port_bindings()
self.subscribe()
qos_driver.OVNQosNotificationDriver.create()
@ -1070,18 +1070,18 @@ class OVNMechanismDriver(driver_api.MechanismDriver):
# network types. Once bug/1621879 is fixed, refuse to bind
# ports with unsupported network types.
if not self._is_network_type_supported(network_type):
LOG.info(_LI('Upgrade allowing bind port %(port_id)s with '
'unsupported network type: %(network_type)s'),
LOG.info('Upgrade allowing bind port %(port_id)s with '
'unsupported network type: %(network_type)s',
{'port_id': port['id'],
'network_type': network_type})
if (network_type in ['flat', 'vlan']) and \
(physical_network not in chassis_physnets):
LOG.info(_LI('Refusing to bind port %(port_id)s on '
'host %(host)s due to the OVN chassis '
'bridge mapping physical networks '
'%(chassis_physnets)s not supporting '
'physical network: %(physical_network)s'),
LOG.info('Refusing to bind port %(port_id)s on '
'host %(host)s due to the OVN chassis '
'bridge mapping physical networks '
'%(chassis_physnets)s not supporting '
'physical network: %(physical_network)s',
{'port_id': port['id'],
'host': context.host,
'chassis_physnets': chassis_physnets,
@ -1118,7 +1118,7 @@ class OVNMechanismDriver(driver_api.MechanismDriver):
# Port provisioning is complete now that OVN has reported that the
# port is up. Any provisioning block (possibly added during port
# creation or when OVN reports that the port is down) must be removed.
LOG.info(_LI("OVN reports status up for port: %s"), port_id)
LOG.info("OVN reports status up for port: %s", port_id)
provisioning_blocks.provisioning_complete(
n_context.get_admin_context(),
port_id,
@ -1131,7 +1131,7 @@ class OVNMechanismDriver(driver_api.MechanismDriver):
# in neutron. The block is inserted before the port status update
# to prevent another entity from bypassing the block with its own
# port status update.
LOG.info(_LI("OVN reports status down for port: %s"), port_id)
LOG.info("OVN reports status down for port: %s", port_id)
admin_context = n_context.get_admin_context()
try:
port = self._plugin.get_port(admin_context, port_id)

3
networking_ovn/ml2/qos_driver.py

@ -24,7 +24,6 @@ from neutron.plugins.ml2 import plugin as ml2_plugin
from neutron.services.qos.drivers import base
from neutron.services.qos import qos_consts
from networking_ovn._i18n import _LI
from oslo_config import cfg
LOG = logging.getLogger(__name__)
@ -90,7 +89,7 @@ class OVNQosDriver(object):
"""Qos driver for OVN"""
def __init__(self, driver):
LOG.info(_LI("Starting OVNQosDriver"))
LOG.info("Starting OVNQosDriver")
super(OVNQosDriver, self).__init__()
self._driver = driver
self._plugin_property = None

150
networking_ovn/ovn_db_sync.py

@ -25,7 +25,6 @@ from oslo_log import log
from neutron.services.segments import db as segments_db
from networking_ovn._i18n import _LW
from networking_ovn.common import acl as acl_utils
from networking_ovn.common import config
from networking_ovn.common import constants as const
@ -260,16 +259,16 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
num_acls_to_add = len(list(itertools.chain(*neutron_acls.values())))
num_acls_to_remove = len(list(itertools.chain(*nb_acls.values())))
if 0 != num_acls_to_add or 0 != num_acls_to_remove:
LOG.warning(_LW('ACLs-to-be-added %(add)d '
'ACLs-to-be-removed %(remove)d'),
LOG.warning('ACLs-to-be-added %(add)d '
'ACLs-to-be-removed %(remove)d',
{'add': num_acls_to_add,
'remove': num_acls_to_remove})
if self.mode == SYNC_MODE_REPAIR:
with self.ovn_api.transaction(check_error=True) as txn:
for acla in list(itertools.chain(*neutron_acls.values())):
LOG.warning(_LW('ACL found in Neutron but not in '
'OVN DB for port %s'), acla['lport'])
LOG.warning('ACL found in Neutron but not in '
'OVN DB for port %s', acla['lport'])
txn.add(self.ovn_api.add_acl(**acla))
with self.ovn_api.transaction(check_error=True) as txn:
@ -278,8 +277,8 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
lswitchr = aclr.pop('lswitch').replace('neutron-', '')
lportr = aclr.pop('lport')
aclr_dict = {lportr: aclr}
LOG.warning(_LW('ACLs found in OVN DB but not in '
'Neutron for port %s'), lportr)
LOG.warning('ACLs found in OVN DB but not in '
'Neutron for port %s', lportr)
txn.add(self.ovn_api.update_acls(
[lswitchr],
[lportr],
@ -407,11 +406,11 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
del_lrouters_list.append(lrouter)
for r_id, router in db_routers.items():
LOG.warning(_LW("Router found in Neutron but not in "
"OVN DB, router id=%s"), router['id'])
LOG.warning("Router found in Neutron but not in "
"OVN DB, router id=%s", router['id'])
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.warning(_LW("Creating the router %s in OVN NB DB"),
LOG.warning("Creating the router %s in OVN NB DB",
router['id'])
self.l3_plugin.create_lrouter_in_ovn(router)
if 'routes' in router:
@ -434,53 +433,52 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
'add': db_extends[router['id']]['fips'],
'del': []})
except RuntimeError:
LOG.warning(_LW("Create router in OVN NB failed for"
" router %s"), router['id'])
LOG.warning("Create router in OVN NB failed for router %s",
router['id'])
for rp_id, rrport in db_router_ports.items():
LOG.warning(_LW("Router Port found in Neutron but not in OVN "
"DB, router port_id=%s"), rrport['id'])
LOG.warning("Router Port found in Neutron but not in OVN "
"DB, router port_id=%s", rrport['id'])
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.warning(_LW("Creating the router port %s in "
"OVN NB DB"), rrport['id'])
LOG.warning("Creating the router port %s in OVN NB DB",
rrport['id'])
self.l3_plugin.create_lrouter_port_in_ovn(
ctx, rrport['device_id'], rrport)
except RuntimeError:
LOG.warning(_LW("Create router port in OVN "
"NB failed for"
" router port %s"), rrport['id'])
LOG.warning("Create router port in OVN "
"NB failed for router port %s", rrport['id'])
for router_id, rport in update_lrport_list:
LOG.warning(_LW("Router Port port_id=%s needs to be updated"
" for networks changed"),
LOG.warning("Router Port port_id=%s needs to be updated "
"for networks changed",
rport['id'])
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.warning(_LW("Updating networks on router port %s in "
"OVN NB DB"), rport['id'])
LOG.warning(
"Updating networks on router port %s in OVN NB DB",
rport['id'])
self.l3_plugin.update_lrouter_port_in_ovn(
ctx, router_id, rport, rport['networks'])
except RuntimeError:
LOG.warning(_LW("Update router port networks in OVN "
"NB failed for"
" router port %s"), rport['id'])
LOG.warning("Update router port networks in OVN "
"NB failed for router port %s", rport['id'])
with self.ovn_api.transaction(check_error=True) as txn:
for lrouter in del_lrouters_list:
LOG.warning(_LW("Router found in OVN but not in "
"Neutron, router id=%s"), lrouter['name'])
LOG.warning("Router found in OVN but not in "
"Neutron, router id=%s", lrouter['name'])
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Deleting the router %s from OVN NB DB"),
LOG.warning("Deleting the router %s from OVN NB DB",
lrouter['name'])
txn.add(self.ovn_api.delete_lrouter(
utils.ovn_name(lrouter['name'])))
for lrport_info in del_lrouter_ports_list:
LOG.warning(_LW("Router Port found in OVN but not in "
"Neutron, port_id=%s"), lrport_info['port'])
LOG.warning("Router Port found in OVN but not in "
"Neutron, port_id=%s", lrport_info['port'])
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Deleting the port %s from OVN NB DB"),
LOG.warning("Deleting the port %s from OVN NB DB",
lrport_info['port'])
txn.add(self.ovn_api.delete_lrouter_port(
utils.ovn_lrouter_port_name(lrport_info['port']),
@ -488,11 +486,11 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
if_exists=False))
for sroute in update_sroutes_list:
if sroute['add']:
LOG.warning(_LW("Router %(id)s static routes %(route)s "
"found in Neutron but not in OVN"),
LOG.warning("Router %(id)s static routes %(route)s "
"found in Neutron but not in OVN",
{'id': sroute['id'], 'route': sroute['add']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Add static routes %s to OVN NB DB"),
LOG.warning("Add static routes %s to OVN NB DB",
sroute['add'])
for route in sroute['add']:
txn.add(self.ovn_api.add_static_route(
@ -500,12 +498,12 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
ip_prefix=route['destination'],
nexthop=route['nexthop']))
if sroute['del']:
LOG.warning(_LW("Router %(id)s static routes %(route)s "
"found in OVN but not in Neutron"),
LOG.warning("Router %(id)s static routes %(route)s "
"found in OVN but not in Neutron",
{'id': sroute['id'], 'route': sroute['del']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Delete static routes %s from OVN "
"NB DB"), sroute['del'])
LOG.warning("Delete static routes %s from OVN NB DB",
sroute['del'])
for route in sroute['del']:
txn.add(self.ovn_api.delete_static_route(
utils.ovn_name(sroute['id']),
@ -513,12 +511,12 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
nexthop=route['nexthop']))
for fip in update_fips_list:
if fip['del']:
LOG.warning(_LW("Router %(id)s floating ips %(fip)s "
"found in OVN but not in Neutron"),
LOG.warning("Router %(id)s floating ips %(fip)s "
"found in OVN but not in Neutron",
{'id': fip['id'], 'fip': fip['del']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW(
"Delete floating ips %s from OVN NB DB"),
LOG.warning(
"Delete floating ips %s from OVN NB DB",
fip['del'])
for nat in fip['del']:
txn.add(self.ovn_api.delete_nat_rule_in_lrouter(
@ -527,11 +525,11 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
external_ip=nat['external_ip'],
type='dnat_and_snat'))
if fip['add']:
LOG.warning(_LW("Router %(id)s floating ips %(fip)s "
"found in Neutron but not in OVN"),
LOG.warning("Router %(id)s floating ips %(fip)s "
"found in Neutron but not in OVN",
{'id': fip['id'], 'fip': fip['add']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Add floating ips %s to OVN NB DB"),
LOG.warning("Add floating ips %s to OVN NB DB",
fip['add'])
for nat in fip['add']:
txn.add(self.ovn_api.add_nat_rule_in_lrouter(
@ -541,11 +539,11 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
type='dnat_and_snat'))
for snat in update_snats_list:
if snat['del']:
LOG.warning(_LW("Router %(id)s snat %(snat)s "
"found in OVN but not in Neutron"),
LOG.warning("Router %(id)s snat %(snat)s "
"found in OVN but not in Neutron",
{'id': snat['id'], 'snat': snat['del']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Delete snats %s from OVN NB DB"),
LOG.warning("Delete snats %s from OVN NB DB",
snat['del'])
for nat in snat['del']:
txn.add(self.ovn_api.delete_nat_rule_in_lrouter(
@ -554,11 +552,11 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
external_ip=nat['external_ip'],
type='snat'))
if snat['add']:
LOG.warning(_LW("Router %(id)s snat %(snat)s "
"found in Neutron but not in OVN"),
LOG.warning("Router %(id)s snat %(snat)s "
"found in Neutron but not in OVN",
{'id': snat['id'], 'snat': snat['add']})
if self.mode == SYNC_MODE_REPAIR:
LOG.warning(_LW("Add snats %s to OVN NB DB"),
LOG.warning("Add snats %s to OVN NB DB",
snat['add'])
for nat in snat['add']:
txn.add(self.ovn_api.add_nat_rule_in_lrouter(
@ -603,8 +601,8 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
del_subnet_dhcp_opts_list.append(ovn_dhcp_opts)
for subnet_id, subnet in db_subnets.items():
LOG.warning(_LW('DHCP options for subnet %s is present in '
'Neutron but out of sync for OVN'), subnet_id)
LOG.warning('DHCP options for subnet %s is present in '
'Neutron but out of sync for OVN', subnet_id)
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.debug('Adding/Updating DHCP options for subnet %s in '
@ -616,13 +614,13 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
self.ovn_driver.add_subnet_dhcp_options_in_ovn(
subnet, network, subnet.get('ovn_dhcp_options'))
except RuntimeError:
LOG.warning(_LW('Adding/Updating DHCP options for subnet '
'%s failed in OVN NB DB'), subnet_id)
LOG.warning('Adding/Updating DHCP options for subnet '
'%s failed in OVN NB DB', subnet_id)
txn_commands = []
for dhcp_opt in del_subnet_dhcp_opts_list:
LOG.warning(_LW('Out of sync subnet DHCP options for subnet %s '
'found in OVN NB DB which needs to be deleted'),
LOG.warning('Out of sync subnet DHCP options for subnet %s '
'found in OVN NB DB which needs to be deleted',
dhcp_opt['external_ids']['subnet_id'])
if self.mode == SYNC_MODE_REPAIR:
LOG.debug('Deleting subnet DHCP options for subnet %s ',
@ -677,9 +675,9 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
for ip_v in [constants.IP_VERSION_4, constants.IP_VERSION_6]:
for port_id, dhcp_opt in ovn_port_dhcp_opts[ip_v].items():
LOG.warning(
_LW('Out of sync port DHCPv%(ip_version)d options for '
'(subnet %(subnet_id)s port %(port_id)s) found in OVN '
'NB DB which needs to be deleted'),
'Out of sync port DHCPv%(ip_version)d options for '
'(subnet %(subnet_id)s port %(port_id)s) found in OVN '
'NB DB which needs to be deleted',
{'ip_version': ip_v,
'subnet_id': dhcp_opt['external_ids']['subnet_id'],
'port_id': port_id})
@ -741,23 +739,23 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
del_lswitchs_list.append(lswitch)
for net_id, network in db_networks.items():
LOG.warning(_LW("Network found in Neutron but not in "
"OVN DB, network_id=%s"), network['id'])
LOG.warning("Network found in Neutron but not in "
"OVN DB, network_id=%s", network['id'])
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.debug('Creating the network %s in OVN NB DB',
network['id'])
self._create_network_in_ovn(network)
except RuntimeError:
LOG.warning(_LW("Create network in OVN NB failed for"
" network %s"), network['id'])
LOG.warning("Create network in OVN NB failed for "
"network %s", network['id'])
self._sync_subnet_dhcp_options(
ctx, db_network_cache, ovn_all_dhcp_options['subnets'])
for port_id, port in db_ports.items():
LOG.warning(_LW("Port found in Neutron but not in OVN "
"DB, port_id=%s"), port['id'])
LOG.warning("Port found in Neutron but not in OVN "
"DB, port_id=%s", port['id'])
if self.mode == SYNC_MODE_REPAIR:
try:
LOG.debug('Creating the port %s in OVN NB DB',
@ -774,13 +772,13 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
if lsp_opts:
ovn_all_dhcp_options['ports_v6'].pop(port_id)
except RuntimeError:
LOG.warning(_LW("Create port in OVN NB failed for"
" port %s"), port['id'])
LOG.warning("Create port in OVN NB failed for"
" port %s", port['id'])
with self.ovn_api.transaction(check_error=True) as txn:
for lswitch in del_lswitchs_list:
LOG.warning(_LW("Network found in OVN but not in "
"Neutron, network_id=%s"), lswitch['name'])
LOG.warning("Network found in OVN but not in "
"Neutron, network_id=%s", lswitch['name'])
if self.mode == SYNC_MODE_REPAIR:
LOG.debug('Deleting the network %s from OVN NB DB',
lswitch['name'])
@ -789,9 +787,9 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
for provnet_port_info in add_provnet_ports_list:
network = provnet_port_info['network']
LOG.warning(_LW("Provider network found in Neutron but "
"provider network port not found in OVN DB, "
"network_id=%s"), provnet_port_info['lswitch'])
LOG.warning("Provider network found in Neutron but "
"provider network port not found in OVN DB, "
"network_id=%s", provnet_port_info['lswitch'])
if self.mode == SYNC_MODE_REPAIR:
LOG.debug('Creating the provnet port %s in OVN NB DB',
utils.ovn_provnet_port_name(network['id']))
@ -800,8 +798,8 @@ class OvnNbSynchronizer(OvnDbSynchronizer):
network.get(pnet.SEGMENTATION_ID))
for lport_info in del_lports_list:
LOG.warning(_LW("Port found in OVN but not in "
"Neutron, port_id=%s"), lport_info['port'])
LOG.warning("Port found in OVN but not in "
"Neutron, port_id=%s", lport_info['port'])
if self.mode == SYNC_MODE_REPAIR:
LOG.debug('Deleting the port %s from OVN NB DB',
lport_info['port'])

4
networking_ovn/ovsdb/impl_idl_ovn.py

@ -18,7 +18,7 @@ from neutron.agent.ovsdb.native import idlutils
from neutron_lib.utils import helpers
from ovsdbapp.backend.ovs_idl import transaction as idl_trans
from networking_ovn._i18n import _, _LI
from networking_ovn._i18n import _
from networking_ovn.common import config as cfg
from networking_ovn.common import constants as ovn_const
from networking_ovn.common import utils
@ -45,7 +45,7 @@ def get_ovn_idls(driver, trigger):
wait=tenacity.wait_exponential(max=180),
reraise=True)
def get_ovn_idl_retry(cls, driver, trigger):
LOG.info(_LI('Getting %(cls)s for %(trigger)s with retry'),
LOG.info('Getting %(cls)s for %(trigger)s with retry',
{'cls': cls.__name__, 'trigger': trigger.im_class.__name__})
return cls(driver, trigger)

3
networking_ovn/ovsdb/ovsdb_monitor.py

@ -23,7 +23,6 @@ from ovs.db import idl
from ovs import poller
from ovs.stream import Stream
from networking_ovn._i18n import _LE
from networking_ovn.common import config as ovn_config
from networking_ovn.ovsdb import row_event
from neutron.agent.ovsdb.native import connection
@ -203,7 +202,7 @@ class OvnDbNotifyHandler(object):
except Exception:
# If any unexpected exception happens we don't want the
# notify_loop to exit.
LOG.exception(_LE('Unexpected exception in notify_loop'))
LOG.exception('Unexpected exception in notify_loop')
def notify(self, event, row, updates=None):
matching = self.matching_events(

5
networking_ovn/tests/functional/base.py

@ -28,7 +28,6 @@ from neutron.plugins.ml2 import config
from neutron.plugins.ml2.drivers import type_geneve # noqa
from neutron.tests.unit.plugins.ml2 import test_plugin
from networking_ovn._i18n import _LE
from networking_ovn.ovsdb import impl_idl_ovn
from networking_ovn.ovsdb import ovsdb_monitor
from networking_ovn.tests.functional.resources import process
@ -161,7 +160,7 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
self.monitor_nb_db_idl = self.monitor_nb_idl_con.idl
break
except Exception:
LOG.exception(_LE("Error connecting to the OVN_Northbound DB"))
LOG.exception("Error connecting to the OVN_Northbound DB")
num_attempts += 1
time.sleep(1)
@ -181,7 +180,7 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase):
self.monitor_sb_db_idl = self.monitor_sb_idl_con.idl
break
except Exception:
LOG.exception(_LE("Error connecting to the OVN_Southbound DB"))
LOG.exception("Error connecting to the OVN_Southbound DB")
num_attempts += 1
time.sleep(1)

8
networking_ovn/tests/unit/cmd/test_neutron_ovn_db_sync_util.py

@ -134,23 +134,23 @@ class TestNeutronOVNDBSyncUtil(base.TestCase):
def test_main_sync_stage1_fail(self):
self._test_main_sync_fail(1)
self.cmd_log.exception.assert_called_once_with(
"Error syncing the Address Sets. Check the "
"Error syncing the Address Sets. Check the "
"--database-connection value again")
def test_main_sync_stage2_fail(self):
self._test_main_sync_fail(2)
self.cmd_log.exception.assert_called_once_with(
"Error syncing Networks, Ports and DHCP options "
"Error syncing Networks, Ports and DHCP options "
"for unknown reason please try again")
def test_main_sync_stage3_fail(self):
self._test_main_sync_fail(3)
self.cmd_log.exception.assert_called_once_with(
"Error syncing ACLs for unknown "
"Error syncing ACLs for unknown "
"reason please try again")
def test_main_sync_stage4_fail(self):
self._test_main_sync_fail(4)
self.cmd_log.exception.assert_called_once_with(
"Error syncing Routers and Router ports "
"Error syncing Routers and Router ports "
"please try again")

4
tox.ini

@ -84,11 +84,9 @@ extensions = .rst
# E123, E125 skipped as they are invalid PEP-8.
# TODO(dougwig) -- uncomment this to test for remaining linkages
# N530 direct neutron imports not allowed
# TODO(ihrachys) -- reenable N537 when new neutron-lib release is available
# N537 Log messages should not be translated
show-source = True
ignore = E123,E125,N530,N537
ignore = E123,E125,N530
builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.tmp

Loading…
Cancel
Save