Fix i18n messages

Fix the last scraps of messages

Change-Id: I0494ab43fa95b7040de2b5a596fa08b9c73aab8d
This commit is contained in:
He Jie Xu 2013-01-19 19:58:47 +08:00
parent 5462907d77
commit 5019749dc8
46 changed files with 276 additions and 255 deletions

View File

@ -24,7 +24,7 @@ def setup_conf():
bind_opts = [
cfg.StrOpt('state_path',
default='/var/lib/quantum',
help='Top-level directory for maintaining dhcp state'),
help=_('Top-level directory for maintaining dhcp state')),
]
conf = cfg.CommonConfigOpts()

View File

@ -47,9 +47,9 @@ class DhcpAgent(object):
cfg.IntOpt('resync_interval', default=30),
cfg.StrOpt('dhcp_driver',
default='quantum.agent.linux.dhcp.Dnsmasq',
help="The driver used to manage the DHCP server."),
help=_("The driver used to manage the DHCP server.")),
cfg.BoolOpt('use_namespaces', default=True,
help="Allow overlapping IP.")
help=_("Allow overlapping IP."))
]
def __init__(self, conf):
@ -91,7 +91,7 @@ class DhcpAgent(object):
except Exception, e:
self.needs_resync = True
LOG.exception('Unable to %s dhcp.' % action)
LOG.exception(_('Unable to %s dhcp.'), action)
def update_lease(self, network_id, ip_address, time_remaining):
try:
@ -135,7 +135,7 @@ class DhcpAgent(object):
network = self.plugin_rpc.get_network_info(network_id)
except:
self.needs_resync = True
LOG.exception(_('Network %s RPC info call failed.') % network_id)
LOG.exception(_('Network %s RPC info call failed.'), network_id)
return
if not network.admin_state_up:
@ -168,7 +168,7 @@ class DhcpAgent(object):
network = self.plugin_rpc.get_network_info(network_id)
except:
self.needs_resync = True
LOG.exception(_('Network %s RPC info call failed.') % network_id)
LOG.exception(_('Network %s RPC info call failed.'), network_id)
return
old_cidrs = set(s.cidr for s in old_network.subnets if s.enable_dhcp)
@ -382,7 +382,7 @@ class DeviceManager(object):
help=_("The type of authentication to use")),
cfg.StrOpt('auth_region'),
cfg.StrOpt('interface_driver',
help="The driver used to manage the virtual interface.")
help=_("The driver used to manage the virtual interface."))
]
def __init__(self, conf, plugin):
@ -426,7 +426,7 @@ class DeviceManager(object):
raise exceptions.PreexistingDeviceFailure(
dev_name=interface_name)
LOG.debug(_('Reusing existing device: %s.') % interface_name)
LOG.debug(_('Reusing existing device: %s.'), interface_name)
else:
self.driver.plug(network.id,
port.id,
@ -488,7 +488,7 @@ class DhcpLeaseRelay(object):
OPTS = [
cfg.StrOpt('dhcp_lease_relay_socket',
default='$state_path/dhcp/lease_relay',
help='Location to DHCP lease relay UNIX domain socket')
help=_('Location to DHCP lease relay UNIX domain socket'))
]
def __init__(self, lease_update_callback):
@ -519,14 +519,14 @@ class DhcpLeaseRelay(object):
network_id = data['network_id']
if not uuidutils.is_uuid_like(network_id):
raise ValueError(_("Network ID %s is not a valid UUID") %
(network_id))
network_id)
ip_address = str(netaddr.IPAddress(data['ip_address']))
lease_remaining = int(data['lease_remaining'])
self.callback(network_id, ip_address, lease_remaining)
except ValueError, e:
LOG.warn(_('Unable to parse lease relay msg to dict.'))
LOG.warn(_('Exception value: %s') % e)
LOG.warn(_('Message representation: %s') % repr(msg))
LOG.warn(_('Exception value: %s'), e)
LOG.warn(_('Message representation: %s'), repr(msg))
except Exception, e:
LOG.exception(_('Unable update lease. Exception'))

View File

@ -113,27 +113,32 @@ class L3NATAgent(manager.Manager):
OPTS = [
cfg.StrOpt('root_helper', default='sudo'),
cfg.StrOpt('external_network_bridge', default='br-ex',
help="Name of bridge used for external network traffic."),
help=_("Name of bridge used for external network "
"traffic.")),
cfg.StrOpt('interface_driver',
help="The driver used to manage the virtual interface."),
help=_("The driver used to manage the virtual "
"interface.")),
cfg.IntOpt('metadata_port',
default=9697,
help="TCP Port used by Quantum metadata namespace proxy."),
help=_("TCP Port used by Quantum metadata namespace "
"proxy.")),
cfg.IntOpt('send_arp_for_ha',
default=3,
help="Send this many gratuitous ARPs for HA setup, "
"set it below or equal to 0 to disable this feature."),
help=_("Send this many gratuitous ARPs for HA setup, "
"set it below or equal to 0 to disable this "
"feature.")),
cfg.BoolOpt('use_namespaces', default=True,
help="Allow overlapping IP."),
help=_("Allow overlapping IP.")),
cfg.StrOpt('router_id', default='',
help="If namespaces is disabled, the l3 agent can only"
" confgure a router that has the matching router ID."),
help=_("If namespaces is disabled, the l3 agent can only"
" confgure a router that has the matching router "
"ID.")),
cfg.BoolOpt('handle_internal_only_routers',
default=True,
help="Agent should implement routers with no gateway"),
help=_("Agent should implement routers with no gateway")),
cfg.StrOpt('gateway_external_network_id', default='',
help="UUID of external network for routers implemented "
"by the agents."),
help=_("UUID of external network for routers implemented "
"by the agents.")),
cfg.StrOpt('l3_agent_manager',
default='quantum.agent.l3_agent.L3NATAgent'),
]
@ -152,8 +157,8 @@ class L3NATAgent(manager.Manager):
self.driver = importutils.import_object(self.conf.interface_driver,
self.conf)
except:
LOG.exception(_("Error importing interface driver '%s'"
% self.conf.interface_driver))
LOG.exception(_("Error importing interface driver '%s'"),
self.conf.interface_driver)
sys.exit(1)
self.plugin_rpc = L3PluginApi(topics.PLUGIN, host)
self.fullsync = True
@ -172,7 +177,7 @@ class L3NATAgent(manager.Manager):
try:
self._destroy_router_namespace(ns)
except:
LOG.exception(_("Failed deleting namespace '%s'") % ns)
LOG.exception(_("Failed deleting namespace '%s'"), ns)
def _destroy_router_namespace(self, namespace):
ns_ip = ip_lib.IPWrapper(self.conf.root_helper,
@ -261,7 +266,7 @@ class L3NATAgent(manager.Manager):
if not ips:
raise Exception(_("Router port %s has no IP address") % port['id'])
if len(ips) > 1:
LOG.error(_("Ignoring multiple IPs on router port %s") %
LOG.error(_("Ignoring multiple IPs on router port %s"),
port['id'])
prefixlen = netaddr.IPNetwork(port['subnet']['cidr']).prefixlen
port['ip_cidr'] = "%s/%s" % (ips[0]['ip_address'], prefixlen)
@ -364,7 +369,7 @@ class L3NATAgent(manager.Manager):
utils.execute(arping_cmd, check_exit_code=True,
root_helper=self.conf.root_helper)
except Exception as e:
LOG.error(_("Failed sending gratuitous ARP: %s") % str(e))
LOG.error(_("Failed sending gratuitous ARP: %s"), str(e))
def get_internal_device_name(self, port_id):
return (INTERNAL_DEV_PREFIX + port_id)[:self.driver.DEV_NAME_LEN]
@ -552,8 +557,8 @@ class L3NATAgent(manager.Manager):
def _process_routers(self, routers):
if (self.conf.external_network_bridge and
not ip_lib.device_exists(self.conf.external_network_bridge)):
LOG.error(_("The external network bridge '%s' does not exist")
% self.conf.external_network_bridge)
LOG.error(_("The external network bridge '%s' does not exist"),
self.conf.external_network_bridge)
return
target_ex_net_id = self._fetch_external_net_id()

View File

@ -32,7 +32,7 @@ class Pidfile(object):
try:
self.fd = os.open(pidfile, os.O_CREAT | os.O_RDWR)
except IOError, e:
LOG.exception(_("Failed to open pidfile: %s") % pidfile)
LOG.exception(_("Failed to open pidfile: %s"), pidfile)
sys.exit(1)
self.pidfile = pidfile
self.procname = procname
@ -130,8 +130,8 @@ class Daemon(object):
if self.pidfile.is_running():
self.pidfile.unlock()
message = _('pidfile %s already exist. Daemon already running?\n')
LOG.error(message % self.pidfile)
message = _('Pidfile %s already exist. Daemon already running?')
LOG.error(message, self.pidfile)
sys.exit(1)
# Start the daemon

View File

@ -36,18 +36,19 @@ LOG = logging.getLogger(__name__)
OPTS = [
cfg.StrOpt('dhcp_confs',
default='$state_path/dhcp',
help='Location to store DHCP server config files'),
help=_('Location to store DHCP server config files')),
cfg.IntOpt('dhcp_lease_time',
default=120,
help='Lifetime of a DHCP lease in seconds'),
help=_('Lifetime of a DHCP lease in seconds')),
cfg.StrOpt('dhcp_domain',
default='openstacklocal',
help='Domain to use for building the hostnames'),
help=_('Domain to use for building the hostnames')),
cfg.StrOpt('dnsmasq_config_file',
default='',
help='Override the default dnsmasq settings with this file'),
help=_('Override the default dnsmasq settings with this file')),
cfg.StrOpt('dnsmasq_dns_server',
help='Use another DNS server before any in /etc/resolv.conf.'),
help=_('Use another DNS server before any in '
'/etc/resolv.conf.')),
]
IPV4 = 4
@ -128,10 +129,10 @@ class DhcpLocalProcess(DhcpBase):
self.device_delegate.destroy(self.network, self.interface_name)
elif pid:
LOG.debug(_('DHCP for %s pid %d is stale, ignoring command') %
(self.network.id, pid))
LOG.debug(_('DHCP for %(net_id)s pid %(pid)d is stale, ignoring '
'command'), {'net_id': self.network.id, 'pid': pid})
else:
LOG.debug(_('No DHCP started for %s') % self.network.id)
LOG.debug(_('No DHCP started for %s'), self.network.id)
def get_conf_file_name(self, kind, ensure_conf_dir=False):
"""Returns the file name for a given kind of config file."""
@ -264,8 +265,8 @@ class Dnsmasq(DhcpLocalProcess):
"""If all subnets turn off dhcp, kill the process."""
if not self._enable_dhcp():
self.disable()
LOG.debug(_('Killing dhcpmasq for network since all subnets have \
turned off DHCP: %s') % self.network.id)
LOG.debug(_('Killing dhcpmasq for network since all subnets have '
'turned off DHCP: %s'), self.network.id)
return
"""Rebuilds the dnsmasq config and signal the dnsmasq to reload."""
@ -278,7 +279,7 @@ class Dnsmasq(DhcpLocalProcess):
ip_wrapper.netns.execute(cmd)
else:
utils.execute(cmd, self.root_helper)
LOG.debug(_('Reloading allocations for network: %s') % self.network.id)
LOG.debug(_('Reloading allocations for network: %s'), self.network.id)
def _output_hosts_file(self):
"""Writes a dnsmasq compatible hosts file."""

View File

@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
OPTS = [
cfg.StrOpt('external_pids',
default='$state_path/external/pids',
help='Location to store child pid files'),
help=_('Location to store child pid files')),
]
cfg.CONF.register_opts(OPTS)
@ -69,9 +69,9 @@ class ProcessManager(object):
elif pid:
LOG.debug(_('Process for %(uuid)s pid %(pid)d is stale, ignoring '
'command') % {'uuid': self.uuid, 'pid': pid})
'command'), {'uuid': self.uuid, 'pid': pid})
else:
LOG.debug(_('No process started for %s') % self.uuid)
LOG.debug(_('No process started for %s'), self.uuid)
def get_pid_file_name(self, ensure_pids_dir=False):
"""Returns the file name for a given kind of config file."""
@ -95,7 +95,7 @@ class ProcessManager(object):
except ValueError, e:
msg = _('Unable to convert value in %s')
LOG.debug(msg % file_name)
LOG.debug(msg, file_name)
return None
@property

View File

@ -33,14 +33,14 @@ LOG = logging.getLogger(__name__)
OPTS = [
cfg.StrOpt('ovs_integration_bridge',
default='br-int',
help='Name of Open vSwitch bridge to use'),
help=_('Name of Open vSwitch bridge to use')),
cfg.BoolOpt('ovs_use_veth',
default=False,
help='Uses veth for an interface or not'),
help=_('Uses veth for an interface or not')),
cfg.StrOpt('network_device_mtu',
help='MTU setting for device.'),
help=_('MTU setting for device.')),
cfg.StrOpt('meta_flavor_driver_mappings',
help='Mapping between flavor and LinuxInterfaceDriver')
help=_('Mapping between flavor and LinuxInterfaceDriver'))
]
@ -172,7 +172,7 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
if self.conf.ovs_use_veth:
root_dev.link.set_up()
else:
LOG.warn(_("Device %s already exists") % device_name)
LOG.warn(_("Device %s already exists"), device_name)
def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
"""Unplug the interface."""
@ -189,9 +189,9 @@ class OVSInterfaceDriver(LinuxInterfaceDriver):
device = ip_lib.IPDevice(device_name, self.conf.root_helper,
namespace)
device.link.delete()
LOG.debug(_("Unplugged interface '%s'") % device_name)
LOG.debug(_("Unplugged interface '%s'"), device_name)
except RuntimeError:
LOG.error(_("Failed unplugging interface '%s'") %
LOG.error(_("Failed unplugging interface '%s'"),
device_name)
@ -228,16 +228,16 @@ class BridgeInterfaceDriver(LinuxInterfaceDriver):
ns_veth.link.set_up()
else:
LOG.warn(_("Device %s already exists") % device_name)
LOG.warn(_("Device %s already exists"), device_name)
def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
"""Unplug the interface."""
device = ip_lib.IPDevice(device_name, self.conf.root_helper, namespace)
try:
device.link.delete()
LOG.debug(_("Unplugged interface '%s'") % device_name)
LOG.debug(_("Unplugged interface '%s'"), device_name)
except RuntimeError:
LOG.error(_("Failed unplugging interface '%s'") %
LOG.error(_("Failed unplugging interface '%s'"),
device_name)
@ -270,7 +270,7 @@ class MetaInterfaceDriver(LinuxInterfaceDriver):
mac_address = device.link.address
ports = self.quantum.list_ports(mac_address=mac_address)
if not 'ports' in ports or len(ports['ports']) < 1:
raise Exception('No port for this device %s' % device_name)
raise Exception(_('No port for this device %s') % device_name)
return self._get_driver_by_network_id(ports['ports'][0]['network_id'])
def get_device_name(self, port):

View File

@ -58,7 +58,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
LOG.debug(_("Updating device (%s) filter"), port['device'])
if not port['device'] in self.filtered_ports:
LOG.info(_('Attempted to update port filter which is not '
'filtered %s') % port['device'])
'filtered %s'), port['device'])
return
self._remove_chains()
self.filtered_ports[port['device']] = port

View File

@ -122,7 +122,7 @@ class IptablesTable(object):
chain_set = self._select_chain_set(wrap)
if name not in chain_set:
LOG.warn(('Attempted to remove chain %s which does not exist'),
LOG.warn(_('Attempted to remove chain %s which does not exist'),
name)
return
@ -147,7 +147,7 @@ class IptablesTable(object):
"""
if wrap and chain not in self.chains:
raise LookupError(('Unknown chain: %r') % chain)
raise LookupError(_('Unknown chain: %r') % chain)
if '$' in rule:
rule = ' '.join(map(self._wrap_target_chain, rule.split(' ')))
@ -170,7 +170,7 @@ class IptablesTable(object):
try:
self.rules.remove(IptablesRule(chain, rule, wrap, top))
except ValueError:
LOG.warn(('Tried to remove rule that was not there:'
LOG.warn(_('Tried to remove rule that was not there:'
' %(chain)r %(rule)r %(wrap)r %(top)r'),
{'chain': chain, 'rule': rule,
'top': top, 'wrap': wrap})
@ -319,7 +319,7 @@ class IptablesManager(object):
self.execute(args,
process_input='\n'.join(new_filter),
root_helper=self.root_helper)
LOG.debug(("IPTablesManager.apply completed with success"))
LOG.debug(_("IPTablesManager.apply completed with success"))
def _modify_rules(self, current_lines, table, binary=None):
unwrapped_chains = table.unwrapped_chains

View File

@ -286,7 +286,8 @@ def get_bridge_for_iface(root_helper, iface):
try:
return utils.execute(args, root_helper=root_helper).strip()
except Exception, e:
LOG.error(_("iface %s not found. Exception: %s"), iface, e)
LOG.exception(_("Interface %(iface)s not found. Exception: %(e)s"),
locals())
return None
@ -295,5 +296,5 @@ def get_bridges(root_helper):
try:
return utils.execute(args, root_helper=root_helper).strip().split("\n")
except Exception, e:
LOG.error(_("Unable to retrieve bridges. Exception: %s"), e)
LOG.exception(_("Unable to retrieve bridges. Exception: %s"), e)
return []

View File

@ -47,13 +47,13 @@ class MetadataProxyHandler(object):
help=_("The type of authentication to use")),
cfg.StrOpt('auth_region'),
cfg.StrOpt('nova_metadata_ip', default='127.0.0.1',
help="IP address used by Nova metadata server."),
help=_("IP address used by Nova metadata server.")),
cfg.IntOpt('nova_metadata_port',
default=8775,
help="TCP Port used by Nova metadata server."),
help=_("TCP Port used by Nova metadata server.")),
cfg.StrOpt('metadata_proxy_shared_secret',
default='',
help='Shared secret to sign instance-id request')
help=_('Shared secret to sign instance-id request'))
]
def __init__(self, conf):
@ -181,7 +181,7 @@ class UnixDomainMetadataProxy(object):
OPTS = [
cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy',
help='Location for Metadata Proxy UNIX domain socket')
help=_('Location for Metadata Proxy UNIX domain socket'))
]
def __init__(self, conf):

View File

@ -32,7 +32,8 @@ from quantum import wsgi
proxy_socket = cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy',
help='Location of Metadata Proxy UNIX domain socket')
help=_('Location of Metadata Proxy UNIX domain '
'socket'))
cfg.CONF.register_opt(proxy_socket)
@ -145,7 +146,8 @@ def main():
cfg.BoolOpt('daemonize', default=True),
cfg.IntOpt('metadata_port',
default=9697,
help="TCP Port to listen for metadata server requests."),
help=_("TCP Port to listen for metadata server "
"requests.")),
]
cfg.CONF.register_cli_opts(opts)

View File

@ -59,13 +59,13 @@ def setup_conf():
cfg.StrOpt('root_helper', default='sudo'),
cfg.StrOpt('dhcp_driver',
default='quantum.agent.linux.dhcp.Dnsmasq',
help="The driver used to manage the DHCP server."),
help=_("The driver used to manage the DHCP server.")),
cfg.StrOpt('state_path',
default='.',
help='Top-level directory for maintaining dhcp state'),
help=_('Top-level directory for maintaining dhcp state')),
cfg.BoolOpt('force',
default=False,
help='Delete the namespace by removing all devices.'),
help=_('Delete the namespace by removing all devices.')),
]
conf = cfg.CommonConfigOpts()
conf.register_opts(opts)
@ -117,7 +117,7 @@ def unplug_device(conf, device):
conf.root_helper)
bridge.delete_port(device.name)
else:
LOG.debug(_('Unable to find bridge for device: %s') % device.name)
LOG.debug(_('Unable to find bridge for device: %s'), device.name)
def destroy_namespace(conf, namespace, force=False):
@ -140,7 +140,7 @@ def destroy_namespace(conf, namespace, force=False):
ip.garbage_collect_namespace()
except Exception, e:
LOG.exception(_('Error unable to destroy namespace: %s') % namespace)
LOG.exception(_('Error unable to destroy namespace: %s'), namespace)
def main():

View File

@ -35,9 +35,10 @@ def setup_conf():
opts = [
cfg.BoolOpt('ovs_all_ports',
default=False,
help='True to delete all ports on all the OpenvSwitch '
'bridges. False to delete ports created by Quantum '
'on integration and external network bridges.')
help=_('True to delete all ports on all the OpenvSwitch '
'bridges. False to delete ports created by '
'Quantum on integration and external network '
'bridges.'))
]
conf = cfg.CommonConfigOpts()

View File

@ -107,6 +107,6 @@ class NotificationDispatcher(object):
if hasattr(handler, name):
getattr(handler, name)(msg['payload'])
else:
LOG.debug('Unknown event_type: %s.' % msg['event_type'])
LOG.debug(_('Unknown event_type: %s.'), msg['event_type'])
except Exception, e:
LOG.warn('Error processing message. Exception: %s' % e)
LOG.warn(_('Error processing message. Exception: %s'), e)

View File

@ -496,9 +496,8 @@ class ExtensionManager(object):
new_ext = new_ext_class()
self.add_extension(new_ext)
except Exception as exception:
LOG.warn(_("extension file %(file)s wasn't loaded due to "
"%(e)s"),
{'file': f, 'e': exception})
LOG.warn(_("Extension file %(f)s wasn't loaded due to "
"%(exception)s"), locals())
def add_extension(self, ext):
# Do nothing if the extension doesn't check out
@ -539,7 +538,7 @@ class PluginAwareExtensionManager(ExtensionManager):
for plugin in self.plugins.values())
plugin_provider = cfg.CONF.core_plugin
if not supports_extension:
LOG.warn(_("extension %s not supported by any of loaded plugins"),
LOG.warn(_("Extension %s not supported by any of loaded plugins"),
alias)
return supports_extension

View File

@ -49,19 +49,19 @@ def is_attr_set(attribute):
def _validate_values(data, valid_values=None):
if data not in valid_values:
msg = _("'%(data)s' is not in %(valid_values)s") % locals()
LOG.debug("validate_values: %s", msg)
LOG.debug(msg)
return msg
def _validate_string(data, max_len=None):
if not isinstance(data, basestring):
msg = _("'%s' is not a valid string") % data
LOG.debug("validate_string: %s", msg)
LOG.debug(msg)
return msg
if max_len is not None and len(data) > max_len:
msg = _("'%(data)s' exceeds maximum length of %(max_len)s") % locals()
LOG.debug("validate_string: %s", msg)
LOG.debug(msg)
return msg
@ -71,7 +71,7 @@ def _validate_range(data, valid_values=None):
if not min_value <= data <= max_value:
msg = _("'%(data)s' is not in range %(min_value)s through "
"%(max_value)s") % locals()
LOG.debug("validate_range: %s", msg)
LOG.debug(msg)
return msg
@ -80,7 +80,7 @@ def _validate_mac_address(data, valid_values=None):
netaddr.EUI(data)
except Exception:
msg = _("'%s' is not a valid MAC address") % data
LOG.debug("validate_mac_address: %s", msg)
LOG.debug(msg)
return msg
@ -89,7 +89,7 @@ def _validate_ip_address(data, valid_values=None):
netaddr.IPAddress(data)
except Exception:
msg = _("'%s' is not a valid IP address") % data
LOG.debug("validate_ip_address: %s", msg)
LOG.debug(msg)
return msg
@ -101,26 +101,26 @@ def _validate_ip_pools(data, valid_values=None):
"""
if not isinstance(data, list):
msg = _("'%s' is not a valid IP pool") % data
LOG.debug("validate_ip_pools: %s", msg)
LOG.debug(msg)
return msg
expected_keys = ['start', 'end']
for ip_pool in data:
msg = _verify_dict_keys(expected_keys, ip_pool)
if msg:
LOG.debug("validate_ip_pools: %s", msg)
LOG.debug(msg)
return msg
for k in expected_keys:
msg = _validate_ip_address(ip_pool[k])
if msg:
LOG.debug("validate_ip_pools: %s", msg)
LOG.debug(msg)
return msg
def _validate_fixed_ips(data, valid_values=None):
if not isinstance(data, list):
msg = _("'%s' is not a valid fixed IP") % data
LOG.debug("validate_fixed_ips: %s", msg)
LOG.debug(msg)
return msg
ips = []
@ -134,20 +134,20 @@ def _validate_fixed_ips(data, valid_values=None):
else:
msg = _validate_ip_address(fixed_ip_address)
if msg:
LOG.debug("validate_fixed_ips: %s", msg)
LOG.debug(msg)
return msg
ips.append(fixed_ip_address)
if 'subnet_id' in fixed_ip:
msg = _validate_uuid(fixed_ip['subnet_id'])
if msg:
LOG.debug("validate_fixed_ips: %s", msg)
LOG.debug(msg)
return msg
def _validate_nameservers(data, valid_values=None):
if not hasattr(data, '__iter__'):
msg = _("'%s' is not a valid nameserver") % data
LOG.debug("validate_nameservers: %s", msg)
LOG.debug(msg)
return msg
ips = []
@ -158,11 +158,11 @@ def _validate_nameservers(data, valid_values=None):
msg = _validate_regex(ip, HOSTNAME_PATTERN)
if msg:
msg = _("'%s' is not a valid nameserver") % ip
LOG.debug("validate_nameservers: %s", msg)
LOG.debug(msg)
return msg
if ip in ips:
msg = _("Duplicate nameserver %s") % ip
LOG.debug("validate_nameservers: %s", msg)
LOG.debug(msg)
return msg
ips.append(ip)
@ -170,7 +170,7 @@ def _validate_nameservers(data, valid_values=None):
def _validate_hostroutes(data, valid_values=None):
if not isinstance(data, list):
msg = _("'%s' is not a valid hostroute") % data
LOG.debug("validate_hostroutes: %s", msg)
LOG.debug(msg)
return msg
expected_keys = ['destination', 'nexthop']
@ -178,19 +178,19 @@ def _validate_hostroutes(data, valid_values=None):
for hostroute in data:
msg = _verify_dict_keys(expected_keys, hostroute)
if msg:
LOG.debug("validate_hostroutes: %s", msg)
LOG.debug(msg)
return msg
msg = _validate_subnet(hostroute['destination'])
if msg:
LOG.debug("validate_hostroutes: %s", msg)
LOG.debug(msg)
return msg
msg = _validate_ip_address(hostroute['nexthop'])
if msg:
LOG.debug("validate_hostroutes: %s", msg)
LOG.debug(msg)
return msg
if hostroute in hostroutes:
msg = _("Duplicate hostroute %s") % hostroute
LOG.debug("validate_hostroutes: %s", msg)
LOG.debug(msg)
return msg
hostroutes.append(hostroute)
@ -210,7 +210,7 @@ def _validate_subnet(data, valid_values=None):
pass
msg = _("'%s' is not a valid IP subnet") % data
LOG.debug("validate_subnet: %s", msg)
LOG.debug(msg)
return msg
@ -222,14 +222,14 @@ def _validate_regex(data, valid_values=None):
pass
msg = _("'%s' is not a valid input") % data
LOG.debug("validate_regex: %s", msg)
LOG.debug(msg)
return msg
def _validate_uuid(data, valid_values=None):
if not uuidutils.is_uuid_like(data):
msg = _("'%s' is not a valid UUID") % data
LOG.debug("validate_uuid: %s", msg)
LOG.debug(msg)
return msg
@ -241,25 +241,25 @@ def _validate_uuid_or_none(data, valid_values=None):
def _validate_uuid_list(data, valid_values=None):
if not isinstance(data, list):
msg = _("'%s' is not a list") % data
LOG.debug("validate_uuid_list: %s", msg)
LOG.debug(msg)
return msg
for item in data:
msg = _validate_uuid(item)
if msg:
LOG.debug("validate_uuid_list: %s", msg)
LOG.debug(msg)
return msg
if len(set(data)) != len(data):
msg = _("Duplicate items in the list: %s") % ', '.join(data)
LOG.debug("validate_uuid_list: %s", msg)
LOG.debug(msg)
return msg
def _validate_dict(data, valid_values=None):
if not isinstance(data, dict):
msg = _("'%s' is not a dictionary") % data
LOG.debug("validate_dict: %s", msg)
LOG.debug(msg)
return msg
@ -268,12 +268,12 @@ def _validate_non_negative(data, valid_values=None):
data = int(data)
except (ValueError, TypeError):
msg = _("'%s' is not an integer") % data
LOG.debug("validate_non_negative: %s", msg)
LOG.debug(msg)
return msg
if data < 0:
msg = _("'%s' should be non-negative") % data
LOG.debug("validate_non_negative: %s", msg)
LOG.debug(msg)
return msg

View File

@ -97,7 +97,7 @@ def Resource(controller, faults=None, deserializers=None, serializers=None):
except (ValueError, AttributeError,
exceptions.QuantumException,
netaddr.AddrFormatError) as e:
LOG.exception('%s failed' % action)
LOG.exception(_('%s failed'), action)
body = serializer({'QuantumError': str(e)})
kwargs = {'body': body, 'content_type': content_type}
for fault in faults:
@ -105,13 +105,13 @@ def Resource(controller, faults=None, deserializers=None, serializers=None):
raise faults[fault](**kwargs)
raise webob.exc.HTTPInternalServerError(**kwargs)
except webob.exc.HTTPException as e:
LOG.exception('%s failed' % action)
LOG.exception(_('%s failed'), action)
e.body = serializer({'QuantumError': str(e)})
e.content_type = content_type
raise
except Exception as e:
# NOTE(jkoelker) Everyting else is 500
LOG.exception('%s failed' % action)
LOG.exception(_('%s failed'), action)
# Do not expose details of 500 error to clients.
msg = _('Request Failed: internal server error while '
'processing your request.')

View File

@ -33,7 +33,7 @@ class QuantumKeystoneContext(wsgi.Middleware):
# Determine the user ID
user_id = req.headers.get('X_USER_ID', req.headers.get('X_USER'))
if not user_id:
LOG.debug("Neither X_USER_ID nor X_USER found in request")
LOG.debug(_("Neither X_USER_ID nor X_USER found in request"))
return webob.exc.HTTPUnauthorized()
# Determine the tenant

View File

@ -90,7 +90,7 @@ def parse(args):
msg = attributes._validate_regex(cfg.CONF.base_mac,
attributes.MAC_PATTERN)
if msg:
msg = "Base MAC: %s" % msg
msg = _("Base MAC: %s") % msg
raise Exception(msg)
@ -123,7 +123,7 @@ def load_paste_app(app_name):
try:
app = deploy.loadapp("config:%s" % config_path, name=app_name)
except (LookupError, ImportError):
msg = ("Unable to load %(app_name)s from "
msg = _("Unable to load %(app_name)s from "
"configuration file %(config_path)s.") % locals()
LOG.exception(msg)
raise RuntimeError(msg)

View File

@ -47,7 +47,7 @@ def read_cached_file(filename, cache_info, reload_func=None):
"""
mtime = os.path.getmtime(filename)
if not cache_info or mtime != cache_info.get('mtime'):
LOG.debug(_("Reloading cached file %s") % filename)
LOG.debug(_("Reloading cached file %s"), filename)
with open(filename) as fap:
cache_info['data'] = fap.read()
cache_info['mtime'] = mtime
@ -139,11 +139,11 @@ def parse_mappings(mapping_list, unique_values=True):
if not value:
raise ValueError(_("Missing value in mapping: '%s'") % mapping)
if key in mappings:
raise ValueError(_("Key %s in mapping: '%s' not unique") %
(key, mapping))
raise ValueError(_("Key %(key)s in mapping: '%(mapping)s' not "
"unique") % locals())
if unique_values and value in mappings.itervalues():
raise ValueError(_("Value %s in mapping: '%s' not unique") %
(value, mapping))
raise ValueError(_("Value %(value)s in mapping: '%(mapping)s' "
"not unique") % locals())
mappings[key] = value
return mappings

View File

@ -45,7 +45,7 @@ class ContextBase(common_context.RequestContext):
"""
if kwargs:
LOG.warn(_('Arguments dropped when creating '
'context: %s') % str(kwargs))
'context: %s'), kwargs)
super(ContextBase, self).__init__(user=user_id, tenant=tenant_id,
is_admin=is_admin)
self.roles = roles or []

View File

@ -147,7 +147,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
except exc.NoResultFound:
raise q_exc.NetworkNotFound(net_id=id)
except exc.MultipleResultsFound:
LOG.error('Multiple networks match for %s' % id)
LOG.error(_('Multiple networks match for %s'), id)
raise q_exc.NetworkNotFound(net_id=id)
return network
@ -157,7 +157,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
except exc.NoResultFound:
raise q_exc.SubnetNotFound(subnet_id=id)
except exc.MultipleResultsFound:
LOG.error('Multiple subnets match for %s' % id)
LOG.error(_('Multiple subnets match for %s'), id)
raise q_exc.SubnetNotFound(subnet_id=id)
return subnet
@ -169,7 +169,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
# kwarg in order to set the message correctly
raise q_exc.PortNotFound(port_id=id, net_id=None)
except exc.MultipleResultsFound:
LOG.error('Multiple ports match for %s' % id)
LOG.error(_('Multiple ports match for %s'), id)
raise q_exc.PortNotFound(port_id=id)
return port
@ -783,11 +783,11 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
netaddr.IPNetwork(route['destination'])
netaddr.IPAddress(route['nexthop'])
except netaddr.core.AddrFormatError:
err_msg = ("invalid route: %s" % (str(route)))
err_msg = _("Invalid route: %s") % route
raise q_exc.InvalidInput(error_message=err_msg)
except ValueError:
# netaddr.IPAddress would raise this
err_msg = _("invalid route: %s") % str(route)
err_msg = _("Invalid route: %s") % route
raise q_exc.InvalidInput(error_message=err_msg)
self._validate_ip_version(ip_version, route['nexthop'], 'nexthop')
self._validate_ip_version(ip_version, route['destination'],
@ -1023,7 +1023,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
netaddr.IPAddress(dns)
except Exception:
raise q_exc.InvalidInput(
error_message=(_("error parsing dns address %s") %
error_message=(_("Error parsing dns address %s") %
dns))
self._validate_ip_version(ip_ver, dns, 'dns_nameserver')

View File

@ -29,7 +29,7 @@ class DhcpRpcCallbackMixin(object):
def get_active_networks(self, context, **kwargs):
"""Retrieve and return a list of the active network ids."""
host = kwargs.get('host')
LOG.debug('Network list requested from %s', host)
LOG.debug(_('Network list requested from %s'), host)
plugin = manager.QuantumManager.get_plugin()
filters = dict(admin_state_up=[True])
@ -61,8 +61,8 @@ class DhcpRpcCallbackMixin(object):
# There could be more than one dhcp server per network, so create
# a device id that combines host and network ids
LOG.debug('Port %s for %s requested from %s', device_id, network_id,
host)
LOG.debug(_('Port %(device_id)s for %(network_id)s requested from '
'%(host)s'), locals())
plugin = manager.QuantumManager.get_plugin()
retval = None
@ -93,8 +93,8 @@ class DhcpRpcCallbackMixin(object):
if retval is None:
# No previous port exists, so create a new one.
LOG.debug('DHCP port %s on network %s does not exist on %s',
device_id, network_id, host)
LOG.debug(_('DHCP port %(device_id)s on network %(network_id)s '
'does not exist on %(host)s'), locals())
network = plugin.get_network(context, network_id)
@ -123,8 +123,8 @@ class DhcpRpcCallbackMixin(object):
network_id = kwargs.get('network_id')
device_id = kwargs.get('device_id')
LOG.debug('DHCP port deletion for %s d request from %s', network_id,
host)
LOG.debug(_('DHCP port deletion for %(network_id)s request from '
'%(host)s'), locals())
plugin = manager.QuantumManager.get_plugin()
filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters)
@ -139,9 +139,8 @@ class DhcpRpcCallbackMixin(object):
device_id = kwargs.get('device_id')
subnet_id = kwargs.get('subnet_id')
LOG.debug('DHCP port remove fixed_ip for %s d request from %s',
subnet_id,
host)
LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request '
'from %(host)s'), locals())
plugin = manager.QuantumManager.get_plugin()
filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters)
@ -163,8 +162,8 @@ class DhcpRpcCallbackMixin(object):
ip_address = kwargs.get('ip_address')
lease_remaining = kwargs.get('lease_remaining')
LOG.debug('Updating lease expiration for %s on network %s from %s.',
ip_address, network_id, host)
LOG.debug(_('Updating lease expiration for %(ip_address)s on network '
'%(network_id)s from %(host)s.'), locals())
plugin = manager.QuantumManager.get_plugin()
plugin.update_fixed_ip_lease_expiration(context, network_id,

View File

@ -107,7 +107,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
except exc.NoResultFound:
raise l3.RouterNotFound(router_id=id)
except exc.MultipleResultsFound:
LOG.error('Multiple routers match for %s' % id)
LOG.error(_('Multiple routers match for %s'), id)
raise l3.RouterNotFound(router_id=id)
return router
@ -174,7 +174,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if network_id:
self._get_network(context, network_id)
if not self._network_is_external(context, network_id):
msg = "Network %s is not a valid external network" % network_id
msg = _("Network %s is not a valid external "
"network") % network_id
raise q_exc.BadRequest(resource='router', msg=msg)
# figure out if we need to delete existing port
@ -214,7 +215,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if not len(gw_port['fixed_ips']):
self.delete_port(context.elevated(), gw_port['id'],
l3_port_check=False)
msg = ('No IPs available for external network %s' %
msg = (_('No IPs available for external network %s') %
network_id)
raise q_exc.BadRequest(resource='router', msg=msg)
@ -275,7 +276,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
for p in rports:
for ip in p['fixed_ips']:
if ip['subnet_id'] == subnet_id:
msg = ("Router already has a port on subnet %s"
msg = (_("Router already has a port on subnet %s")
% subnet_id)
raise q_exc.BadRequest(resource='router', msg=msg)
sub_id = ip['subnet_id']
@ -296,7 +297,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
# make sure router exists
router = self._get_router(context, router_id)
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 q_exc.BadRequest(resource='router', msg=msg)
try:
@ -308,7 +309,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if 'port_id' in interface_info:
if 'subnet_id' in interface_info:
msg = "cannot specify both subnet-id and port-id"
msg = _("Cannot specify both subnet-id and port-id")
raise q_exc.BadRequest(resource='router', msg=msg)
port = self._get_port(context, interface_info['port_id'])
@ -318,7 +319,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
device_id=port['device_id'])
fixed_ips = [ip for ip in port['fixed_ips']]
if len(fixed_ips) != 1:
msg = 'Router port must have exactly one fixed IP'
msg = _('Router port must have exactly one fixed IP')
raise q_exc.BadRequest(resource='router', msg=msg)
subnet = self._get_subnet(context, fixed_ips[0]['subnet_id'])
self._check_for_dup_router_subnet(context, router_id,
@ -332,7 +333,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
subnet = self._get_subnet(context, subnet_id)
# Ensure the subnet has a gateway
if not subnet['gateway_ip']:
msg = 'Subnet for router interface must have a gateway IP'
msg = _('Subnet for router interface must have a gateway IP')
raise q_exc.BadRequest(resource='router', msg=msg)
self._check_for_dup_router_subnet(context, router_id,
subnet['network_id'],
@ -383,7 +384,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
raise l3.RouterNotFound(router_id=router_id)
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 q_exc.BadRequest(resource='router', msg=msg)
if 'port_id' in interface_info:
port_id = interface_info['port_id']
@ -445,7 +446,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
except exc.NoResultFound:
raise l3.FloatingIPNotFound(floatingip_id=id)
except exc.MultipleResultsFound:
LOG.error('Multiple floating ips match for %s' % id)
LOG.error(_('Multiple floating ips match for %s'), id)
raise l3.FloatingIPNotFound(floatingip_id=id)
return floatingip
@ -464,8 +465,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
external_network_id):
subnet_db = self._get_subnet(context, internal_subnet_id)
if not subnet_db['gateway_ip']:
msg = ('Cannot add floating IP to port on subnet %s '
'which has no gateway_ip' % internal_subnet_id)
msg = (_('Cannot add floating IP to port on subnet %s '
'which has no gateway_ip') % internal_subnet_id)
raise q_exc.BadRequest(resource='floatingip', msg=msg)
# find router interface ports on this network
@ -518,18 +519,19 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if ip['ip_address'] == internal_ip_address:
internal_subnet_id = ip['subnet_id']
if not internal_subnet_id:
msg = ('Port %s does not have fixed ip %s' %
(internal_port['id'], internal_ip_address))
msg = (_('Port %(id)s does not have fixed ip %(address)s') %
{'id': internal_port['id'],
'address': internal_ip_address})
raise q_exc.BadRequest(resource='floatingip', msg=msg)
else:
ips = [ip['ip_address'] for ip in internal_port['fixed_ips']]
if len(ips) == 0:
msg = ('Cannot add floating IP to port %s that has'
'no fixed IP addresses' % internal_port['id'])
msg = (_('Cannot add floating IP to port %s that has'
'no fixed IP addresses') % internal_port['id'])
raise q_exc.BadRequest(resource='floatingip', msg=msg)
if len(ips) > 1:
msg = ('Port %s has multiple fixed IPs. Must provide'
' a specific IP when assigning a floating IP' %
msg = (_('Port %s has multiple fixed IPs. Must provide'
' a specific IP when assigning a floating IP') %
internal_port['id'])
raise q_exc.BadRequest(resource='floatingip', msg=msg)
internal_ip_address = internal_port['fixed_ips'][0]['ip_address']
@ -558,7 +560,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
port_id = internal_ip_address = router_id = None
if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and
not ('port_id' in fip and fip['port_id'])):
msg = "fixed_ip_address cannot be specified without a port_id"
msg = _("fixed_ip_address cannot be specified without a port_id")
raise q_exc.BadRequest(resource='floatingip', msg=msg)
if 'port_id' in fip and fip['port_id']:
port_id, internal_ip_address, router_id = self.get_assoc_data(
@ -590,7 +592,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
f_net_id = fip['floating_network_id']
if not self._network_is_external(context, f_net_id):
msg = "Network %s is not a valid external network" % f_net_id
msg = _("Network %s is not a valid external network") % f_net_id
raise q_exc.BadRequest(resource='floatingip', msg=msg)
try:
@ -610,7 +612,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
'name': ''}})
# Ensure IP addresses are allocated on external port
if not external_port['fixed_ips']:
msg = "Unable to find any IP address on external network"
msg = _("Unable to find any IP address on external "
"network")
raise q_exc.BadRequest(resource='floatingip', msg=msg)
floating_fixed_ip = external_port['fixed_ips'][0]
@ -717,7 +720,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
return
except exc.MultipleResultsFound:
# should never happen
raise Exception('Multiple floating IPs found for port %s'
raise Exception(_('Multiple floating IPs found for port %s')
% port_id)
if router_id:
routers = self.get_sync_data(context.elevated(), [router_id])
@ -875,7 +878,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
for port in ports:
fixed_ips = port.get('fixed_ips', [])
if len(fixed_ips) > 1:
LOG.error(_("Ignoring multiple IPs on router port %s") %
LOG.error(_("Ignoring multiple IPs on router port %s"),
port['id'])
continue
# Empty fixed_ips should not happen

View File

@ -29,19 +29,19 @@ from quantum.openstack.common import cfg
_core_opts = [
cfg.StrOpt('core_plugin',
default='',
help='Quantum plugin provider module'),
help=_('Quantum plugin provider module')),
]
_quota_opts = [
cfg.StrOpt('quota_driver',
default='',
help='Quantum quota driver class'),
help=_('Quantum quota driver class')),
]
_db_opts = [
cfg.StrOpt('sql_connection',
default='',
help='URL to database'),
help=_('URL to database')),
]
CONF = cfg.CommonConfigOpts()
@ -118,7 +118,7 @@ def add_command_parsers(subparsers):
command_opt = cfg.SubCommandOpt('command',
title='Command',
help='Available commands',
help=_('Available commands'),
handler=add_command_parsers)
CONF.register_cli_opt(command_opt)

View File

@ -43,7 +43,7 @@ class CreateProbe(ProbeCommand):
parser = super(CreateProbe, self).get_parser(prog_name)
parser.add_argument(
'id', metavar='network_id',
help='ID of network to probe')
help=_('ID of network to probe'))
return parser
def run(self, parsed_args):
@ -62,7 +62,7 @@ class DeleteProbe(ProbeCommand):
parser = super(DeleteProbe, self).get_parser(prog_name)
parser.add_argument(
'id', metavar='port_id',
help='ID of probe port to delete')
help=_('ID of probe port to delete'))
return parser
def run(self, parsed_args):
@ -113,12 +113,12 @@ class ExecProbe(ProbeCommand):
parser = super(ExecProbe, self).get_parser(prog_name)
parser.add_argument(
'id', metavar='port_id',
help='ID of probe port to execute command')
help=_('ID of probe port to execute command'))
parser.add_argument(
'command', metavar='command',
nargs='?',
default=None,
help='Command to execute')
help=_('Command to execute'))
return parser
def run(self, parsed_args):
@ -139,11 +139,11 @@ class PingAll(ProbeCommand):
parser.add_argument(
'--timeout', metavar='<timeout>',
default=10,
help='Ping timeout')
help=_('Ping timeout'))
parser.add_argument(
'--id', metavar='network_id',
default=None,
help='ID of network')
help=_('ID of network'))
return parser
def run(self, parsed_args):

View File

@ -46,9 +46,11 @@ class QuantumDebugAgent():
cfg.StrOpt('auth_region'),
cfg.BoolOpt('use_namespaces', default=True),
cfg.StrOpt('interface_driver',
help="The driver used to manage the virtual interface."),
help=_("The driver used to manage the virtual "
"interface.")),
cfg.StrOpt('external_network_bridge', default='br-ex',
help="Name of bridge used for external network traffic."),
help=_("Name of bridge used for external network "
"traffic.")),
]
def __init__(self, conf, client, driver):
@ -74,7 +76,7 @@ class QuantumDebugAgent():
if ip_lib.device_exists(interface_name,
self.conf.root_helper, namespace):
LOG.debug(_('Reusing existing device: %s.') % interface_name)
LOG.debug(_('Reusing existing device: %s.'), interface_name)
else:
self.driver.plug(network.id,
port.id,
@ -125,7 +127,7 @@ class QuantumDebugAgent():
try:
ip.netns.delete(namespace)
except:
LOG.warn(_('failed to delete namespace %s') % namespace)
LOG.warn(_('Failed to delete namespace %s'), namespace)
else:
self.driver.unplug(self.driver.get_device_name(port),
bridge=bridge)

View File

@ -56,16 +56,16 @@ class QuantumDebugShell(QuantumShell):
parser.add_argument(
'--config-file',
default=env('QUANTUM_TEST_CONFIG_FILE'),
help='Config file for interface driver '
'(You may also use l3_agent.ini)')
help=_('Config file for interface driver '
'(You may also use l3_agent.ini)'))
return parser
def initialize_app(self, argv):
super(QuantumDebugShell, self).initialize_app(argv)
if not self.options.config_file:
raise exc.CommandError(
"You must provide a config file for bridge -"
" either --config-file or env[QUANTUM_TEST_CONFIG_FILE]")
_("You must provide a config file for bridge -"
" either --config-file or env[QUANTUM_TEST_CONFIG_FILE]"))
client = self.client_manager.quantum
cfg.CONF.register_opts(interface.OPTS)
cfg.CONF.register_opts(QuantumDebugAgent.OPTS)

View File

@ -147,11 +147,12 @@ EXTENDED_ATTRIBUTES_2_0 = {
l3_quota_opts = [
cfg.IntOpt('quota_router',
default=10,
help='number of routers allowed per tenant, -1 for unlimited'),
help=_('Number of routers allowed per tenant, -1 for '
'unlimited')),
cfg.IntOpt('quota_floatingip',
default=50,
help='number of floating IPs allowed per tenant, '
'-1 for unlimited'),
help=_('Number of floating IPs allowed per tenant, '
'-1 for unlimited')),
]
cfg.CONF.register_opts(l3_quota_opts, 'QUOTAS')

View File

@ -145,7 +145,7 @@ class Quotasv2(object):
def check_env(self):
if cfg.CONF.QUOTAS.quota_driver != DB_QUOTA_DRIVER:
msg = _('quota driver %s is needed.') % DB_QUOTA_DRIVER
msg = _('Quota driver %s is needed.') % DB_QUOTA_DRIVER
raise exceptions.InvalidExtenstionEnv(reason=msg)
@classmethod

View File

@ -78,7 +78,7 @@ class SecurityGroupNotSingleGroupRules(qexception.InvalidInput):
class SecurityGroupSourceGroupNotFound(qexception.NotFound):
message = _("source group id %(id)s does not exist")
message = _("Source group id %(id)s does not exist")
class SecurityGroupNotFound(qexception.NotFound):
@ -225,12 +225,12 @@ EXTENDED_ATTRIBUTES_2_0 = {
security_group_quota_opts = [
cfg.IntOpt('quota_security_group',
default=10,
help='number of security groups allowed per tenant,'
'-1 for unlimited'),
help=_('Number of security groups allowed per tenant,'
'-1 for unlimited')),
cfg.IntOpt('quota_security_group_rule',
default=100,
help='number of security rules allowed per tenant, '
'-1 for unlimited'),
help=_('Number of security rules allowed per tenant, '
'-1 for unlimited')),
]
cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS')

View File

@ -99,19 +99,19 @@ def _validate_service_defs(data, valid_values=None):
except KeyError:
msg = (_("Required attributes missing in service "
"definition: %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
# Validate 'service' attribute
if not svc_name in constants.ALLOWED_SERVICES:
msg = (_("Service name '%s' unspecified "
"or invalid") % svc_name)
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
# Validate 'plugin' attribute
if not plugin_name:
msg = (_("Plugin name not specified in "
"service definition %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
# TODO(salvatore-orlando): This code will need to change when
# multiple plugins for each adv service will be supported
@ -119,11 +119,11 @@ def _validate_service_defs(data, valid_values=None):
svc_name)
if not svc_plugin:
msg = _("No plugin for service '%s'") % svc_name
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
if svc_plugin.get_plugin_name() != plugin_name:
msg = _("Plugin name '%s' is not correct ") % plugin_name
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
# Validate 'driver' attribute (just check it's a string)
# FIXME(salvatore-orlando): This should be a list
@ -139,14 +139,14 @@ def _validate_service_defs(data, valid_values=None):
if len(svc_def_copy):
msg = (_("Unparseable attributes found in "
"service definition %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
except TypeError:
LOG.exception(_("Exception while parsing service "
"definition:%s"), svc_def)
msg = (_("Was expecting a dict for service definition, found "
"the following: %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals())
LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg
except TypeError:
return (_("%s: provided data are not iterable") %

View File

@ -623,7 +623,7 @@ def main():
LOG.error(_("Parsing physical_interface_mappings failed: %s."
" Agent terminated!"), e)
sys.exit(1)
LOG.info(_("Interface mappings: %s") % interface_mappings)
LOG.info(_("Interface mappings: %s"), interface_mappings)
polling_interval = cfg.CONF.AGENT.polling_interval
root_helper = cfg.CONF.AGENT.root_helper

View File

@ -25,18 +25,18 @@ DEFAULT_INTERFACE_MAPPINGS = []
vlan_opts = [
cfg.StrOpt('tenant_network_type', default='local',
help="Network type for tenant networks "
"(local, vlan, or none)"),
help=_("Network type for tenant networks "
"(local, vlan, or none)")),
cfg.ListOpt('network_vlan_ranges',
default=DEFAULT_VLAN_RANGES,
help="List of <physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network>"),
help=_("List of <physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network>")),
]
bridge_opts = [
cfg.ListOpt('physical_interface_mappings',
default=DEFAULT_INTERFACE_MAPPINGS,
help="List of <physical_network>:<physical_interface>"),
help=_("List of <physical_network>:<physical_interface>")),
]
agent_opts = [

View File

@ -400,7 +400,7 @@ class OVSQuantumAgent(object):
net_uuid = self.get_net_uuid(vif_id)
if not self.local_vlan_map.get(net_uuid):
LOG.info('port_unbound() net_uuid %s not in local_vlan_map',
LOG.info(_('port_unbound() net_uuid %s not in local_vlan_map'),
net_uuid)
return
lvm = self.local_vlan_map[net_uuid]
@ -413,7 +413,8 @@ class OVSQuantumAgent(object):
if vif_id in lvm.vif_ports:
del lvm.vif_ports[vif_id]
else:
LOG.info('port_unbound: vif_id %s not in local_vlan_map', vif_id)
LOG.info(_('port_unbound: vif_id %s not in local_vlan_map'),
vif_id)
if not lvm.vif_ports:
self.reclaim_local_vlan(net_uuid, lvm)
@ -678,7 +679,7 @@ def create_agent_config_map(config):
)
if kwargs['enable_tunneling'] and not kwargs['local_ip']:
msg = 'Tunnelling cannot be enabled without a valid local_ip.'
msg = _('Tunnelling cannot be enabled without a valid local_ip.')
raise ValueError(msg)
return kwargs

View File

@ -26,23 +26,25 @@ ovs_opts = [
cfg.BoolOpt('enable_tunneling', default=False),
cfg.StrOpt('tunnel_bridge', default='br-tun'),
cfg.StrOpt('int_peer_patch_port', default='patch-tun',
help="Peer patch port in integration bridge for tunnel bridge"),
help=_("Peer patch port in integration bridge for tunnel "
"bridge")),
cfg.StrOpt('tun_peer_patch_port', default='patch-int',
help="Peer patch port in tunnel bridge for integration bridge"),
help=_("Peer patch port in tunnel bridge for integration "
"bridge")),
cfg.StrOpt('local_ip', default=''),
cfg.ListOpt('bridge_mappings',
default=DEFAULT_BRIDGE_MAPPINGS,
help="List of <physical_network>:<bridge>"),
help=_("List of <physical_network>:<bridge>")),
cfg.StrOpt('tenant_network_type', default='local',
help="Network type for tenant networks "
"(local, vlan, gre, or none)"),
help=_("Network type for tenant networks "
"(local, vlan, gre, or none)")),
cfg.ListOpt('network_vlan_ranges',
default=DEFAULT_VLAN_RANGES,
help="List of <physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network>"),
help=_("List of <physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network>")),
cfg.ListOpt('tunnel_id_ranges',
default=DEFAULT_TUNNEL_RANGES,
help="List of <tun_min>:<tun_max>"),
help=_("List of <tun_min>:<tun_max>")),
]
agent_opts = [

View File

@ -399,7 +399,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
# Authorize before exposing plugin details to client
self._enforce_set_auth(context, attrs, self.network_set)
msg = _("plugin does not support updating provider attributes")
msg = _("Plugin does not support updating provider attributes")
raise q_exc.InvalidInput(error_message=msg)
def create_network(self, context, network):

View File

@ -55,7 +55,7 @@ class LoadBalancerPlugin(loadbalancer_db.LoadBalancerPluginDb):
v = super(LoadBalancerPlugin, self).create_vip(context, vip)
self.update_status(context, loadbalancer_db.Vip, v['id'],
constants.PENDING_CREATE)
LOG.debug(_("Create vip: %s") % v['id'])
LOG.debug(_("Create vip: %s"), v['id'])
# If we adopt asynchronous mode, this method should return immediately
# and let client to query the object status. The plugin will listen on

View File

@ -147,8 +147,10 @@ class FieldCheck(policy.Check):
target_value = target_dict.get(self.field)
# target_value might be a boolean, explicitly compare with None
if target_value is None:
LOG.debug("Unable to find requested field: %s in target: %s",
self.field, target_dict)
LOG.debug(_("Unable to find requested field: %(field)s in "
"target: %(target_dict)s"),
{'field': self.field,
'target_dict': target_dict})
return False
return target_value == self.value

View File

@ -25,25 +25,27 @@ LOG = logging.getLogger(__name__)
quota_opts = [
cfg.ListOpt('quota_items',
default=['network', 'subnet', 'port'],
help='resource name(s) that are supported in quota features'),
help=_('Resource name(s) that are supported in quota '
'features')),
cfg.IntOpt('default_quota',
default=-1,
help='default number of resource allowed per tenant, '
'minus for unlimited'),
help=_('Default number of resource allowed per tenant, '
'minus for unlimited')),
cfg.IntOpt('quota_network',
default=10,
help='number of networks allowed per tenant,'
'minus for unlimited'),
help=_('Number of networks allowed per tenant,'
'minus for unlimited')),
cfg.IntOpt('quota_subnet',
default=10,
help='number of subnets allowed per tenant, '
'minus for unlimited'),
help=_('Number of subnets allowed per tenant, '
'minus for unlimited')),
cfg.IntOpt('quota_port',
default=50,
help='number of ports allowed per tenant, minus for unlimited'),
help=_('number of ports allowed per tenant, minus for '
'unlimited')),
cfg.StrOpt('quota_driver',
default='quantum.quota.ConfDriver',
help='default driver to use for quota checks'),
help=_('Default driver to use for quota checks')),
]
# Register the configuration options
cfg.CONF.register_opts(quota_opts, 'QUOTAS')
@ -196,7 +198,7 @@ class QuotaEngine(object):
def register_resource(self, resource):
"""Register a resource."""
if resource.name in self._resources:
LOG.warn('%s is already registered.', resource.name)
LOG.warn(_('%s is already registered.'), resource.name)
return
self._resources[resource.name] = resource

View File

@ -30,14 +30,14 @@ def main():
# the configuration will be read into the cfg.CONF global data structure
config.parse(sys.argv[1:])
if not cfg.CONF.config_file:
sys.exit("ERROR: Unable to find configuration file via the default"
sys.exit(_("ERROR: Unable to find configuration file via the default"
" search paths (~/.quantum/, ~/, /etc/quantum/, /etc/) and"
" the '--config-file' option!")
" the '--config-file' option!"))
try:
quantum_service = service.serve_wsgi(service.QuantumApiService)
quantum_service.wait()
except RuntimeError, e:
sys.exit("ERROR: %s" % e)
sys.exit(_("ERROR: %s") % e)
if __name__ == "__main__":

View File

@ -35,15 +35,15 @@ LOG = logging.getLogger(__name__)
service_opts = [
cfg.IntOpt('report_interval',
default=10,
help='seconds between nodes reporting state to datastore'),
help=_('Seconds between nodes reporting state to datastore')),
cfg.IntOpt('periodic_interval',
default=40,
help='seconds between running periodic tasks'),
help=_('Seconds between running periodic tasks')),
cfg.IntOpt('periodic_fuzzy_delay',
default=5,
help='range of seconds to randomly delay when starting the'
help=_('range of seconds to randomly delay when starting the'
' periodic task scheduler to reduce stampeding.'
' (Disable by setting to 0)'),
' (Disable by setting to 0)')),
]
CONF = cfg.CONF
CONF.register_opts(service_opts)
@ -211,7 +211,7 @@ class Service(service.Service):
try:
x.stop()
except Exception:
LOG.exception("exception occurs when timer stops")
LOG.exception(_("Exception occurs when timer stops"))
pass
self.timers = []
@ -221,7 +221,7 @@ class Service(service.Service):
try:
x.wait()
except Exception:
LOG.exception("exception occurs when waiting for timer")
LOG.exception(_("Exception occurs when waiting for timer"))
pass
def periodic_tasks(self, raise_on_error=False):

View File

@ -128,7 +128,7 @@ class AgentRPCNotificationDispatcher(unittest.TestCase):
with mock.patch('quantum.agent.rpc.LOG') as log:
self._test_run_dispatch_helper(msg, handler)
log.assert_has_calls([mock.call.debug(mock.ANY)])
log.assert_has_calls([mock.call.debug(mock.ANY, mock.ANY)])
def test_run_dispatch_handler_raises(self):
class SimpleHandler:
@ -142,4 +142,4 @@ class AgentRPCNotificationDispatcher(unittest.TestCase):
with mock.patch('quantum.agent.rpc.LOG') as log:
self._test_run_dispatch_helper(msg, handler)
log.assert_has_calls([mock.call.warn(mock.ANY)])
log.assert_has_calls([mock.call.warn(mock.ANY, mock.ANY)])

View File

@ -111,7 +111,7 @@ class TestProcessManager(unittest.TestCase):
with mock.patch.object(ep.LOG, 'debug') as debug:
manager = ep.ProcessManager(self.conf, 'uuid')
manager.disable()
debug.assert_called_once_with(mock.ANY)
debug.assert_called_once_with(mock.ANY, mock.ANY)
def test_disable_no_pid(self):
with mock.patch.object(ep.ProcessManager, 'pid') as pid:
@ -121,7 +121,7 @@ class TestProcessManager(unittest.TestCase):
with mock.patch.object(ep.LOG, 'debug') as debug:
manager = ep.ProcessManager(self.conf, 'uuid')
manager.disable()
debug.assert_called_once_with(mock.ANY)
debug.assert_called_once_with(mock.ANY, mock.ANY)
def test_get_pid_file_name_existing(self):
with mock.patch.object(ep.os.path, 'isdir') as isdir:

View File

@ -377,7 +377,7 @@ class JSONDeserializer(TextDeserializer):
try:
return jsonutils.loads(datastring)
except ValueError:
msg = _("cannot understand JSON")
msg = _("Cannot understand JSON")
raise exception.MalformedRequestBody(reason=msg)
def default(self, datastring):
@ -400,7 +400,7 @@ class XMLDeserializer(TextDeserializer):
node = minidom.parseString(datastring).childNodes[0]
return {node.nodeName: self._from_xml_node(node, plurals)}
except expat.ExpatError:
msg = _("cannot understand XML")
msg = _("Cannot understand XML")
raise exception.MalformedRequestBody(reason=msg)
def _from_xml_node(self, node, listnames):
@ -973,7 +973,7 @@ class Serializer(object):
try:
return self.get_deserialize_handler(content_type)(datastring)
except Exception:
raise webob.exc.HTTPBadRequest("Could not deserialize data")
raise webob.exc.HTTPBadRequest(_("Could not deserialize data"))
def get_deserialize_handler(self, content_type):
handlers = {