mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -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
|
@ -224,10 +224,10 @@ def wait_to_complete_state_transition(api, lb, force_wait=False):
|
|||
|
||||
|
||||
def lb_attributes_should_be_changed(target_lb, wished_lb):
|
||||
diff = dict((attr, wished_lb[attr]) for attr in MUTABLE_ATTRIBUTES if target_lb[attr] != wished_lb[attr])
|
||||
diff = {attr: wished_lb[attr] for attr in MUTABLE_ATTRIBUTES if target_lb[attr] != wished_lb[attr]}
|
||||
|
||||
if diff:
|
||||
return dict((attr, wished_lb[attr]) for attr in MUTABLE_ATTRIBUTES)
|
||||
return {attr: wished_lb[attr] for attr in MUTABLE_ATTRIBUTES}
|
||||
else:
|
||||
return diff
|
||||
|
||||
|
@ -241,8 +241,7 @@ def present_strategy(api, wished_lb):
|
|||
response.status_code, response.json['message']))
|
||||
|
||||
lbs_list = response.json["lbs"]
|
||||
lb_lookup = dict((lb["name"], lb)
|
||||
for lb in lbs_list)
|
||||
lb_lookup = {lb["name"]: lb for lb in lbs_list}
|
||||
|
||||
if wished_lb["name"] not in lb_lookup.keys():
|
||||
changed = True
|
||||
|
@ -298,8 +297,7 @@ def absent_strategy(api, wished_lb):
|
|||
api.module.fail_json(msg='Error getting load-balancers [{0}: {1}]'.format(
|
||||
status_code, response.json['message']))
|
||||
|
||||
lb_lookup = dict((lb["name"], lb)
|
||||
for lb in lbs_list)
|
||||
lb_lookup = {lb["name"]: lb for lb in lbs_list}
|
||||
if wished_lb["name"] not in lb_lookup.keys():
|
||||
return changed, {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue