1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-25 22:57:21 +00:00

Reformat everything.

This commit is contained in:
Felix Fontein 2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View file

@ -175,7 +175,7 @@ CATEGORY_COMMANDS_ALL = {
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "PowerModeLow", "PowerModeNormal"],
"Systems": ["PowerGracefulRestart"],
"Update": ["FWUpload", "FWUpdate", "FWActivate"],
"Jobs": ["DeleteJob"]
"Jobs": ["DeleteJob"],
}
@ -184,29 +184,26 @@ def main():
module = AnsibleModule(
argument_spec=dict(
category=dict(required=True),
command=dict(required=True, type='str'),
job_name=dict(type='str'),
baseuri=dict(required=True, type='str'),
proxy_slot_number=dict(type='int'),
update_image_path=dict(type='str'),
command=dict(required=True, type="str"),
job_name=dict(type="str"),
baseuri=dict(required=True, type="str"),
proxy_slot_number=dict(type="int"),
update_image_path=dict(type="str"),
username=dict(required=True),
password=dict(required=True, no_log=True),
timeout=dict(type='int', default=10)
timeout=dict(type="int", default=10),
),
supports_check_mode=True
supports_check_mode=True,
)
category = module.params['category']
command = module.params['command']
category = module.params["category"]
command = module.params["command"]
# admin credentials used for authentication
creds = {
'user': module.params['username'],
'pswd': module.params['password']
}
creds = {"user": module.params["username"], "pswd": module.params["password"]}
# timeout
timeout = module.params['timeout']
timeout = module.params["timeout"]
base_uri = f"https://{module.params['baseuri']}"
proxy_slot_number = module.params.get("proxy_slot_number")
@ -214,11 +211,15 @@ def main():
# Check that Category is valid
if category not in CATEGORY_COMMANDS_ALL:
module.fail_json(msg=to_native(f"Invalid Category '{category}'. Valid Categories = {list(CATEGORY_COMMANDS_ALL.keys())}"))
module.fail_json(
msg=to_native(f"Invalid Category '{category}'. Valid Categories = {list(CATEGORY_COMMANDS_ALL.keys())}")
)
# Check that the command is valid
if command not in CATEGORY_COMMANDS_ALL[category]:
module.fail_json(msg=to_native(f"Invalid Command '{command}'. Valid Commands = {CATEGORY_COMMANDS_ALL[category]}"))
module.fail_json(
msg=to_native(f"Invalid Command '{command}'. Valid Commands = {CATEGORY_COMMANDS_ALL[category]}")
)
# Organize by Categories / Commands
if category == "Chassis":
@ -247,18 +248,18 @@ def main():
job_uri = urljoin(base_uri, f"Jobs/{job_name}")
result = ocapi_utils.delete_job(job_uri)
if result['ret'] is False:
module.fail_json(msg=to_native(result['msg']))
if result["ret"] is False:
module.fail_json(msg=to_native(result["msg"]))
else:
del result['ret']
changed = result.get('changed', True)
session = result.get('session', dict())
del result["ret"]
changed = result.get("changed", True)
session = result.get("session", dict())
kwargs = {
"changed": changed,
"session": session,
"msg": "Action was successful." if not module.check_mode else result.get(
"msg", "No action performed in check mode."
)
"msg": "Action was successful."
if not module.check_mode
else result.get("msg", "No action performed in check mode."),
}
result_keys = [result_key for result_key in result if result_key not in kwargs]
for result_key in result_keys:
@ -266,5 +267,5 @@ def main():
module.exit_json(**kwargs)
if __name__ == '__main__':
if __name__ == "__main__":
main()