Fix message i18n error

Partial-Bug: #1217100

Using tools/check_i18n.py to scan source directory, and fix most of
the errors.

- Message internationalization
- First letter must be capital
- Using comma instead of percent in LOG.xxx

Note: all extension's description are not touched in this patch,
can be fixed after discussing.
Note: all nicira/check_nvp_config.py print messages are not fixed.

Change-Id: I79ef06fd42f6780beb5019c592662536c2a51864
This commit is contained in:
ZhiQiang Fan 2013-08-27 08:02:04 +08:00
parent 57ce39fa66
commit 9842dcb34c
58 changed files with 153 additions and 144 deletions

View File

@ -145,7 +145,7 @@ class DhcpAgent(manager.Manager):
except Exception:
self.needs_resync = True
LOG.exception(_('Unable to sync network state on deleted '
'network %s') % deleted_id)
'network %s'), deleted_id)
for network in active_networks:
pool.spawn_n(self.configure_dhcp_for_network, network)

View File

@ -258,7 +258,7 @@ class InvalidExtensionEnv(BadRequest):
class InvalidContentType(NeutronException):
message = "Invalid content type %(content_type)s"
message = _("Invalid content type %(content_type)s")
class ExternalIpAddressExhausted(BadRequest):

View File

@ -216,7 +216,7 @@ class DhcpRpcCallbackMixin(object):
host = kwargs.get('host')
LOG.warning(_('Updating lease expiration is now deprecated. Issued '
'from host %(host)s.') % host)
'from host %s.'), host)
def create_dhcp_port(self, context, **kwargs):
"""Create the dhcp port."""

View File

@ -126,7 +126,7 @@ class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
context, router['id'])
added, removed = utils.diff_list_of_dict(old_routes,
routes)
LOG.debug('Added routes are %s' % added)
LOG.debug(_('Added routes are %s'), added)
for route in added:
router_routes = RouterRoute(
router_id=router['id'],
@ -134,7 +134,7 @@ class ExtraRoute_db_mixin(l3_db.L3_NAT_db_mixin):
nexthop=route['nexthop'])
context.session.add(router_routes)
LOG.debug('Removed routes are %s' % removed)
LOG.debug(_('Removed routes are %s'), removed)
for route in removed:
del_context = context.session.query(RouterRoute)
del_context.filter_by(router_id=router['id'],

View File

@ -59,8 +59,8 @@ class L3RpcCallbackMixin(object):
def _ensure_host_set_on_ports(self, context, plugin, host, routers):
for router in routers:
LOG.debug("checking router: %s for host: %s" %
(router['id'], host))
LOG.debug(_("Checking router: %(id)s for host: %(host)s"),
{'id': router['id'], 'host': host})
self._ensure_host_set_on_port(context, plugin, host,
router.get('gw_port'))
for interface in router.get(constants.INTERFACE_KEY, []):

View File

@ -47,7 +47,7 @@ class CreateProbe(ProbeCommand):
parser.add_argument(
'--device-owner',
default='network', choices=['network', 'compute'],
help=_('owner type of the device: network/compute'))
help=_('Owner type of the device: network/compute'))
return parser
def run(self, parsed_args):

View File

@ -53,7 +53,7 @@ def _raise_if_updates_provider_attributes(attrs):
"""
immutable = (NETWORK_TYPE, PHYSICAL_NETWORK, SEGMENTATION_ID)
if any(attributes.is_attr_set(attrs.get(a)) for a in immutable):
msg = _("plugin does not support updating provider attributes")
msg = _("Plugin does not support updating provider attributes")
raise q_exc.InvalidInput(error_message=msg)

View File

@ -159,7 +159,7 @@ ROUTER_INTF_PATH = "/tenants/%s/routers/%s/interfaces/%s"
SUCCESS_CODES = range(200, 207)
FAILURE_CODES = [0, 301, 302, 303, 400, 401, 403, 404, 500, 501, 502, 503,
504, 505]
SYNTAX_ERROR_MESSAGE = 'Syntax error in server config file, aborting plugin'
SYNTAX_ERROR_MESSAGE = _('Syntax error in server config file, aborting plugin')
BASE_URI = '/networkService/v1.1'
ORCHESTRATION_SERVICE_ID = 'Neutron v2.0'
METADATA_SERVER_IP = '169.254.169.254'
@ -455,7 +455,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2,
timeout = server_timeout
# validate config
assert servers is not None, 'Servers not defined. Aborting plugin'
assert servers is not None, _('Servers not defined. Aborting plugin')
servers = tuple(s.rsplit(':', 1) for s in servers.split(','))
servers = tuple((server, int(port)) for server, port in servers)
assert all(len(s) == 2 for s in servers), SYNTAX_ERROR_MESSAGE
@ -992,7 +992,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2,
# we will first get the interface identifier before deleting in the DB
if not interface_info:
msg = "Either subnet_id or port_id must be specified"
msg = _("Either subnet_id or port_id must be specified")
raise exceptions.BadRequest(resource='router', msg=msg)
if 'port_id' in interface_info:
port = self._get_port(context, interface_info['port_id'])
@ -1001,7 +1001,7 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2,
subnet = self._get_subnet(context, interface_info['subnet_id'])
interface_id = subnet['network_id']
else:
msg = "Either subnet_id or port_id must be specified"
msg = _("Either subnet_id or port_id must be specified")
raise exceptions.BadRequest(resource='router', msg=msg)
with context.session.begin(subtransactions=True):
@ -1144,9 +1144,9 @@ class NeutronRestProxyV2(db_base_plugin_v2.NeutronDbPluginV2,
payload = {'subnet': updated_subnet}
self._dhcp_agent_notifier.notify(context, payload,
'subnet.update.end')
LOG.debug("Adding host route: ")
LOG.debug("destination:%s nexthop:%s" % (destination,
nexthop))
LOG.debug(_("Adding host route: "))
LOG.debug(_("Destination:%(dst)s nexthop:%(next)s"),
{'dst': destination, 'next': nexthop})
def _get_network_with_floatingips(self, network, context=None):
if context is None:

View File

@ -74,7 +74,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'])
@ -88,7 +88,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

@ -290,7 +290,8 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("Returning the allocated vlan (%d) to the pool"),
vlan_id)
self._vlan_bitmap.release_vlan(int(vlan_id))
raise Exception("Brocade plugin raised exception, check logs")
raise Exception(_("Brocade plugin raised exception, "
"check logs"))
brocade_db.create_network(context, net_uuid, vlan_id)
self._process_l3_create(context, net, network['network'])
@ -330,7 +331,8 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
# Proper formatting
LOG.warning(_("Brocade NOS driver:"))
LOG.warning(_("%s"), e)
raise Exception("Brocade plugin raised exception, check logs")
raise Exception(_("Brocade plugin raised exception, "
"check logs"))
# now ok to delete the network
brocade_db.delete_network(context, net_id)
@ -383,7 +385,8 @@ class BrocadePluginV2(db_base_plugin_v2.NeutronDbPluginV2,
# Proper formatting
LOG.warning(_("Brocade NOS driver:"))
LOG.warning(_("%s"), e)
raise Exception("Brocade plugin raised exception, check logs")
raise Exception(_("Brocade plugin raised exception, "
"check logs"))
# save to brocade persistent db
brocade_db.create_port(context, port_id, network_id,

View File

@ -36,11 +36,11 @@ cisco_opts = [
cfg.StrOpt('provider_vlan_name_prefix', default='p-',
help=_("VLAN Name prefix for provider vlans")),
cfg.BoolOpt('provider_vlan_auto_create', default=True,
help='Provider VLANs are automatically created as needed '
'on the Nexus switch'),
help=_('Provider VLANs are automatically created as needed '
'on the Nexus switch')),
cfg.BoolOpt('provider_vlan_auto_trunk', default=True,
help='Provider VLANs are automatically trunked as needed '
'on the ports of the Nexus switch'),
help=_('Provider VLANs are automatically trunked as needed '
'on the ports of the Nexus switch')),
cfg.BoolOpt('svi_round_robin', default=False,
help=_("Distribute SVI interfaces over all switches")),
cfg.StrOpt('model_class',
@ -121,7 +121,7 @@ class CiscoConfigOptions():
read_ok = multi_parser.read(CONF.config_file)
if len(read_ok) != len(CONF.config_file):
raise cfg.Error("Some config files were not parsed properly")
raise cfg.Error(_("Some config files were not parsed properly"))
for parsed_file in multi_parser.parsed:
for parsed_item in parsed_file.keys():

View File

@ -667,7 +667,7 @@ def delete_vxlan_allocations(db_session, vxlan_id_ranges):
filter_by(allocated=False))
for alloc in allocs:
if alloc.vxlan_id in vxlan_ids:
LOG.debug(_("Removing vxlan %s from pool") %
LOG.debug(_("Removing vxlan %s from pool"),
alloc.vxlan_id)
db_session.delete(alloc)
@ -698,9 +698,9 @@ def reserve_specific_vxlan(db_session, vxlan_id):
one())
if alloc.allocated:
raise c_exc.VxlanIdInUse(vxlan_id=vxlan_id)
LOG.debug(_("Reserving specific vxlan %s from pool") % vxlan_id)
LOG.debug(_("Reserving specific vxlan %s from pool"), vxlan_id)
except exc.NoResultFound:
LOG.debug(_("Reserving specific vxlan %s outside pool") % vxlan_id)
LOG.debug(_("Reserving specific vxlan %s outside pool"), vxlan_id)
alloc = n1kv_models_v2.N1kvVxlanAllocation(vxlan_id=vxlan_id)
db_session.add(alloc)
alloc.allocated = True
@ -946,7 +946,7 @@ def get_policy_profile(db_session, id):
def create_profile_binding(tenant_id, profile_id, profile_type):
"""Create Network/Policy Profile association with a tenant."""
if profile_type not in ["network", "policy"]:
raise q_exc.NeutronException("Invalid profile type")
raise q_exc.NeutronException(_("Invalid profile type"))
if _profile_binding_exists(tenant_id, profile_id, profile_type):
return get_profile_binding(tenant_id, profile_id)
@ -994,7 +994,7 @@ def delete_profile_binding(tenant_id, profile_id):
db_session.delete(binding)
except c_exc.ProfileTenantBindingNotFound:
LOG.debug(_("Profile-Tenant binding missing for profile ID "
"%(profile_id)s and tenant ID %(tenant_id)s") %
"%(profile_id)s and tenant ID %(tenant_id)s"),
{"profile_id": profile_id, "tenant_id": tenant_id})
return
@ -1221,7 +1221,7 @@ class NetworkProfile_db_mixin(object):
:param network_profile: network profile object
"""
if not re.match(r"(\d+)\-(\d+)", network_profile["segment_range"]):
msg = _("invalid segment range. example range: 500-550")
msg = _("Invalid segment range. example range: 500-550")
raise q_exc.InvalidInput(error_message=msg)
def _validate_network_profile(self, net_p):
@ -1231,7 +1231,7 @@ class NetworkProfile_db_mixin(object):
:param net_p: network profile object
"""
if any(net_p[arg] == "" for arg in ["segment_type"]):
msg = _("arguments segment_type missing"
msg = _("Arguments segment_type missing"
" for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
@ -1246,21 +1246,21 @@ class NetworkProfile_db_mixin(object):
raise q_exc.InvalidInput(error_message=msg)
if segment_type == c_const.NETWORK_TYPE_VLAN:
if "physical_network" not in net_p:
msg = _("argument physical_network missing "
msg = _("Argument physical_network missing "
"for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_TRUNK,
c_const.NETWORK_TYPE_OVERLAY]:
if "sub_type" not in net_p:
msg = _("argument sub_type missing "
msg = _("Argument sub_type missing "
"for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_VLAN,
c_const.NETWORK_TYPE_OVERLAY]:
if "segment_range" not in net_p:
msg = _("argument segment_range missing "
msg = _("Argument segment_range missing "
"for network profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)
@ -1306,7 +1306,7 @@ class NetworkProfile_db_mixin(object):
(profile_seg_min <= seg_max <= profile_seg_max) or
((seg_min <= profile_seg_min) and
(seg_max >= profile_seg_max))):
msg = _("segment range overlaps with another profile")
msg = _("Segment range overlaps with another profile")
LOG.exception(msg)
raise q_exc.InvalidInput(error_message=msg)

View File

@ -233,9 +233,9 @@ class VirtualPhysicalSwitchModelV2(neutron_plugin_base_v2.NeutronPluginBaseV2):
cdb.add_provider_network(network_id,
const.NETWORK_TYPE_VLAN,
provider_vlan_id)
LOG.debug(_("provider network added to DB: %(network_id)s, "
"%(vlan_id)s"), {'network_id': network_id,
'vlan_id': provider_vlan_id})
LOG.debug(_("Provider network added to DB: %(network_id)s, "
"%(vlan_id)s"),
{'network_id': network_id, 'vlan_id': provider_vlan_id})
return ovs_output[0]
def update_network(self, context, id, network):
@ -277,7 +277,7 @@ class VirtualPhysicalSwitchModelV2(neutron_plugin_base_v2.NeutronPluginBaseV2):
self._func_name(),
args)
if cdb.remove_provider_network(id):
LOG.debug(_("provider network removed from DB: %s"), id)
LOG.debug(_("Provider network removed from DB: %s"), id)
return ovs_output[0]
def get_network(self, context, id, fields=None):

View File

@ -253,7 +253,7 @@ class Client(object):
:param network_profile: network profile dict
"""
LOG.debug(_("logical network"))
LOG.debug(_("Logical network"))
body = {'name': network_profile['name']}
return self._post(self.logical_networks_path,
body=body)
@ -459,7 +459,7 @@ class Client(object):
elif type(data) is dict:
return wsgi.Serializer().serialize(data, self._set_content_type())
else:
raise Exception("unable to serialize object of type = '%s'" %
raise Exception(_("Unable to serialize object of type = '%s'") %
type(data))
def _deserialize(self, data, status_code):

View File

@ -350,7 +350,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
if network_type == c_const.NETWORK_TYPE_VLAN:
if physical_network_set:
if physical_network not in self.network_vlan_ranges:
msg = (_("unknown provider:physical_network %s"),
msg = (_("Unknown provider:physical_network %s") %
physical_network)
raise q_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
@ -376,7 +376,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
return
# TBD : Need to handle provider network updates
msg = _("plugin does not support updating provider attributes")
msg = _("Plugin does not support updating provider attributes")
raise q_exc.InvalidInput(error_message=msg)
def _get_cluster(self, segment1, segment2, clusters):
@ -992,7 +992,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
self._add_dummy_profile_only_if_testing(network)
profile_id = self._process_network_profile(context, network['network'])
segment_pairs = None
LOG.debug(_('create network: profile_id=%s'), profile_id)
LOG.debug(_('Create network: profile_id=%s'), profile_id)
session = context.session
with session.begin(subtransactions=True):
if not network_type:
@ -1012,7 +1012,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
segment_pairs = (
self._parse_multi_segments(context, network['network'],
n1kv_profile.SEGMENT_ADD))
LOG.debug(_('seg list %s '), segment_pairs)
LOG.debug(_('Seg list %s '), segment_pairs)
elif network_type == c_const.NETWORK_TYPE_TRUNK:
network_profile = self.get_network_profile(context,
profile_id)
@ -1022,7 +1022,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
physical_network,
network_profile['sub_type']
))
LOG.debug(_('seg list %s '), segment_pairs)
LOG.debug(_('Seg list %s '), segment_pairs)
else:
if not segmentation_id:
raise q_exc.TenantNetworksDisabled()
@ -1238,7 +1238,7 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
if profile_id_set:
profile_id = self._process_policy_profile(context,
port['port'])
LOG.debug(_('create port: profile_id=%s'), profile_id)
LOG.debug(_('Create port: profile_id=%s'), profile_id)
session = context.session
with session.begin(subtransactions=True):
pt = super(N1kvNeutronPluginV2, self).create_port(context,

View File

@ -113,8 +113,9 @@ class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
else:
# Must make sure we re-raise the error that led us here, since
# otherwise getattr() and even hasattr() doesn't work corretly.
raise AttributeError("'%s' object has no attribute '%s'" %
(self._model, name))
raise AttributeError(
_("'%(model)s' object has no attribute '%(name)s'") %
{'model': self._model, 'name': name})
def _extend_fault_map(self):
"""Extend the Neutron Fault Map for Cisco exceptions.

View File

@ -109,19 +109,19 @@ class NexusPlugin(L2DevicePluginBase):
except cisco_exc.NexusPortBindingNotFound:
if auto_create and auto_trunk:
# Create vlan and trunk vlan on the port
LOG.debug("Nexus: create & trunk vlan %s" % vlan_name)
LOG.debug(_("Nexus: create & trunk vlan %s"), vlan_name)
self._client.create_and_trunk_vlan(
switch_ip, vlan_id, vlan_name, etype, port_id)
vlan_created = True
vlan_trunked = True
elif auto_create:
# Create vlan but do not trunk it on the port
LOG.debug("Nexus: create vlan %s" % vlan_name)
LOG.debug(_("Nexus: create vlan %s"), vlan_name)
self._client.create_vlan(switch_ip, vlan_id, vlan_name)
vlan_created = True
elif auto_trunk:
# Only trunk vlan on the port
LOG.debug("Nexus: trunk vlan %s" % vlan_name)
LOG.debug(_("Nexus: trunk vlan %s"), vlan_name)
self._client.enable_vlan_on_trunk_int(
switch_ip, vlan_id, etype, port_id)
vlan_trunked = True
@ -134,16 +134,16 @@ class NexusPlugin(L2DevicePluginBase):
with excutils.save_and_reraise_exception():
# Add binding failed, roll back any vlan creation/enabling
if vlan_created and vlan_trunked:
LOG.debug("Nexus: delete & untrunk vlan %s" %
LOG.debug(_("Nexus: delete & untrunk vlan %s"),
vlan_name)
self._client.delete_and_untrunk_vlan(switch_ip,
vlan_id,
etype, port_id)
elif vlan_created:
LOG.debug("Nexus: delete vlan %s" % vlan_name)
LOG.debug(_("Nexus: delete vlan %s"), vlan_name)
self._client.delete_vlan(switch_ip, vlan_id)
elif vlan_trunked:
LOG.debug("Nexus: untrunk vlan %s" % vlan_name)
LOG.debug(_("Nexus: untrunk vlan %s"), vlan_name)
self._client.disable_vlan_on_trunk_int(switch_ip,
vlan_id,
etype,
@ -273,7 +273,7 @@ class NexusPlugin(L2DevicePluginBase):
if cdb.is_provider_vlan(vlan_id):
auto_delete = conf.CISCO.provider_vlan_auto_create
auto_untrunk = conf.CISCO.provider_vlan_auto_trunk
LOG.debug("delete_network(): provider vlan %s" % vlan_id)
LOG.debug(_("delete_network(): provider vlan %s"), vlan_id)
instance_id = False
for row in rows:

View File

@ -133,7 +133,7 @@ class EmbranePlugin(object):
"device_owner": ["network:router_gateway"]})
if len(gw_ports) != 1:
raise c_exc.EmbranePluginException(
err_msg=_("there must be only one gateway port "
err_msg=_("There must be only one gateway port "
"per router at once"))
gw_port = gw_ports[0]
@ -170,8 +170,8 @@ class EmbranePlugin(object):
"device_owner": ["network:router_gateway"]})
if len(gw_ports) != 1:
raise c_exc.EmbranePluginException(
err_msg=_("there must be only one gateway port"
" per router at once"))
err_msg=_("There must be only one gateway port "
"per router at once"))
gw_port = gw_ports[0]
utif_info = (self._plugin_support.retrieve_utif_info(context,

View File

@ -42,7 +42,7 @@ heleos_opts = [
cfg.StrOpt('resource_pool_id', default='default',
help=_('Shared resource pool id')),
cfg.BoolOpt('async_requests', default=True,
help=_('define if the requests have '
help=_('Define if the requests have '
'run asynchronously or not')),
]

View File

@ -21,5 +21,5 @@ from neutron.plugins.embrane.common import exceptions as embrane_exc
class UtifInfoError(embrane_exc.EmbranePluginException):
message = _("cannot retrieve utif info for the following reason: "
message = _("Cannot retrieve utif info for the following reason: "
"%(err_msg)s")

View File

@ -258,22 +258,23 @@ class HyperVNeutronAgent(object):
def _treat_devices_added(self, devices):
resync = False
for device in devices:
LOG.info(_("Adding port %s") % device)
LOG.info(_("Adding port %s"), device)
try:
device_details = self.plugin_rpc.get_device_details(
self.context,
device,
self.agent_id)
except Exception as e:
LOG.debug(_(
"Unable to get port details for device %(device)s: %(e)s"),
dict(device=device, e=e))
LOG.debug(
_("Unable to get port details for "
"device %(device)s: %(e)s"),
{'device': device, 'e': e})
resync = True
continue
if 'port_id' in device_details:
LOG.info(_(
"Port %(device)s updated. Details: %(device_details)s") %
dict(device=device, device_details=device_details))
LOG.info(
_("Port %(device)s updated. Details: %(device_details)s"),
{'device': device, 'device_details': device_details})
self._treat_vif_port(
device_details['port_id'],
device_details['network_id'],

View File

@ -152,7 +152,7 @@ class HyperVUtils(object):
desc = job.Description
elap = job.ElapsedTime
LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s") %
LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s"),
{'desc': desc, 'elap': elap})
def _create_switch_port(self, vswitch_name, switch_port_name):

View File

@ -31,7 +31,7 @@ if sys.platform == 'win32':
hyper_opts = [
cfg.BoolOpt('force_hyperv_utils_v1',
default=False,
help='Force V1 WMI utility classes'),
help=_('Force V1 WMI utility classes')),
]
CONF = cfg.CONF
@ -56,7 +56,7 @@ def _get_class(v1_class, v2_class, force_v1_flag):
cls = v2_class
else:
cls = v1_class
LOG.debug("Loading class: %(module_name)s.%(class_name)s",
LOG.debug(_("Loading class: %(module_name)s.%(class_name)s"),
{'module_name': cls.__module__, 'class_name': cls.__name__})
return cls

View File

@ -512,7 +512,7 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
self.agent_state)
self.agent_state.pop('start_flag', None)
except Exception:
LOG.exception("Failed reporting state!")
LOG.exception(_("Failed reporting state!"))
def setup_rpc(self, physical_interfaces):
if physical_interfaces:
@ -523,7 +523,7 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
mac = utils.get_interface_mac(devices[0].name)
else:
LOG.error(_("Unable to obtain MAC address for unique ID. "
"Agent terminated!"))
"Agent terminated!"))
exit(1)
self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
LOG.info(_("RPC agent_id: %s"), self.agent_id)

View File

@ -192,7 +192,8 @@ class MidoClient:
{'bridge': bridge})
dhcp = bridge.get_dhcp_subnets()
if not dhcp:
raise MidonetApiException(msg="Tried to delete non-existent DHCP")
raise MidonetApiException(
msg=_("Tried to delete non-existent DHCP"))
dhcp[0].delete()
@handle_api_error

View File

@ -53,7 +53,7 @@ class ML2MechCiscoConfig(object):
read_ok = multi_parser.read(cfg.CONF.config_file)
if len(read_ok) != len(cfg.CONF.config_file):
raise cfg.Error("Some config files were not parsed properly")
raise cfg.Error(_("Some config files were not parsed properly"))
for parsed_file in multi_parser.parsed:
for parsed_item in parsed_file.keys():

View File

@ -27,7 +27,7 @@ from neutron.plugins.ml2.drivers.mech_arista import exceptions as arista_exc
LOG = logging.getLogger(__name__)
EOS_UNREACHABLE_MSG = 'Unable to reach EOS'
EOS_UNREACHABLE_MSG = _('Unable to reach EOS')
class AristaRPCWrapper(object):
@ -235,9 +235,10 @@ class AristaRPCWrapper(object):
ret = ret[len(command_start):-len(command_end)]
except Exception as error:
host = cfg.CONF.ml2_arista.eapi_host
msg = ('Error %s while trying to execute commands %s on EOS %s' %
(error, full_command, host))
LOG.exception(_("%s"), msg)
msg = (_('Error %(err)s while trying to execute '
'commands %(cmd)s on EOS %(host)s') %
{'err': error, 'cmd': full_command, 'host': host})
LOG.exception(msg)
raise arista_exc.AristaRpcError(msg=msg)
return ret
@ -275,7 +276,7 @@ class SyncService(object):
def synchronize(self):
"""Sends data to EOS which differs from neutron DB."""
LOG.info('Syncing Neutron <-> EOS')
LOG.info(_('Syncing Neutron <-> EOS'))
try:
eos_tenants = self._rpc.get_tenants()
except arista_exc.AristaRpcError:

View File

@ -100,7 +100,7 @@ class TunnelRpcCallbackMixin(object):
tunnel_ip = kwargs.get('tunnel_ip')
tunnel_type = kwargs.get('tunnel_type')
if not tunnel_type:
msg = "network_type value needed by the ML2 plugin"
msg = _("Network_type value needed by the ML2 plugin")
raise exc.InvalidInput(error_message=msg)
driver = self.type_manager.drivers.get(tunnel_type)
if driver:

View File

@ -130,9 +130,9 @@ class EswitchManager(object):
physical_network, segmentation_id):
LOG.info(_("Provisioning network %s"), network_id)
if network_type == constants.TYPE_VLAN:
LOG.debug(_("creating VLAN Network"))
LOG.debug(_("Creating VLAN Network"))
elif network_type == constants.TYPE_IB:
LOG.debug(_("creating IB Network"))
LOG.debug(_("Creating IB Network"))
else:
LOG.error(_("Unknown network type %(network_type)s "
"for network %(network_id)s"),
@ -295,10 +295,10 @@ class MlnxEswitchNeutronAgent(sg_rpc.SecurityGroupAgentRpcMixin):
resync_a = False
resync_b = False
if port_info.get('added'):
LOG.debug(_("ports added!"))
LOG.debug(_("Ports added!"))
resync_a = self.treat_devices_added(port_info['added'])
if port_info.get('removed'):
LOG.debug(_("ports removed!"))
LOG.debug(_("Ports removed!"))
resync_b = self.treat_devices_removed(port_info['removed'])
# If one of the above opertaions fails => resync with plugin
return (resync_a | resync_b)

View File

@ -40,7 +40,7 @@ eswitch_opts = [
help=_("List of <physical_network>:<physical_interface>")),
cfg.StrOpt('vnic_type',
default=constants.VIF_TYPE_DIRECT,
help=_("type of VM network interface: mlnx_direct or "
help=_("Type of VM network interface: mlnx_direct or "
"hostdev")),
cfg.StrOpt('daemon_endpoint',
default='tcp://127.0.0.1:5001',

View File

@ -65,7 +65,7 @@ def _remove_unconfigured_vlans(session, allocations):
for entries in allocations.itervalues():
for entry in entries:
if not entry.allocated:
LOG.debug(_("removing vlan %(seg_id)s on physical "
LOG.debug(_("Removing vlan %(seg_id)s on physical "
"network %(net)s from pool"),
{'seg_id': entry.segmentation_id,
'net': entry.physical_network})

View File

@ -240,7 +240,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2,
constants.TYPE_FLAT]:
if physical_network_set:
if physical_network not in self.network_vlan_ranges:
msg = _("unknown provider:physical_network "
msg = _("Unknown provider:physical_network "
"%s") % physical_network
raise q_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
@ -277,11 +277,11 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2,
self.base_binding_dict[portbindings.VIF_TYPE] = vnic_type
return vnic_type
else:
msg = (_("unsupported vnic type %(vnic_type)s "
msg = (_("Unsupported vnic type %(vnic_type)s "
"for network type %(net_type)s") %
{'vnic_type': vnic_type, 'net_type': net_type})
else:
msg = _("invalid vnic_type on port_create")
msg = _("Invalid vnic_type on port_create")
else:
msg = _("vnic_type is not defined in port profile")
raise q_exc.InvalidInput(error_message=msg)
@ -328,7 +328,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2,
return net
def update_network(self, context, net_id, network):
LOG.debug(_("update network"))
LOG.debug(_("Update network"))
provider._raise_if_updates_provider_attributes(network['network'])
session = context.session
@ -341,7 +341,7 @@ class MellanoxEswitchPlugin(db_base_plugin_v2.NeutronDbPluginV2,
return net
def delete_network(self, context, net_id):
LOG.debug(_("delete network"))
LOG.debug(_("Delete network"))
session = context.session
with session.begin(subtransactions=True):
binding = db.get_network_binding(session, net_id)

View File

@ -95,7 +95,7 @@ class MlnxRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
db.set_port_status(port['id'], new_status)
else:
entry = {'device': device}
LOG.debug("%s can not be found in database", device)
LOG.debug(_("%s can not be found in database"), device)
return entry
def update_device_down(self, rpc_context, **kwargs):

View File

@ -273,7 +273,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
self.ofc.create_ofc_tenant(context, tenant_id)
self.ofc.create_ofc_network(context, tenant_id, net_id, net_name)
except (nexc.OFCException, nexc.OFCConsistencyBroken) as exc:
LOG.error(_("failed to create network id=%(id)s on "
LOG.error(_("Failed to create network id=%(id)s on "
"OFC: %(exc)s"), {'id': net_id, 'exc': exc})
network['network']['status'] = const.NET_STATUS_ERROR

View File

@ -89,7 +89,7 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
pf = self.deactivate_packet_filter(context, pf)
if pf['status'] == pf_db.PF_STATUS_ERROR:
msg = _("failed to delete packet_filter id=%s which remains in "
msg = _("Failed to delete packet_filter id=%s which remains in "
"error status.") % id
LOG.error(msg)
raise nexc.OFCException(reason=msg)
@ -128,7 +128,7 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
packet_filter)
pf_status = pf_db.PF_STATUS_ACTIVE
except (nexc.OFCException, nexc.OFCConsistencyBroken) as exc:
LOG.error(_("failed to create packet_filter id=%(id)s on "
LOG.error(_("Failed to create packet_filter id=%(id)s on "
"OFC: %(exc)s"), {'id': pf_id, 'exc': str(exc)})
pf_status = pf_db.PF_STATUS_ERROR
@ -154,7 +154,7 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
self.ofc.delete_ofc_packet_filter(context, pf_id)
pf_status = pf_db.PF_STATUS_DOWN
except (nexc.OFCException, nexc.OFCConsistencyBroken) as exc:
LOG.error(_("failed to delete packet_filter id=%(id)s from "
LOG.error(_("Failed to delete packet_filter id=%(id)s from "
"OFC: %(exc)s"), {'id': pf_id, 'exc': str(exc)})
pf_status = pf_db.PF_STATUS_ERROR
else:

View File

@ -511,7 +511,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
'net_id': port_data['network_id']})
except q_exc.NotFound:
LOG.warning(_("port %s not found in NVP"), port_data['id'])
LOG.warning(_("Port %s not found in NVP"), port_data['id'])
def _nvp_delete_router_port(self, context, port_data):
# Delete logical router port
@ -1438,9 +1438,9 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"L3GatewayAttachment",
self.cluster.default_l3_gw_service_uuid)
except nvp_exc.NvpPluginException:
LOG.exception(_("Unable to create L3GW port on logical router "
LOG.exception(_("Unable to create L3GW port on logical router "
"%(router_uuid)s. Verify Default Layer-3 Gateway "
"service %(def_l3_gw_svc)s id is correct") %
"service %(def_l3_gw_svc)s id is correct"),
{'router_uuid': lrouter['uuid'],
'def_l3_gw_svc':
self.cluster.default_l3_gw_service_uuid})
@ -1546,10 +1546,10 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
nvplib.delete_lrouter(self.cluster, router_id)
except q_exc.NotFound:
LOG.warning(_("Logical router '%s' not found "
"on NVP Platform") % router_id)
"on NVP Platform"), router_id)
except NvpApiClient.NvpApiException:
raise nvp_exc.NvpPluginException(
err_msg=(_("Unable to delete logical router '%s'"
err_msg=(_("Unable to delete logical router '%s' "
"on NVP Platform") % router_id))
def add_router_interface(self, context, router_id, interface_info):

View File

@ -175,7 +175,7 @@ def register_deprecated(conf):
multi_parser = cfg.MultiConfigParser()
read_ok = multi_parser.read(conf.config_file)
if len(read_ok) != len(conf.config_file):
raise cfg.Error("Some config files were not parsed properly")
raise cfg.Error(_("Some config files were not parsed properly"))
for parsed_file in multi_parser.parsed:
for section in parsed_file.keys():

View File

@ -79,8 +79,8 @@ def _validate_device_list(data, valid_values=None):
return err_msg
unexpected_keys = [key for key in device if key not in key_specs]
if unexpected_keys:
err_msg = ("Unexpected keys found in device description:%s",
",".join(unexpected_keys))
err_msg = (_("Unexpected keys found in device description:%s")
% ",".join(unexpected_keys))
return err_msg
except TypeError:
return (_("%s: provided data are not iterable") %
@ -89,7 +89,7 @@ def _validate_device_list(data, valid_values=None):
nw_gw_quota_opts = [
cfg.IntOpt('quota_network_gateway',
default=5,
help=_('number of network gateways allowed per tenant, '
help=_('Number of network gateways allowed per tenant, '
'-1 for unlimited'))
]

View File

@ -530,9 +530,9 @@ def update_explicit_routes_lrouter(cluster, router_id, routes):
router_id, route)
added_routes.append(uuid)
except NvpApiClient.NvpApiException:
LOG.exception(_('Cannot update NVP routes %(routes)s for'
' router %(router_id)s') % {'routes': routes,
'router_id': router_id})
LOG.exception(_('Cannot update NVP routes %(routes)s for '
'router %(router_id)s'),
{'routes': routes, 'router_id': router_id})
# Roll back to keep NVP in consistent state
with excutils.save_and_reraise_exception():
if nvp_routes:
@ -665,7 +665,7 @@ def get_port_by_neutron_tag(cluster, lswitch_uuid, neutron_port_id):
filters={'tag': neutron_port_id,
'tag_scope': 'q_port_id'})
LOG.debug(_("Looking for port with q_port_id tag '%(neutron_port_id)s' "
"on: '%(lswitch_uuid)s'") %
"on: '%(lswitch_uuid)s'"),
{'neutron_port_id': neutron_port_id,
'lswitch_uuid': lswitch_uuid})
res = do_request(HTTP_GET, uri, cluster=cluster)
@ -674,7 +674,7 @@ def get_port_by_neutron_tag(cluster, lswitch_uuid, neutron_port_id):
if num_results > 1:
LOG.warn(_("Found '%(num_ports)d' ports with "
"q_port_id tag: '%(neutron_port_id)s'. "
"Only 1 was expected.") %
"Only 1 was expected."),
{'num_ports': num_results,
'neutron_port_id': neutron_port_id})
return res["results"][0]
@ -963,10 +963,11 @@ def format_exception(etype, e, exception_locals):
:param execption_locals: calling context local variable dict.
:returns: a formatted string.
"""
msg = ["Error. %s exception: %s." % (etype, e)]
msg = [_("Error. %(type)s exception: %(exc)s.") %
{'type': etype, 'exc': e}]
l = dict((k, v) for k, v in exception_locals.iteritems()
if k != 'request')
msg.append("locals=[%s]" % str(l))
msg.append(_("locals=[%s]") % str(l))
return ' '.join(msg)
@ -1326,8 +1327,8 @@ def config_helper(http_method, http_uri, cluster):
http_uri,
cluster=cluster)
except Exception as e:
msg = ("Error '%s' when connecting to controller(s): %s."
% (str(e), ', '.join(cluster.nvp_controllers)))
msg = (_("Error '%(err)s' when connecting to controller(s): %(ctl)s.")
% {'err': str(e), 'ctl': ', '.join(cluster.nvp_controllers)})
raise Exception(msg)

View File

@ -211,9 +211,8 @@ class TaskManager():
'cb': str(task._result_callback)}
LOG.exception(msg)
LOG.debug(_("Task %(task)s return %(status)s") % {
'task': str(task),
'status': task.status})
LOG.debug(_("Task %(task)s return %(status)s"),
{'task': str(task), 'status': task.status})
task._finished()

View File

@ -397,4 +397,5 @@ def add_tunnel_endpoint(ip, max_retries=10):
'transaction had been commited (%s attempts left)'),
max_retries - (i + 1))
raise q_exc.NeutronException(message='Unable to generate a new tunnel id')
raise q_exc.NeutronException(
message=_('Unable to generate a new tunnel id'))

View File

@ -29,12 +29,13 @@ class Plumlib():
"""
def __init__(self):
LOG.info('Python PLUMgrid Fake Library Started ')
LOG.info(_('Python PLUMgrid Fake Library Started '))
pass
def director_conn(self, director_plumgrid, director_port, timeout,
director_admin, director_password):
LOG.info('Fake Director: %s', director_plumgrid + ':' + director_port)
LOG.info(_('Fake Director: %s'),
director_plumgrid + ':' + director_port)
pass
def create_network(self, tenant_id, net_db):

View File

@ -35,7 +35,7 @@ class Plumlib(object):
"""
def __init__(self):
LOG.info('Python PLUMgrid Library Started ')
LOG.info(_('Python PLUMgrid Library Started '))
def director_conn(self, director_plumgrid, director_port, timeout,
director_admin, director_password):

View File

@ -37,7 +37,7 @@ from neutron.plugins.plumgrid.plumgrid_plugin.plugin_ver import VERSION
LOG = logging.getLogger(__name__)
PLUM_DRIVER = 'neutron.plugins.plumgrid.drivers.plumlib.Plumlib'
ERR_MESSAGE = 'PLUMgrid Director communication failed'
ERR_MESSAGE = _('PLUMgrid Director communication failed')
director_server_opts = [
cfg.StrOpt('director_server', default='localhost',

View File

@ -235,7 +235,7 @@ class OVSNeutronOFPRyuAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
'tcp:%s:%d' % (ovsdb_ip, ovsdb_port))
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:

View File

@ -85,7 +85,7 @@ def get_resource_and_action(action):
def _set_rules(data):
default_rule = 'default'
LOG.debug(_("loading policies from file: %s"), _POLICY_PATH)
LOG.debug(_("Loading policies from file: %s"), _POLICY_PATH)
# Ensure backward compatibility with folsom/grizzly convention
# for extension rules
policies = policy.Rules.load_json(data, default_rule)

View File

@ -44,7 +44,7 @@ quota_opts = [
'minus for unlimited')),
cfg.IntOpt('quota_port',
default=50,
help=_('number of ports allowed per tenant, minus for '
help=_('Number of ports allowed per tenant, minus for '
'unlimited')),
cfg.StrOpt('quota_driver',
default='neutron.quota.ConfDriver',

View File

@ -38,9 +38,9 @@ service_opts = [
help=_('Seconds between running periodic tasks')),
cfg.IntOpt('periodic_fuzzy_delay',
default=5,
help=_('range of seconds to randomly delay when starting the'
' periodic task scheduler to reduce stampeding.'
' (Disable by setting to 0)')),
help=_('Range of seconds to randomly delay when starting the '
'periodic task scheduler to reduce stampeding. '
'(Disable by setting to 0)')),
]
CONF = cfg.CONF
CONF.register_opts(service_opts)

View File

@ -282,10 +282,10 @@ class vArmourL3NATAgent(l3_agent.L3NATAgent,
try:
plist = resp['body']['response']
except ValueError:
LOG.warn(_("unable to parse interface mapping."))
LOG.warn(_("Unable to parse interface mapping."))
return
else:
LOG.warn(_("unable to read interface mapping."))
LOG.warn(_("Unable to read interface mapping."))
return
if ri.ex_gw_port:

View File

@ -99,7 +99,7 @@ class ChanceScheduler(object):
candidates = plugin.get_lbaas_agents(context, active=True)
if not candidates:
LOG.warn(_('No active lbaas agents for pool %s') % pool['id'])
LOG.warn(_('No active lbaas agents for pool %s'), pool['id'])
return
chosen_agent = random.choice(candidates)

View File

@ -178,7 +178,7 @@ class LbaasAgentManager(periodic_task.PeriodicTasks):
self.agent_state)
self.agent_state.pop('start_flag', None)
except Exception:
LOG.exception("Failed reporting state!")
LOG.exception(_("Failed reporting state!"))
def initialize_service_hook(self, started_by):
self.sync_state()

View File

@ -117,7 +117,7 @@ class HaproxyNSDriver(object):
pool_stats['members'] = self._get_servers_stats(parsed_stats)
return pool_stats
else:
LOG.warn(_('Stats socket not found for pool %s') % pool_id)
LOG.warn(_('Stats socket not found for pool %s'), pool_id)
return {}
def _get_backend_stats(self, parsed_stats):

View File

@ -82,7 +82,7 @@ class LoadBalancerCallbacks(object):
if not agents:
return []
elif len(agents) > 1:
LOG.warning(_('Multiple lbaas agents found on host %s') % host)
LOG.warning(_('Multiple lbaas agents found on host %s'), host)
pools = self.plugin.list_pools_on_lbaas_agent(context,
agents[0].id)

View File

@ -92,7 +92,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
def _load_drivers(self):
"""Loads plugin-driver from configuration."""
LOG.info(_("Loading Metering driver %s") % self.conf.driver)
LOG.info(_("Loading Metering driver %s"), self.conf.driver)
if not self.conf.driver:
raise SystemExit(_('A metering driver must be specified'))
self.metering_driver = importutils.import_object(
@ -109,7 +109,7 @@ class MeteringAgent(MeteringPluginRpc, manager.Manager):
'last_update': info['last_update'],
'host': self.host}
LOG.debug("Send metering report: %s" % data)
LOG.debug(_("Send metering report: %s"), data)
notifier_api.notify(self.context,
notifier_api.publisher_id('metering'),
'l3.meter',

View File

@ -96,7 +96,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
if not self.conf.interface_driver:
raise SystemExit(_('An interface driver must be specified'))
LOG.info(_("Loading interface driver %s") % self.conf.interface_driver)
LOG.info(_("Loading interface driver %s"), self.conf.interface_driver)
self.driver = importutils.import_object(self.conf.interface_driver,
self.conf)

View File

@ -58,13 +58,13 @@ openswan_opts = [
default=os.path.join(
TEMPLATE_PATH,
'template/openswan/ipsec.conf.template'),
help='Template file for ipsec configuration'),
help=_('Template file for ipsec configuration')),
cfg.StrOpt(
'ipsec_secret_template',
default=os.path.join(
TEMPLATE_PATH,
'template/openswan/ipsec.secret.template'),
help='Template file for ipsec secret configuration')
help=_('Template file for ipsec secret configuration'))
]
cfg.CONF.register_opts(openswan_opts, 'openswan')

View File

@ -102,7 +102,7 @@ class Server(object):
family = info[0]
bind_addr = info[-1]
except Exception:
LOG.exception(_("Unable to listen on %(host)s:%(port)s") %
LOG.exception(_("Unable to listen on %(host)s:%(port)s"),
{'host': host, 'port': port})
sys.exit(1)

View File

@ -94,4 +94,4 @@ msg_format_checkers = [
file_black_list = ["./neutron/tests/unit",
"./neutron/openstack",
"./quantum/plugins/bigswitch/tests"]
"./neutron/plugins/bigswitch/tests"]