]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove locals() from strings substitutions
authorGary Kotton <gkotton@redhat.com>
Tue, 16 Apr 2013 07:20:31 +0000 (07:20 +0000)
committerGary Kotton <gkotton@redhat.com>
Sat, 20 Apr 2013 11:56:26 +0000 (11:56 +0000)
Fixes bug 1168988

Change-Id: Ifd1e7a027f16062ff35e777cf2d953f652a806a7

30 files changed:
HACKING.rst
quantum/agent/l3_agent.py
quantum/agent/linux/ovs_lib.py
quantum/api/extensions.py
quantum/api/v2/attributes.py
quantum/common/config.py
quantum/common/utils.py
quantum/db/api.py
quantum/db/db_base_plugin_v2.py
quantum/db/dhcp_rpc_base.py
quantum/db/l3_db.py
quantum/extensions/servicetype.py
quantum/plugins/bigswitch/plugin.py
quantum/plugins/brocade/QuantumPlugin.py
quantum/plugins/cisco/models/virt_phy_sw_v2.py
quantum/plugins/cisco/tests/unit/test_cisco_extension.py
quantum/plugins/hyperv/agent/utils.py
quantum/plugins/hyperv/db.py
quantum/plugins/hyperv/hyperv_quantum_plugin.py
quantum/plugins/hyperv/rpc_callbacks.py
quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py
quantum/plugins/linuxbridge/db/l2network_db_v2.py
quantum/plugins/linuxbridge/lb_quantum_plugin.py
quantum/plugins/nicira/NvpApiClient.py
quantum/plugins/nicira/QuantumPlugin.py
quantum/plugins/nicira/nvplib.py
quantum/plugins/openvswitch/agent/ovs_quantum_agent.py
quantum/plugins/openvswitch/ovs_db_v2.py
quantum/plugins/openvswitch/ovs_quantum_plugin.py
quantum/plugins/ryu/db/api_v2.py

index 84e81af97d7f92481448f2e841aa560539035324..d3330c023a0d157fa00c140b5d0cbe42193ad27b 100644 (file)
@@ -190,6 +190,8 @@ Example::
     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
 -------------------
index 07eecc675003c5db5bbc927f0504c32c8687e83b..b1dcc442851876dbe2a14fb386a509609ff31521 100644 (file)
@@ -466,7 +466,8 @@ class L3NATAgent(manager.Manager):
                                    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
index 0d8ee843bfcfdcd470687f5d1ae230c208963108..5c38b58b7444cb1391c465908440c5216ad5b61f 100644 (file)
@@ -54,7 +54,10 @@ class OVSBridge:
         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):
@@ -285,9 +288,8 @@ def get_bridge_for_iface(root_helper, iface):
     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
 
 
index ce562ca8d0ad864934e17655b73724f10ef59ea5..ac2d1c3a85d37e29f6f235651c3605866e8b7a41 100644 (file)
@@ -526,7 +526,7 @@ class ExtensionManager(object):
                     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
index fa3e81cfbb276b2189bc05cab8a3ec837bc63ff6..aea6094ed5c62cbb56dd489de8c806008b127580 100644 (file)
@@ -41,7 +41,7 @@ def _verify_dict_keys(expected_keys, target_dict, strict=True):
     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)
@@ -52,7 +52,9 @@ def _verify_dict_keys(expected_keys, target_dict, strict=True):
     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
 
 
@@ -63,7 +65,7 @@ def is_attr_set(attribute):
 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
 
@@ -76,7 +78,7 @@ def _validate_string(data, max_len=None):
 
     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
 
@@ -86,9 +88,9 @@ def _validate_range(data, valid_values=None):
     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
 
index a1c0a7c5c856f47bc80daff6c2e53263735146b5..8d66d949cc749d330b04e2548c81638bfcdf812b 100644 (file)
@@ -134,8 +134,10 @@ def load_paste_app(app_name):
     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
index 8c3467a844c516e4faec27105bba248071f04f11..379e9c4a4138f3c494c0798f7b18a2fccc79f0f6 100644 (file)
@@ -141,10 +141,11 @@ def parse_mappings(mapping_list, unique_values=True):
             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
 
index 826b93efe84bb94784dd72f4039531de28759439..5919ecccec6737bc72b0293822f03960c3090316 100644 (file)
@@ -206,7 +206,8 @@ def retry_registration(remaining, reconnect_interval, base=BASE):
             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
index 6f2172d2450a24c4a8b4e75168a7b06c387c6eef..ace3a22452f4a45862f3a1d6e5ebbf041b3b36da 100644 (file)
@@ -259,7 +259,9 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             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 "
@@ -298,7 +300,10 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         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
@@ -429,19 +434,23 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         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):
@@ -806,7 +815,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     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,
@@ -934,7 +944,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
             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
@@ -1029,8 +1040,11 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         """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):
@@ -1313,7 +1327,10 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     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,
@@ -1384,8 +1401,8 @@ class QuantumDbPluginV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
                     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)
index ea4a5a5f7e6aee5d32b4b05b63ad9f21ca23403a..1eca64a6f757cc272f0c31aff2a3c097d12fe083 100644 (file)
@@ -109,7 +109,10 @@ class DhcpRpcCallbackMixin(object):
         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)
 
@@ -139,7 +142,8 @@ class DhcpRpcCallbackMixin(object):
         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)
@@ -155,7 +159,8 @@ class DhcpRpcCallbackMixin(object):
         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)
@@ -178,7 +183,10 @@ class DhcpRpcCallbackMixin(object):
         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,
index 6e140bb825898e09f7f8e10095bc647fbfe5fc3c..f0209f1468a2dc0c307fc49e5f3b085f4a43b168 100644 (file)
@@ -303,9 +303,13 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
                     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
@@ -516,14 +520,16 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
             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']:
@@ -558,7 +564,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase):
         # 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()
index 270bbb5dbfb5fb14519cc2fefde18125314c36a6..262a7b8eefbd6625035e8545a115b00538a4cd5c 100644 (file)
@@ -100,19 +100,22 @@ def _validate_service_defs(data, valid_values=None):
                 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
@@ -120,11 +123,13 @@ def _validate_service_defs(data, valid_values=None):
                     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
@@ -140,14 +145,16 @@ def _validate_service_defs(data, valid_values=None):
                 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") %
index 849c38e26f2a5f8b046045d8b178168d116ca6b5..c979626e7b53a547e7ff8c8b4f476f9f2fa16e70 100644 (file)
@@ -163,7 +163,8 @@ class ServerProxy(object):
                   {'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:
@@ -194,7 +195,8 @@ class ServerProxy(object):
                     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, "
index 5639dc40ed582bf9c4ae716f07c30a8b1a9f8187..ee097f3a0b6066eda597fe95b605aecb69c3fecd 100644 (file)
@@ -125,7 +125,7 @@ class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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,
index 1623153f166c5b95304cf1b301b1fccdabb5b4e1..7fe00daa0e491e0f646222f13f48ad8d9012285f 100644 (file)
@@ -125,7 +125,9 @@ class VirtualPhysicalSwitchModelV2(quantum_plugin_base_v2.QuantumPluginBaseV2):
         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: []}
index 7eb0af95473b0a4b2a24c52466156732b6d142cb..04b72e0670c8597164cd68e42f271131060402de 100644 (file)
@@ -126,8 +126,9 @@ class ExtensionsTestApp(wsgi.Router):
     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)
index 1c0468b6386e7ef53e596c499619507f98fce6b7..860a08f703a57fdcd86c6d2d3aabe8fb79e317af 100644 (file)
@@ -123,25 +123,31 @@ class HyperVUtils(object):
                 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."""
@@ -170,18 +176,24 @@ class HyperVUtils(object):
         (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)
index b88d286a1efa7a4ee1734f6ebbe2d5bfa2b5e705..38e6e900edb4f1c3ebc974ad39b00ddb8624083b 100644 (file)
@@ -78,7 +78,8 @@ class HyperVPluginDB(object):
                             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()
@@ -134,11 +135,13 @@ class HyperVPluginDB(object):
                 #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):
index 887b89f8b8279864347c9228f6c550bb23e11a6c..9e27a815cf1f766429328ed547f98783d78b0367 100644 (file)
@@ -174,8 +174,8 @@ class HyperVQuantumPlugin(db_base_plugin_v2.QuantumDbPluginV2,
                                        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
 
index f2e17f16ab28c4375f3601ad52b941f1a2691d0b..8a47052e7a5d017c279a03eea0f8cbe4c2c10935 100644 (file)
@@ -51,7 +51,7 @@ class HyperVRpcCallbacks(
         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'])
@@ -75,7 +75,7 @@ class HyperVRpcCallbacks(
         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,
index 269101df33624cdfebc68f4e86f6ce3fdf083e88..40ce7cf2daeaad88545ceb87073087960ff1b571 100755 (executable)
@@ -169,7 +169,8 @@ class LinuxBridgeManager:
             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',
@@ -216,7 +217,8 @@ class LinuxBridgeManager:
         """
         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
@@ -231,7 +233,7 @@ class LinuxBridgeManager:
                 return
             LOG.debug(_("Done starting bridge %(bridge_name)s for "
                         "subinterface %(interface)s"),
-                      locals())
+                      {'bridge_name': bridge_name, 'interface': interface})
 
         if not interface:
             return
@@ -246,7 +248,9 @@ class LinuxBridgeManager:
                               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,
@@ -289,15 +293,19 @@ class LinuxBridgeManager:
         # 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
 
@@ -343,16 +351,22 @@ class LinuxBridgeManager:
             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):
@@ -550,12 +564,13 @@ class LinuxBridgeQuantumAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
                                                              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'],
@@ -580,7 +595,7 @@ class LinuxBridgeQuantumAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
                                                              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)
index 8a5631e537d636c5a03da87ec8ca9c86b9381473..46b1f6ec1665c83d61e8646459df97590ca027ef 100644 (file)
@@ -138,11 +138,15 @@ def reserve_specific_network(session, physical_network, vlan_id):
                     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)
@@ -165,14 +169,19 @@ def release_network(session, physical_network, vlan_id, network_vlan_ranges):
             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):
index 28741516e31f4ecc1846ba0396b84842b4a9877e..e53c9b2b8c026480248209470105c1020c1594bc 100644 (file)
@@ -80,7 +80,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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(),
@@ -106,7 +106,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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,
@@ -125,7 +125,7 @@ class LinuxBridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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:
@@ -262,7 +262,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                     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)
index 62f2c57ba6aa767aa9ddadebef57ed2099c49f89..74d82bba2fffcc4410474ebc8593e8d9bce1749a 100644 (file)
@@ -121,7 +121,8 @@ class NVPApiHelper(client_eventlet.NvpApiClientEventlet):
 
         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
index 3f7d21aa9a6d96f33540b6bd2915a309bee29ddf..09aae0f38e05ad31c80e94031f613037a61f19fb 100644 (file)
@@ -769,7 +769,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         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
@@ -912,7 +913,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         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):
@@ -1072,7 +1074,8 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                                 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
@@ -1760,8 +1763,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         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(
@@ -1840,7 +1844,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         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,
index 0a5eadfd7dff161ac0c6d109e5cc79b0fcaa03a6..60a1993b016e15dd660eebb38a9e788a321b885e 100644 (file)
@@ -229,7 +229,8 @@ def find_port_and_cluster(clusters, port_id):
     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:
@@ -664,7 +665,8 @@ def get_port_by_display_name(clusters, lswitch, display_name):
     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)
@@ -709,7 +711,8 @@ def get_port_by_quantum_tag(cluster, lswitch_uuid, quantum_port_id):
 
 
 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
@@ -1354,8 +1357,9 @@ def update_lrouter_port_ips(cluster, lrouter_id, lport_id,
         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:
index b278fef8c28ac7c3d6716a89c1489d23c8b26653..e369934555364c314f188d3e50b89bb83ad9c80c 100644 (file)
@@ -345,7 +345,8 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                 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
@@ -364,14 +365,16 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                 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.
@@ -546,13 +549,15 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         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()
@@ -615,13 +620,14 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                                                              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'],
@@ -645,7 +651,7 @@ class OVSQuantumAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
                                                              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']:
index a03dc732459eb001c5f456294cd6abb036690251..63ca3141c887054c77219ae98f715cf0028bb694 100644 (file)
@@ -156,12 +156,15 @@ def reserve_specific_vlan(session, physical_network, vlan_id):
                     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)
@@ -185,15 +188,18 @@ def release_vlan(session, physical_network, vlan_id, network_vlan_ranges):
                 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):
@@ -206,7 +212,7 @@ 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))
 
index faf8f65197dc14824f1b1059723cd1d07626f3ae..eeb8bd944d45e8a39057e8e1091dd50ce256a8db 100644 (file)
@@ -89,7 +89,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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'])
@@ -115,7 +115,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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,
@@ -134,7 +134,7 @@ class OVSRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,
         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:
index fd6f0ce73950e9b5c440a642d49d920049f98a68..e67f7ec926a2bbdb590fb115e11e16508c5556cb 100644 (file)
@@ -153,7 +153,7 @@ class TunnelKey(object):
 
         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()