Change '== None' to 'is None'
This commit is contained in:
1
Authors
1
Authors
@@ -27,6 +27,7 @@ Gabe Westmaas <gabe.westmaas@rackspace.com>
|
|||||||
Hisaharu Ishii <ishii.hisaharu@lab.ntt.co.jp>
|
Hisaharu Ishii <ishii.hisaharu@lab.ntt.co.jp>
|
||||||
Hisaki Ohara <hisaki.ohara@intel.com>
|
Hisaki Ohara <hisaki.ohara@intel.com>
|
||||||
Ilya Alekseyev <ialekseev@griddynamics.com>
|
Ilya Alekseyev <ialekseev@griddynamics.com>
|
||||||
|
Jason Koelker <jason@koelker.net>
|
||||||
Jay Pipes <jaypipes@gmail.com>
|
Jay Pipes <jaypipes@gmail.com>
|
||||||
Jesse Andrews <anotherjesse@gmail.com>
|
Jesse Andrews <anotherjesse@gmail.com>
|
||||||
Joe Heck <heckj@mac.com>
|
Joe Heck <heckj@mac.com>
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ class FixedIpCommands(object):
|
|||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if host == None:
|
if host is None:
|
||||||
fixed_ips = db.fixed_ip_get_all(ctxt)
|
fixed_ips = db.fixed_ip_get_all(ctxt)
|
||||||
else:
|
else:
|
||||||
fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host)
|
fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host)
|
||||||
@@ -499,7 +499,7 @@ class FloatingIpCommands(object):
|
|||||||
"""Lists all floating ips (optionally by host)
|
"""Lists all floating ips (optionally by host)
|
||||||
arguments: [host]"""
|
arguments: [host]"""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
if host == None:
|
if host is None:
|
||||||
floating_ips = db.floating_ip_get_all(ctxt)
|
floating_ips = db.floating_ip_get_all(ctxt)
|
||||||
else:
|
else:
|
||||||
floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
|
floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
|
||||||
@@ -591,7 +591,7 @@ class VmCommands(object):
|
|||||||
_('zone'),
|
_('zone'),
|
||||||
_('index'))
|
_('index'))
|
||||||
|
|
||||||
if host == None:
|
if host is None:
|
||||||
instances = db.instance_get_all(context.get_admin_context())
|
instances = db.instance_get_all(context.get_admin_context())
|
||||||
else:
|
else:
|
||||||
instances = db.instance_get_all_by_host(
|
instances = db.instance_get_all_by_host(
|
||||||
@@ -864,7 +864,7 @@ class InstanceTypeCommands(object):
|
|||||||
"""Lists all active or specific instance types / flavors
|
"""Lists all active or specific instance types / flavors
|
||||||
arguments: [name]"""
|
arguments: [name]"""
|
||||||
try:
|
try:
|
||||||
if name == None:
|
if name is None:
|
||||||
inst_types = instance_types.get_all_types()
|
inst_types = instance_types.get_all_types()
|
||||||
elif name == "--all":
|
elif name == "--all":
|
||||||
inst_types = instance_types.get_all_types(True)
|
inst_types = instance_types.get_all_types(True)
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ class CloudController(object):
|
|||||||
group_name)
|
group_name)
|
||||||
|
|
||||||
criteria = self._revoke_rule_args_to_dict(context, **kwargs)
|
criteria = self._revoke_rule_args_to_dict(context, **kwargs)
|
||||||
if criteria == None:
|
if criteria is None:
|
||||||
raise exception.ApiError(_("Not enough parameters to build a "
|
raise exception.ApiError(_("Not enough parameters to build a "
|
||||||
"valid rule."))
|
"valid rule."))
|
||||||
|
|
||||||
@@ -664,7 +664,7 @@ class CloudController(object):
|
|||||||
'volumeId': ec2utils.id_to_ec2_id(volume_id, 'vol-%08x')}
|
'volumeId': ec2utils.id_to_ec2_id(volume_id, 'vol-%08x')}
|
||||||
|
|
||||||
def _convert_to_set(self, lst, label):
|
def _convert_to_set(self, lst, label):
|
||||||
if lst == None or lst == []:
|
if lst is None or lst == []:
|
||||||
return None
|
return None
|
||||||
if not isinstance(lst, list):
|
if not isinstance(lst, list):
|
||||||
lst = [lst]
|
lst = [lst]
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ class AuthManager(object):
|
|||||||
LOG.debug(_('Looking up user: %r'), access_key)
|
LOG.debug(_('Looking up user: %r'), access_key)
|
||||||
user = self.get_user_from_access_key(access_key)
|
user = self.get_user_from_access_key(access_key)
|
||||||
LOG.debug('user: %r', user)
|
LOG.debug('user: %r', user)
|
||||||
if user == None:
|
if user is None:
|
||||||
LOG.audit(_("Failed authorization for access key %s"), access_key)
|
LOG.audit(_("Failed authorization for access key %s"), access_key)
|
||||||
raise exception.NotFound(_('No user found for access key %s')
|
raise exception.NotFound(_('No user found for access key %s')
|
||||||
% access_key)
|
% access_key)
|
||||||
@@ -280,7 +280,7 @@ class AuthManager(object):
|
|||||||
project_id = user.name
|
project_id = user.name
|
||||||
|
|
||||||
project = self.get_project(project_id)
|
project = self.get_project(project_id)
|
||||||
if project == None:
|
if project is None:
|
||||||
pjid = project_id
|
pjid = project_id
|
||||||
uname = user.name
|
uname = user.name
|
||||||
LOG.audit(_("failed authorization: no project named %(pjid)s"
|
LOG.audit(_("failed authorization: no project named %(pjid)s"
|
||||||
@@ -646,9 +646,9 @@ class AuthManager(object):
|
|||||||
@rtype: User
|
@rtype: User
|
||||||
@return: The new user.
|
@return: The new user.
|
||||||
"""
|
"""
|
||||||
if access == None:
|
if access is None:
|
||||||
access = str(uuid.uuid4())
|
access = str(uuid.uuid4())
|
||||||
if secret == None:
|
if secret is None:
|
||||||
secret = str(uuid.uuid4())
|
secret = str(uuid.uuid4())
|
||||||
with self.driver() as drv:
|
with self.driver() as drv:
|
||||||
user_dict = drv.create_user(name, access, secret, admin)
|
user_dict = drv.create_user(name, access, secret, admin)
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ class API(base.Base):
|
|||||||
# Set sane defaults if not specified
|
# Set sane defaults if not specified
|
||||||
updates = dict(hostname=self.hostname_factory(instance_id))
|
updates = dict(hostname=self.hostname_factory(instance_id))
|
||||||
if (not hasattr(instance, 'display_name') or
|
if (not hasattr(instance, 'display_name') or
|
||||||
instance.display_name == None):
|
instance.display_name is None):
|
||||||
updates['display_name'] = "Server %s" % instance_id
|
updates['display_name'] = "Server %s" % instance_id
|
||||||
|
|
||||||
instance = self.update(context, instance_id, **updates)
|
instance = self.update(context, instance_id, **updates)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def create(name, memory, vcpus, local_gb, flavorid, swap=0,
|
|||||||
|
|
||||||
def destroy(name):
|
def destroy(name):
|
||||||
"""Marks instance types as deleted."""
|
"""Marks instance types as deleted."""
|
||||||
if name == None:
|
if name is None:
|
||||||
raise exception.InvalidInputException(_("No instance type specified"))
|
raise exception.InvalidInputException(_("No instance type specified"))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@@ -73,7 +73,7 @@ def destroy(name):
|
|||||||
|
|
||||||
def purge(name):
|
def purge(name):
|
||||||
"""Removes instance types from database."""
|
"""Removes instance types from database."""
|
||||||
if name == None:
|
if name is None:
|
||||||
raise exception.InvalidInputException(_("No instance type specified"))
|
raise exception.InvalidInputException(_("No instance type specified"))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class Instance(object):
|
|||||||
LOG.debug('CPU: %d', self.cputime)
|
LOG.debug('CPU: %d', self.cputime)
|
||||||
|
|
||||||
# Skip calculation on first pass. Need delta to get a meaningful value.
|
# Skip calculation on first pass. Need delta to get a meaningful value.
|
||||||
if cputime_last_updated == None:
|
if cputime_last_updated is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Calculate the number of seconds between samples.
|
# Calculate the number of seconds between samples.
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class LocalImageService(service.BaseImageService):
|
|||||||
if name == cantidate.get('name'):
|
if name == cantidate.get('name'):
|
||||||
image = cantidate
|
image = cantidate
|
||||||
break
|
break
|
||||||
if image == None:
|
if image is None:
|
||||||
raise exception.NotFound
|
raise exception.NotFound
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ flags.DEFINE_string('image_decryption_dir', '/tmp',
|
|||||||
class S3ImageService(service.BaseImageService):
|
class S3ImageService(service.BaseImageService):
|
||||||
"""Wraps an existing image service to support s3 based register"""
|
"""Wraps an existing image service to support s3 based register"""
|
||||||
def __init__(self, service=None, *args, **kwargs):
|
def __init__(self, service=None, *args, **kwargs):
|
||||||
if service == None:
|
if service is None:
|
||||||
service = utils.import_object(FLAGS.image_service)
|
service = utils.import_object(FLAGS.image_service)
|
||||||
self.service = service
|
self.service = service
|
||||||
self.service.__init__(*args, **kwargs)
|
self.service.__init__(*args, **kwargs)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ logging.addLevelName(AUDIT, 'AUDIT')
|
|||||||
|
|
||||||
|
|
||||||
def _dictify_context(context):
|
def _dictify_context(context):
|
||||||
if context == None:
|
if context is None:
|
||||||
return None
|
return None
|
||||||
if not isinstance(context, dict) \
|
if not isinstance(context, dict) \
|
||||||
and getattr(context, 'to_dict', None):
|
and getattr(context, 'to_dict', None):
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ def ensure_vlan_bridge(vlan_num, bridge, net_attrs=None):
|
|||||||
network_ref = network_utils.NetworkHelper.find_network_with_name_label(
|
network_ref = network_utils.NetworkHelper.find_network_with_name_label(
|
||||||
session,
|
session,
|
||||||
bridge)
|
bridge)
|
||||||
if network_ref == None:
|
if network_ref is None:
|
||||||
# If bridge does not exists
|
# If bridge does not exists
|
||||||
# 1 - create network
|
# 1 - create network
|
||||||
description = "network for nova bridge %s" % bridge
|
description = "network for nova bridge %s" % bridge
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ def stub_instance(id, user_id=1, private_address=None, public_addresses=None,
|
|||||||
|
|
||||||
inst_type = instance_types.get_instance_type_by_flavor_id(1)
|
inst_type = instance_types.get_instance_type_by_flavor_id(1)
|
||||||
|
|
||||||
if public_addresses == None:
|
if public_addresses is None:
|
||||||
public_addresses = list()
|
public_addresses = list()
|
||||||
|
|
||||||
if host != None:
|
if host != None:
|
||||||
|
|||||||
@@ -737,7 +737,7 @@ class SimpleDriverTestCase(test.TestCase):
|
|||||||
ret = self.scheduler.driver._live_migration_src_check(self.context,
|
ret = self.scheduler.driver._live_migration_src_check(self.context,
|
||||||
i_ref)
|
i_ref)
|
||||||
|
|
||||||
self.assertTrue(ret == None)
|
self.assertTrue(ret is None)
|
||||||
db.instance_destroy(self.context, instance_id)
|
db.instance_destroy(self.context, instance_id)
|
||||||
db.service_destroy(self.context, s_ref['id'])
|
db.service_destroy(self.context, s_ref['id'])
|
||||||
|
|
||||||
@@ -805,7 +805,7 @@ class SimpleDriverTestCase(test.TestCase):
|
|||||||
ret = self.scheduler.driver._live_migration_dest_check(self.context,
|
ret = self.scheduler.driver._live_migration_dest_check(self.context,
|
||||||
i_ref,
|
i_ref,
|
||||||
'somewhere')
|
'somewhere')
|
||||||
self.assertTrue(ret == None)
|
self.assertTrue(ret is None)
|
||||||
db.instance_destroy(self.context, instance_id)
|
db.instance_destroy(self.context, instance_id)
|
||||||
db.service_destroy(self.context, s_ref['id'])
|
db.service_destroy(self.context, s_ref['id'])
|
||||||
|
|
||||||
|
|||||||
@@ -1116,7 +1116,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||||||
if child.name == 'target':
|
if child.name == 'target':
|
||||||
devdst = child.prop('dev')
|
devdst = child.prop('dev')
|
||||||
|
|
||||||
if devdst == None:
|
if devdst is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
disks.append(devdst)
|
disks.append(devdst)
|
||||||
@@ -1158,7 +1158,7 @@ class LibvirtConnection(driver.ComputeDriver):
|
|||||||
if child.name == 'target':
|
if child.name == 'target':
|
||||||
devdst = child.prop('dev')
|
devdst = child.prop('dev')
|
||||||
|
|
||||||
if devdst == None:
|
if devdst is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
interfaces.append(devdst)
|
interfaces.append(devdst)
|
||||||
|
|||||||
Reference in New Issue
Block a user