mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-26 21:52:48 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -113,9 +113,7 @@ msg:
|
|||
sample: "Action was successful"
|
||||
"""
|
||||
|
||||
CATEGORY_COMMANDS_ALL = {
|
||||
"Manager": ["SetTimeZone", "SetDNSserver", "SetDomainName", "SetNTPServers", "SetWINSReg"]
|
||||
}
|
||||
CATEGORY_COMMANDS_ALL = {"Manager": ["SetTimeZone", "SetDNSserver", "SetDomainName", "SetNTPServers", "SetWINSReg"]}
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.ilo_redfish_utils import iLORedfishUtils
|
||||
from ansible_collections.community.general.plugins.module_utils.redfish_utils import REDFISH_COMMON_ARGUMENT_SPEC
|
||||
|
|
@ -126,73 +124,73 @@ from ansible.module_utils.common.text.converters import to_native
|
|||
def main():
|
||||
result = {}
|
||||
argument_spec = dict(
|
||||
category=dict(required=True, choices=list(
|
||||
CATEGORY_COMMANDS_ALL.keys())),
|
||||
command=dict(required=True, type='list', elements='str'),
|
||||
category=dict(required=True, choices=list(CATEGORY_COMMANDS_ALL.keys())),
|
||||
command=dict(required=True, type="list", elements="str"),
|
||||
baseuri=dict(required=True),
|
||||
username=dict(),
|
||||
password=dict(no_log=True),
|
||||
auth_token=dict(no_log=True),
|
||||
attribute_name=dict(required=True),
|
||||
attribute_value=dict(type='str'),
|
||||
timeout=dict(type='int', default=10)
|
||||
attribute_value=dict(type="str"),
|
||||
timeout=dict(type="int", default=10),
|
||||
)
|
||||
argument_spec.update(REDFISH_COMMON_ARGUMENT_SPEC)
|
||||
module = AnsibleModule(
|
||||
argument_spec,
|
||||
required_together=[
|
||||
('username', 'password'),
|
||||
("username", "password"),
|
||||
],
|
||||
required_one_of=[
|
||||
('username', 'auth_token'),
|
||||
("username", "auth_token"),
|
||||
],
|
||||
mutually_exclusive=[
|
||||
('username', 'auth_token'),
|
||||
("username", "auth_token"),
|
||||
],
|
||||
supports_check_mode=False
|
||||
supports_check_mode=False,
|
||||
)
|
||||
|
||||
category = module.params['category']
|
||||
command_list = module.params['command']
|
||||
category = module.params["category"]
|
||||
command_list = module.params["command"]
|
||||
|
||||
creds = {"user": module.params['username'],
|
||||
"pswd": module.params['password'],
|
||||
"token": module.params['auth_token']}
|
||||
creds = {"user": module.params["username"], "pswd": module.params["password"], "token": module.params["auth_token"]}
|
||||
|
||||
timeout = module.params['timeout']
|
||||
timeout = module.params["timeout"]
|
||||
|
||||
root_uri = f"https://{module.params['baseuri']}"
|
||||
rf_utils = iLORedfishUtils(creds, root_uri, timeout, module)
|
||||
mgr_attributes = {'mgr_attr_name': module.params['attribute_name'],
|
||||
'mgr_attr_value': module.params['attribute_value']}
|
||||
mgr_attributes = {
|
||||
"mgr_attr_name": module.params["attribute_name"],
|
||||
"mgr_attr_value": module.params["attribute_value"],
|
||||
}
|
||||
changed = False
|
||||
|
||||
offending = [
|
||||
cmd for cmd in command_list if cmd not in CATEGORY_COMMANDS_ALL[category]]
|
||||
offending = [cmd for cmd in command_list if cmd not in CATEGORY_COMMANDS_ALL[category]]
|
||||
|
||||
if offending:
|
||||
module.fail_json(msg=to_native(f"Invalid Command(s): '{offending}'. Allowed Commands = {CATEGORY_COMMANDS_ALL[category]}"))
|
||||
module.fail_json(
|
||||
msg=to_native(f"Invalid Command(s): '{offending}'. Allowed Commands = {CATEGORY_COMMANDS_ALL[category]}")
|
||||
)
|
||||
|
||||
if category == "Manager":
|
||||
resource = rf_utils._find_managers_resource()
|
||||
if not resource['ret']:
|
||||
module.fail_json(msg=to_native(resource['msg']))
|
||||
if not resource["ret"]:
|
||||
module.fail_json(msg=to_native(resource["msg"]))
|
||||
|
||||
dispatch = dict(
|
||||
SetTimeZone=rf_utils.set_time_zone,
|
||||
SetDNSserver=rf_utils.set_dns_server,
|
||||
SetDomainName=rf_utils.set_domain_name,
|
||||
SetNTPServers=rf_utils.set_ntp_server,
|
||||
SetWINSReg=rf_utils.set_wins_registration
|
||||
SetWINSReg=rf_utils.set_wins_registration,
|
||||
)
|
||||
|
||||
for command in command_list:
|
||||
result[command] = dispatch[command](mgr_attributes)
|
||||
if 'changed' in result[command]:
|
||||
changed |= result[command]['changed']
|
||||
if "changed" in result[command]:
|
||||
changed |= result[command]["changed"]
|
||||
|
||||
module.exit_json(ilo_redfish_config=result, changed=changed)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue