use dict comprehension in plugins, part 3 (#8833)

* use dict comprehension in plugins, part 3

* add changelog frag
This commit is contained in:
Alexei Znamensky 2024-09-09 00:22:37 +12:00 committed by GitHub
parent 43f8adf1a5
commit 26df6c7657
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 81 additions and 61 deletions

View file

@ -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, {}