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()
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):
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:
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:
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)
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):
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,
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):
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'))
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'),
]
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
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,
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)
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]
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()
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
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
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
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."""
"""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."""
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."""
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)
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."""
except ValueError, e:
msg = _('Unable to convert value in %s')
- LOG.debug(msg % file_name)
+ LOG.debug(msg, file_name)
return None
@property
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'))
]
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."""
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)
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)
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):
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
LOG.debug(_("Removing device (%s) filter"), port['device'])
if not self.filtered_ports.get(port['device']):
LOG.info(_('Attempted to remove port filter which is not '
- 'filtered %r'), port)
+ 'filtered %r'), port)
return
self._remove_chains()
self.filtered_ports.pop(port['device'], None)
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
"""
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(' ')))
try:
self.rules.remove(IptablesRule(chain, rule, wrap, top))
except ValueError:
- LOG.warn(('Tried to remove rule that was not there:'
- ' %(chain)r %(rule)r %(wrap)r %(top)r'),
+ 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})
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
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
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 []
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):
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):
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)
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)
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)
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):
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():
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()
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)
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
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
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
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
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
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
"""
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 = []
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 = []
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)
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']
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)
pass
msg = _("'%s' is not a valid IP subnet") % data
- LOG.debug("validate_subnet: %s", msg)
+ LOG.debug(msg)
return msg
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
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
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
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:
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.')
# 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
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)
try:
app = deploy.loadapp("config:%s" % config_path, name=app_name)
except (LookupError, ImportError):
- msg = ("Unable to load %(app_name)s from "
- "configuration file %(config_path)s.") % locals()
+ msg = _("Unable to load %(app_name)s from "
+ "configuration file %(config_path)s.") % locals()
LOG.exception(msg)
raise RuntimeError(msg)
return app
"""
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
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
"""
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 []
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
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
# 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
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'],
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')
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])
# 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
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)
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)
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)
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,
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
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
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)
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']
# 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:
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'])
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,
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'],
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']
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
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
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']
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(
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:
'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]
# Maybe by introducing base class for L3 exceptions
except q_exc.BadRequest:
LOG.exception(_("Unable to create Floating ip due to a "
- "malformed request"))
+ "malformed request"))
raise
except Exception:
LOG.exception(_("Floating IP association failed"))
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])
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
_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()
command_opt = cfg.SubCommandOpt('command',
title='Command',
- help='Available commands',
+ help=_('Available commands'),
handler=add_command_parsers)
CONF.register_cli_opt(command_opt)
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):
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):
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):
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):
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):
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,
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)
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)
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')
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
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):
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')
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
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
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") %
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
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 = [
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]
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)
)
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
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 = [
# 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):
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
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
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')
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
# 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"
- " search paths (~/.quantum/, ~/, /etc/quantum/, /etc/) and"
- " the '--config-file' option!")
+ sys.exit(_("ERROR: Unable to find configuration file via the default"
+ " search paths (~/.quantum/, ~/, /etc/quantum/, /etc/) and"
+ " 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__":
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'
- ' periodic task scheduler to reduce stampeding.'
- ' (Disable by setting to 0)'),
+ help=_('range of seconds to randomly delay when starting the'
+ ' periodic task scheduler to reduce stampeding.'
+ ' (Disable by setting to 0)')),
]
CONF = cfg.CONF
CONF.register_opts(service_opts)
try:
x.stop()
except Exception:
- LOG.exception("exception occurs when timer stops")
+ LOG.exception(_("Exception occurs when timer stops"))
pass
self.timers = []
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):
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:
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)])
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:
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:
try:
return jsonutils.loads(datastring)
except ValueError:
- msg = _("cannot understand JSON")
+ msg = _("Cannot understand JSON")
raise exception.MalformedRequestBody(reason=msg)
def default(self, datastring):
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):
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 = {