mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
replace type() with isinstance() (#3404)
Replace use of type() with isinstance() Addresses https://github.com/ansible/ansible/issues/18310
This commit is contained in:
@@ -430,7 +430,7 @@ def core(module):
|
||||
|
||||
if state and command=='list_vms':
|
||||
res = v.list_vms(state=state)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
@@ -477,13 +477,13 @@ def core(module):
|
||||
res = {'changed': True, 'created': guest}
|
||||
return VIRT_SUCCESS, res
|
||||
res = getattr(v, command)(guest)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
elif hasattr(v, command):
|
||||
res = getattr(v, command)()
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
|
||||
6
lib/ansible/modules/extras/cloud/misc/virt_net.py
Executable file → Normal file
6
lib/ansible/modules/extras/cloud/misc/virt_net.py
Executable file → Normal file
@@ -466,7 +466,7 @@ def core(module):
|
||||
|
||||
if state and command == 'list_nets':
|
||||
res = v.list_nets(state=state)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
@@ -523,13 +523,13 @@ def core(module):
|
||||
res = {'changed': mod, 'modified': name}
|
||||
return VIRT_SUCCESS, res
|
||||
res = getattr(v, command)(name)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
elif hasattr(v, command):
|
||||
res = getattr(v, command)()
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
|
||||
10
lib/ansible/modules/extras/cloud/misc/virt_pool.py
Executable file → Normal file
10
lib/ansible/modules/extras/cloud/misc/virt_pool.py
Executable file → Normal file
@@ -561,7 +561,7 @@ def core(module):
|
||||
|
||||
if state and command == 'list_pools':
|
||||
res = v.list_pools(state=state)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
@@ -623,22 +623,22 @@ def core(module):
|
||||
return VIRT_SUCCESS, res
|
||||
elif command == 'build':
|
||||
res = v.build(name, mode)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { 'changed': True, command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
elif command == 'delete':
|
||||
res = v.delete(name, mode)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { 'changed': True, command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
res = getattr(v, command)(name)
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
elif hasattr(v, command):
|
||||
res = getattr(v, command)()
|
||||
if type(res) != dict:
|
||||
if not isinstance(res, dict):
|
||||
res = { command: res }
|
||||
return VIRT_SUCCESS, res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user