Update i18n translation for BigSwitch plugin log msg's

All the log messages now have the required hints. In addition to this
debug messages are not translated.

This is done for the plugins/bigswitch and plugins/common directories

Change-Id: If661fcfac3b22c8cffee65c3e8073e746ef3468e
This commit is contained in:
Gary Kotton 2014-11-23 04:08:52 -08:00
parent 990e714904
commit 792f963fd5
8 changed files with 111 additions and 89 deletions

View File

@ -73,12 +73,28 @@ def _directory_to_check_translation(filename):
"neutron/scheduler",
"neutron/server",
"neutron/services",
#"neutron/plugins",
"neutron/plugins/bigswitch",
#"neutron/plugins/brocade",
"neutron/plugins/cisco",
"neutron/plugins/ml2",
"neutron/plugins/openvswitch",
"neutron/plugins/common",
#"neutron/plugins/embrane",
#"neutron/plugins/hyperv",
#"neutron/plugins/ibm",
"neutron/plugins/linuxbridge",
"neutron/plugins/vmware",
"neutron/plugins/mlnx"]
#"neutron/plugins/metaplugin",
#"neutron/plugins/midonet",
"neutron/plugins/ml2",
"neutron/plugins/mlnx",
#"neutron/plugins/nec",
#"neutron/plugins/nuage",
#"neutron/plugins/ofagent",
#"neutron/plugins/oneconvergence",
#"neutron/plugins/opencontrail",
"neutron/plugins/openvswitch",
#"neutron/plugins/plumgrid",
#"neutron/plugins/sriovnicagent",
"neutron/plugins/vmware"]
return any([dir in filename for dir in dirs])

View File

@ -34,6 +34,7 @@ from neutron.common import rpc as n_rpc
from neutron.common import topics
from neutron import context as q_context
from neutron.extensions import securitygroup as ext_sg
from neutron.i18n import _LE
from neutron.openstack.common import log
from neutron.plugins.bigswitch import config as pl_config
@ -51,8 +52,8 @@ class IVSBridge(ovs_lib.OVSBridge):
return utils.execute(full_args, root_helper=self.root_helper)
except Exception as e:
with excutils.save_and_reraise_exception() as ctxt:
LOG.error(_("Unable to execute %(cmd)s. "
"Exception: %(exception)s"),
LOG.error(_LE("Unable to execute %(cmd)s. "
"Exception: %(exception)s"),
{'cmd': full_args, 'exception': e})
if not check_error:
ctxt.reraise = False
@ -112,14 +113,14 @@ class RestProxyAgent(n_rpc.RpcCallback,
consumers)
def port_update(self, context, **kwargs):
LOG.debug(_("Port update received"))
LOG.debug("Port update received")
port = kwargs.get('port')
vif_port = self.int_br.get_vif_port_by_id(port['id'])
if not vif_port:
LOG.debug(_("Port %s is not present on this host."), port['id'])
LOG.debug("Port %s is not present on this host.", port['id'])
return
LOG.debug(_("Port %s found. Refreshing firewall."), port['id'])
LOG.debug("Port %s found. Refreshing firewall.", port['id'])
if ext_sg.SECURITYGROUPS in port:
self.sg_agent.refresh_firewall()
@ -147,18 +148,18 @@ class RestProxyAgent(n_rpc.RpcCallback,
try:
port_info = self._update_ports(ports)
if port_info:
LOG.debug(_("Agent loop has new device"))
LOG.debug("Agent loop has new device")
self._process_devices_filter(port_info)
ports = port_info['current']
except Exception:
LOG.exception(_("Error in agent event loop"))
LOG.exception(_LE("Error in agent event loop"))
elapsed = max(time.time() - start, 0)
if (elapsed < self.polling_interval):
time.sleep(self.polling_interval - elapsed)
else:
LOG.debug(_("Loop iteration exceeded interval "
"(%(polling_interval)s vs. %(elapsed)s)!"),
LOG.debug("Loop iteration exceeded interval "
"(%(polling_interval)s vs. %(elapsed)s)!",
{'polling_interval': self.polling_interval,
'elapsed': elapsed})

View File

@ -221,5 +221,5 @@ class HashHandler(object):
else:
conhash = ConsistencyHash(hash_id=self.hash_id, hash=hash)
self.session.merge(conhash)
LOG.debug(_("Consistency hash for group %(hash_id)s updated "
"to %(hash)s"), {'hash_id': self.hash_id, 'hash': hash})
LOG.debug("Consistency hash for group %(hash_id)s updated "
"to %(hash)s", {'hash_id': self.hash_id, 'hash': hash})

View File

@ -14,6 +14,7 @@
# under the License.
from neutron.api.v2 import attributes
from neutron.i18n import _LW
from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@ -36,15 +37,15 @@ def put_port_hostid(context, port_id, host):
# relational table generation until one of the functions is called.
from neutron.db import portbindings_db
if not attributes.is_attr_set(host):
LOG.warning(_("No host_id in port request to track port location."))
LOG.warning(_LW("No host_id in port request to track port location."))
return
if port_id == '':
LOG.warning(_("Received an empty port ID for host_id '%s'"), host)
LOG.warning(_LW("Received an empty port ID for host_id '%s'"), host)
return
if host == '':
LOG.debug(_("Received an empty host_id for port '%s'"), port_id)
LOG.debug("Received an empty host_id for port '%s'", port_id)
return
LOG.debug(_("Logging port %(port)s on host_id %(host)s"),
LOG.debug("Logging port %(port)s on host_id %(host)s",
{'port': port_id, 'host': host})
with context.session.begin(subtransactions=True):
location = portbindings_db.PortBindingPort(port_id=port_id, host=host)

View File

@ -31,6 +31,7 @@ from neutron.common import log
from neutron.common import utils
from neutron.db import l3_db
from neutron.extensions import l3
from neutron.i18n import _LE
from neutron.openstack.common import log as logging
from neutron.plugins.bigswitch import extensions
from neutron.plugins.bigswitch import plugin as cplugin
@ -209,8 +210,8 @@ class L3RestProxy(cplugin.NeutronRestProxyV2Base,
except servermanager.RemoteRestError as e:
with excutils.save_and_reraise_exception():
LOG.error(
_("NeutronRestProxyV2: Unable to create remote "
"floating IP: %s"), e)
_LE("NeutronRestProxyV2: Unable to create remote "
"floating IP: %s"), e)
# return created floating IP
return new_fl_ip
@ -278,7 +279,7 @@ class L3RestProxy(cplugin.NeutronRestProxyV2Base,
except exceptions.TooManyExternalNetworks:
# get_external_network can raise errors when multiple external
# networks are detected, which isn't supported by the Plugin
LOG.error(_("NeutronRestProxyV2: too many external networks"))
LOG.error(_LE("NeutronRestProxyV2: too many external networks"))
def _get_tenant_default_router_rules(self, tenant):
rules = cfg.CONF.ROUTER.tenant_default_router_rule

View File

@ -79,6 +79,7 @@ from neutron.extensions import external_net
from neutron.extensions import extra_dhcp_opt as edo_ext
from neutron.extensions import portbindings
from neutron import manager
from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.plugins.bigswitch import config as pl_config
from neutron.plugins.bigswitch.db import porttracker_db
@ -119,7 +120,7 @@ class SecurityGroupServerRpcMixin(sg_db_rpc.SecurityGroupServerRpcMixin):
def get_port_and_sgs(self, port_id):
"""Get port from database with security group info."""
LOG.debug(_("get_port_and_sgs() called for port_id %s"), port_id)
LOG.debug("get_port_and_sgs() called for port_id %s", port_id)
session = db.get_session()
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
@ -314,14 +315,14 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
def _warn_on_state_status(self, resource):
if resource.get('admin_state_up', True) is False:
LOG.warning(_("Setting admin_state_up=False is not supported "
"in this plugin version. Ignoring setting for "
"resource: %s"), resource)
LOG.warning(_LW("Setting admin_state_up=False is not supported "
"in this plugin version. Ignoring setting for "
"resource: %s"), resource)
if 'status' in resource:
if resource['status'] != const.NET_STATUS_ACTIVE:
LOG.warning(_("Operational status is internally set by the "
"plugin. Ignoring setting status=%s."),
LOG.warning(_LW("Operational status is internally set by the "
"plugin. Ignoring setting status=%s."),
resource['status'])
def _get_router_intf_details(self, context, intf_id, subnet_id):
@ -345,8 +346,8 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
cfg_vif_type = cfg.CONF.NOVA.vif_type.lower()
if cfg_vif_type not in (portbindings.VIF_TYPE_OVS,
portbindings.VIF_TYPE_IVS):
LOG.warning(_("Unrecognized vif_type in configuration "
"[%s]. Defaulting to ovs."),
LOG.warning(_LW("Unrecognized vif_type in configuration "
"[%s]. Defaulting to ovs."),
cfg_vif_type)
cfg_vif_type = portbindings.VIF_TYPE_OVS
# In ML2, the host_id is already populated
@ -394,8 +395,8 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
if (cfg.CONF.RESTPROXY.auto_sync_on_failure and
e.status == httplib.NOT_FOUND and
servermanager.NXNETWORK in e.reason):
LOG.error(_("Iconsistency with backend controller "
"triggering full synchronization."))
LOG.error(_LE("Iconsistency with backend controller "
"triggering full synchronization."))
# args depend on if we are operating in ML2 driver
# or as the full plugin
topoargs = self.servers.get_topo_function_args
@ -411,7 +412,7 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
# Any errors that don't result in a successful auto-sync
# require that the port be placed into the error state.
LOG.error(
_("NeutronRestProxyV2: Unable to create port: %s"), e)
_LE("NeutronRestProxyV2: Unable to create port: %s"), e)
try:
self._set_port_status(port['id'], const.PORT_STATUS_ERROR)
except exceptions.PortNotFound:
@ -472,7 +473,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
def __init__(self):
super(NeutronRestProxyV2, self).__init__()
LOG.info(_('NeutronRestProxy: Starting plugin. Version=%s'),
LOG.info(_LI('NeutronRestProxy: Starting plugin. Version=%s'),
version.version_string_with_vcs())
pl_config.register_config()
self.evpool = eventlet.GreenPool(cfg.CONF.RESTPROXY.thread_pool_size)
@ -499,7 +500,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
if cfg.CONF.RESTPROXY.sync_data:
self._send_all_data()
LOG.debug(_("NeutronRestProxyV2: initialization done"))
LOG.debug("NeutronRestProxyV2: initialization done")
def _setup_rpc(self):
self.conn = n_rpc.create_connection(new=True)
@ -544,7 +545,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2: create_network() called"))
LOG.debug("NeutronRestProxyV2: create_network() called")
self._warn_on_state_status(network['network'])
@ -587,7 +588,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: exceptions.NetworkNotFound
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2.update_network() called"))
LOG.debug("NeutronRestProxyV2.update_network() called")
self._warn_on_state_status(network['network'])
@ -615,7 +616,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: exceptions.NetworkNotFound
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2: delete_network() called"))
LOG.debug("NeutronRestProxyV2: delete_network() called")
# Validate args
orig_net = super(NeutronRestProxyV2, self).get_network(context, net_id)
@ -653,7 +654,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: exceptions.StateInvalid
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2: create_port() called"))
LOG.debug("NeutronRestProxyV2: create_port() called")
# Update DB in new session so exceptions rollback changes
with context.session.begin(subtransactions=True):
@ -745,7 +746,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: exceptions.PortNotFound
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2: update_port() called"))
LOG.debug("NeutronRestProxyV2: update_port() called")
self._warn_on_state_status(port['port'])
@ -808,7 +809,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
:raises: exceptions.NetworkNotFound
:raises: RemoteRestError
"""
LOG.debug(_("NeutronRestProxyV2: delete_port() called"))
LOG.debug("NeutronRestProxyV2: delete_port() called")
# if needed, check to see if this is a port owned by
# and l3-router. If so, we should prevent deletion.
@ -831,7 +832,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
@put_context_in_serverpool
def create_subnet(self, context, subnet):
LOG.debug(_("NeutronRestProxyV2: create_subnet() called"))
LOG.debug("NeutronRestProxyV2: create_subnet() called")
self._warn_on_state_status(subnet['subnet'])
@ -848,7 +849,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
@put_context_in_serverpool
def update_subnet(self, context, id, subnet):
LOG.debug(_("NeutronRestProxyV2: update_subnet() called"))
LOG.debug("NeutronRestProxyV2: update_subnet() called")
self._warn_on_state_status(subnet['subnet'])
@ -865,7 +866,7 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
@put_context_in_serverpool
def delete_subnet(self, context, id):
LOG.debug(_("NeutronRestProxyV2: delete_subnet() called"))
LOG.debug("NeutronRestProxyV2: delete_subnet() called")
orig_subnet = super(NeutronRestProxyV2, self).get_subnet(context, id)
net_id = orig_subnet['network_id']
with context.session.begin(subtransactions=True):
@ -889,6 +890,6 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
payload = {'subnet': updated_subnet}
self._dhcp_agent_notifier.notify(context, payload,
'subnet.update.end')
LOG.debug(_("Adding host route: "))
LOG.debug(_("Destination:%(dst)s nexthop:%(next)s"),
LOG.debug("Adding host route: ")
LOG.debug("Destination:%(dst)s nexthop:%(next)s",
{'dst': destination, 'next': nexthop})

View File

@ -72,7 +72,7 @@ class RouterRule_db_mixin(l3_db.L3_NAT_db_mixin):
router_db,
r['router_rules'])
else:
LOG.debug(_('No rules in router'))
LOG.debug('No rules in router')
router_db['router_rules'] = self._get_router_rules_by_router_id(
context, router_db['id'])
@ -86,7 +86,7 @@ class RouterRule_db_mixin(l3_db.L3_NAT_db_mixin):
del_context = context.session.query(RouterRule)
del_context.filter_by(router_id=router['id']).delete()
context.session.expunge_all()
LOG.debug(_('Updating router rules to %s'), rules)
LOG.debug('Updating router rules to %s', rules)
for rule in rules:
router_rule = RouterRule(
router_id=router['id'],

View File

@ -41,6 +41,7 @@ from oslo.serialization import jsonutils
from oslo.utils import excutils
from neutron.common import exceptions
from neutron.i18n import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron.plugins.bigswitch.db import consistency_db as cdb
@ -114,11 +115,11 @@ class ServerProxy(object):
body = self.rest_call('GET', CAPABILITIES_PATH)[2]
self.capabilities = jsonutils.loads(body)
except Exception:
LOG.exception(_("Couldn't retrieve capabilities. "
"Newer API calls won't be supported."))
LOG.info(_("The following capabilities were received "
"for %(server)s: %(cap)s"), {'server': self.server,
'cap': self.capabilities})
LOG.exception(_LE("Couldn't retrieve capabilities. "
"Newer API calls won't be supported."))
LOG.info(_LI("The following capabilities were received "
"for %(server)s: %(cap)s"), {'server': self.server,
'cap': self.capabilities})
return self.capabilities
def rest_call(self, action, resource, data='', headers=None,
@ -144,11 +145,11 @@ class ServerProxy(object):
if self.auth:
headers['Authorization'] = self.auth
LOG.debug(_("ServerProxy: server=%(server)s, port=%(port)d, "
"ssl=%(ssl)r"),
LOG.debug("ServerProxy: server=%(server)s, port=%(port)d, "
"ssl=%(ssl)r",
{'server': self.server, 'port': self.port, 'ssl': self.ssl})
LOG.debug(_("ServerProxy: resource=%(resource)s, data=%(data)r, "
"headers=%(headers)r, action=%(action)s"),
LOG.debug("ServerProxy: resource=%(resource)s, data=%(data)r, "
"headers=%(headers)r, action=%(action)s",
{'resource': resource, 'data': data, 'headers': headers,
'action': action})
@ -168,16 +169,16 @@ class ServerProxy(object):
self.currentconn = HTTPSConnectionWithValidation(
self.server, self.port, timeout=timeout)
if self.currentconn is None:
LOG.error(_('ServerProxy: Could not establish HTTPS '
'connection'))
LOG.error(_LE('ServerProxy: Could not establish HTTPS '
'connection'))
return 0, None, None, None
self.currentconn.combined_cert = self.combined_cert
else:
self.currentconn = httplib.HTTPConnection(
self.server, self.port, timeout=timeout)
if self.currentconn is None:
LOG.error(_('ServerProxy: Could not establish HTTP '
'connection'))
LOG.error(_LE('ServerProxy: Could not establish HTTP '
'connection'))
return 0, None, None, None
try:
@ -218,14 +219,14 @@ class ServerProxy(object):
timeout=timeout, reconnect=True)
except (socket.timeout, socket.error) as e:
self.currentconn.close()
LOG.error(_('ServerProxy: %(action)s failure, %(e)r'),
LOG.error(_LE('ServerProxy: %(action)s failure, %(e)r'),
{'action': action, 'e': e})
ret = 0, None, None, None
LOG.debug(_("ServerProxy: status=%(status)d, reason=%(reason)r, "
"ret=%(ret)s, data=%(data)r"), {'status': ret[0],
'reason': ret[1],
'ret': ret[2],
'data': ret[3]})
LOG.debug("ServerProxy: status=%(status)d, reason=%(reason)r, "
"ret=%(ret)s, data=%(data)r", {'status': ret[0],
'reason': ret[1],
'ret': ret[2],
'data': ret[3]})
return ret
@ -242,7 +243,7 @@ class ServerPool(object):
def __init__(self, timeout=False,
base_uri=BASE_URI, name='NeutronRestProxy'):
LOG.debug(_("ServerPool: initializing"))
LOG.debug("ServerPool: initializing")
# 'servers' is the list of network controller REST end-points
# (used in order specified till one succeeds, and it is sticky
# till next failure). Use 'server_auth' to encode api-key
@ -281,7 +282,7 @@ class ServerPool(object):
eventlet.spawn(self._consistency_watchdog,
cfg.CONF.RESTPROXY.consistency_interval)
ServerPool._instance = self
LOG.debug(_("ServerPool: initialization done"))
LOG.debug("ServerPool: initialization done")
def set_context(self, context):
# this context needs to be local to the greenthread
@ -396,9 +397,9 @@ class ServerPool(object):
'Error details: %(error)s') %
{'server': server, 'error': str(e)})
LOG.warning(_("Storing to certificate for host %(server)s "
"at %(path)s") % {'server': server,
'path': path})
LOG.warning(_LW("Storing to certificate for host %(server)s "
"at %(path)s"), {'server': server,
'path': path})
self._file_put_contents(path, cert)
return cert
@ -465,14 +466,14 @@ class ServerPool(object):
active_server.failed = False
return ret
else:
LOG.error(_('ServerProxy: %(action)s failure for servers: '
'%(server)r Response: %(response)s'),
LOG.error(_LE('ServerProxy: %(action)s failure for servers: '
'%(server)r Response: %(response)s'),
{'action': action,
'server': (active_server.server,
active_server.port),
'response': ret[3]})
LOG.error(_("ServerProxy: Error details: status=%(status)d, "
"reason=%(reason)r, ret=%(ret)s, data=%(data)r"),
LOG.error(_LE("ServerProxy: Error details: status=%(status)d, "
"reason=%(reason)r, ret=%(ret)s, data=%(data)r"),
{'status': ret[0], 'reason': ret[1], 'ret': ret[2],
'data': ret[3]})
active_server.failed = True
@ -485,8 +486,8 @@ class ServerPool(object):
if action == 'DELETE':
hash_handler.put_hash('INCONSISTENT,INCONSISTENT')
# All servers failed, reset server list and try again next time
LOG.error(_('ServerProxy: %(action)s failure for all servers: '
'%(server)r'),
LOG.error(_LE('ServerProxy: %(action)s failure for all servers: '
'%(server)r'),
{'action': action,
'server': tuple((s.server,
s.port) for s in self.servers)})
@ -510,9 +511,9 @@ class ServerPool(object):
LOG.error(errstr, resp[2])
raise RemoteRestError(reason=resp[2], status=resp[0])
if resp[0] in ignore_codes:
LOG.warning(_("NeutronRestProxyV2: Received and ignored error "
"code %(code)s on %(action)s action to resource "
"%(resource)s"),
LOG.warning(_LW("NeutronRestProxyV2: Received and ignored error "
"code %(code)s on %(action)s action to resource "
"%(resource)s"),
{'code': resp[2], 'action': action,
'resource': resource})
return resp
@ -568,8 +569,9 @@ class ServerPool(object):
device_id = port.get("device_id")
if not port["mac_address"] or not device_id:
# controller only cares about ports attached to devices
LOG.warning(_("No device MAC attached to port %s. "
"Skipping notification to controller."), port["id"])
LOG.warning(_LW("No device MAC attached to port %s. "
"Skipping notification to controller."),
port["id"])
return
data["attachment"] = {"id": device_id,
"mac": port["mac_address"]}
@ -608,12 +610,12 @@ class ServerPool(object):
def _consistency_watchdog(self, polling_interval=60):
if 'consistency' not in self.get_capabilities():
LOG.warning(_("Backend server(s) do not support automated "
"consitency checks."))
LOG.warning(_LW("Backend server(s) do not support automated "
"consitency checks."))
return
if not polling_interval:
LOG.warning(_("Consistency watchdog disabled by polling interval "
"setting of %s."), polling_interval)
LOG.warning(_LW("Consistency watchdog disabled by polling "
"interval setting of %s."), polling_interval)
return
while True:
# If consistency is supported, all we have to do is make any
@ -624,8 +626,8 @@ class ServerPool(object):
try:
self.rest_action('GET', HEALTH_PATH)
except Exception:
LOG.exception(_("Encountered an error checking controller "
"health."))
LOG.exception(_LE("Encountered an error checking controller "
"health."))
class HTTPSConnectionWithValidation(httplib.HTTPSConnection):