exceptions or other objects directly (LOG.error(exc), LOG.error(port), etc.).
See http://docs.openstack.org/developer/oslo.log/usage.html#no-more-implicit-conversion-to-unicode-str
for more details.
+* Don't pass exceptions into LOG.exception: it is already implicitly included
+ in the log message by Python logging module.
+* Don't use LOG.exception when there is no exception registered in current
+ thread context: Python 3.x versions before 3.5 are known to fail on it.
Project interfaces
~~~~~~~~~~~~~~~~~~
ofport = INVALID_OFPORT
try:
ofport = self._get_port_ofport(port_name)
- except retrying.RetryError as e:
- LOG.exception(_LE("Timed out retrieving ofport on port %(pname)s. "
- "Exception: %(exception)s"),
- {'pname': port_name, 'exception': e})
+ except retrying.RetryError:
+ LOG.exception(_LE("Timed out retrieving ofport on port %s."),
+ port_name)
return ofport
def get_datapath_id(self):
from neutron.common import exceptions as n_exc
from neutron.common import ipv6_utils
from neutron.common import utils as common_utils
-from neutron.i18n import _LW
+from neutron.i18n import _LE, _LW
LOG = logging.getLogger(__name__)
INTERNAL_DEV_PREFIX = namespaces.INTERNAL_DEV_PREFIX
fip_statuses = self.configure_fip_addresses(interface_name)
except (n_exc.FloatingIpSetupException,
- n_exc.IpTablesApplyException) as e:
+ n_exc.IpTablesApplyException):
# All floating IPs must be put in error state
- LOG.exception(e)
+ LOG.exception(_LE("Failed to process floating IPs."))
fip_statuses = self.put_fips_in_error_state()
finally:
agent.update_fip_statuses(
LOG.debug('Ext alias: %s', extension.get_alias())
LOG.debug('Ext description: %s', extension.get_description())
LOG.debug('Ext updated: %s', extension.get_updated())
- except AttributeError as ex:
- LOG.exception(_LE("Exception loading extension: %s"),
- six.text_type(ex))
+ except AttributeError:
+ LOG.exception(_LE("Exception loading extension"))
return False
return True
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import uuidutils
-import six
from neutron.agent.common import ovs_lib
from neutron.agent.l3 import ha_router
LOG.error(_LE("Failed to import required modules. Ensure that the "
"python-openvswitch package is installed. Error: %s"),
ex)
- except Exception as ex:
- LOG.exception(six.text_type(ex))
+ except Exception:
+ LOG.exception(_LE("Unexpected exception occurred."))
return False
self.configure_trunk_mode_for_vlan_profile(mgr, name)
self.configure_allowed_vlans_for_vlan_profile(mgr, name, net_id)
self.activate_port_profile(mgr, name)
- except Exception as ex:
+ except Exception:
with excutils.save_and_reraise_exception():
- LOG.exception(_LE("NETCONF error: %s"), ex)
+ LOG.exception(_LE("NETCONF error"))
self.close_session()
def delete_network(self, host, username, password, net_id):
self.deactivate_port_profile(mgr, name)
self.delete_port_profile(mgr, name)
self.delete_vlan_interface(mgr, net_id)
- except Exception as ex:
+ except Exception:
with excutils.save_and_reraise_exception():
- LOG.exception(_LE("NETCONF error: %s"), ex)
+ LOG.exception(_LE("NETCONF error"))
self.close_session()
def associate_mac_to_network(self, host, username, password,
try:
mgr = self.connect(host, username, password)
self.associate_mac_to_port_profile(mgr, name, mac)
- except Exception as ex:
+ except Exception:
with excutils.save_and_reraise_exception():
- LOG.exception(_LE("NETCONF error: %s"), ex)
+ LOG.exception(_LE("NETCONF error"))
self.close_session()
def dissociate_mac_from_network(self, host, username, password,
try:
mgr = self.connect(host, username, password)
self.dissociate_mac_from_port_profile(mgr, name, mac)
- except Exception as ex:
+ except Exception:
with excutils.save_and_reraise_exception():
- LOG.exception(_LE("NETCONF error: %s"), ex)
+ LOG.exception(_LE("NETCONF error"))
self.close_session()
def create_vlan_interface(self, mgr, vlan_id):
if provider_type in self.providers:
msg = (_("Multiple providers specified for service "
"%s") % provider['service_type'])
- LOG.exception(msg)
+ LOG.error(msg)
raise n_exc.Invalid(msg)
self.providers[provider_type] = {'driver': provider['driver'],
'default': provider['default']}