Fix incorrect use of is for comparisons.

See https://bugs.python.org/issue34850 for details.
This commit is contained in:
Matt Clay 2019-02-12 15:15:23 -08:00
commit 0a461380a3
21 changed files with 42 additions and 42 deletions

View file

@ -660,7 +660,7 @@ def main():
if len(instances) > count:
for i in range(0, len(instances) - count):
inst = instances[len(instances) - 1]
if inst.status is not 'stopped' and not force:
if inst.status != 'stopped' and not force:
module.fail_json(msg="That to delete instance {0} is failed results from it is running, "
"and please stop it or set 'force' as True.".format(inst.id))
try:
@ -765,7 +765,7 @@ def main():
else:
try:
for inst in instances:
if inst.status is not 'stopped' and not force:
if inst.status != 'stopped' and not force:
module.fail_json(msg="Instance is running, and please stop it or set 'force' as True.")
if inst.terminate(force=module.params['force']):
changed = True

View file

@ -923,7 +923,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
if set(current_nics) != set(network_interfaces):
self.log('CHANGED: virtual machine {0} - network interfaces are different.'.format(self.name))
differences.append('Network Interfaces')
updated_nics = [dict(id=id, primary=(i is 0))
updated_nics = [dict(id=id, primary=(i == 0))
for i, id in enumerate(network_interfaces)]
vm_dict['properties']['networkProfile']['networkInterfaces'] = updated_nics
changed = True
@ -1067,7 +1067,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
if not self.short_hostname:
self.short_hostname = self.name
nics = [self.compute_models.NetworkInterfaceReference(id=id, primary=(i is 0))
nics = [self.compute_models.NetworkInterfaceReference(id=id, primary=(i == 0))
for i, id in enumerate(network_interfaces)]
# os disk
@ -1217,7 +1217,7 @@ class AzureRMVirtualMachine(AzureRMModuleBase):
self.log("Update virtual machine {0}".format(self.name))
self.results['actions'].append('Updated VM {0}'.format(self.name))
nics = [self.compute_models.NetworkInterfaceReference(id=interface['id'], primary=(i is 0))
nics = [self.compute_models.NetworkInterfaceReference(id=interface['id'], primary=(i == 0))
for i, interface in enumerate(vm_dict['properties']['networkProfile']['networkInterfaces'])]
# os disk

View file

@ -1378,7 +1378,7 @@ def core(module):
# Set VM Host
vmhost = module.params.get('vmhost')
if vmhost is not False and vmhost is not "False":
if vmhost is not False and vmhost != "False":
if r.setVMHost(vminfo['name'], vmhost) is False:
return RHEV_FAILED, msg

View file

@ -489,22 +489,22 @@ def core(module):
module.fail_json(msg="state change requires a guest specified")
if state == 'running':
if v.status(guest) is 'paused':
if v.status(guest) == 'paused':
res['changed'] = True
res['msg'] = v.unpause(guest)
elif v.status(guest) is not 'running':
elif v.status(guest) != 'running':
res['changed'] = True
res['msg'] = v.start(guest)
elif state == 'shutdown':
if v.status(guest) is not 'shutdown':
if v.status(guest) != 'shutdown':
res['changed'] = True
res['msg'] = v.shutdown(guest)
elif state == 'destroyed':
if v.status(guest) is not 'shutdown':
if v.status(guest) != 'shutdown':
res['changed'] = True
res['msg'] = v.destroy(guest)
elif state == 'paused':
if v.status(guest) is 'running':
if v.status(guest) == 'running':
res['changed'] = True
res['msg'] = v.pause(guest)
else:

View file

@ -509,7 +509,7 @@ def core(module):
res['changed'] = False
if state in ['active']:
if v.status(name) is not 'active':
if v.status(name) != 'active':
res['changed'] = True
res['msg'] = v.start(name)
elif state in ['present']:
@ -523,13 +523,13 @@ def core(module):
elif state in ['inactive']:
entries = v.list_nets()
if name in entries:
if v.status(name) is not 'inactive':
if v.status(name) != 'inactive':
res['changed'] = True
res['msg'] = v.destroy(name)
elif state in ['undefined', 'absent']:
entries = v.list_nets()
if name in entries:
if v.status(name) is not 'inactive':
if v.status(name) != 'inactive':
v.destroy(name)
res['changed'] = True
res['msg'] = v.undefine(name)

View file

@ -578,7 +578,7 @@ def core(module):
res['changed'] = False
if state in ['active']:
if v.status(name) is not 'active':
if v.status(name) != 'active':
res['changed'] = True
res['msg'] = v.start(name)
elif state in ['present']:
@ -592,20 +592,20 @@ def core(module):
elif state in ['inactive']:
entries = v.list_pools()
if name in entries:
if v.status(name) is not 'inactive':
if v.status(name) != 'inactive':
res['changed'] = True
res['msg'] = v.destroy(name)
elif state in ['undefined', 'absent']:
entries = v.list_pools()
if name in entries:
if v.status(name) is not 'inactive':
if v.status(name) != 'inactive':
v.destroy(name)
res['changed'] = True
res['msg'] = v.undefine(name)
elif state in ['deleted']:
entries = v.list_pools()
if name in entries:
if v.status(name) is not 'inactive':
if v.status(name) != 'inactive':
v.destroy(name)
v.delete(name, mode)
res['changed'] = True

View file

@ -196,7 +196,7 @@ def _choose_id_value(module):
def _choose_if_password_only(module, patch):
if len(patch) is 1:
if len(patch) == 1:
if 'password' in patch[0]['path'] and module.params['skip_update_of_masked_password']:
# Return false to abort update as the password appears
# to be the only element in the patch.

View file

@ -259,7 +259,7 @@ def main():
timeout = module.params['timeout']
# User has reqeusted desired state to be in maintenance state.
if module.params['state'] is 'maintenance':
if module.params['state'] == 'maintenance':
module.params['maintenance'] = True
if node['provision_state'] in [