mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-06 16:29:09 -07:00
[PR #8814/ecc048bc backport][stable-9] Use dict comprehension in plugins (#8819)
Use dict comprehension in plugins (#8814)
* use dict comprehension in plugins
* Apply suggestions from code review
* add changelog frag
* fix references in changelog frag
(cherry picked from commit ecc048bc12
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
7f729d99a2
commit
af08ea33b1
24 changed files with 81 additions and 45 deletions
|
@ -524,8 +524,11 @@ class ProxmoxDiskAnsible(ProxmoxAnsible):
|
|||
# - Remove not defined args
|
||||
# - Ensure True and False converted to int.
|
||||
# - Remove unnecessary parameters
|
||||
params = dict((k, v) for k, v in self.module.params.items() if v is not None and k in self.create_update_fields)
|
||||
params.update(dict((k, int(v)) for k, v in params.items() if isinstance(v, bool)))
|
||||
params = {
|
||||
k: int(v) if isinstance(v, bool) else v
|
||||
for k, v in self.module.params.items()
|
||||
if v is not None and k in self.create_update_fields
|
||||
}
|
||||
return params
|
||||
|
||||
def wait_till_complete_or_timeout(self, node_name, task_id):
|
||||
|
@ -598,7 +601,7 @@ class ProxmoxDiskAnsible(ProxmoxAnsible):
|
|||
if iso_image is not None:
|
||||
playbook_config['volume'] = iso_image
|
||||
# Values in params are numbers, but strings are needed to compare with disk_config
|
||||
playbook_config = dict((k, str(v)) for k, v in playbook_config.items())
|
||||
playbook_config = {k: str(v) for k, v in playbook_config.items()}
|
||||
|
||||
# Now compare old and new config to detect if changes are needed
|
||||
if proxmox_config == playbook_config:
|
||||
|
@ -626,7 +629,7 @@ class ProxmoxDiskAnsible(ProxmoxAnsible):
|
|||
params['format'] = self.module.params['format']
|
||||
params['delete'] = 1 if self.module.params.get('delete_moved', False) else 0
|
||||
# Remove not defined args
|
||||
params = dict((k, v) for k, v in params.items() if v is not None)
|
||||
params = {k: v for k, v in params.items() if v is not None}
|
||||
|
||||
if params.get('storage', False):
|
||||
disk_config = disk_conf_str_to_dict(vm_config[disk])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue