1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/plugins/modules/remote_management/redfish/ilo_redfish_info.py

187 lines
5.8 KiB
Python
Raw Normal View History

Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2021-2022 Hewlett Packard Enterprise, Inc. All rights reserved.
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: ilo_redfish_info
short_description: Gathers server information through iLO using Redfish APIs
version_added: 4.2.0
description:
- Builds Redfish URIs locally and sends them to iLO to
get information back.
- For use with HPE iLO operations that require Redfish OEM extensions.
options:
category:
required: true
description:
- List of categories to execute on iLO.
type: list
elements: str
command:
required: true
description:
- List of commands to execute on iLO.
type: list
elements: str
baseuri:
required: true
description:
- Base URI of iLO.
type: str
username:
description:
redfish modules: documentation language and formatting (#4722) * redfish_command: documentation language and formatting Update the documentation block with more English language more consistent with other modules and finish each description with a full stop. * redfish_command: do not end short desc in full stop * redfish_command: remove more "the" on documentation Remove "The" from beginning of descriptions. * redfish_command: start documentation description with capital case * redfish_config: update documentation language and format Add full stops at end of descriptions, small updates to language, ensure descriptions start with a capital case letter. * redfish_config: documentation consistency Use "username" for description similarly to redfish_command. * redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: more doc consistency fixes Call it iDRAC everywhere and not sometimes OOB controller. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_config: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation language Call it "HTTP request" and not "URL request". * idrac_redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * idrac_redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_info: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Boot device should be two words. Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-24 20:07:10 +02:00
- Username for authenticating to iLO.
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
type: str
password:
description:
redfish modules: documentation language and formatting (#4722) * redfish_command: documentation language and formatting Update the documentation block with more English language more consistent with other modules and finish each description with a full stop. * redfish_command: do not end short desc in full stop * redfish_command: remove more "the" on documentation Remove "The" from beginning of descriptions. * redfish_command: start documentation description with capital case * redfish_config: update documentation language and format Add full stops at end of descriptions, small updates to language, ensure descriptions start with a capital case letter. * redfish_config: documentation consistency Use "username" for description similarly to redfish_command. * redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: more doc consistency fixes Call it iDRAC everywhere and not sometimes OOB controller. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_config: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation language Call it "HTTP request" and not "URL request". * idrac_redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * idrac_redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_info: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Boot device should be two words. Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-24 20:07:10 +02:00
- Password for authenticating to iLO.
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
type: str
auth_token:
description:
redfish modules: documentation language and formatting (#4722) * redfish_command: documentation language and formatting Update the documentation block with more English language more consistent with other modules and finish each description with a full stop. * redfish_command: do not end short desc in full stop * redfish_command: remove more "the" on documentation Remove "The" from beginning of descriptions. * redfish_command: start documentation description with capital case * redfish_config: update documentation language and format Add full stops at end of descriptions, small updates to language, ensure descriptions start with a capital case letter. * redfish_config: documentation consistency Use "username" for description similarly to redfish_command. * redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: more doc consistency fixes Call it iDRAC everywhere and not sometimes OOB controller. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_config: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation language Call it "HTTP request" and not "URL request". * idrac_redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * idrac_redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_info: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Boot device should be two words. Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-24 20:07:10 +02:00
- Security token for authenticating to iLO.
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
type: str
timeout:
description:
redfish modules: documentation language and formatting (#4722) * redfish_command: documentation language and formatting Update the documentation block with more English language more consistent with other modules and finish each description with a full stop. * redfish_command: do not end short desc in full stop * redfish_command: remove more "the" on documentation Remove "The" from beginning of descriptions. * redfish_command: start documentation description with capital case * redfish_config: update documentation language and format Add full stops at end of descriptions, small updates to language, ensure descriptions start with a capital case letter. * redfish_config: documentation consistency Use "username" for description similarly to redfish_command. * redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_command: more doc consistency fixes Call it iDRAC everywhere and not sometimes OOB controller. * idrac_redfish_command: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_config: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * ilo_redfish_info: documentation formatting and language Update documentation block for consistency with other modules with full stop at end of descriptions and small language updates. * idrac_redfish_info: documentation language Call it "HTTP request" and not "URL request". * idrac_redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * idrac_redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Call it "HTTP request" and not "URL request". * redfish_config: documentation language fix Call it "HTTP request" and not "URL request". * redfish_info: documentation language fix Call it "HTTP request" and not "URL request". * redfish_command: documentation language fix Boot device should be two words. Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
2022-05-24 20:07:10 +02:00
- Timeout in seconds for HTTP requests to iLO.
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
default: 10
type: int
author:
- "Bhavya B (@bhavya06)"
'''
EXAMPLES = '''
- name: Get iLO Sessions
community.general.ilo_redfish_info:
category: Sessions
command: GetiLOSessions
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
register: result_sessions
'''
RETURN = '''
ilo_redfish_info:
description: Returns iLO sessions.
type: dict
contains:
GetiLOSessions:
description: Returns the iLO session msg and whether the function executed successfully.
type: dict
contains:
ret:
description: Check variable to see if the information was successfully retrieved.
Modules for managing HPE iLO (#3740) * Adding HPE ilo modules * lint fix * symlink created * Fan message enhancement * Removed comments * Added uniform constuct * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/module_utils/redfish_utils.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added info module and minor changes * lint fixes * lint fixes * lint fixes * lint fixes * Added tests and modifed ilo_redfish_info * Modified tests * lint fix * result overwrite fixed * result overwrite fixed * Added result * Changed RESULT * Modified contains * Added License * lint fix * Changed RESULT * lint fix * Changed return * Changed return * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_config.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> * Added - changed * Modified changed attribute * Changed modified * lint fix * Removed req * Minor changes * Update plugins/modules/remote_management/redfish/ilo_redfish_info.py Co-authored-by: Rajeevalochana Kallur <rajeevalochana.kallur@hpe.com> Co-authored-by: Felix Fontein <felix@fontein.de>
2021-12-11 21:27:09 +01:00
type: bool
msg:
description: Information of all active iLO sessions.
type: list
elements: dict
contains:
Description:
description: Provides a description of the resource.
type: str
Id:
description: The sessionId.
type: str
Name:
description: The name of the resource.
type: str
UserName:
description: Name to use to log in to the management processor.
type: str
returned: always
'''
CATEGORY_COMMANDS_ALL = {
"Sessions": ["GetiLOSessions"]
}
CATEGORY_COMMANDS_DEFAULT = {
"Sessions": "GetiLOSessions"
}
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ilo_redfish_utils import iLORedfishUtils
def main():
result = {}
category_list = []
module = AnsibleModule(
argument_spec=dict(
category=dict(required=True, type='list', elements='str'),
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),
timeout=dict(type='int', default=10)
),
required_together=[
('username', 'password'),
],
required_one_of=[
('username', 'auth_token'),
],
mutually_exclusive=[
('username', 'auth_token'),
],
supports_check_mode=True
)
creds = {"user": module.params['username'],
"pswd": module.params['password'],
"token": module.params['auth_token']}
timeout = module.params['timeout']
root_uri = "https://" + module.params['baseuri']
rf_utils = iLORedfishUtils(creds, root_uri, timeout, module)
# Build Category list
if "all" in module.params['category']:
for entry in CATEGORY_COMMANDS_ALL:
category_list.append(entry)
else:
# one or more categories specified
category_list = module.params['category']
for category in category_list:
command_list = []
# Build Command list for each Category
if category in CATEGORY_COMMANDS_ALL:
if not module.params['command']:
# True if we don't specify a command --> use default
command_list.append(CATEGORY_COMMANDS_DEFAULT[category])
elif "all" in module.params['command']:
for entry in CATEGORY_COMMANDS_ALL[category]:
command_list.append(entry)
# one or more commands
else:
command_list = module.params['command']
# Verify that all commands are valid
for cmd in command_list:
# Fail if even one command given is invalid
if cmd not in CATEGORY_COMMANDS_ALL[category]:
module.fail_json(msg="Invalid Command: %s" % cmd)
else:
# Fail if even one category given is invalid
module.fail_json(msg="Invalid Category: %s" % category)
# Organize by Categories / Commands
if category == "Sessions":
for command in command_list:
if command == "GetiLOSessions":
result[command] = rf_utils.get_ilo_sessions()
module.exit_json(ilo_redfish_info=result)
if __name__ == '__main__':
main()