mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 10:21:25 -07:00
use dict comprehension in plugins, part 3 (#8833)
* use dict comprehension in plugins, part 3 * add changelog frag
This commit is contained in:
parent
43f8adf1a5
commit
26df6c7657
25 changed files with 81 additions and 61 deletions
|
@ -586,9 +586,11 @@ def server_attributes_should_be_changed(compute_api, target_server, wished_serve
|
|||
compute_api.module.debug("Checking if server attributes should be changed")
|
||||
compute_api.module.debug("Current Server: %s" % target_server)
|
||||
compute_api.module.debug("Wished Server: %s" % wished_server)
|
||||
debug_dict = dict((x, (target_server[x], wished_server[x]))
|
||||
for x in PATCH_MUTABLE_SERVER_ATTRIBUTES
|
||||
if x in target_server and x in wished_server)
|
||||
debug_dict = {
|
||||
x: (target_server[x], wished_server[x])
|
||||
for x in PATCH_MUTABLE_SERVER_ATTRIBUTES
|
||||
if x in target_server and x in wished_server
|
||||
}
|
||||
compute_api.module.debug("Debug dict %s" % debug_dict)
|
||||
try:
|
||||
for key in PATCH_MUTABLE_SERVER_ATTRIBUTES:
|
||||
|
@ -614,7 +616,7 @@ def server_change_attributes(compute_api, target_server, wished_server):
|
|||
# When you are working with dict, only ID matter as we ask user to put only the resource ID in the playbook
|
||||
if isinstance(target_server[key], dict) and "id" in target_server[key] and wished_server[key]:
|
||||
# Setting all key to current value except ID
|
||||
key_dict = dict((x, target_server[key][x]) for x in target_server[key].keys() if x != "id")
|
||||
key_dict = {x: target_server[key][x] for x in target_server[key].keys() if x != "id"}
|
||||
# Setting ID to the user specified ID
|
||||
key_dict["id"] = wished_server[key]
|
||||
patch_payload[key] = key_dict
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue