Do not use log hints for exceptions

According to the guidlines:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html, a
exception message should not have a log translation hint.

Change-Id: I2d1a5c4ac2a7fa102596891da12b747c27a88e7a
This commit is contained in:
Gary Kotton 2016-12-29 00:53:32 -08:00
parent 56bdf7ae0e
commit 04b0b960b5
3 changed files with 62 additions and 65 deletions

View File

@ -20,8 +20,6 @@ Octavia base exception handling.
from oslo_utils import excutils
from webob import exc
from octavia.i18n import _LE, _LI
class OctaviaException(Exception):
"""Base Octavia Exception.
@ -156,40 +154,40 @@ class TooManyL7RulesOnL7Policy(APIException):
class ComputeBuildException(OctaviaException):
message = _LE('Failed to build compute instance.')
message = _('Failed to build compute instance.')
class ComputeDeleteException(OctaviaException):
message = _LE('Failed to delete compute instance.')
message = _('Failed to delete compute instance.')
class ComputeGetException(OctaviaException):
message = _LE('Failed to retrieve compute instance.')
message = _('Failed to retrieve compute instance.')
class ComputeStatusException(OctaviaException):
message = _LE('Failed to retrieve compute instance status.')
message = _('Failed to retrieve compute instance status.')
class ComputeGetInterfaceException(OctaviaException):
message = _LE('Failed to retrieve compute virtual interfaces.')
message = _('Failed to retrieve compute virtual interfaces.')
class IDAlreadyExists(OctaviaException):
message = _LE('Already an entity with that specified id.')
message = _('Already an entity with that specified id.')
code = 409
class NoReadyAmphoraeException(OctaviaException):
message = _LE('There are not any READY amphora available.')
message = _('There are not any READY amphora available.')
class GlanceNoTaggedImages(OctaviaException):
message = _LE("No Glance images are tagged with %(tag)s tag.")
message = _("No Glance images are tagged with %(tag)s tag.")
class NoSuitableAmphoraException(OctaviaException):
message = _LE('Unable to allocate an amphora due to: %(msg)s')
message = _('Unable to allocate an amphora due to: %(msg)s')
# This is an internal use exception for the taskflow work flow
@ -197,43 +195,43 @@ class NoSuitableAmphoraException(OctaviaException):
# normal part of operation while waiting for compute to go active
# on the instance
class ComputeWaitTimeoutException(OctaviaException):
message = _LI('Waiting for compute to go active timeout.')
message = _('Waiting for compute to go active timeout.')
class InvalidTopology(OctaviaException):
message = _LE('Invalid topology specified: %(topology)s')
message = _('Invalid topology specified: %(topology)s')
# L7 policy and rule exceptions
class InvalidL7PolicyAction(APIException):
message = _LE('Invalid L7 Policy action specified: %(action)s')
message = _('Invalid L7 Policy action specified: %(action)s')
code = 400
class InvalidL7PolicyArgs(APIException):
message = _LE('Invalid L7 Policy arguments: %(msg)s')
message = _('Invalid L7 Policy arguments: %(msg)s')
code = 400
class InvalidURL(OctaviaException):
message = _LE('Not a valid URL: %(url)s')
message = _('Not a valid URL: %(url)s')
class InvalidString(OctaviaException):
message = _LE('Invalid characters in %(what)s')
message = _('Invalid characters in %(what)s')
class InvalidRegex(OctaviaException):
message = _LE('Unable to parse regular expression: %(e)s')
message = _('Unable to parse regular expression: %(e)s')
class InvalidL7Rule(OctaviaException):
message = _LE('Invalid L7 Rule: $(msg)s')
message = _('Invalid L7 Rule: $(msg)s')
class ServerGroupObjectCreateException(OctaviaException):
message = _LE('Failed to create server group object.')
message = _('Failed to create server group object.')
class ServerGroupObjectDeleteException(OctaviaException):
message = _LE('Failed to delete server group object.')
message = _('Failed to delete server group object.')

View File

@ -95,10 +95,10 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
interface = self.plug_port(amphora, new_port)
except Exception:
message = _LE('Error plugging amphora (compute_id: {compute_id}) '
'into vip network {network_id}.').format(
compute_id=amphora.compute_id,
network_id=network_id)
message = _('Error plugging amphora (compute_id: {compute_id}) '
'into vip network {network_id}.').format(
compute_id=amphora.compute_id,
network_id=network_id)
LOG.exception(message)
raise base.PlugVIPException(message)
return interface
@ -109,9 +109,9 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
except neutron_client_exceptions.PortNotFoundClient as e:
raise base.PortNotFound(e.message)
except Exception:
message = _LE('Error adding allowed address pair {ip} '
'to port {port_id}.').format(ip=vip_address,
port_id=port_id)
message = _('Error adding allowed address pair {ip} '
'to port {port_id}.').format(ip=vip_address,
port_id=port_id)
LOG.exception(message)
raise base.PlugVIPException(message)
@ -229,8 +229,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
{'attempt': attempts + 1, 'sg': sec_grp})
attempts += 1
time.sleep(CONF.networking.retry_interval)
message = _LE("All attempts to remove security group {0} have "
"failed.").format(sec_grp)
message = _("All attempts to remove security group {0} have "
"failed.").format(sec_grp)
LOG.exception(message)
raise base.DeallocateVIPException(message)
@ -281,8 +281,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
try:
self.neutron_client.delete_port(vip.port_id)
except Exception:
message = _LE('Error deleting VIP port_id {port_id} from '
'neutron').format(port_id=vip.port_id)
message = _('Error deleting VIP port_id {port_id} from '
'neutron').format(port_id=vip.port_id)
LOG.exception(message)
raise base.DeallocateVIPException(message)
else:
@ -344,8 +344,8 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
try:
new_port = self.neutron_client.create_port(port)
except Exception:
message = _LE('Error creating neutron port on network '
'{network_id}.').format(
message = _('Error creating neutron port on network '
'{network_id}.').format(
network_id=subnet.network_id)
LOG.exception(message)
raise base.AllocateVIPException(message)
@ -383,9 +383,9 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
self.neutron_client.update_port(interface.port_id,
aap_update)
except Exception:
message = _LE('Error unplugging VIP. Could not clear '
'allowed address pairs from port '
'{port_id}.').format(port_id=vip.port_id)
message = _('Error unplugging VIP. Could not clear '
'allowed address pairs from port '
'{port_id}.').format(port_id=vip.port_id)
LOG.exception(message)
raise base.UnplugVIPException(message)
@ -415,10 +415,10 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
else:
raise base.PlugNetworkException(e.message)
except Exception:
message = _LE('Error plugging amphora (compute_id: {compute_id}) '
'into network {network_id}.').format(
compute_id=compute_id,
network_id=network_id)
message = _('Error plugging amphora (compute_id: {compute_id}) '
'into network {network_id}.').format(
compute_id=compute_id,
network_id=network_id)
LOG.exception(message)
raise base.PlugNetworkException(message)
@ -438,20 +438,20 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
self.nova_client.servers.interface_detach(
server=compute_id, port_id=unplugger.port_id)
except Exception:
message = _LE('Error unplugging amphora {amphora_id} from network '
'{network_id}.').format(amphora_id=compute_id,
network_id=network_id)
message = _('Error unplugging amphora {amphora_id} from network '
'{network_id}.').format(amphora_id=compute_id,
network_id=network_id)
if len(unpluggers) > 1:
message = _LE('{base} Other interfaces have been successfully '
'unplugged: ').format(base=message)
message = _('{base} Other interfaces have been successfully '
'unplugged: ').format(base=message)
unpluggeds = unpluggers[:index]
for unplugged in unpluggeds:
message = _LE('{base} neutron port '
'{port_id} ').format(
base=message, port_id=unplugged.port_id)
message = _('{base} neutron port '
'{port_id} ').format(
base=message, port_id=unplugged.port_id)
else:
message = _LE('{base} No other networks were '
'unplugged.').format(base=message)
message = _('{base} No other networks were '
'unplugged.').format(base=message)
LOG.exception(message)
raise base.UnplugNetworkException(message)
@ -508,11 +508,11 @@ class AllowedAddressPairsDriver(neutron_base.BaseNeutronDriver):
port_id=port.id,
fixed_ips=port.fixed_ips)
except Exception:
message = _LE('Error plugging amphora (compute_id: '
'{compute_id}) into port '
'{port_id}.').format(
compute_id=amphora.compute_id,
port_id=port.id)
message = _('Error plugging amphora (compute_id: '
'{compute_id}) into port '
'{port_id}.').format(
compute_id=amphora.compute_id,
port_id=port.id)
LOG.exception(message)
raise base.PlugNetworkException(message)

View File

@ -18,7 +18,6 @@ from oslo_log import log as logging
from octavia.common import clients
from octavia.common import data_models
from octavia.i18n import _LE
from octavia.network import base
from octavia.network import data_models as network_models
from octavia.network.drivers.neutron import utils
@ -150,14 +149,14 @@ class BaseNeutronDriver(base.AbstractNetworkDriver):
return getattr(utils, 'convert_%s_dict_to_model' %
resource_type)(resource)
except neutron_client_exceptions.NotFound:
message = _LE('{resource_type} not found '
'({resource_type} id: {resource_id}.').format(
message = _('{resource_type} not found '
'({resource_type} id: {resource_id}.').format(
resource_type=resource_type, resource_id=resource_id)
raise getattr(base, '%sNotFound' %
resource_type.capitalize())(message)
except Exception:
message = _LE('Error retrieving {resource_type} '
'({resource_type} id: {resource_id}.').format(
message = _('Error retrieving {resource_type} '
'({resource_type} id: {resource_id}.').format(
resource_type=resource_type, resource_id=resource_id)
LOG.exception(message)
raise base.NetworkException(message)
@ -171,15 +170,15 @@ class BaseNeutronDriver(base.AbstractNetworkDriver):
return getattr(utils, 'convert_%s_dict_to_model' %
resource_type)(resource)
except neutron_client_exceptions.NotFound:
message = _LE('{resource_type} not found '
'({resource_type} Filters: {filters}.').format(
message = _('{resource_type} not found '
'({resource_type} Filters: {filters}.').format(
resource_type=resource_type, filters=filters)
LOG.exception(message)
raise getattr(base, '%sNotFound' %
resource_type.capitalize())(message)
except Exception:
message = _LE('Error retrieving {resource_type} '
'({resource_type} Filters: {filters}.').format(
message = _('Error retrieving {resource_type} '
'({resource_type} Filters: {filters}.').format(
resource_type=resource_type, filters=filters)
LOG.exception(message)
raise base.NetworkException(message)