]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes 'not in' operator usage
authorZhongyue Luo <zhongyue.nah@intel.com>
Thu, 31 Jan 2013 08:08:26 +0000 (16:08 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Fri, 1 Feb 2013 02:14:54 +0000 (10:14 +0800)
Fixes bug #1110058

Change-Id: I45c10097abfb929918925e7befb8ed6c36b1de1c

12 files changed:
quantum/agent/l3_agent.py
quantum/agent/linux/iptables_firewall.py
quantum/api/extensions.py
quantum/extensions/servicetype.py
quantum/plugins/cisco/ucs/cisco_ucs_inventory_v2.py
quantum/plugins/hyperv/agent/hyperv_quantum_agent.py
quantum/plugins/linuxbridge/agent/linuxbridge_quantum_agent.py
quantum/plugins/metaplugin/meta_quantum_plugin.py
quantum/plugins/nicira/nicira_nvp_plugin/QuantumPlugin.py
quantum/plugins/nicira/nicira_nvp_plugin/common/config.py
quantum/tests/unit/test_servicetype.py
quantum/wsgi.py

index ead51988070e3957c1f42602fd02f5806bcad5fd..f15fff6f5eee7430d57cdc0b09e9cfd557dc74f9 100644 (file)
@@ -502,7 +502,7 @@ class L3NATAgent(manager.Manager):
         device = ip_lib.IPDevice(interface_name, self.conf.root_helper,
                                  namespace=ri.ns_name())
 
-        if not ip_cidr in [addr['cidr'] for addr in device.addr.list()]:
+        if ip_cidr not in [addr['cidr'] for addr in device.addr.list()]:
             net = netaddr.IPNetwork(ip_cidr)
             device.addr.add(net.version, ip_cidr, str(net.broadcast))
             self._send_gratuitous_arp_packet(ri, interface_name, floating_ip)
index c01e22676617ccd3bd6c82b967389ec59a1451ee..a0f342e4154f37a02dca92186d4baa62259f3014 100644 (file)
@@ -56,7 +56,7 @@ class IptablesFirewallDriver(firewall.FirewallDriver):
 
     def update_port_filter(self, port):
         LOG.debug(_("Updating device (%s) filter"), port['device'])
-        if not port['device'] in self.filtered_ports:
+        if port['device'] not in self.filtered_ports:
             LOG.info(_('Attempted to update port filter which is not '
                        'filtered %s'), port['device'])
             return
index bcb8603cf2b882e2a5f7eca74569cafd8d2792ab..707383fe8b8dd6fc7f83291526bedaab044c31c1 100644 (file)
@@ -302,7 +302,7 @@ class ExtensionMiddleware(wsgi.Middleware):
         """Return a dict of ActionExtensionController-s by collection."""
         action_controllers = {}
         for action in ext_mgr.get_actions():
-            if not action.collection in action_controllers.keys():
+            if action.collection not in action_controllers.keys():
                 controller = ActionExtensionController(application)
                 mapper.connect("/%s/:(id)/action.:(format)" %
                                action.collection,
@@ -321,7 +321,7 @@ class ExtensionMiddleware(wsgi.Middleware):
         """Returns a dict of RequestExtensionController-s by collection."""
         request_ext_controllers = {}
         for req_ext in ext_mgr.get_request_extensions():
-            if not req_ext.key in request_ext_controllers.keys():
+            if req_ext.key not in request_ext_controllers.keys():
                 controller = RequestExtensionController(application)
                 mapper.connect(req_ext.url_route + '.:(format)',
                                action='process',
index b5e4b7f133febc8603602d2a0f260cb00f20bc03..45ea1612f6bd4d65fd7dffc6e237041cd0ca4075 100644 (file)
@@ -103,7 +103,7 @@ def _validate_service_defs(data, valid_values=None):
                     LOG.error(_("%(f_name)s: %(msg)s"), locals())
                     return msg
                 # Validate 'service' attribute
-                if not svc_name in constants.ALLOWED_SERVICES:
+                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())
index ac757e56c0b975d9e170e16387c56ab5f9e4f6d2..d9d78bf30787d16f2a70e53514e3aa05cf829d41 100644 (file)
@@ -166,15 +166,15 @@ class UCSInventory(L2NetworkDeviceInventoryBase):
             # marked as reserved, else we temporarily mark it as unreserved
             # based on the UCSM state, but may later change it if a port
             # association is found in the DB
-            if not const.TENANTID in blade_intf_data[blade_intf].keys():
+            if const.TENANTID not in blade_intf_data[blade_intf].keys():
                 blade_intf_data[blade_intf][const.TENANTID] = None
-            if not const.PORTID in blade_intf_data[blade_intf].keys():
+            if const.PORTID not in blade_intf_data[blade_intf].keys():
                 blade_intf_data[blade_intf][const.PORTID] = None
-            if not const.PROFILE_ID in blade_intf_data[blade_intf].keys():
+            if const.PROFILE_ID not in blade_intf_data[blade_intf].keys():
                 blade_intf_data[blade_intf][const.PROFILE_ID] = None
-            if not const.INSTANCE_ID in blade_intf_data[blade_intf].keys():
+            if const.INSTANCE_ID not in blade_intf_data[blade_intf].keys():
                 blade_intf_data[blade_intf][const.INSTANCE_ID] = None
-            if not const.VIF_ID in blade_intf_data[blade_intf].keys():
+            if const.VIF_ID not in blade_intf_data[blade_intf].keys():
                 blade_intf_data[blade_intf][const.VIF_ID] = None
 
             if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] ==
index 35d042a780f04cbf8d4d0ba3bd0a2eb7e25e4756..81e50437f94bca75a85ac2e1c6534d8caede4407 100644 (file)
@@ -220,7 +220,7 @@ class HyperVQuantumAgent(object):
 
     def _port_unbound(self, port_id):
         (net_uuid, map) = self._get_network_vswitch_map_by_port_id(port_id)
-        if not net_uuid in self._network_vswitch_map:
+        if net_uuid not in self._network_vswitch_map:
             LOG.info(_('Network %s is not avalailable on this agent'),
                      net_uuid)
             return
index 56d11ccfd2af2ce56554912daf6edb42dc28402b..75ba36324ea424b057d9ce04a25f11867fd34875 100755 (executable)
@@ -414,7 +414,7 @@ class LinuxBridgeRpcCallbacks(sg_rpc.SecurityGroupAgentRpcCallbackMixin):
         port = kwargs.get('port')
         tap_device_name = self.agent.br_mgr.get_tap_device_name(port['id'])
         devices = self.agent.br_mgr.udev_get_tap_devices()
-        if not tap_device_name in devices:
+        if tap_device_name not in devices:
             return
 
         if 'security_groups' in port:
index 6312f72ed8feb33ee086675d97270ce878c9bf53..dccd1fe3e98cfec78318f218a598bd1ea366103c 100644 (file)
@@ -87,12 +87,12 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                 db._ENGINE = None
 
         self.default_flavor = cfg.CONF.META.default_flavor
-        if not self.default_flavor in self.plugins:
+        if self.default_flavor not in self.plugins:
             raise exc.Invalid(_('default_flavor %s is not plugin list') %
                               self.default_flavor)
 
         self.default_l3_flavor = cfg.CONF.META.default_l3_flavor
-        if not self.default_l3_flavor in self.l3_plugins:
+        if self.default_l3_flavor not in self.l3_plugins:
             raise exc.Invalid(_('default_l3_flavor %s is not plugin list') %
                               self.default_l3_flavor)
 
@@ -114,12 +114,12 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         return plugin_klass()
 
     def _get_plugin(self, flavor):
-        if not flavor in self.plugins:
+        if flavor not in self.plugins:
             raise FlavorNotFound(flavor=flavor)
         return self.plugins[flavor]
 
     def _get_l3_plugin(self, flavor):
-        if not flavor in self.l3_plugins:
+        if flavor not in self.l3_plugins:
             raise FlavorNotFound(flavor=flavor)
         return self.l3_plugins[flavor]
 
@@ -152,7 +152,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
     def create_network(self, context, network):
         n = network['network']
         flavor = n.get(FLAVOR_NETWORK)
-        if not str(flavor) in self.plugins:
+        if str(flavor) not in self.plugins:
             flavor = self.default_flavor
         plugin = self._get_plugin(flavor)
         with context.session.begin(subtransactions=True):
@@ -238,7 +238,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def create_port(self, context, port):
         p = port['port']
-        if not 'network_id' in p:
+        if 'network_id' not in p:
             raise exc.NotFound
         plugin = self._get_plugin_by_network_id(context, p['network_id'])
         return plugin.create_port(context, port)
@@ -260,7 +260,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
 
     def create_subnet(self, context, subnet):
         s = subnet['subnet']
-        if not 'network_id' in s:
+        if 'network_id' not in s:
             raise exc.NotFound
         plugin = self._get_plugin_by_network_id(context,
                                                 s['network_id'])
@@ -285,7 +285,7 @@ class MetaPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
     def create_router(self, context, router):
         r = router['router']
         flavor = r.get(FLAVOR_ROUTER)
-        if not str(flavor) in self.l3_plugins:
+        if str(flavor) not in self.l3_plugins:
             flavor = self.default_l3_flavor
         plugin = self._get_l3_plugin(flavor)
         with context.session.begin(subtransactions=True):
index 1d21da3a992ab85ee24d13508950a2428e4aefbd..51864393c2c0a3be12e039830ea5080903c337a2 100644 (file)
@@ -305,7 +305,7 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
         if allow_extra_lswitches:
             main_ls = [ls for ls in lswitches if ls['uuid'] == network.id]
             tag_dict = dict((x['scope'], x['tag']) for x in main_ls[0]['tags'])
-            if not 'multi_lswitch' in tag_dict:
+            if 'multi_lswitch' not in tag_dict:
                 nvplib.update_lswitch(cluster,
                                       main_ls[0]['uuid'],
                                       main_ls[0]['display_name'],
index c1fa6851f416cde616c82ae0f69c4682976acd4c..aa891142746c5ce27adf4bc162a9ca0a57de3f49 100644 (file)
@@ -132,7 +132,7 @@ def _retrieve_extra_groups(conf, key=None, delimiter=':'):
     results = []
     for parsed_file in cfg.CONF._cparser.parsed:
         for parsed_item in parsed_file.keys():
-            if not parsed_item in cfg.CONF:
+            if parsed_item not in cfg.CONF:
                 items = key and parsed_item.split(delimiter)
                 if not key or key == items[0]:
                     results.append(parsed_item)
index e2c937d3540506f4d79e8551a8b5445b5056baa2..160c806f9268d8a6786378854ff6742371fc1f31 100644 (file)
@@ -283,7 +283,7 @@ class ServiceTypeManagerTestCase(ServiceTypeTestCaseBase):
                 }
         if default:
             data[self.resource_name]['default'] = default
-        if not 'tenant_id' in data[self.resource_name]:
+        if 'tenant_id' not in data[self.resource_name]:
             data[self.resource_name]['tenant_id'] = 'fake'
         return self.api.post_json(_get_path('service-types'), data,
                                   expect_errors=expect_errors)
index baa0e729850721b65854bbeaf652a800708c0169..5b052712b31f842d32064dfd111ba8c3d128e7e4 100644 (file)
@@ -192,7 +192,7 @@ class Request(webob.Request):
 
     def get_content_type(self):
         allowed_types = ("application/xml", "application/json")
-        if not "Content-Type" in self.headers:
+        if "Content-Type" not in self.headers:
             LOG.debug(_("Missing Content-Type"))
             return None
         type = self.content_type