1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-08 04:57:16 +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

@ -144,9 +144,7 @@ from ansible_collections.community.general.plugins.module_utils.ocapi_utils impo
from ansible.module_utils.common.text.converters import to_native
# More will be added as module features are expanded
CATEGORY_COMMANDS_ALL = {
"Jobs": ["JobStatus"]
}
CATEGORY_COMMANDS_ALL = {"Jobs": ["JobStatus"]}
def main():
@ -154,28 +152,25 @@ 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'),
command=dict(required=True, type="str"),
job_name=dict(type="str"),
baseuri=dict(required=True, type="str"),
proxy_slot_number=dict(type="int"),
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")
@ -183,33 +178,36 @@ 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 == "Jobs":
if command == "JobStatus":
if module.params.get("job_name") is None:
module.fail_json(msg=to_native(
"job_name required for JobStatus command."))
module.fail_json(msg=to_native("job_name required for JobStatus command."))
job_uri = urljoin(base_uri, f"Jobs/{module.params['job_name']}")
result = ocapi_utils.get_job_status(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']
del result["ret"]
changed = False
session = result.get('session', dict())
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:
@ -217,5 +215,5 @@ def main():
module.exit_json(**kwargs)
if __name__ == '__main__':
if __name__ == "__main__":
main()