msg = _("The server with id %(s_id)s has no key %(m_key)s")
LOG.error(msg % {"s_id": "1234", "m_key": "imageId"})
+Please do not use locals() for string substitutions.
+
Creating Unit Tests
-------------------
interface_name):
rules = [('POSTROUTING', '! -i %(interface_name)s '
'! -o %(interface_name)s -m conntrack ! '
- '--ctstate DNAT -j ACCEPT' % locals())]
+ '--ctstate DNAT -j ACCEPT' %
+ {'interface_name': interface_name})]
for cidr in internal_cidrs:
rules.extend(self.internal_network_nat_rules(ex_gw_ip, cidr))
return rules
name = 'name\s*:\s"(?P<port_name>[^"]*)"'
port = 'ofport\s*:\s(?P<ofport>-?\d+)'
_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)
def run_vsctl(self, args):
args = ["ovs-vsctl", "--timeout=2", "iface-to-br", iface]
try:
return utils.execute(args, root_helper=root_helper).strip()
- except Exception, e:
- LOG.exception(_("Interface %(iface)s not found. Exception: %(e)s"),
- locals())
+ except Exception:
+ LOG.exception(_("Interface %s not found."), iface)
return None
self.add_extension(new_ext)
except Exception as exception:
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):
# Do nothing if the extension doesn't check out
if not isinstance(target_dict, dict):
msg = (_("Invalid input. '%(target_dict)s' must be a dictionary "
"with keys: %(expected_keys)s") %
- dict(target_dict=target_dict, expected_keys=expected_keys))
+ {'target_dict': target_dict, 'expected_keys': expected_keys})
return msg
expected_keys = set(expected_keys)
if not predicate(provided_keys):
msg = (_("Validation of dictionary's keys failed."
"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
def _validate_values(data, valid_values=None):
if data not in valid_values:
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)
return msg
if max_len is not None and len(data) > max_len:
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)
return msg
max_value = valid_values[1]
if not min_value <= data <= max_value:
msg = _("'%(data)s' is not in range %(min_value)s through "
- "%(max_value)s") % dict(data=data,
- min_value=min_value,
- max_value=max_value)
+ "%(max_value)s") % {'data': data,
+ 'min_value': min_value,
+ 'max_value': max_value}
LOG.debug(msg)
return 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.") %
+ {'app_name': app_name,
+ 'config_path': config_path})
LOG.exception(msg)
raise RuntimeError(msg)
return app
raise ValueError(_("Missing value in mapping: '%s'") % mapping)
if key in mappings:
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():
raise ValueError(_("Value %(value)s in mapping: '%(mapping)s' "
- "not unique") % locals())
+ "not unique") % {'value': value,
+ 'mapping': mapping})
mappings[key] = value
return mappings
remaining -= 1
LOG.info(_("Unable to connect to database, %(remaining)s attempts "
"left. Retrying in %(reconnect_interval)s seconds"),
- locals())
+ {'remaining': remaining,
+ 'reconnect_interval': reconnect_interval})
time.sleep(reconnect_interval)
if register_models(base):
break
if QuantumDbPluginV2._check_unique_mac(context, network_id,
mac_address):
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
else:
LOG.debug(_("Generated mac %(mac_address)s exists. Remaining "
else:
LOG.debug(_("Hold allocated IP %(ip_address)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
@staticmethod
except exc.NoResultFound:
LOG.debug(_("No fixed IP found that matches the network "
"%(network_id)s and ip address %(ip_address)s."),
- locals())
+ {'network_id': network_id,
+ 'ip_address': ip_address})
@staticmethod
def _delete_ip_allocation(context, network_id, subnet_id, ip_address):
# Delete the IP address from the IPAllocate table
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(
models_v2.IPAllocation).with_lockmode('update')
- allocated = alloc_qry.filter_by(network_id=network_id,
- ip_address=ip_address,
- subnet_id=subnet_id).delete()
+ alloc_qry.filter_by(network_id=network_id,
+ ip_address=ip_address,
+ subnet_id=subnet_id).delete()
@staticmethod
def _generate_ip(context, subnets):
l_range = ip_ranges[l_cursor]
r_range = ip_ranges[r_cursor]
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(
pool_1=l_range,
pool_2=r_range,
context.session.commit()
except Exception as e:
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()
raise e
return objects
"""Check IP field of a subnet match specified ip version."""
ip = netaddr.IPNetwork(addr)
if ip.version != ip_version:
+ data = {'name': name,
+ 'addr': addr,
+ 'ip_version': ip_version}
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)
def _validate_subnet(self, s):
subnet_id = ip['subnet_id']
LOG.debug(_("Allocated IP %(ip_address)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(
network_id=network_id,
port_id=port_id,
QuantumDbPluginV2._delete_ip_allocation(
context, a['network_id'],
a['subnet_id'], a['ip_address'])
- msg_dict = dict(address=a['ip_address'],
- subnet_id=a['subnet_id'])
+ msg_dict = {'address': a['ip_address'],
+ 'subnet_id': a['subnet_id']}
msg = _("%(address)s (%(subnet_id)s) is not "
"recycled") % msg_dict
LOG.debug(msg)
if retval is None:
# No previous port exists, so create a new one.
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)
device_id = kwargs.get('device_id')
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()
filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters)
subnet_id = kwargs.get('subnet_id')
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()
filters = dict(network_id=[network_id], device_id=[device_id])
ports = plugin.get_ports(context, filters=filters)
lease_remaining = kwargs.get('lease_remaining')
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.update_fixed_ip_lease_expiration(context, network_id,
match1 = netaddr.all_matching_cidrs(new_ipnet, [cidr])
match2 = netaddr.all_matching_cidrs(ipnet, [subnet_cidr])
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 "
"%(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)
except exc.NoResultFound:
pass
port_id = fip['port_id']
if 'id' in fip:
floatingip_id = fip['id']
- msg = _('Port %(port_id)s is associated with a different '
- 'tenant than Floating IP %(floatingip_id)s and '
- 'therefore cannot be bound.')
+ data = {'port_id': port_id,
+ 'floatingip_id': floatingip_id}
+ msg = (_('Port %(port_id)s is associated with a different '
+ 'tenant than Floating IP %(floatingip_id)s and '
+ 'therefore cannot be bound.') % data)
else:
- msg = _('Cannnot create floating IP and bind it to '
- 'Port %(port_id)s, since that port is owned by a '
- 'different tenant.')
- raise q_exc.BadRequest(resource='floatingip', msg=msg % locals())
+ msg = (_('Cannnot create floating IP and bind it to '
+ 'Port %s, since that port is owned by a '
+ 'different tenant.') % port_id)
+ raise q_exc.BadRequest(resource='floatingip', msg=msg)
internal_subnet_id = None
if 'fixed_ip_address' in fip and fip['fixed_ip_address']:
# ip enabled gateway with support for this floating IP network
try:
port_qry = context.elevated().session.query(models_v2.Port)
- ports = port_qry.filter_by(
+ port_qry.filter_by(
network_id=floating_network_id,
device_id=router_id,
device_owner=DEVICE_OWNER_ROUTER_GW).one()
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"),
+ {'f_name': f_name, 'msg': msg})
return msg
# Validate 'service' attribute
if svc_name not 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"),
+ {'f_name': f_name, 'msg': msg})
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"),
+ {'f_name': f_name, 'msg': msg})
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"),
+ {'f_name': f_name, 'msg': msg})
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"),
+ {'f_name': f_name, 'msg': msg})
return msg
# Validate 'driver' attribute (just check it's a string)
# FIXME(salvatore-orlando): This should be a list
if 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"),
+ {'f_name': f_name, 'msg': msg})
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"),
+ {'f_name': f_name, 'msg': msg})
return msg
except TypeError:
return (_("%s: provided data are not iterable") %
{'server': self.server, 'port': self.port, 'ssl': self.ssl,
'action': action})
LOG.debug(_("ServerProxy: resource=%(resource)s, data=%(data)r, "
- "headers=%(headers)r"), locals())
+ "headers=%(headers)r"),
+ {'resource': resource, 'data': data, 'headers': headers})
conn = None
if self.ssl:
pass
ret = (response.status, response.reason, respstr, respdata)
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
conn.close()
LOG.debug(_("ServerProxy: status=%(status)d, reason=%(reason)r, "
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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:])
if port:
entry = {'device': device,
if plugin_key not in self._plugins:
LOG.info(_("No %s Plugin loaded"), plugin_key)
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
device_params = {const.DEVICE_IP: []}
def _delete_port(self, network_id, port_id):
"""Delete port."""
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" %
- locals())
+ data)
port_req = self.create_request(port_path, None,
self.contenttype, 'DELETE')
port_req.get_response(self.api)
err_sum_desc = job.ErrorSummaryDescription
err_desc = job.ErrorDescription
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(
msg=_("WMI job failed with status %(job_state)d. "
"Error details: %(err_sum_desc)s - %(err_desc)s - "
- "Error code: %(err_code)d") % locals())
+ "Error code: %(err_code)d") % data)
else:
(error, ret_val) = job.GetError()
if not ret_val and error:
+ data = {'job_state': job_state,
+ 'error': error}
raise HyperVException(
msg=_("WMI job failed with status %(job_state)d. "
- "Error details: %(error)s") % locals())
+ "Error details: %(error)s") % data)
else:
raise HyperVException(
- msg=_("WMI job failed with status %(job_state)d. "
- "No error description available") % locals())
+ msg=_("WMI job failed with status %d. "
+ "No error description available") % job_state)
desc = job.Description
elap = job.ElapsedTime
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):
"""Creates a switch port."""
(ret_val, ) = switch_svc.DisconnectSwitchPort(
SwitchPort=switch_port_path)
if ret_val != 0:
+ data = {'switch_port_name': switch_port_name,
+ 'vswitch_name': vswitch_name,
+ 'ret_val': ret_val}
raise HyperVException(
msg=_('Failed to disconnect port %(switch_port_name)s '
'from switch %(vswitch_name)s '
- 'with error %(ret_val)s') % locals())
+ 'with error %(ret_val)s') % data)
if delete_port:
(ret_val, ) = switch_svc.DeleteSwitchPort(
SwitchPort=switch_port_path)
if ret_val != 0:
+ data = {'switch_port_name': switch_port_name,
+ 'vswitch_name': vswitch_name,
+ 'ret_val': ret_val}
raise HyperVException(
msg=_('Failed to delete port %(switch_port_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):
vswitch = self._conn.Msvm_VirtualSwitch(ElementName=vswitch_name)
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
alloc.allocated = True
except exc.NoResultFound:
raise q_exc.NoNetworkAvailable()
#session.delete(alloc)
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
except exc.NoResultFound:
LOG.warning(_("vlan_id %(vlan_id)s on physical network "
"%(physical_network)s not found"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
def _add_missing_allocatable_vlans(self, session, vlan_ids,
physical_network):
constants.TYPE_VLAN,
constants.TYPE_NONE]:
msg = _(
- "Invalid tenant_network_type: %(tenant_network_type)s. "
- "Agent terminated!") % locals()
+ "Invalid tenant_network_type: %s. "
+ "Agent terminated!") % tenant_network_type
raise q_exc.InvalidInput(error_message=msg)
self._tenant_network_type = tenant_network_type
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
LOG.debug(_("Device %(device)s details requested from %(agent_id)s"),
- locals())
+ {'device': device, 'agent_id': agent_id})
port = self._db.get_port(device)
if port:
binding = self._db.get_network_binding(None, port['network_id'])
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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)
if port:
entry = {'device': device,
LOG.debug(_("Creating subinterface %(interface)s for "
"VLAN %(vlan_id)s on interface "
"%(physical_interface)s"),
- locals())
+ {'interface': interface, 'vlan_id': vlan_id,
+ 'physical_interface': physical_interface})
if utils.execute(['ip', 'link', 'add', 'link',
physical_interface,
'name', interface, 'type', 'vlan', 'id',
"""
if not self.device_exists(bridge_name):
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],
root_helper=self.root_helper):
return
return
LOG.debug(_("Done starting bridge %(bridge_name)s for "
"subinterface %(interface)s"),
- locals())
+ {'bridge_name': bridge_name, 'interface': interface})
if not interface:
return
root_helper=self.root_helper)
except Exception as e:
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
def ensure_physical_in_bridge(self, network_id,
# Check if device needs to be added to bridge
tap_device_in_bridge = self.get_bridge_for_tap_device(tap_device_name)
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 "
- "%(bridge_name)s") % locals()
+ "%(bridge_name)s") % data
LOG.debug(msg)
if utils.execute(['brctl', 'addif', bridge_name, tap_device_name],
root_helper=self.root_helper):
return False
else:
+ data = {'tap_device_name': tap_device_name,
+ 'bridge_name': bridge_name}
msg = _("%(tap_device_name)s already exists on bridge "
- "%(bridge_name)s") % locals()
+ "%(bridge_name)s") % data
LOG.debug(msg)
return True
if not self.is_device_on_bridge(interface_name):
return True
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],
root_helper=self.root_helper):
return False
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
else:
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
def delete_vlan(self, interface):
self.agent_id)
except Exception as e:
LOG.debug(_("Unable to get port details for "
- "%(device)s: %(e)s"), locals())
+ "%(device)s: %(e)s"),
+ {'device': device, 'e': e})
resync = True
continue
if 'port_id' in details:
LOG.info(_("Port %(device)s updated. Details: %(details)s"),
- locals())
+ {'device': device, 'details': details})
if details['admin_state_up']:
# create the networking for the port
self.br_mgr.add_interface(details['network_id'],
self.agent_id)
except Exception as e:
LOG.debug(_("port_removed failed for %(device)s: %(e)s"),
- locals())
+ {'device': device, 'e': e})
resync = True
if details['exists']:
LOG.info(_("Port %s updated."), device)
raise q_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network)
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
except exc.NoResultFound:
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.allocated = True
session.add(state)
if inside:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s to pool"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
else:
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)
except exc.NoResultFound:
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):
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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)
if port:
binding = db.get_network_binding(db_api.get_session(),
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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)
if port:
entry = {'device': device,
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
LOG.debug(_("Device %(device)s up %(agent_id)s"),
- locals())
+ {'device': device, 'agent_id': agent_id})
port = self.get_port_from_device(device)
if port:
if port['status'] != q_const.PORT_STATUS_ACTIVE:
LOG.error(_("Invalid network VLAN range: "
"'%(entry)s' - %(ex)s. "
"Service terminated!"),
- locals())
+ {'entry': entry, 'ex': ex})
sys.exit(1)
else:
self._add_network(entry)
if response is None:
# 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()
status = response.status
LOG.debug(_("Looking for nova zone: %s"), novazone_id)
for x in self.clusters:
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):
self.novazone_cluster_map[x.zone] = x
return x
for c in self.clusters:
networks.extend(nvplib.get_all_networks(c, tenant_id, networks))
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
def create_network(self, context, network):
break
LOG.debug(_("Current network status:%(nvp_net_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:
# update the network status
network.status = nvp_net_status
else:
raise nvp_exc.NvpPluginException(
err_msg=(_("The port %(port_id)s, connected to the router "
- "%(router_id)s was not found on the NVP backend.")
- % locals()))
+ "%(router_id)s was not found on the NVP "
+ "backend.") % {'port_id': port_id,
+ 'router_id': router_id}))
# Create logical router port and patch attachment
self._create_and_attach_router_port(
else:
LOG.warning(_("The port %(port_id)s, connected to the router "
"%(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
# This will also destroy the port on the logical switch
super(NvpPluginV2, self).remove_router_interface(context,
for c in clusters:
query = "/ws.v1/lswitch/*/lport?uuid=%s&fields=*" % 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:
res = do_single_request(HTTP_GET, query, cluster=c)
except Exception as e:
query = ("/ws.v1/lswitch/%s/lport?display_name=%s&fields=*" %
(lswitch, 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:
try:
res_obj = do_single_request(HTTP_GET, query, cluster=c)
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 + "?"
if relations:
uri += "relations=%s" % relations
port['ip_addresses'] = list(ip_address_set)
do_single_request(HTTP_PUT, uri, json.dumps(port), cluster=cluster)
except NvpApiClient.ResourceNotFound as e:
+ data = {'lport_id': lport_id, 'lrouter_id': lrouter_id}
msg = (_("Router Port %(lport_id)s not found on router "
- "%(lrouter_id)s") % locals())
+ "%(lrouter_id)s") % data)
LOG.exception(msg)
raise nvp_exc.NvpPluginException(err_msg=msg)
except NvpApiClient.NvpApiException as e:
LOG.error(_("Cannot provision flat network for "
"net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"),
- locals())
+ {'net_uuid': net_uuid,
+ 'physical_network': physical_network})
elif network_type == constants.TYPE_VLAN:
if physical_network in self.phys_brs:
# outbound
LOG.error(_("Cannot provision VLAN network for "
"net-id=%(net_uuid)s - no bridge for "
"physical_network %(physical_network)s"),
- locals())
+ {'net_uuid': net_uuid,
+ 'physical_network': physical_network})
elif network_type == constants.TYPE_LOCAL:
# no flows needed for local networks
pass
else:
LOG.error(_("Cannot provision unknown network type "
"%(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):
'''Reclaim a local VLAN.
for physical_network, bridge in bridge_mappings.iteritems():
LOG.info(_("Mapping physical network %(physical_network)s to "
"bridge %(bridge)s"),
- locals())
+ {'physical_network': physical_network,
+ 'bridge': bridge})
# setup physical bridge
if not ip_lib.device_exists(bridge, self.root_helper):
LOG.error(_("Bridge %(bridge)s for physical network "
"%(physical_network)s does not exist. Agent "
"terminated!"),
- locals())
+ {'physical_network': physical_network,
+ 'bridge': bridge})
sys.exit(1)
br = ovs_lib.OVSBridge(bridge, self.root_helper)
br.remove_all_flows()
self.agent_id)
except Exception as e:
LOG.debug(_("Unable to get port details for "
- "%(device)s: %(e)s"), locals())
+ "%(device)s: %(e)s"),
+ {'device': device, 'e': e})
resync = True
continue
port = self.int_br.get_vif_port_by_id(details['device'])
if 'port_id' in details:
LOG.info(_("Port %(device)s updated. Details: %(details)s"),
- locals())
+ {'device': device, 'details': details})
self.treat_vif_port(port, details['port_id'],
details['network_id'],
details['network_type'],
self.agent_id)
except Exception as e:
LOG.debug(_("port_removed failed for %(device)s: %(e)s"),
- locals())
+ {'device': device, 'e': e})
resync = True
continue
if details['exists']:
raise q_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network)
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
except exc.NoResultFound:
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"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.allocated = True
session.add(alloc)
session.delete(alloc)
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s outside pool"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
else:
LOG.debug(_("Releasing vlan %(vlan_id)s on physical network "
"%(physical_network)s to pool"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
except exc.NoResultFound:
LOG.warning(_("vlan_id %(vlan_id)s on physical network "
"%(physical_network)s not found"),
- locals())
+ {'vlan_id': vlan_id,
+ 'physical_network': physical_network})
def sync_tunnel_allocations(tunnel_id_ranges):
if tun_max + 1 - tun_min > 1000000:
LOG.error(_("Skipping unreasonable tunnel ID range "
"%(tun_min)s:%(tun_max)s"),
- locals())
+ {'tun_min': tun_min, 'tun_max': tun_max})
else:
tunnel_ids |= set(xrange(tun_min, tun_max + 1))
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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)
if port:
binding = ovs_db_v2.get_network_binding(None, port['network_id'])
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
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)
if port:
entry = {'device': device,
agent_id = kwargs.get('agent_id')
device = kwargs.get('device')
LOG.debug(_("Device %(device)s up on %(agent_id)s"),
- locals())
+ {'device': device, 'agent_id': agent_id})
port = ovs_db_v2.get_port(device)
if port:
if port['status'] != q_const.PORT_STATUS_ACTIVE:
new_key = new_key[0] # the result is tuple.
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:
LOG.debug(_("No key found"))
raise orm_exc.NoResultFound()