Remove locals() from strings substitutions

Fixes bug 1168988

Change-Id: Ifd1e7a027f16062ff35e777cf2d953f652a806a7
This commit is contained in:
Gary Kotton 2013-04-16 07:20:31 +00:00
parent d04b3deafa
commit c117074a4b
30 changed files with 234 additions and 120 deletions

View File

@ -190,6 +190,8 @@ Example::
msg = _("The server with id %(s_id)s has no key %(m_key)s") msg = _("The server with id %(s_id)s has no key %(m_key)s")
LOG.error(msg % {"s_id": "1234", "m_key": "imageId"}) LOG.error(msg % {"s_id": "1234", "m_key": "imageId"})
Please do not use locals() for string substitutions.
Creating Unit Tests Creating Unit Tests
------------------- -------------------

View File

@ -466,7 +466,8 @@ class L3NATAgent(manager.Manager):
interface_name): interface_name):
rules = [('POSTROUTING', '! -i %(interface_name)s ' rules = [('POSTROUTING', '! -i %(interface_name)s '
'! -o %(interface_name)s -m conntrack ! ' '! -o %(interface_name)s -m conntrack ! '
'--ctstate DNAT -j ACCEPT' % locals())] '--ctstate DNAT -j ACCEPT' %
{'interface_name': interface_name})]
for cidr in internal_cidrs: for cidr in internal_cidrs:
rules.extend(self.internal_network_nat_rules(ex_gw_ip, cidr)) rules.extend(self.internal_network_nat_rules(ex_gw_ip, cidr))
return rules return rules

View File

@ -54,7 +54,10 @@ class OVSBridge:
name = 'name\s*:\s"(?P<port_name>[^"]*)"' name = 'name\s*:\s"(?P<port_name>[^"]*)"'
port = 'ofport\s*:\s(?P<ofport>-?\d+)' port = 'ofport\s*:\s(?P<ofport>-?\d+)'
_re = ('%(external)s:\s{ ( %(mac)s,? | %(iface)s,? | . )* }' _re = ('%(external)s:\s{ ( %(mac)s,? | %(iface)s,? | . )* }'
' \s+ %(name)s \s+ %(port)s' % locals()) ' \s+ %(name)s \s+ %(port)s' % {'external': external,
'mac': mac,
'iface': iface, 'name': name,
'port': port})
return re.compile(_re, re.M | re.X) return re.compile(_re, re.M | re.X)
def run_vsctl(self, args): def run_vsctl(self, args):
@ -285,9 +288,8 @@ def get_bridge_for_iface(root_helper, iface):
args = ["ovs-vsctl", "--timeout=2", "iface-to-br", iface] args = ["ovs-vsctl", "--timeout=2", "iface-to-br", 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:
LOG.exception(_("Interface %(iface)s not found. Exception: %(e)s"), LOG.exception(_("Interface %s not found."), iface)
locals())
return None return None

View File

@ -526,7 +526,7 @@ class ExtensionManager(object):
self.add_extension(new_ext) self.add_extension(new_ext)
except Exception as exception: except Exception as exception:
LOG.warn(_("Extension file %(f)s wasn't loaded due to " LOG.warn(_("Extension file %(f)s wasn't loaded due to "
"%(exception)s"), locals()) "%(exception)s"), {'f': f, 'exception': 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

View File

@ -41,7 +41,7 @@ def _verify_dict_keys(expected_keys, target_dict, strict=True):
if not isinstance(target_dict, dict): if not isinstance(target_dict, dict):
msg = (_("Invalid input. '%(target_dict)s' must be a dictionary " msg = (_("Invalid input. '%(target_dict)s' must be a dictionary "
"with keys: %(expected_keys)s") % "with keys: %(expected_keys)s") %
dict(target_dict=target_dict, expected_keys=expected_keys)) {'target_dict': target_dict, 'expected_keys': expected_keys})
return msg return msg
expected_keys = set(expected_keys) expected_keys = set(expected_keys)
@ -52,7 +52,9 @@ def _verify_dict_keys(expected_keys, target_dict, strict=True):
if not predicate(provided_keys): if not predicate(provided_keys):
msg = (_("Validation of dictionary's keys failed." msg = (_("Validation of dictionary's keys failed."
"Expected keys: %(expected_keys)s " "Expected keys: %(expected_keys)s "
"Provided keys: %(provided_keys)s") % locals()) "Provided keys: %(provided_keys)s") %
{'expected_keys': expected_keys,
'provided_keys': provided_keys})
return msg return msg
@ -63,7 +65,7 @@ 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") % msg = (_("'%(data)s' is not in %(valid_values)s") %
dict(data=data, valid_values=valid_values)) {'data': data, 'valid_values': valid_values})
LOG.debug(msg) LOG.debug(msg)
return msg return msg
@ -76,7 +78,7 @@ def _validate_string(data, max_len=None):
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") % msg = (_("'%(data)s' exceeds maximum length of %(max_len)s") %
dict(data=data, max_len=max_len)) {'data': data, 'max_len': max_len})
LOG.debug(msg) LOG.debug(msg)
return msg return msg
@ -86,9 +88,9 @@ def _validate_range(data, valid_values=None):
max_value = valid_values[1] max_value = valid_values[1]
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") % dict(data=data, "%(max_value)s") % {'data': data,
min_value=min_value, 'min_value': min_value,
max_value=max_value) 'max_value': max_value}
LOG.debug(msg) LOG.debug(msg)
return msg return msg

View File

@ -134,8 +134,10 @@ 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.") %
{'app_name': app_name,
'config_path': config_path})
LOG.exception(msg) LOG.exception(msg)
raise RuntimeError(msg) raise RuntimeError(msg)
return app return app

View File

@ -141,10 +141,11 @@ def parse_mappings(mapping_list, unique_values=True):
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 %(key)s in mapping: '%(mapping)s' not " raise ValueError(_("Key %(key)s in mapping: '%(mapping)s' not "
"unique") % locals()) "unique") % {'key': key, 'mapping': mapping})
if unique_values and value in mappings.itervalues(): if unique_values and value in mappings.itervalues():
raise ValueError(_("Value %(value)s in mapping: '%(mapping)s' " raise ValueError(_("Value %(value)s in mapping: '%(mapping)s' "
"not unique") % locals()) "not unique") % {'value': value,
'mapping': mapping})
mappings[key] = value mappings[key] = value
return mappings return mappings

View File

@ -206,7 +206,8 @@ def retry_registration(remaining, reconnect_interval, base=BASE):
remaining -= 1 remaining -= 1
LOG.info(_("Unable to connect to database, %(remaining)s attempts " LOG.info(_("Unable to connect to database, %(remaining)s attempts "
"left. Retrying in %(reconnect_interval)s seconds"), "left. Retrying in %(reconnect_interval)s seconds"),
locals()) {'remaining': remaining,
'reconnect_interval': reconnect_interval})
time.sleep(reconnect_interval) time.sleep(reconnect_interval)
if register_models(base): if register_models(base):
break break

View File

@ -259,7 +259,9 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
if QuantumDbPluginV2._check_unique_mac(context, network_id, if QuantumDbPluginV2._check_unique_mac(context, network_id,
mac_address): mac_address):
LOG.debug(_("Generated mac for network %(network_id)s " LOG.debug(_("Generated mac for network %(network_id)s "
"is %(mac_address)s"), locals()) "is %(mac_address)s"),
{'network_id': network_id,
'mac_address': mac_address})
return mac_address return mac_address
else: else:
LOG.debug(_("Generated mac %(mac_address)s exists. Remaining " LOG.debug(_("Generated mac %(mac_address)s exists. Remaining "
@ -298,7 +300,10 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
else: else:
LOG.debug(_("Hold allocated IP %(ip_address)s " LOG.debug(_("Hold allocated IP %(ip_address)s "
"(%(network_id)s/%(subnet_id)s/%(port_id)s)"), "(%(network_id)s/%(subnet_id)s/%(port_id)s)"),
locals()) {'ip_address': ip_address,
'network_id': network_id,
'subnet_id': subnet_id,
'port_id': port_id})
allocated.port_id = None allocated.port_id = None
@staticmethod @staticmethod
@ -429,19 +434,23 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug(_("No fixed IP found that matches the network " LOG.debug(_("No fixed IP found that matches the network "
"%(network_id)s and ip address %(ip_address)s."), "%(network_id)s and ip address %(ip_address)s."),
locals()) {'network_id': network_id,
'ip_address': ip_address})
@staticmethod @staticmethod
def _delete_ip_allocation(context, network_id, subnet_id, ip_address): def _delete_ip_allocation(context, network_id, subnet_id, ip_address):
# Delete the IP address from the IPAllocate table # Delete the IP address from the IPAllocate table
LOG.debug(_("Delete allocated IP %(ip_address)s " LOG.debug(_("Delete allocated IP %(ip_address)s "
"(%(network_id)s/%(subnet_id)s)"), locals()) "(%(network_id)s/%(subnet_id)s)"),
{'ip_address': ip_address,
'network_id': network_id,
'subnet_id': subnet_id})
alloc_qry = context.session.query( alloc_qry = context.session.query(
models_v2.IPAllocation).with_lockmode('update') models_v2.IPAllocation).with_lockmode('update')
allocated = alloc_qry.filter_by(network_id=network_id, alloc_qry.filter_by(network_id=network_id,
ip_address=ip_address, ip_address=ip_address,
subnet_id=subnet_id).delete() subnet_id=subnet_id).delete()
@staticmethod @staticmethod
def _generate_ip(context, subnets): def _generate_ip(context, subnets):
@ -806,7 +815,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
l_range = ip_ranges[l_cursor] l_range = ip_ranges[l_cursor]
r_range = ip_ranges[r_cursor] r_range = ip_ranges[r_cursor]
LOG.error(_("Found overlapping ranges: %(l_range)s and " LOG.error(_("Found overlapping ranges: %(l_range)s and "
"%(r_range)s"), locals()) "%(r_range)s"),
{'l_range': l_range, 'r_range': r_range})
raise q_exc.OverlappingAllocationPools( raise q_exc.OverlappingAllocationPools(
pool_1=l_range, pool_1=l_range,
pool_2=r_range, pool_2=r_range,
@ -934,7 +944,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
context.session.commit() context.session.commit()
except Exception as e: except Exception as e:
LOG.exception(_("An exception occured while creating " LOG.exception(_("An exception occured while creating "
"the %(resource)s:%(item)s"), locals()) "the %(resource)s:%(item)s"),
{'resource': resource, 'item': item})
context.session.rollback() context.session.rollback()
raise e raise e
return objects return objects
@ -1029,8 +1040,11 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
"""Check IP field of a subnet match specified ip version.""" """Check IP field of a subnet match specified ip version."""
ip = netaddr.IPNetwork(addr) ip = netaddr.IPNetwork(addr)
if ip.version != ip_version: if ip.version != ip_version:
data = {'name': name,
'addr': addr,
'ip_version': ip_version}
msg = _("%(name)s '%(addr)s' does not match " msg = _("%(name)s '%(addr)s' does not match "
"the ip_version '%(ip_version)s'") % locals() "the ip_version '%(ip_version)s'") % data
raise q_exc.InvalidInput(error_message=msg) raise q_exc.InvalidInput(error_message=msg)
def _validate_subnet(self, s): def _validate_subnet(self, s):
@ -1313,7 +1327,10 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
subnet_id = ip['subnet_id'] subnet_id = ip['subnet_id']
LOG.debug(_("Allocated IP %(ip_address)s " LOG.debug(_("Allocated IP %(ip_address)s "
"(%(network_id)s/%(subnet_id)s/%(port_id)s)"), "(%(network_id)s/%(subnet_id)s/%(port_id)s)"),
locals()) {'ip_address': ip_address,
'network_id': network_id,
'subnet_id': subnet_id,
'port_id': port_id})
allocated = models_v2.IPAllocation( allocated = models_v2.IPAllocation(
network_id=network_id, network_id=network_id,
port_id=port_id, port_id=port_id,
@ -1384,8 +1401,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
QuantumDbPluginV2._delete_ip_allocation( QuantumDbPluginV2._delete_ip_allocation(
context, a['network_id'], context, a['network_id'],
a['subnet_id'], a['ip_address']) a['subnet_id'], a['ip_address'])
msg_dict = dict(address=a['ip_address'], msg_dict = {'address': a['ip_address'],
subnet_id=a['subnet_id']) 'subnet_id': a['subnet_id']}
msg = _("%(address)s (%(subnet_id)s) is not " msg = _("%(address)s (%(subnet_id)s) is not "
"recycled") % msg_dict "recycled") % msg_dict
LOG.debug(msg) LOG.debug(msg)

View File

@ -109,7 +109,10 @@ 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 %(device_id)s on network %(network_id)s ' LOG.debug(_('DHCP port %(device_id)s on network %(network_id)s '
'does not exist on %(host)s'), locals()) 'does not exist on %(host)s'),
{'device_id': device_id,
'network_id': network_id,
'host': host})
network = plugin.get_network(context, network_id) network = plugin.get_network(context, network_id)
@ -139,7 +142,8 @@ class DhcpRpcCallbackMixin(object):
device_id = kwargs.get('device_id') device_id = kwargs.get('device_id')
LOG.debug(_('DHCP port deletion for %(network_id)s request from ' LOG.debug(_('DHCP port deletion for %(network_id)s request from '
'%(host)s'), locals()) '%(host)s'),
{'network_id': network_id, 'host': 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)
@ -155,7 +159,8 @@ class DhcpRpcCallbackMixin(object):
subnet_id = kwargs.get('subnet_id') subnet_id = kwargs.get('subnet_id')
LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request ' LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request '
'from %(host)s'), locals()) 'from %(host)s'),
{'subnet_id': subnet_id, 'host': 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)
@ -178,7 +183,10 @@ class DhcpRpcCallbackMixin(object):
lease_remaining = kwargs.get('lease_remaining') lease_remaining = kwargs.get('lease_remaining')
LOG.debug(_('Updating lease expiration for %(ip_address)s on network ' LOG.debug(_('Updating lease expiration for %(ip_address)s on network '
'%(network_id)s from %(host)s.'), locals()) '%(network_id)s from %(host)s.'),
{'ip_address': ip_address,
'network_id': network_id,
'host': host})
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

@ -303,9 +303,13 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
match1 = netaddr.all_matching_cidrs(new_ipnet, [cidr]) match1 = netaddr.all_matching_cidrs(new_ipnet, [cidr])
match2 = netaddr.all_matching_cidrs(ipnet, [subnet_cidr]) match2 = netaddr.all_matching_cidrs(ipnet, [subnet_cidr])
if match1 or match2: if match1 or match2:
data = {'subnet_cidr': subnet_cidr,
'subnet_id': subnet_id,
'cidr': cidr,
'sub_id': sub_id}
msg = (_("Cidr %(subnet_cidr)s of subnet " msg = (_("Cidr %(subnet_cidr)s of subnet "
"%(subnet_id)s overlaps with cidr %(cidr)s " "%(subnet_id)s overlaps with cidr %(cidr)s "
"of subnet %(sub_id)s") % locals()) "of subnet %(sub_id)s") % data)
raise q_exc.BadRequest(resource='router', msg=msg) raise q_exc.BadRequest(resource='router', msg=msg)
except exc.NoResultFound: except exc.NoResultFound:
pass pass
@ -516,14 +520,16 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
port_id = fip['port_id'] port_id = fip['port_id']
if 'id' in fip: if 'id' in fip:
floatingip_id = fip['id'] floatingip_id = fip['id']
msg = _('Port %(port_id)s is associated with a different ' data = {'port_id': port_id,
'tenant than Floating IP %(floatingip_id)s and ' 'floatingip_id': floatingip_id}
'therefore cannot be bound.') msg = (_('Port %(port_id)s is associated with a different '
'tenant than Floating IP %(floatingip_id)s and '
'therefore cannot be bound.') % data)
else: else:
msg = _('Cannnot create floating IP and bind it to ' msg = (_('Cannnot create floating IP and bind it to '
'Port %(port_id)s, since that port is owned by a ' 'Port %s, since that port is owned by a '
'different tenant.') 'different tenant.') % port_id)
raise q_exc.BadRequest(resource='floatingip', msg=msg % locals()) raise q_exc.BadRequest(resource='floatingip', msg=msg)
internal_subnet_id = None internal_subnet_id = None
if 'fixed_ip_address' in fip and fip['fixed_ip_address']: if 'fixed_ip_address' in fip and fip['fixed_ip_address']:
@ -558,7 +564,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
# ip enabled gateway with support for this floating IP network # ip enabled gateway with support for this floating IP network
try: try:
port_qry = context.elevated().session.query(models_v2.Port) port_qry = context.elevated().session.query(models_v2.Port)
ports = port_qry.filter_by( port_qry.filter_by(
network_id=floating_network_id, network_id=floating_network_id,
device_id=router_id, device_id=router_id,
device_owner=DEVICE_OWNER_ROUTER_GW).one() device_owner=DEVICE_OWNER_ROUTER_GW).one()

View File

@ -100,19 +100,22 @@ 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"),
{'f_name': f_name, 'msg': msg})
return msg return msg
# Validate 'service' attribute # Validate 'service' attribute
if svc_name not in constants.ALLOWED_SERVICES: if svc_name not 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"),
{'f_name': f_name, 'msg': msg})
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"),
{'f_name': f_name, 'msg': msg})
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
@ -120,11 +123,13 @@ 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"),
{'f_name': f_name, 'msg': msg})
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"),
{'f_name': f_name, 'msg': msg})
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
@ -140,14 +145,16 @@ def _validate_service_defs(data, valid_values=None):
if svc_def_copy: if 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"),
{'f_name': f_name, 'msg': msg})
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"),
{'f_name': f_name, 'msg': msg})
return msg return msg
except TypeError: except TypeError:
return (_("%s: provided data are not iterable") % return (_("%s: provided data are not iterable") %

View File

@ -163,7 +163,8 @@ class ServerProxy(object):
{'server': self.server, 'port': self.port, 'ssl': self.ssl, {'server': self.server, 'port': self.port, 'ssl': self.ssl,
'action': action}) 'action': action})
LOG.debug(_("ServerProxy: resource=%(resource)s, data=%(data)r, " LOG.debug(_("ServerProxy: resource=%(resource)s, data=%(data)r, "
"headers=%(headers)r"), locals()) "headers=%(headers)r"),
{'resource': resource, 'data': data, 'headers': headers})
conn = None conn = None
if self.ssl: if self.ssl:
@ -194,7 +195,8 @@ class ServerProxy(object):
pass pass
ret = (response.status, response.reason, respstr, respdata) ret = (response.status, response.reason, respstr, respdata)
except (socket.timeout, socket.error) as e: except (socket.timeout, socket.error) as e:
LOG.error(_('ServerProxy: %(action)s failure, %(e)r'), locals()) LOG.error(_('ServerProxy: %(action)s failure, %(e)r'),
{'action': action, 'e': e})
ret = 0, None, None, None ret = 0, None, None, None
conn.close() conn.close()
LOG.debug(_("ServerProxy: status=%(status)d, reason=%(reason)r, " LOG.debug(_("ServerProxy: status=%(status)d, reason=%(reason)r, "

View File

@ -125,7 +125,7 @@ class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = brocade_db.get_port(rpc_context, device[self.TAP_PREFIX_LEN:]) port = brocade_db.get_port(rpc_context, device[self.TAP_PREFIX_LEN:])
if port: if port:
entry = {'device': device, entry = {'device': device,

View File

@ -125,7 +125,9 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
if plugin_key not in self._plugins: if plugin_key not in self._plugins:
LOG.info(_("No %s Plugin loaded"), plugin_key) LOG.info(_("No %s Plugin loaded"), plugin_key)
LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s " LOG.info(_("%(plugin_key)s: %(function_name)s with args %(args)s "
"ignored"), locals()) "ignored"),
{'plugin_key': plugin_key, 'function_name': function_name,
'args': args})
return return
device_params = {const.DEVICE_IP: []} device_params = {const.DEVICE_IP: []}

View File

@ -126,8 +126,9 @@ class ExtensionsTestApp(wsgi.Router):
def _delete_port(self, network_id, port_id): def _delete_port(self, network_id, port_id):
"""Delete port.""" """Delete port."""
LOG.debug("Deleting port for network %s - START", network_id) LOG.debug("Deleting port for network %s - START", network_id)
data = {'network_id': network_id, 'port_id': port_id}
port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" % port_path = ("/tenants/tt/networks/%(network_id)s/ports/%(port_id)s" %
locals()) data)
port_req = self.create_request(port_path, None, port_req = self.create_request(port_path, None,
self.contenttype, 'DELETE') self.contenttype, 'DELETE')
port_req.get_response(self.api) port_req.get_response(self.api)

View File

@ -123,25 +123,31 @@ class HyperVUtils(object):
err_sum_desc = job.ErrorSummaryDescription err_sum_desc = job.ErrorSummaryDescription
err_desc = job.ErrorDescription err_desc = job.ErrorDescription
err_code = job.ErrorCode err_code = job.ErrorCode
data = {'job_state': job_state,
'err_sum_desc': err_sum_desc,
'err_desc': err_desc,
'err_code': err_code}
raise HyperVException( raise HyperVException(
msg=_("WMI job failed with status %(job_state)d. " msg=_("WMI job failed with status %(job_state)d. "
"Error details: %(err_sum_desc)s - %(err_desc)s - " "Error details: %(err_sum_desc)s - %(err_desc)s - "
"Error code: %(err_code)d") % locals()) "Error code: %(err_code)d") % data)
else: else:
(error, ret_val) = job.GetError() (error, ret_val) = job.GetError()
if not ret_val and error: if not ret_val and error:
data = {'job_state': job_state,
'error': error}
raise HyperVException( raise HyperVException(
msg=_("WMI job failed with status %(job_state)d. " msg=_("WMI job failed with status %(job_state)d. "
"Error details: %(error)s") % locals()) "Error details: %(error)s") % data)
else: else:
raise HyperVException( raise HyperVException(
msg=_("WMI job failed with status %(job_state)d. " msg=_("WMI job failed with status %d. "
"No error description available") % locals()) "No error description available") % job_state)
desc = job.Description desc = job.Description
elap = job.ElapsedTime elap = job.ElapsedTime
LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s") % LOG.debug(_("WMI job succeeded: %(desc)s, Elapsed=%(elap)s") %
locals()) {'desc': desc, 'elap': elap})
def _create_switch_port(self, vswitch_name, switch_port_name): def _create_switch_port(self, vswitch_name, switch_port_name):
"""Creates a switch port.""" """Creates a switch port."""
@ -170,18 +176,24 @@ class HyperVUtils(object):
(ret_val, ) = switch_svc.DisconnectSwitchPort( (ret_val, ) = switch_svc.DisconnectSwitchPort(
SwitchPort=switch_port_path) SwitchPort=switch_port_path)
if ret_val != 0: if ret_val != 0:
data = {'switch_port_name': switch_port_name,
'vswitch_name': vswitch_name,
'ret_val': ret_val}
raise HyperVException( raise HyperVException(
msg=_('Failed to disconnect port %(switch_port_name)s ' msg=_('Failed to disconnect port %(switch_port_name)s '
'from switch %(vswitch_name)s ' 'from switch %(vswitch_name)s '
'with error %(ret_val)s') % locals()) 'with error %(ret_val)s') % data)
if delete_port: if delete_port:
(ret_val, ) = switch_svc.DeleteSwitchPort( (ret_val, ) = switch_svc.DeleteSwitchPort(
SwitchPort=switch_port_path) SwitchPort=switch_port_path)
if ret_val != 0: if ret_val != 0:
data = {'switch_port_name': switch_port_name,
'vswitch_name': vswitch_name,
'ret_val': ret_val}
raise HyperVException( raise HyperVException(
msg=_('Failed to delete port %(switch_port_name)s ' msg=_('Failed to delete port %(switch_port_name)s '
'from switch %(vswitch_name)s ' 'from switch %(vswitch_name)s '
'with error %(ret_val)s') % locals()) 'with error %(ret_val)s') % data)
def _get_vswitch(self, vswitch_name): def _get_vswitch(self, vswitch_name):
vswitch = self._conn.Msvm_VirtualSwitch(ElementName=vswitch_name) vswitch = self._conn.Msvm_VirtualSwitch(ElementName=vswitch_name)

View File

@ -78,7 +78,8 @@ class HyperVPluginDB(object):
physical_network=physical_network) physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"), "network %(physical_network)s from pool"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
alloc.allocated = True alloc.allocated = True
except exc.NoResultFound: except exc.NoResultFound:
raise q_exc.NoNetworkAvailable() raise q_exc.NoNetworkAvailable()
@ -134,11 +135,13 @@ class HyperVPluginDB(object):
#session.delete(alloc) #session.delete(alloc)
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network " LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s"), "%(physical_network)s"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
except exc.NoResultFound: except exc.NoResultFound:
LOG.warning(_("vlan_id %(vlan_id)s on physical network " LOG.warning(_("vlan_id %(vlan_id)s on physical network "
"%(physical_network)s not found"), "%(physical_network)s not found"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
def _add_missing_allocatable_vlans(self, session, vlan_ids, def _add_missing_allocatable_vlans(self, session, vlan_ids,
physical_network): physical_network):

View File

@ -174,8 +174,8 @@ class HyperVQuantumPlugin(db_base_plugin_v2.QuantumDbPluginV2,
constants.TYPE_VLAN, constants.TYPE_VLAN,
constants.TYPE_NONE]: constants.TYPE_NONE]:
msg = _( msg = _(
"Invalid tenant_network_type: %(tenant_network_type)s. " "Invalid tenant_network_type: %s. "
"Agent terminated!") % locals() "Agent terminated!") % tenant_network_type
raise q_exc.InvalidInput(error_message=msg) raise q_exc.InvalidInput(error_message=msg)
self._tenant_network_type = tenant_network_type self._tenant_network_type = tenant_network_type

View File

@ -51,7 +51,7 @@ class HyperVRpcCallbacks(
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = self._db.get_port(device) port = self._db.get_port(device)
if port: if port:
binding = self._db.get_network_binding(None, port['network_id']) binding = self._db.get_network_binding(None, port['network_id'])
@ -75,7 +75,7 @@ class HyperVRpcCallbacks(
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"), LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = self._db.get_port(device) port = self._db.get_port(device)
if port: if port:
entry = {'device': device, entry = {'device': device,

View File

@ -169,7 +169,8 @@ class LinuxBridgeManager:
LOG.debug(_("Creating subinterface %(interface)s for " LOG.debug(_("Creating subinterface %(interface)s for "
"VLAN %(vlan_id)s on interface " "VLAN %(vlan_id)s on interface "
"%(physical_interface)s"), "%(physical_interface)s"),
locals()) {'interface': interface, 'vlan_id': vlan_id,
'physical_interface': physical_interface})
if utils.execute(['ip', 'link', 'add', 'link', if utils.execute(['ip', 'link', 'add', 'link',
physical_interface, physical_interface,
'name', interface, 'type', 'vlan', 'id', 'name', interface, 'type', 'vlan', 'id',
@ -216,7 +217,8 @@ class LinuxBridgeManager:
""" """
if not self.device_exists(bridge_name): if not self.device_exists(bridge_name):
LOG.debug(_("Starting bridge %(bridge_name)s for subinterface " LOG.debug(_("Starting bridge %(bridge_name)s for subinterface "
"%(interface)s"), locals()) "%(interface)s"),
{'bridge_name': bridge_name, 'interface': interface})
if utils.execute(['brctl', 'addbr', bridge_name], if utils.execute(['brctl', 'addbr', bridge_name],
root_helper=self.root_helper): root_helper=self.root_helper):
return return
@ -231,7 +233,7 @@ class LinuxBridgeManager:
return return
LOG.debug(_("Done starting bridge %(bridge_name)s for " LOG.debug(_("Done starting bridge %(bridge_name)s for "
"subinterface %(interface)s"), "subinterface %(interface)s"),
locals()) {'bridge_name': bridge_name, 'interface': interface})
if not interface: if not interface:
return return
@ -246,7 +248,9 @@ class LinuxBridgeManager:
root_helper=self.root_helper) root_helper=self.root_helper)
except Exception as e: except Exception as e:
LOG.error(_("Unable to add %(interface)s to %(bridge_name)s! " LOG.error(_("Unable to add %(interface)s to %(bridge_name)s! "
"Exception: %(e)s"), locals()) "Exception: %(e)s"),
{'interface': interface, 'bridge_name': bridge_name,
'e': e})
return return
def ensure_physical_in_bridge(self, network_id, def ensure_physical_in_bridge(self, network_id,
@ -289,15 +293,19 @@ class LinuxBridgeManager:
# Check if device needs to be added to bridge # Check if device needs to be added to bridge
tap_device_in_bridge = self.get_bridge_for_tap_device(tap_device_name) tap_device_in_bridge = self.get_bridge_for_tap_device(tap_device_name)
if not tap_device_in_bridge: if not tap_device_in_bridge:
data = {'tap_device_name': tap_device_name,
'bridge_name': bridge_name}
msg = _("Adding device %(tap_device_name)s to bridge " msg = _("Adding device %(tap_device_name)s to bridge "
"%(bridge_name)s") % locals() "%(bridge_name)s") % data
LOG.debug(msg) LOG.debug(msg)
if utils.execute(['brctl', 'addif', bridge_name, tap_device_name], if utils.execute(['brctl', 'addif', bridge_name, tap_device_name],
root_helper=self.root_helper): root_helper=self.root_helper):
return False return False
else: else:
data = {'tap_device_name': tap_device_name,
'bridge_name': bridge_name}
msg = _("%(tap_device_name)s already exists on bridge " msg = _("%(tap_device_name)s already exists on bridge "
"%(bridge_name)s") % locals() "%(bridge_name)s") % data
LOG.debug(msg) LOG.debug(msg)
return True return True
@ -343,16 +351,22 @@ class LinuxBridgeManager:
if not self.is_device_on_bridge(interface_name): if not self.is_device_on_bridge(interface_name):
return True return True
LOG.debug(_("Removing device %(interface_name)s from bridge " LOG.debug(_("Removing device %(interface_name)s from bridge "
"%(bridge_name)s"), locals()) "%(bridge_name)s"),
{'interface_name': interface_name,
'bridge_name': bridge_name})
if utils.execute(['brctl', 'delif', bridge_name, interface_name], if utils.execute(['brctl', 'delif', bridge_name, interface_name],
root_helper=self.root_helper): root_helper=self.root_helper):
return False return False
LOG.debug(_("Done removing device %(interface_name)s from bridge " LOG.debug(_("Done removing device %(interface_name)s from bridge "
"%(bridge_name)s"), locals()) "%(bridge_name)s"),
{'interface_name': interface_name,
'bridge_name': bridge_name})
return True return True
else: else:
LOG.debug(_("Cannot remove device %(interface_name)s bridge " LOG.debug(_("Cannot remove device %(interface_name)s bridge "
"%(bridge_name)s does not exist"), locals()) "%(bridge_name)s does not exist"),
{'interface_name': interface_name,
'bridge_name': bridge_name})
return False return False
def delete_vlan(self, interface): def delete_vlan(self, interface):
@ -550,12 +564,13 @@ class LinuxBridgeQuantumAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug(_("Unable to get port details for " LOG.debug(_("Unable to get port details for "
"%(device)s: %(e)s"), locals()) "%(device)s: %(e)s"),
{'device': device, 'e': e})
resync = True resync = True
continue continue
if 'port_id' in details: if 'port_id' in details:
LOG.info(_("Port %(device)s updated. Details: %(details)s"), LOG.info(_("Port %(device)s updated. Details: %(details)s"),
locals()) {'device': device, 'details': details})
if details['admin_state_up']: if details['admin_state_up']:
# create the networking for the port # create the networking for the port
self.br_mgr.add_interface(details['network_id'], self.br_mgr.add_interface(details['network_id'],
@ -580,7 +595,7 @@ class LinuxBridgeQuantumAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug(_("port_removed failed for %(device)s: %(e)s"), LOG.debug(_("port_removed failed for %(device)s: %(e)s"),
locals()) {'device': device, 'e': e})
resync = True resync = True
if details['exists']: if details['exists']:
LOG.info(_("Port %s updated."), device) LOG.info(_("Port %s updated."), device)

View File

@ -138,11 +138,15 @@ def reserve_specific_network(session, physical_network, vlan_id):
raise q_exc.VlanIdInUse(vlan_id=vlan_id, raise q_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network) physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"), locals()) "network %(physical_network)s from pool"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
state.allocated = True state.allocated = True
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s outside pool"), locals()) "network %(physical_network)s outside pool"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
state = l2network_models_v2.NetworkState(physical_network, vlan_id) state = l2network_models_v2.NetworkState(physical_network, vlan_id)
state.allocated = True state.allocated = True
session.add(state) session.add(state)
@ -165,14 +169,19 @@ def release_network(session, physical_network, vlan_id, network_vlan_ranges):
if inside: if inside:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network " LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s to pool"), "%(physical_network)s to pool"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
else: else:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network " LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s outside pool"), locals()) "%(physical_network)s outside pool"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
session.delete(state) session.delete(state)
except exc.NoResultFound: except exc.NoResultFound:
LOG.warning(_("vlan_id %(vlan_id)s on physical network " LOG.warning(_("vlan_id %(vlan_id)s on physical network "
"%(physical_network)s not found"), locals()) "%(physical_network)s not found"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
def add_network_binding(session, network_id, physical_network, vlan_id): def add_network_binding(session, network_id, physical_network, vlan_id):

View File

@ -80,7 +80,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = self.get_port_from_device(device) port = self.get_port_from_device(device)
if port: if port:
binding = db.get_network_binding(db_api.get_session(), binding = db.get_network_binding(db_api.get_session(),
@ -106,7 +106,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"), LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = self.get_port_from_device(device) port = self.get_port_from_device(device)
if port: if port:
entry = {'device': device, entry = {'device': device,
@ -125,7 +125,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s up %(agent_id)s"), LOG.debug(_("Device %(device)s up %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = self.get_port_from_device(device) port = self.get_port_from_device(device)
if port: if port:
if port['status'] != q_const.PORT_STATUS_ACTIVE: if port['status'] != q_const.PORT_STATUS_ACTIVE:
@ -262,7 +262,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
LOG.error(_("Invalid network VLAN range: " LOG.error(_("Invalid network VLAN range: "
"'%(entry)s' - %(ex)s. " "'%(entry)s' - %(ex)s. "
"Service terminated!"), "Service terminated!"),
locals()) {'entry': entry, 'ex': ex})
sys.exit(1) sys.exit(1)
else: else:
self._add_network(entry) self._add_network(entry)

View File

@ -121,7 +121,8 @@ class NVPApiHelper(client_eventlet.NvpApiClientEventlet):
if response is None: if response is None:
# Timeout. # Timeout.
LOG.error(_('Request timed out: %(method)s to %(url)s'), locals()) LOG.error(_('Request timed out: %(method)s to %(url)s'),
{'method': method, 'url': url})
raise RequestTimeout() raise RequestTimeout()
status = response.status status = response.status

View File

@ -769,7 +769,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
LOG.debug(_("Looking for nova zone: %s"), novazone_id) LOG.debug(_("Looking for nova zone: %s"), novazone_id)
for x in self.clusters: for x in self.clusters:
LOG.debug(_("Looking for nova zone %(novazone_id)s in " LOG.debug(_("Looking for nova zone %(novazone_id)s in "
"cluster: %(x)s"), locals()) "cluster: %(x)s"),
{'novazone_id': novazone_id, 'x': x})
if x.zone == str(novazone_id): if x.zone == str(novazone_id):
self.novazone_cluster_map[x.zone] = x self.novazone_cluster_map[x.zone] = x
return x return x
@ -912,7 +913,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
for c in self.clusters: for c in self.clusters:
networks.extend(nvplib.get_all_networks(c, tenant_id, networks)) networks.extend(nvplib.get_all_networks(c, tenant_id, networks))
LOG.debug(_("get_all_networks() completed for tenant " LOG.debug(_("get_all_networks() completed for tenant "
"%(tenant_id)s: %(networks)s"), locals()) "%(tenant_id)s: %(networks)s"),
{'tenant_id': tenant_id, 'networks': networks})
return networks return networks
def create_network(self, context, network): def create_network(self, context, network):
@ -1072,7 +1074,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
break break
LOG.debug(_("Current network status:%(nvp_net_status)s; " LOG.debug(_("Current network status:%(nvp_net_status)s; "
"Status in Quantum DB:%(quantum_status)s"), "Status in Quantum DB:%(quantum_status)s"),
locals()) {'nvp_net_status': nvp_net_status,
'quantum_status': quantum_status})
if nvp_net_status != network.status: if nvp_net_status != network.status:
# update the network status # update the network status
network.status = nvp_net_status network.status = nvp_net_status
@ -1760,8 +1763,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
else: else:
raise nvp_exc.NvpPluginException( raise nvp_exc.NvpPluginException(
err_msg=(_("The port %(port_id)s, connected to the router " err_msg=(_("The port %(port_id)s, connected to the router "
"%(router_id)s was not found on the NVP backend.") "%(router_id)s was not found on the NVP "
% locals())) "backend.") % {'port_id': port_id,
'router_id': router_id}))
# Create logical router port and patch attachment # Create logical router port and patch attachment
self._create_and_attach_router_port( self._create_and_attach_router_port(
@ -1840,7 +1844,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
else: else:
LOG.warning(_("The port %(port_id)s, connected to the router " LOG.warning(_("The port %(port_id)s, connected to the router "
"%(router_id)s was not found on the NVP backend"), "%(router_id)s was not found on the NVP backend"),
locals()) {'port_id': port_id, 'router_id': router_id})
# Finally remove the data from the Quantum DB # Finally remove the data from the Quantum DB
# This will also destroy the port on the logical switch # This will also destroy the port on the logical switch
super(NvpPluginV2, self).remove_router_interface(context, super(NvpPluginV2, self).remove_router_interface(context,

View File

@ -229,7 +229,8 @@ def find_port_and_cluster(clusters, port_id):
for c in clusters: for c in clusters:
query = "/ws.v1/lswitch/*/lport?uuid=%s&fields=*" % port_id query = "/ws.v1/lswitch/*/lport?uuid=%s&fields=*" % port_id
LOG.debug(_("Looking for lswitch with port id " LOG.debug(_("Looking for lswitch with port id "
"'%(port_id)s' on: %(c)s"), locals()) "'%(port_id)s' on: %(c)s"),
{'port_id': port_id, 'c': c})
try: try:
res = do_single_request(HTTP_GET, query, cluster=c) res = do_single_request(HTTP_GET, query, cluster=c)
except Exception as e: except Exception as e:
@ -664,7 +665,8 @@ def get_port_by_display_name(clusters, lswitch, display_name):
query = ("/ws.v1/lswitch/%s/lport?display_name=%s&fields=*" % query = ("/ws.v1/lswitch/%s/lport?display_name=%s&fields=*" %
(lswitch, display_name)) (lswitch, display_name))
LOG.debug(_("Looking for port with display_name " LOG.debug(_("Looking for port with display_name "
"'%(display_name)s' on: %(lswitch)s"), locals()) "'%(display_name)s' on: %(lswitch)s"),
{'display_name': display_name, 'lswitch': lswitch})
for c in clusters: for c in clusters:
try: try:
res_obj = do_single_request(HTTP_GET, query, cluster=c) res_obj = do_single_request(HTTP_GET, query, cluster=c)
@ -709,7 +711,8 @@ def get_port_by_quantum_tag(cluster, lswitch_uuid, quantum_port_id):
def get_port(cluster, network, port, relations=None): def get_port(cluster, network, port, relations=None):
LOG.info(_("get_port() %(network)s %(port)s"), locals()) LOG.info(_("get_port() %(network)s %(port)s"),
{'network': network, 'port': port})
uri = "/ws.v1/lswitch/" + network + "/lport/" + port + "?" uri = "/ws.v1/lswitch/" + network + "/lport/" + port + "?"
if relations: if relations:
uri += "relations=%s" % relations uri += "relations=%s" % relations
@ -1354,8 +1357,9 @@ def update_lrouter_port_ips(cluster, lrouter_id, lport_id,
port['ip_addresses'] = list(ip_address_set) port['ip_addresses'] = list(ip_address_set)
do_single_request(HTTP_PUT, uri, json.dumps(port), cluster=cluster) do_single_request(HTTP_PUT, uri, json.dumps(port), cluster=cluster)
except NvpApiClient.ResourceNotFound as e: except NvpApiClient.ResourceNotFound as e:
data = {'lport_id': lport_id, 'lrouter_id': lrouter_id}
msg = (_("Router Port %(lport_id)s not found on router " msg = (_("Router Port %(lport_id)s not found on router "
"%(lrouter_id)s") % locals()) "%(lrouter_id)s") % data)
LOG.exception(msg) LOG.exception(msg)
raise nvp_exc.NvpPluginException(err_msg=msg) raise nvp_exc.NvpPluginException(err_msg=msg)
except NvpApiClient.NvpApiException as e: except NvpApiClient.NvpApiException as e:

View File

@ -345,7 +345,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
LOG.error(_("Cannot provision flat network for " LOG.error(_("Cannot provision flat network for "
"net-id=%(net_uuid)s - no bridge for " "net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"), "physical_network %(physical_network)s"),
locals()) {'net_uuid': net_uuid,
'physical_network': physical_network})
elif network_type == constants.TYPE_VLAN: elif network_type == constants.TYPE_VLAN:
if physical_network in self.phys_brs: if physical_network in self.phys_brs:
# outbound # outbound
@ -364,14 +365,16 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
LOG.error(_("Cannot provision VLAN network for " LOG.error(_("Cannot provision VLAN network for "
"net-id=%(net_uuid)s - no bridge for " "net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"), "physical_network %(physical_network)s"),
locals()) {'net_uuid': net_uuid,
'physical_network': physical_network})
elif network_type == constants.TYPE_LOCAL: elif network_type == constants.TYPE_LOCAL:
# no flows needed for local networks # no flows needed for local networks
pass pass
else: else:
LOG.error(_("Cannot provision unknown network type " LOG.error(_("Cannot provision unknown network type "
"%(network_type)s for net-id=%(net_uuid)s"), "%(network_type)s for net-id=%(net_uuid)s"),
locals()) {'network_type': network_type,
'net_uuid': net_uuid})
def reclaim_local_vlan(self, net_uuid, lvm): def reclaim_local_vlan(self, net_uuid, lvm):
'''Reclaim a local VLAN. '''Reclaim a local VLAN.
@ -546,13 +549,15 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
for physical_network, bridge in bridge_mappings.iteritems(): for physical_network, bridge in bridge_mappings.iteritems():
LOG.info(_("Mapping physical network %(physical_network)s to " LOG.info(_("Mapping physical network %(physical_network)s to "
"bridge %(bridge)s"), "bridge %(bridge)s"),
locals()) {'physical_network': physical_network,
'bridge': bridge})
# setup physical bridge # setup physical bridge
if not ip_lib.device_exists(bridge, self.root_helper): if not ip_lib.device_exists(bridge, self.root_helper):
LOG.error(_("Bridge %(bridge)s for physical network " LOG.error(_("Bridge %(bridge)s for physical network "
"%(physical_network)s does not exist. Agent " "%(physical_network)s does not exist. Agent "
"terminated!"), "terminated!"),
locals()) {'physical_network': physical_network,
'bridge': bridge})
sys.exit(1) sys.exit(1)
br = ovs_lib.OVSBridge(bridge, self.root_helper) br = ovs_lib.OVSBridge(bridge, self.root_helper)
br.remove_all_flows() br.remove_all_flows()
@ -615,13 +620,14 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug(_("Unable to get port details for " LOG.debug(_("Unable to get port details for "
"%(device)s: %(e)s"), locals()) "%(device)s: %(e)s"),
{'device': device, 'e': e})
resync = True resync = True
continue continue
port = self.int_br.get_vif_port_by_id(details['device']) port = self.int_br.get_vif_port_by_id(details['device'])
if 'port_id' in details: if 'port_id' in details:
LOG.info(_("Port %(device)s updated. Details: %(details)s"), LOG.info(_("Port %(device)s updated. Details: %(details)s"),
locals()) {'device': device, 'details': details})
self.treat_vif_port(port, details['port_id'], self.treat_vif_port(port, details['port_id'],
details['network_id'], details['network_id'],
details['network_type'], details['network_type'],
@ -645,7 +651,7 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
self.agent_id) self.agent_id)
except Exception as e: except Exception as e:
LOG.debug(_("port_removed failed for %(device)s: %(e)s"), LOG.debug(_("port_removed failed for %(device)s: %(e)s"),
locals()) {'device': device, 'e': e})
resync = True resync = True
continue continue
if details['exists']: if details['exists']:

View File

@ -156,12 +156,15 @@ def reserve_specific_vlan(session, physical_network, vlan_id):
raise q_exc.VlanIdInUse(vlan_id=vlan_id, raise q_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network) physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"), locals()) "network %(physical_network)s from pool"),
{'vlan_id': vlan_id,
'physical_network': physical_network})
alloc.allocated = True alloc.allocated = True
except exc.NoResultFound: except exc.NoResultFound:
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical " LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s outside pool"), "network %(physical_network)s outside pool"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id) alloc = ovs_models_v2.VlanAllocation(physical_network, vlan_id)
alloc.allocated = True alloc.allocated = True
session.add(alloc) session.add(alloc)
@ -185,15 +188,18 @@ def release_vlan(session, physical_network, vlan_id, network_vlan_ranges):
session.delete(alloc) session.delete(alloc)
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network " LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s outside pool"), "%(physical_network)s outside pool"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
else: else:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network " LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s to pool"), "%(physical_network)s to pool"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
except exc.NoResultFound: except exc.NoResultFound:
LOG.warning(_("vlan_id %(vlan_id)s on physical network " LOG.warning(_("vlan_id %(vlan_id)s on physical network "
"%(physical_network)s not found"), "%(physical_network)s not found"),
locals()) {'vlan_id': vlan_id,
'physical_network': physical_network})
def sync_tunnel_allocations(tunnel_id_ranges): def sync_tunnel_allocations(tunnel_id_ranges):
@ -206,7 +212,7 @@ def sync_tunnel_allocations(tunnel_id_ranges):
if tun_max + 1 - tun_min > 1000000: if tun_max + 1 - tun_min > 1000000:
LOG.error(_("Skipping unreasonable tunnel ID range " LOG.error(_("Skipping unreasonable tunnel ID range "
"%(tun_min)s:%(tun_max)s"), "%(tun_min)s:%(tun_max)s"),
locals()) {'tun_min': tun_min, 'tun_max': tun_max})
else: else:
tunnel_ids |= set(xrange(tun_min, tun_max + 1)) tunnel_ids |= set(xrange(tun_min, tun_max + 1))

View File

@ -89,7 +89,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"), LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = ovs_db_v2.get_port(device) port = ovs_db_v2.get_port(device)
if port: if port:
binding = ovs_db_v2.get_network_binding(None, port['network_id']) binding = ovs_db_v2.get_network_binding(None, port['network_id'])
@ -115,7 +115,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"), LOG.debug(_("Device %(device)s no longer exists on %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = ovs_db_v2.get_port(device) port = ovs_db_v2.get_port(device)
if port: if port:
entry = {'device': device, entry = {'device': device,
@ -134,7 +134,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
agent_id = kwargs.get('agent_id') agent_id = kwargs.get('agent_id')
device = kwargs.get('device') device = kwargs.get('device')
LOG.debug(_("Device %(device)s up on %(agent_id)s"), LOG.debug(_("Device %(device)s up on %(agent_id)s"),
locals()) {'device': device, 'agent_id': agent_id})
port = ovs_db_v2.get_port(device) port = ovs_db_v2.get_port(device)
if port: if port:
if port['status'] != q_const.PORT_STATUS_ACTIVE: if port['status'] != q_const.PORT_STATUS_ACTIVE:

View File

@ -153,7 +153,7 @@ class TunnelKey(object):
new_key = new_key[0] # the result is tuple. new_key = new_key[0] # the result is tuple.
LOG.debug(_("last_key %(last_key)s new_key %(new_key)s"), LOG.debug(_("last_key %(last_key)s new_key %(new_key)s"),
locals()) {'last_key': last_key, 'new_key': new_key})
if new_key > self.key_max: if new_key > self.key_max:
LOG.debug(_("No key found")) LOG.debug(_("No key found"))
raise orm_exc.NoResultFound() raise orm_exc.NoResultFound()