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 414a171a01
commit ac9aefab75
46 changed files with 276 additions and 255 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ LOG = logging.getLogger(__name__)
OPTS = [ OPTS = [
cfg.StrOpt('external_pids', cfg.StrOpt('external_pids',
default='$state_path/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) cfg.CONF.register_opts(OPTS)
@ -69,9 +69,9 @@ class ProcessManager(object):
elif pid: elif pid:
LOG.debug(_('Process for %(uuid)s pid %(pid)d is stale, ignoring ' 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: 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): def get_pid_file_name(self, ensure_pids_dir=False):
"""Returns the file name for a given kind of config file.""" """Returns the file name for a given kind of config file."""
@ -95,7 +95,7 @@ class ProcessManager(object):
except ValueError, e: except ValueError, e:
msg = _('Unable to convert value in %s') msg = _('Unable to convert value in %s')
LOG.debug(msg % file_name) LOG.debug(msg, file_name)
return None return None
@property @property

View File

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

View File

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

View File

@ -122,7 +122,7 @@ class IptablesTable(object):
chain_set = self._select_chain_set(wrap) chain_set = self._select_chain_set(wrap)
if name not in chain_set: 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) name)
return return
@ -147,7 +147,7 @@ class IptablesTable(object):
""" """
if wrap and chain not in self.chains: if wrap and chain not in self.chains:
raise LookupError(('Unknown chain: %r') % chain) raise LookupError(_('Unknown chain: %r') % chain)
if '$' in rule: if '$' in rule:
rule = ' '.join(map(self._wrap_target_chain, rule.split(' '))) rule = ' '.join(map(self._wrap_target_chain, rule.split(' ')))
@ -170,7 +170,7 @@ class IptablesTable(object):
try: try:
self.rules.remove(IptablesRule(chain, rule, wrap, top)) self.rules.remove(IptablesRule(chain, rule, wrap, top))
except ValueError: 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)r %(rule)r %(wrap)r %(top)r'),
{'chain': chain, 'rule': rule, {'chain': chain, 'rule': rule,
'top': top, 'wrap': wrap}) 'top': top, 'wrap': wrap})
@ -319,7 +319,7 @@ class IptablesManager(object):
self.execute(args, self.execute(args,
process_input='\n'.join(new_filter), process_input='\n'.join(new_filter),
root_helper=self.root_helper) 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): def _modify_rules(self, current_lines, table, binary=None):
unwrapped_chains = table.unwrapped_chains unwrapped_chains = table.unwrapped_chains

View File

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

View File

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

View File

@ -32,7 +32,8 @@ from quantum import wsgi
proxy_socket = cfg.StrOpt('metadata_proxy_socket', proxy_socket = cfg.StrOpt('metadata_proxy_socket',
default='$state_path/metadata_proxy', 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) cfg.CONF.register_opt(proxy_socket)
@ -145,7 +146,8 @@ def main():
cfg.BoolOpt('daemonize', default=True), cfg.BoolOpt('daemonize', default=True),
cfg.IntOpt('metadata_port', cfg.IntOpt('metadata_port',
default=9697, 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) cfg.CONF.register_cli_opts(opts)

View File

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

View File

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

View File

@ -107,6 +107,6 @@ class NotificationDispatcher(object):
if hasattr(handler, name): if hasattr(handler, name):
getattr(handler, name)(msg['payload']) getattr(handler, name)(msg['payload'])
else: else:
LOG.debug('Unknown event_type: %s.' % msg['event_type']) LOG.debug(_('Unknown event_type: %s.'), msg['event_type'])
except Exception, e: 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() new_ext = new_ext_class()
self.add_extension(new_ext) self.add_extension(new_ext)
except Exception as exception: except Exception as exception:
LOG.warn(_("extension file %(file)s wasn't loaded due to " LOG.warn(_("Extension file %(f)s wasn't loaded due to "
"%(e)s"), "%(exception)s"), locals())
{'file': f, 'e': exception})
def add_extension(self, ext): def add_extension(self, ext):
# Do nothing if the extension doesn't check out # Do nothing if the extension doesn't check out
@ -539,7 +538,7 @@ class PluginAwareExtensionManager(ExtensionManager):
for plugin in self.plugins.values()) for plugin in self.plugins.values())
plugin_provider = cfg.CONF.core_plugin plugin_provider = cfg.CONF.core_plugin
if not supports_extension: 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) alias)
return supports_extension return supports_extension

View File

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

View File

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

View File

@ -33,7 +33,7 @@ class QuantumKeystoneContext(wsgi.Middleware):
# Determine the user ID # Determine the user ID
user_id = req.headers.get('X_USER_ID', req.headers.get('X_USER')) user_id = req.headers.get('X_USER_ID', req.headers.get('X_USER'))
if not user_id: 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() return webob.exc.HTTPUnauthorized()
# Determine the tenant # Determine the tenant

View File

@ -90,7 +90,7 @@ def parse(args):
msg = attributes._validate_regex(cfg.CONF.base_mac, msg = attributes._validate_regex(cfg.CONF.base_mac,
attributes.MAC_PATTERN) attributes.MAC_PATTERN)
if msg: if msg:
msg = "Base MAC: %s" % msg msg = _("Base MAC: %s") % msg
raise Exception(msg) raise Exception(msg)
@ -123,7 +123,7 @@ def load_paste_app(app_name):
try: try:
app = deploy.loadapp("config:%s" % config_path, name=app_name) app = deploy.loadapp("config:%s" % config_path, name=app_name)
except (LookupError, ImportError): 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() "configuration file %(config_path)s.") % locals()
LOG.exception(msg) LOG.exception(msg)
raise RuntimeError(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) mtime = os.path.getmtime(filename)
if not cache_info or mtime != cache_info.get('mtime'): 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: with open(filename) as fap:
cache_info['data'] = fap.read() cache_info['data'] = fap.read()
cache_info['mtime'] = mtime cache_info['mtime'] = mtime
@ -139,11 +139,11 @@ def parse_mappings(mapping_list, unique_values=True):
if not value: if not value:
raise ValueError(_("Missing value in mapping: '%s'") % mapping) raise ValueError(_("Missing value in mapping: '%s'") % mapping)
if key in mappings: if key in mappings:
raise ValueError(_("Key %s in mapping: '%s' not unique") % raise ValueError(_("Key %(key)s in mapping: '%(mapping)s' not "
(key, mapping)) "unique") % locals())
if unique_values and value in mappings.itervalues(): if unique_values and value in mappings.itervalues():
raise ValueError(_("Value %s in mapping: '%s' not unique") % raise ValueError(_("Value %(value)s in mapping: '%(mapping)s' "
(value, mapping)) "not unique") % locals())
mappings[key] = value mappings[key] = value
return mappings return mappings

View File

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

View File

@ -147,7 +147,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
except exc.NoResultFound: except exc.NoResultFound:
raise q_exc.NetworkNotFound(net_id=id) raise q_exc.NetworkNotFound(net_id=id)
except exc.MultipleResultsFound: 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) raise q_exc.NetworkNotFound(net_id=id)
return network return network
@ -157,7 +157,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
except exc.NoResultFound: except exc.NoResultFound:
raise q_exc.SubnetNotFound(subnet_id=id) raise q_exc.SubnetNotFound(subnet_id=id)
except exc.MultipleResultsFound: 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) raise q_exc.SubnetNotFound(subnet_id=id)
return subnet return subnet
@ -169,7 +169,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
# kwarg in order to set the message correctly # kwarg in order to set the message correctly
raise q_exc.PortNotFound(port_id=id, net_id=None) raise q_exc.PortNotFound(port_id=id, net_id=None)
except exc.MultipleResultsFound: 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) raise q_exc.PortNotFound(port_id=id)
return port return port
@ -783,11 +783,11 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
netaddr.IPNetwork(route['destination']) netaddr.IPNetwork(route['destination'])
netaddr.IPAddress(route['nexthop']) netaddr.IPAddress(route['nexthop'])
except netaddr.core.AddrFormatError: 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) raise q_exc.InvalidInput(error_message=err_msg)
except ValueError: except ValueError:
# netaddr.IPAddress would raise this # 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) raise q_exc.InvalidInput(error_message=err_msg)
self._validate_ip_version(ip_version, route['nexthop'], 'nexthop') self._validate_ip_version(ip_version, route['nexthop'], 'nexthop')
self._validate_ip_version(ip_version, route['destination'], self._validate_ip_version(ip_version, route['destination'],
@ -1023,7 +1023,7 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
netaddr.IPAddress(dns) netaddr.IPAddress(dns)
except Exception: except Exception:
raise q_exc.InvalidInput( raise q_exc.InvalidInput(
error_message=(_("error parsing dns address %s") % error_message=(_("Error parsing dns address %s") %
dns)) dns))
self._validate_ip_version(ip_ver, dns, 'dns_nameserver') 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): def get_active_networks(self, context, **kwargs):
"""Retrieve and return a list of the active network ids.""" """Retrieve and return a list of the active network ids."""
host = kwargs.get('host') 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() plugin = manager.QuantumManager.get_plugin()
filters = dict(admin_state_up=[True]) 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 # There could be more than one dhcp server per network, so create
# a device id that combines host and network ids # a device id that combines host and network ids
LOG.debug('Port %s for %s requested from %s', device_id, network_id, LOG.debug(_('Port %(device_id)s for %(network_id)s requested from '
host) '%(host)s'), locals())
plugin = manager.QuantumManager.get_plugin() plugin = manager.QuantumManager.get_plugin()
retval = None retval = None
@ -93,8 +93,8 @@ class DhcpRpcCallbackMixin(object):
if retval is None: if retval is None:
# No previous port exists, so create a new one. # No previous port exists, so create a new one.
LOG.debug('DHCP port %s on network %s does not exist on %s', LOG.debug(_('DHCP port %(device_id)s on network %(network_id)s '
device_id, network_id, host) 'does not exist on %(host)s'), locals())
network = plugin.get_network(context, network_id) network = plugin.get_network(context, network_id)
@ -123,8 +123,8 @@ class DhcpRpcCallbackMixin(object):
network_id = kwargs.get('network_id') network_id = kwargs.get('network_id')
device_id = kwargs.get('device_id') device_id = kwargs.get('device_id')
LOG.debug('DHCP port deletion for %s d request from %s', network_id, LOG.debug(_('DHCP port deletion for %(network_id)s request from '
host) '%(host)s'), locals())
plugin = manager.QuantumManager.get_plugin() plugin = manager.QuantumManager.get_plugin()
filters = dict(network_id=[network_id], device_id=[device_id]) filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters) ports = plugin.get_ports(context, filters=filters)
@ -139,9 +139,8 @@ class DhcpRpcCallbackMixin(object):
device_id = kwargs.get('device_id') device_id = kwargs.get('device_id')
subnet_id = kwargs.get('subnet_id') subnet_id = kwargs.get('subnet_id')
LOG.debug('DHCP port remove fixed_ip for %s d request from %s', LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request '
subnet_id, 'from %(host)s'), locals())
host)
plugin = manager.QuantumManager.get_plugin() plugin = manager.QuantumManager.get_plugin()
filters = dict(network_id=[network_id], device_id=[device_id]) filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters) ports = plugin.get_ports(context, filters=filters)
@ -163,8 +162,8 @@ class DhcpRpcCallbackMixin(object):
ip_address = kwargs.get('ip_address') ip_address = kwargs.get('ip_address')
lease_remaining = kwargs.get('lease_remaining') lease_remaining = kwargs.get('lease_remaining')
LOG.debug('Updating lease expiration for %s on network %s from %s.', LOG.debug(_('Updating lease expiration for %(ip_address)s on network '
ip_address, network_id, host) '%(network_id)s from %(host)s.'), locals())
plugin = manager.QuantumManager.get_plugin() plugin = manager.QuantumManager.get_plugin()
plugin.update_fixed_ip_lease_expiration(context, network_id, 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: except exc.NoResultFound:
raise l3.RouterNotFound(router_id=id) raise l3.RouterNotFound(router_id=id)
except exc.MultipleResultsFound: 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) raise l3.RouterNotFound(router_id=id)
return router return router
@ -174,7 +174,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if network_id: if network_id:
self._get_network(context, network_id) self._get_network(context, network_id)
if not self._network_is_external(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) raise q_exc.BadRequest(resource='router', msg=msg)
# figure out if we need to delete existing port # 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']): if not len(gw_port['fixed_ips']):
self.delete_port(context.elevated(), gw_port['id'], self.delete_port(context.elevated(), gw_port['id'],
l3_port_check=False) l3_port_check=False)
msg = ('No IPs available for external network %s' % msg = (_('No IPs available for external network %s') %
network_id) network_id)
raise q_exc.BadRequest(resource='router', msg=msg) raise q_exc.BadRequest(resource='router', msg=msg)
@ -275,7 +276,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
for p in rports: for p in rports:
for ip in p['fixed_ips']: for ip in p['fixed_ips']:
if ip['subnet_id'] == subnet_id: 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) % subnet_id)
raise q_exc.BadRequest(resource='router', msg=msg) raise q_exc.BadRequest(resource='router', msg=msg)
sub_id = ip['subnet_id'] sub_id = ip['subnet_id']
@ -296,7 +297,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
# make sure router exists # make sure router exists
router = self._get_router(context, router_id) router = self._get_router(context, router_id)
if not interface_info: 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) raise q_exc.BadRequest(resource='router', msg=msg)
try: try:
@ -308,7 +309,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
if 'port_id' in interface_info: if 'port_id' in interface_info:
if 'subnet_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) raise q_exc.BadRequest(resource='router', msg=msg)
port = self._get_port(context, interface_info['port_id']) 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']) device_id=port['device_id'])
fixed_ips = [ip for ip in port['fixed_ips']] fixed_ips = [ip for ip in port['fixed_ips']]
if len(fixed_ips) != 1: 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) raise q_exc.BadRequest(resource='router', msg=msg)
subnet = self._get_subnet(context, fixed_ips[0]['subnet_id']) subnet = self._get_subnet(context, fixed_ips[0]['subnet_id'])
self._check_for_dup_router_subnet(context, router_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) subnet = self._get_subnet(context, subnet_id)
# Ensure the subnet has a gateway # Ensure the subnet has a gateway
if not subnet['gateway_ip']: 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) raise q_exc.BadRequest(resource='router', msg=msg)
self._check_for_dup_router_subnet(context, router_id, self._check_for_dup_router_subnet(context, router_id,
subnet['network_id'], subnet['network_id'],
@ -383,7 +384,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
raise l3.RouterNotFound(router_id=router_id) raise l3.RouterNotFound(router_id=router_id)
if not interface_info: 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) raise q_exc.BadRequest(resource='router', msg=msg)
if 'port_id' in interface_info: if 'port_id' in interface_info:
port_id = interface_info['port_id'] port_id = interface_info['port_id']
@ -445,7 +446,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
except exc.NoResultFound: except exc.NoResultFound:
raise l3.FloatingIPNotFound(floatingip_id=id) raise l3.FloatingIPNotFound(floatingip_id=id)
except exc.MultipleResultsFound: 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) raise l3.FloatingIPNotFound(floatingip_id=id)
return floatingip return floatingip
@ -464,8 +465,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
external_network_id): external_network_id):
subnet_db = self._get_subnet(context, internal_subnet_id) subnet_db = self._get_subnet(context, internal_subnet_id)
if not subnet_db['gateway_ip']: if not subnet_db['gateway_ip']:
msg = ('Cannot add floating IP to port on subnet %s ' msg = (_('Cannot add floating IP to port on subnet %s '
'which has no gateway_ip' % internal_subnet_id) 'which has no gateway_ip') % internal_subnet_id)
raise q_exc.BadRequest(resource='floatingip', msg=msg) raise q_exc.BadRequest(resource='floatingip', msg=msg)
# find router interface ports on this network # 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: if ip['ip_address'] == internal_ip_address:
internal_subnet_id = ip['subnet_id'] internal_subnet_id = ip['subnet_id']
if not internal_subnet_id: if not internal_subnet_id:
msg = ('Port %s does not have fixed ip %s' % msg = (_('Port %(id)s does not have fixed ip %(address)s') %
(internal_port['id'], internal_ip_address)) {'id': internal_port['id'],
'address': internal_ip_address})
raise q_exc.BadRequest(resource='floatingip', msg=msg) raise q_exc.BadRequest(resource='floatingip', msg=msg)
else: else:
ips = [ip['ip_address'] for ip in internal_port['fixed_ips']] ips = [ip['ip_address'] for ip in internal_port['fixed_ips']]
if len(ips) == 0: if len(ips) == 0:
msg = ('Cannot add floating IP to port %s that has' msg = (_('Cannot add floating IP to port %s that has'
'no fixed IP addresses' % internal_port['id']) 'no fixed IP addresses') % internal_port['id'])
raise q_exc.BadRequest(resource='floatingip', msg=msg) raise q_exc.BadRequest(resource='floatingip', msg=msg)
if len(ips) > 1: if len(ips) > 1:
msg = ('Port %s has multiple fixed IPs. Must provide' msg = (_('Port %s has multiple fixed IPs. Must provide'
' a specific IP when assigning a floating IP' % ' a specific IP when assigning a floating IP') %
internal_port['id']) internal_port['id'])
raise q_exc.BadRequest(resource='floatingip', msg=msg) raise q_exc.BadRequest(resource='floatingip', msg=msg)
internal_ip_address = internal_port['fixed_ips'][0]['ip_address'] 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 port_id = internal_ip_address = router_id = None
if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and
not ('port_id' in fip and fip['port_id'])): 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) raise q_exc.BadRequest(resource='floatingip', msg=msg)
if 'port_id' in fip and fip['port_id']: if 'port_id' in fip and fip['port_id']:
port_id, internal_ip_address, router_id = self.get_assoc_data( 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'] f_net_id = fip['floating_network_id']
if not self._network_is_external(context, f_net_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) raise q_exc.BadRequest(resource='floatingip', msg=msg)
try: try:
@ -610,7 +612,8 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
'name': ''}}) 'name': ''}})
# Ensure IP addresses are allocated on external port # Ensure IP addresses are allocated on external port
if not external_port['fixed_ips']: 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) raise q_exc.BadRequest(resource='floatingip', msg=msg)
floating_fixed_ip = external_port['fixed_ips'][0] floating_fixed_ip = external_port['fixed_ips'][0]
@ -717,7 +720,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
return return
except exc.MultipleResultsFound: except exc.MultipleResultsFound:
# should never happen # should never happen
raise Exception('Multiple floating IPs found for port %s' raise Exception(_('Multiple floating IPs found for port %s')
% port_id) % port_id)
if router_id: if router_id:
routers = self.get_sync_data(context.elevated(), [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: for port in ports:
fixed_ips = port.get('fixed_ips', []) fixed_ips = port.get('fixed_ips', [])
if len(fixed_ips) > 1: 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']) port['id'])
continue continue
# Empty fixed_ips should not happen # Empty fixed_ips should not happen

View File

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

View File

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

View File

@ -46,9 +46,11 @@ class QuantumDebugAgent():
cfg.StrOpt('auth_region'), cfg.StrOpt('auth_region'),
cfg.BoolOpt('use_namespaces', default=True), cfg.BoolOpt('use_namespaces', default=True),
cfg.StrOpt('interface_driver', 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', 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): def __init__(self, conf, client, driver):
@ -74,7 +76,7 @@ class QuantumDebugAgent():
if ip_lib.device_exists(interface_name, if ip_lib.device_exists(interface_name,
self.conf.root_helper, namespace): self.conf.root_helper, namespace):
LOG.debug(_('Reusing existing device: %s.') % interface_name) LOG.debug(_('Reusing existing device: %s.'), interface_name)
else: else:
self.driver.plug(network.id, self.driver.plug(network.id,
port.id, port.id,
@ -125,7 +127,7 @@ class QuantumDebugAgent():
try: try:
ip.netns.delete(namespace) ip.netns.delete(namespace)
except: except:
LOG.warn(_('failed to delete namespace %s') % namespace) LOG.warn(_('Failed to delete namespace %s'), namespace)
else: else:
self.driver.unplug(self.driver.get_device_name(port), self.driver.unplug(self.driver.get_device_name(port),
bridge=bridge) bridge=bridge)

View File

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

View File

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

View File

@ -145,7 +145,7 @@ class Quotasv2(object):
def check_env(self): def check_env(self):
if cfg.CONF.QUOTAS.quota_driver != DB_QUOTA_DRIVER: 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) raise exceptions.InvalidExtenstionEnv(reason=msg)
@classmethod @classmethod

View File

@ -78,7 +78,7 @@ class SecurityGroupNotSingleGroupRules(qexception.InvalidInput):
class SecurityGroupSourceGroupNotFound(qexception.NotFound): 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): class SecurityGroupNotFound(qexception.NotFound):
@ -225,12 +225,12 @@ EXTENDED_ATTRIBUTES_2_0 = {
security_group_quota_opts = [ security_group_quota_opts = [
cfg.IntOpt('quota_security_group', cfg.IntOpt('quota_security_group',
default=10, default=10,
help='number of security groups allowed per tenant,' help=_('Number of security groups allowed per tenant,'
'-1 for unlimited'), '-1 for unlimited')),
cfg.IntOpt('quota_security_group_rule', cfg.IntOpt('quota_security_group_rule',
default=100, default=100,
help='number of security rules allowed per tenant, ' help=_('Number of security rules allowed per tenant, '
'-1 for unlimited'), '-1 for unlimited')),
] ]
cfg.CONF.register_opts(security_group_quota_opts, 'QUOTAS') 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: except KeyError:
msg = (_("Required attributes missing in service " msg = (_("Required attributes missing in service "
"definition: %s") % svc_def) "definition: %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals()) LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg return msg
# Validate 'service' attribute # Validate 'service' attribute
if not svc_name in constants.ALLOWED_SERVICES: if not svc_name in constants.ALLOWED_SERVICES:
msg = (_("Service name '%s' unspecified " msg = (_("Service name '%s' unspecified "
"or invalid") % svc_name) "or invalid") % svc_name)
LOG.error("%(f_name)s: %(msg)s", locals()) LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg return msg
# Validate 'plugin' attribute # Validate 'plugin' attribute
if not plugin_name: if not plugin_name:
msg = (_("Plugin name not specified in " msg = (_("Plugin name not specified in "
"service definition %s") % svc_def) "service definition %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals()) LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg return msg
# TODO(salvatore-orlando): This code will need to change when # TODO(salvatore-orlando): This code will need to change when
# multiple plugins for each adv service will be supported # multiple plugins for each adv service will be supported
@ -119,11 +119,11 @@ def _validate_service_defs(data, valid_values=None):
svc_name) svc_name)
if not svc_plugin: if not svc_plugin:
msg = _("No plugin for service '%s'") % svc_name 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 return msg
if svc_plugin.get_plugin_name() != plugin_name: if svc_plugin.get_plugin_name() != plugin_name:
msg = _("Plugin name '%s' is not correct ") % 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 return msg
# Validate 'driver' attribute (just check it's a string) # Validate 'driver' attribute (just check it's a string)
# FIXME(salvatore-orlando): This should be a list # 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): if len(svc_def_copy):
msg = (_("Unparseable attributes found in " msg = (_("Unparseable attributes found in "
"service definition %s") % svc_def) "service definition %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals()) LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg return msg
except TypeError: except TypeError:
LOG.exception(_("Exception while parsing service " LOG.exception(_("Exception while parsing service "
"definition:%s"), svc_def) "definition:%s"), svc_def)
msg = (_("Was expecting a dict for service definition, found " msg = (_("Was expecting a dict for service definition, found "
"the following: %s") % svc_def) "the following: %s") % svc_def)
LOG.error("%(f_name)s: %(msg)s", locals()) LOG.error(_("%(f_name)s: %(msg)s"), locals())
return msg return msg
except TypeError: except TypeError:
return (_("%s: provided data are not iterable") % return (_("%s: provided data are not iterable") %

View File

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

View File

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

View File

@ -400,7 +400,7 @@ class OVSQuantumAgent(object):
net_uuid = self.get_net_uuid(vif_id) net_uuid = self.get_net_uuid(vif_id)
if not self.local_vlan_map.get(net_uuid): 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) net_uuid)
return return
lvm = self.local_vlan_map[net_uuid] lvm = self.local_vlan_map[net_uuid]
@ -413,7 +413,8 @@ class OVSQuantumAgent(object):
if vif_id in lvm.vif_ports: if vif_id in lvm.vif_ports:
del lvm.vif_ports[vif_id] del lvm.vif_ports[vif_id]
else: 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: if not lvm.vif_ports:
self.reclaim_local_vlan(net_uuid, lvm) 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']: 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) raise ValueError(msg)
return kwargs return kwargs

View File

@ -26,23 +26,25 @@ ovs_opts = [
cfg.BoolOpt('enable_tunneling', default=False), cfg.BoolOpt('enable_tunneling', default=False),
cfg.StrOpt('tunnel_bridge', default='br-tun'), cfg.StrOpt('tunnel_bridge', default='br-tun'),
cfg.StrOpt('int_peer_patch_port', default='patch-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', 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.StrOpt('local_ip', default=''),
cfg.ListOpt('bridge_mappings', cfg.ListOpt('bridge_mappings',
default=DEFAULT_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', cfg.StrOpt('tenant_network_type', default='local',
help="Network type for tenant networks " help=_("Network type for tenant networks "
"(local, vlan, gre, or none)"), "(local, vlan, gre, or none)")),
cfg.ListOpt('network_vlan_ranges', cfg.ListOpt('network_vlan_ranges',
default=DEFAULT_VLAN_RANGES, default=DEFAULT_VLAN_RANGES,
help="List of <physical_network>:<vlan_min>:<vlan_max> " help=_("List of <physical_network>:<vlan_min>:<vlan_max> "
"or <physical_network>"), "or <physical_network>")),
cfg.ListOpt('tunnel_id_ranges', cfg.ListOpt('tunnel_id_ranges',
default=DEFAULT_TUNNEL_RANGES, default=DEFAULT_TUNNEL_RANGES,
help="List of <tun_min>:<tun_max>"), help=_("List of <tun_min>:<tun_max>")),
] ]
agent_opts = [ agent_opts = [

View File

@ -399,7 +399,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
# Authorize before exposing plugin details to client # Authorize before exposing plugin details to client
self._enforce_set_auth(context, attrs, self.network_set) 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) raise q_exc.InvalidInput(error_message=msg)
def create_network(self, context, network): 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) v = super(LoadBalancerPlugin, self).create_vip(context, vip)
self.update_status(context, loadbalancer_db.Vip, v['id'], self.update_status(context, loadbalancer_db.Vip, v['id'],
constants.PENDING_CREATE) 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 # If we adopt asynchronous mode, this method should return immediately
# and let client to query the object status. The plugin will listen on # 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 = target_dict.get(self.field)
# target_value might be a boolean, explicitly compare with None # target_value might be a boolean, explicitly compare with None
if target_value is None: if target_value is None:
LOG.debug("Unable to find requested field: %s in target: %s", LOG.debug(_("Unable to find requested field: %(field)s in "
self.field, target_dict) "target: %(target_dict)s"),
{'field': self.field,
'target_dict': target_dict})
return False return False
return target_value == self.value return target_value == self.value

View File

@ -25,25 +25,27 @@ LOG = logging.getLogger(__name__)
quota_opts = [ quota_opts = [
cfg.ListOpt('quota_items', cfg.ListOpt('quota_items',
default=['network', 'subnet', 'port'], 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', cfg.IntOpt('default_quota',
default=-1, default=-1,
help='default number of resource allowed per tenant, ' help=_('Default number of resource allowed per tenant, '
'minus for unlimited'), 'minus for unlimited')),
cfg.IntOpt('quota_network', cfg.IntOpt('quota_network',
default=10, default=10,
help='number of networks allowed per tenant,' help=_('Number of networks allowed per tenant,'
'minus for unlimited'), 'minus for unlimited')),
cfg.IntOpt('quota_subnet', cfg.IntOpt('quota_subnet',
default=10, default=10,
help='number of subnets allowed per tenant, ' help=_('Number of subnets allowed per tenant, '
'minus for unlimited'), 'minus for unlimited')),
cfg.IntOpt('quota_port', cfg.IntOpt('quota_port',
default=50, 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', cfg.StrOpt('quota_driver',
default='quantum.quota.ConfDriver', default='quantum.quota.ConfDriver',
help='default driver to use for quota checks'), help=_('Default driver to use for quota checks')),
] ]
# Register the configuration options # Register the configuration options
cfg.CONF.register_opts(quota_opts, 'QUOTAS') cfg.CONF.register_opts(quota_opts, 'QUOTAS')
@ -196,7 +198,7 @@ class QuotaEngine(object):
def register_resource(self, resource): def register_resource(self, resource):
"""Register a resource.""" """Register a resource."""
if resource.name in self._resources: if resource.name in self._resources:
LOG.warn('%s is already registered.', resource.name) LOG.warn(_('%s is already registered.'), resource.name)
return return
self._resources[resource.name] = resource 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 # the configuration will be read into the cfg.CONF global data structure
config.parse(sys.argv[1:]) config.parse(sys.argv[1:])
if not cfg.CONF.config_file: 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" " search paths (~/.quantum/, ~/, /etc/quantum/, /etc/) and"
" the '--config-file' option!") " the '--config-file' option!"))
try: try:
quantum_service = service.serve_wsgi(service.QuantumApiService) quantum_service = service.serve_wsgi(service.QuantumApiService)
quantum_service.wait() quantum_service.wait()
except RuntimeError, e: except RuntimeError, e:
sys.exit("ERROR: %s" % e) sys.exit(_("ERROR: %s") % e)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -35,15 +35,15 @@ LOG = logging.getLogger(__name__)
service_opts = [ service_opts = [
cfg.IntOpt('report_interval', cfg.IntOpt('report_interval',
default=10, default=10,
help='seconds between nodes reporting state to datastore'), help=_('Seconds between nodes reporting state to datastore')),
cfg.IntOpt('periodic_interval', cfg.IntOpt('periodic_interval',
default=40, default=40,
help='seconds between running periodic tasks'), help=_('Seconds between running periodic tasks')),
cfg.IntOpt('periodic_fuzzy_delay', cfg.IntOpt('periodic_fuzzy_delay',
default=5, 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.' ' periodic task scheduler to reduce stampeding.'
' (Disable by setting to 0)'), ' (Disable by setting to 0)')),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(service_opts) CONF.register_opts(service_opts)
@ -211,7 +211,7 @@ class Service(service.Service):
try: try:
x.stop() x.stop()
except Exception: except Exception:
LOG.exception("exception occurs when timer stops") LOG.exception(_("Exception occurs when timer stops"))
pass pass
self.timers = [] self.timers = []
@ -221,7 +221,7 @@ class Service(service.Service):
try: try:
x.wait() x.wait()
except Exception: except Exception:
LOG.exception("exception occurs when waiting for timer") LOG.exception(_("Exception occurs when waiting for timer"))
pass pass
def periodic_tasks(self, raise_on_error=False): 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: with mock.patch('quantum.agent.rpc.LOG') as log:
self._test_run_dispatch_helper(msg, handler) 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): def test_run_dispatch_handler_raises(self):
class SimpleHandler: class SimpleHandler:
@ -142,4 +142,4 @@ class AgentRPCNotificationDispatcher(unittest.TestCase):
with mock.patch('quantum.agent.rpc.LOG') as log: with mock.patch('quantum.agent.rpc.LOG') as log:
self._test_run_dispatch_helper(msg, handler) 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: with mock.patch.object(ep.LOG, 'debug') as debug:
manager = ep.ProcessManager(self.conf, 'uuid') manager = ep.ProcessManager(self.conf, 'uuid')
manager.disable() manager.disable()
debug.assert_called_once_with(mock.ANY) debug.assert_called_once_with(mock.ANY, mock.ANY)
def test_disable_no_pid(self): def test_disable_no_pid(self):
with mock.patch.object(ep.ProcessManager, 'pid') as pid: 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: with mock.patch.object(ep.LOG, 'debug') as debug:
manager = ep.ProcessManager(self.conf, 'uuid') manager = ep.ProcessManager(self.conf, 'uuid')
manager.disable() 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): def test_get_pid_file_name_existing(self):
with mock.patch.object(ep.os.path, 'isdir') as isdir: with mock.patch.object(ep.os.path, 'isdir') as isdir:

View File

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