Fixes 'not in' operator usage

Fixes bug #1110058

Change-Id: I45c10097abfb929918925e7befb8ed6c36b1de1c
This commit is contained in:
Zhongyue Luo 2013-01-31 16:08:26 +08:00
parent 4e89cc31f9
commit 8f4cbb9578
12 changed files with 24 additions and 24 deletions

View 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)

View 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

View 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',

View 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())

View 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] ==

View 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

View File

@ -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:

View 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):

View 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'],

View 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)

View 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)

View 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