Navigation Menu

Skip to content

Commit

Permalink
Fix message i18n error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zqfan committed Sep 8, 2013
1 parent 57ce39f commit 9842dcb
Show file tree
Hide file tree
Showing 58 changed files with 153 additions and 144 deletions.
2 changes: 1 addition & 1 deletion neutron/agent/dhcp_agent.py
Expand Up @@ -145,7 +145,7 @@ def sync_state(self):
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)
Expand Down
2 changes: 1 addition & 1 deletion neutron/common/exceptions.py
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion neutron/db/dhcp_rpc_base.py
Expand Up @@ -216,7 +216,7 @@ def update_lease_expiration(self, context, **kwargs):
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."""
Expand Down
4 changes: 2 additions & 2 deletions neutron/db/extraroute_db.py
Expand Up @@ -126,15 +126,15 @@ def _update_extra_routes(self, context, router, routes):
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'],
destination=route['destination'],
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'],
Expand Down
4 changes: 2 additions & 2 deletions neutron/db/l3_rpc_base.py
Expand Up @@ -59,8 +59,8 @@ def sync_routers(self, context, **kwargs):

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, []):
Expand Down
2 changes: 1 addition & 1 deletion neutron/debug/commands.py
Expand Up @@ -47,7 +47,7 @@ def get_parser(self, prog_name):
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):
Expand Down
2 changes: 1 addition & 1 deletion neutron/extensions/providernet.py
Expand Up @@ -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)


Expand Down
14 changes: 7 additions & 7 deletions neutron/plugins/bigswitch/plugin.py
Expand Up @@ -159,7 +159,7 @@
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'
Expand Down Expand Up @@ -455,7 +455,7 @@ def __init__(self, server_timeout=None):
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
Expand Down Expand Up @@ -992,7 +992,7 @@ def remove_router_interface(self, context, router_id, interface_info):

# 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'])
Expand All @@ -1001,7 +1001,7 @@ def remove_router_interface(self, context, router_id, interface_info):
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):
Expand Down Expand Up @@ -1144,9 +1144,9 @@ def _add_host_route(self, context, destination, port):
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:
Expand Down
4 changes: 2 additions & 2 deletions neutron/plugins/bigswitch/routerrule_db.py
Expand Up @@ -74,7 +74,7 @@ def create_router(self, context, router):
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'])

Expand All @@ -88,7 +88,7 @@ def _update_router_rules(self, context, router, rules):
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'],
Expand Down
9 changes: 6 additions & 3 deletions neutron/plugins/brocade/NeutronPlugin.py
Expand Up @@ -290,7 +290,8 @@ def create_network(self, context, network):
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'])
Expand Down Expand Up @@ -330,7 +331,8 @@ def delete_network(self, context, net_id):
# 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)
Expand Down Expand Up @@ -383,7 +385,8 @@ def create_port(self, context, port):
# 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,
Expand Down
10 changes: 5 additions & 5 deletions neutron/plugins/cisco/common/config.py
Expand Up @@ -36,11 +36,11 @@
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',
Expand Down Expand Up @@ -121,7 +121,7 @@ def _create_device_dictionary(self):
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():
Expand Down
22 changes: 11 additions & 11 deletions neutron/plugins/cisco/db/n1kv_db_v2.py
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1221,7 +1221,7 @@ def _validate_segment_range(self, network_profile):
: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):
Expand All @@ -1231,7 +1231,7 @@ def _validate_network_profile(self, net_p):
: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)
Expand All @@ -1246,21 +1246,21 @@ def _validate_network_profile(self, net_p):
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)
Expand Down Expand Up @@ -1306,7 +1306,7 @@ def _validate_segment_range_uniqueness(self, context, net_p):
(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)

Expand Down
8 changes: 4 additions & 4 deletions neutron/plugins/cisco/models/virt_phy_sw_v2.py
Expand Up @@ -233,9 +233,9 @@ def create_network(self, context, network):
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):
Expand Down Expand Up @@ -277,7 +277,7 @@ def delete_network(self, context, id):
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):
Expand Down
4 changes: 2 additions & 2 deletions neutron/plugins/cisco/n1kv/n1kv_client.py
Expand Up @@ -253,7 +253,7 @@ def create_logical_network(self, network_profile):
: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)
Expand Down Expand Up @@ -459,7 +459,7 @@ def _serialize(self, data):
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):
Expand Down
12 changes: 6 additions & 6 deletions neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py
Expand Up @@ -350,7 +350,7 @@ def _process_provider_create(self, context, attrs):
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:
Expand All @@ -376,7 +376,7 @@ def _check_provider_update(self, context, attrs):
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):
Expand Down Expand Up @@ -992,7 +992,7 @@ def create_network(self, context, network):
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:
Expand All @@ -1012,7 +1012,7 @@ def create_network(self, context, network):
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)
Expand All @@ -1022,7 +1022,7 @@ def create_network(self, context, network):
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()
Expand Down Expand Up @@ -1238,7 +1238,7 @@ def create_port(self, context, port):
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,
Expand Down
5 changes: 3 additions & 2 deletions neutron/plugins/cisco/network_plugin.py
Expand Up @@ -113,8 +113,9 @@ def __getattr__(self, name):
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.
Expand Down

0 comments on commit 9842dcb

Please sign in to comment.