self.driver = importutils.import_object(conf.interface_driver,
conf)
except:
- LOG.exception(_("Error importing interface driver '%s'"
- % conf.interface_driver))
+ LOG.exception(_("Error importing interface driver '%s'"),
+ conf.interface_driver)
sys.exit(1)
self.polling_interval = conf.polling_interval
try:
self._destroy_router_namespace(ns)
except:
- LOG.exception("couldn't delete namespace '%s'" % ns)
+ LOG.exception(_("Couldn't delete namespace '%s'"), ns)
def _destroy_router_namespace(self, namespace):
ns_ip = ip_lib.IPWrapper(self.conf.root_helper,
try:
self.do_single_loop()
except:
- LOG.exception("Error running l3_nat daemon_loop")
+ LOG.exception(_("Error running l3_nat daemon_loop"))
time.sleep(self.polling_interval)
params = {'router:external': True}
ex_nets = self.qclient.list_networks(**params)['networks']
if len(ex_nets) > 1:
- raise Exception("must configure 'gateway_external_network_id' if "
- "Quantum has more than one external network.")
+ raise Exception(_("Must configure 'gateway_external_network_id' "
+ "if Quantum has more than one external "
+ "network."))
if len(ex_nets) == 0:
return None
return ex_nets[0]['id']
if (self.conf.external_network_bridge and
not ip_lib.device_exists(self.conf.external_network_bridge)):
- LOG.error("external network bridge '%s' does not exist"
- % self.conf.external_network_bridge)
+ LOG.error(_("External network bridge '%s' does not exist"),
+ self.conf.external_network_bridge)
return
prev_router_ids = set(self.router_info)
def _set_subnet_info(self, port):
ips = port['fixed_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:
- LOG.error("Ignoring multiple IPs on router port %s" % port['id'])
+ LOG.error(_("Ignoring multiple IPs on router port %s"), port['id'])
port['subnet'] = self.qclient.show_subnet(
ips[0]['subnet_id'])['subnet']
prefixlen = netaddr.IPNetwork(port['subnet']['cidr']).prefixlen
elif len(ports) == 1:
return ports[0]
else:
- LOG.error("Ignoring multiple gateway ports for router %s"
- % ri.router_id)
+ LOG.error(_("Ignoring multiple gateway ports for router %s"),
+ ri.router_id)
def _send_gratuitous_arp_packet(self, ri, interface_name, ip_address):
if self.conf.send_arp_for_ha > 0:
return driver.unplug(device_name, bridge, namespace, prefix)
def _load_driver(self, driver_provider):
- LOG.debug("Driver location:%s", driver_provider)
+ LOG.debug(_("Driver location: %s"), driver_provider)
plugin_klass = importutils.import_class(driver_provider)
return plugin_klass(self.conf)
try:
return utils.execute(full_args, root_helper=self.root_helper)
except Exception, e:
- LOG.error("Unable to execute %s. Exception: %s", full_args, e)
+ LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
+ {'cmd': full_args, 'exception': e})
def reset_bridge(self):
self.run_vsctl(["--", "--if-exists", "del-br", self.br_name])
try:
return utils.execute(full_args, root_helper=self.root_helper)
except Exception, e:
- LOG.error("Unable to execute %s. Exception: %s", full_args, e)
+ LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
+ {'cmd': full_args, 'exception': e})
def count_flows(self):
flow_list = self.run_ofctl("dump-flows", []).split("\n")[1:]
kwargs.get('priority', '1')))
flow_expr_arr.append(prefix)
elif 'priority' in kwargs:
- raise Exception("Cannot match priority on flow deletion")
+ raise Exception(_("Cannot match priority on flow deletion"))
in_port = ('in_port' in kwargs and ",in_port=%s" %
kwargs['in_port'] or '')
def add_flow(self, **kwargs):
if "actions" not in kwargs:
- raise Exception("must specify one or more actions")
+ raise Exception(_("Must specify one or more actions"))
if "priority" not in kwargs:
kwargs["priority"] = "0"
try:
return utils.execute(args, root_helper=self.root_helper).strip()
except Exception, e:
- LOG.error("Unable to execute %s. Exception: %s", args, e)
+ LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
+ {'cmd': args, 'exception': e})
# returns a VIF object for each VIF port
def get_vif_ports(self):
ofport = int(match.group('ofport'))
return VifPort(port_name, ofport, vif_id, vif_mac, self)
except Exception, e:
- LOG.info("Unable to parse regex results. Exception: %s", e)
+ LOG.info(_("Unable to parse regex results. Exception: %s"), e)
return
cmd = shlex.split(root_helper) + cmd
cmd = map(str, cmd)
- LOG.debug("Running command: " + " ".join(cmd))
+ LOG.debug(_("Running command: %s"), cmd)
env = os.environ.copy()
if addl_env:
env.update(addl_env)
obj.communicate(process_input) or
obj.communicate())
obj.stdin.close()
- m = ("\nCommand: %s\nExit code: %s\nStdout: %r\nStderr: %r" %
- (cmd, obj.returncode, _stdout, _stderr))
+ m = _("\nCommand: %(cmd)s\nExit code: %(code)s\nStdout: %(stdout)r\n"
+ "Stderr: %(stderr)r") % {'cmd': cmd, 'code': obj.returncode,
+ 'stdout': _stdout, 'stderr': _stderr}
LOG.debug(m)
if obj.returncode and check_exit_code:
raise RuntimeError(m)
logging.setup(product_name)
log_root = logging.getLogger(product_name).logger
log_root.propagate = 0
- LOG.info("Logging enabled!")
+ LOG.info(_("Logging enabled!"))
def load_paste_app(app_name):
config_path = os.path.abspath(cfg.CONF.find_file(
cfg.CONF.api_paste_config))
- LOG.info("Config paste file: %s", config_path)
+ LOG.info(_("Config paste file: %s"), config_path)
try:
app = deploy.loadapp("config:%s" % config_path, name=app_name)
# intentianally to allow v2 plugins to be monitored
# for performance metrics.
plugin_provider = cfg.CONF.core_plugin
- LOG.debug("Plugin location:%s", plugin_provider)
+ LOG.debug(_("Plugin location: %s"), plugin_provider)
# If the plugin can't be found let them know gracefully
try:
- LOG.info("Loading Plugin: %s" % plugin_provider)
+ LOG.info(_("Loading Plugin: %s"), plugin_provider)
plugin_klass = importutils.import_class(plugin_provider)
except ClassNotFound:
- LOG.exception("Error loading plugin")
- raise Exception("Plugin not found. You can install a "
+ LOG.exception(_("Error loading plugin"))
+ raise Exception(_("Plugin not found. You can install a "
"plugin with: pip install <plugin-name>\n"
- "Example: pip install quantum-sample-plugin")
+ "Example: pip install quantum-sample-plugin"))
self.plugin = plugin_klass()
# core plugin as a part of plugin collection simplifies
def _load_service_plugins(self):
plugin_providers = cfg.CONF.service_plugins
- LOG.debug(_("Loading service plugins: %s" % plugin_providers))
+ LOG.debug(_("Loading service plugins: %s"), plugin_providers)
for provider in plugin_providers:
if provider == '':
continue
try:
- LOG.info(_("Loading Plugin: %s" % provider))
+ LOG.info(_("Loading Plugin: %s"), provider)
plugin_class = importutils.import_class(provider)
except ClassNotFound:
LOG.exception(_("Error loading plugin"))
# for the same type is a fatal exception
if plugin_inst.get_plugin_type() in self.service_plugins:
raise Exception(_("Multiple plugins for service "
- "%s were configured" %
- plugin_inst.get_plugin_type()))
+ "%s were configured"),
+ plugin_inst.get_plugin_type())
self.service_plugins[plugin_inst.get_plugin_type()] = plugin_inst
try:
service = cls.create()
except Exception:
- LOG.exception('in WsgiService.create()')
+ LOG.exception(_('In WsgiService.create()'))
raise
service.start()
server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host)
# Dump all option values here after all options are parsed
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)
- LOG.info("Quantum service started, listening on %(host)s:%(port)s" %
+ LOG.info(_("Quantum service started, listening on %(host)s:%(port)s"),
{'host': cfg.CONF.bind_host,
'port': cfg.CONF.bind_port})
return server
def __call__(self, request):
"""WSGI method that controls (de)serialization and method dispatch."""
- LOG.info("%(method)s %(url)s" % {"method": request.method,
- "url": request.url})
+ LOG.info(_("%(method)s %(url)s"), {"method": request.method,
+ "url": request.url})
try:
action, args, accept = self.deserializer.deserialize(request)
except exception.InvalidContentType:
msg = _("Unsupported Content-Type")
- LOG.exception("InvalidContentType:%s", msg)
+ LOG.exception(_("InvalidContentType: %s"), msg)
return Fault(webob.exc.HTTPBadRequest(explanation=msg),
self._xmlns)
except exception.MalformedRequestBody:
msg = _("Malformed request body")
- LOG.exception("MalformedRequestBody:%s", msg)
+ LOG.exception(_("MalformedRequestBody: %s"), msg)
return Fault(webob.exc.HTTPBadRequest(explanation=msg),
self._xmlns)
self._xmlns,
self._fault_body_function)
except Exception:
- LOG.exception("Internal error")
+ LOG.exception(_("Internal error"))
# Do not include the traceback to avoid returning it to clients.
action_result = Fault(webob.exc.HTTPServerError(),
self._xmlns,
msg_dict = dict(url=request.url, status=response.status_int)
msg = _("%(url)s returned with HTTP %(status)d") % msg_dict
except AttributeError, e:
- msg_dict = dict(url=request.url, e=e)
- msg = _("%(url)s returned a fault: %(e)s" % msg_dict)
+ msg_dict = dict(url=request.url, exception=e)
+ msg = _("%(url)s returned a fault: %(exception)s") % msg_dict
LOG.info(msg)