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/idrac_redfish_info.py

250 lines
7.8 KiB
Python
Raw Normal View History

2020-03-09 10:11:07 +01:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2019 Dell EMC Inc.
# 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
2020-03-09 10:11:07 +01:00
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = '''
---
module: idrac_redfish_info
short_description: Gather PowerEdge server information through iDRAC using Redfish APIs
description:
- Builds Redfish URIs locally and sends them to remote iDRAC controllers to
get information back.
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
- For use with Dell EMC iDRAC operations that require Redfish OEM extensions.
extends_documentation_fragment:
- community.general.attributes
- community.general.attributes.info_module
attributes:
check_mode:
version_added: 3.3.0
# This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix
2020-03-09 10:11:07 +01:00
options:
category:
required: true
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
- Category to execute on iDRAC.
2020-03-09 10:11:07 +01:00
type: str
command:
required: true
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
- List of commands to execute on iDRAC.
- V(GetManagerAttributes) returns the list of dicts containing iDRAC,
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
LifecycleController and System attributes.
2020-03-09 10:11:07 +01:00
type: list
elements: str
2020-03-09 10:11:07 +01:00
baseuri:
required: true
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
- Base URI of iDRAC.
2020-03-09 10:11:07 +01:00
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 iDRAC.
2020-03-09 10:11:07 +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 iDRAC.
2020-03-09 10:11:07 +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 iDRAC.
type: str
version_added: 2.3.0
2020-03-09 10:11:07 +01:00
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 iDRAC.
2020-03-09 10:11:07 +01:00
default: 10
type: int
author: "Jose Delarosa (@jose-delarosa)"
'''
EXAMPLES = '''
- name: Get Manager attributes with a default of 20 seconds
community.general.idrac_redfish_info:
2020-03-09 10:11:07 +01:00
category: Manager
command: GetManagerAttributes
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
timeout: 20
register: result
# Examples to display the value of all or a single iDRAC attribute
- name: Store iDRAC attributes as a fact variable
ansible.builtin.set_fact:
2020-03-09 10:11:07 +01:00
idrac_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'iDRACAttributes') | list | first }}"
- name: Display all iDRAC attributes
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: idrac_attributes
- name: Display the value of 'Syslog.1.SysLogEnable' iDRAC attribute
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: idrac_attributes['Syslog.1.SysLogEnable']
# Examples to display the value of all or a single LifecycleController attribute
- name: Store LifecycleController attributes as a fact variable
ansible.builtin.set_fact:
2020-03-09 10:11:07 +01:00
lc_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'LCAttributes') | list | first }}"
- name: Display LifecycleController attributes
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: lc_attributes
- name: Display the value of 'CollectSystemInventoryOnRestart' attribute
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: lc_attributes['LCAttributes.1.CollectSystemInventoryOnRestart']
# Examples to display the value of all or a single System attribute
- name: Store System attributes as a fact variable
ansible.builtin.set_fact:
2020-03-09 10:11:07 +01:00
system_attributes: "{{ result.redfish_facts.entries | selectattr('Id', 'defined') | selectattr('Id', 'equalto', 'SystemAttributes') | list | first }}"
- name: Display System attributes
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: system_attributes
- name: Display the value of 'PSRedPolicy'
ansible.builtin.debug:
2020-03-09 10:11:07 +01:00
var: system_attributes['ServerPwr.1.PSRedPolicy']
'''
RETURN = '''
msg:
description: different results depending on task
returned: always
type: dict
sample: List of Manager attributes
'''
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
from ansible.module_utils.common.text.converters import to_native
2020-03-09 10:11:07 +01:00
class IdracRedfishUtils(RedfishUtils):
def get_manager_attributes(self):
result = {}
manager_attributes = []
properties = ['Attributes', 'Id']
response = self.get_request(self.root_uri + self.manager_uri)
if response['ret'] is False:
return response
data = response['data']
# Manager attributes are supported as part of iDRAC OEM extension
# Attributes are supported only on iDRAC9
try:
for members in data[u'Links'][u'Oem'][u'Dell'][u'DellAttributes']:
attributes_uri = members[u'@odata.id']
response = self.get_request(self.root_uri + attributes_uri)
if response['ret'] is False:
return response
data = response['data']
attributes = {}
for prop in properties:
if prop in data:
attributes[prop] = data.get(prop)
if attributes:
manager_attributes.append(attributes)
result['ret'] = True
except (AttributeError, KeyError) as e:
result['ret'] = False
result['msg'] = "Failed to find attribute/key: " + str(e)
result["entries"] = manager_attributes
return result
CATEGORY_COMMANDS_ALL = {
"Manager": ["GetManagerAttributes"]
}
def main():
result = {}
module = AnsibleModule(
argument_spec=dict(
category=dict(required=True),
command=dict(required=True, type='list', elements='str'),
2020-03-09 10:11:07 +01:00
baseuri=dict(required=True),
username=dict(),
password=dict(no_log=True),
auth_token=dict(no_log=True),
2020-03-09 10:11:07 +01:00
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,
2020-03-09 10:11:07 +01:00
)
category = module.params['category']
command_list = module.params['command']
# admin credentials used for authentication
creds = {'user': module.params['username'],
'pswd': module.params['password'],
'token': module.params['auth_token']}
2020-03-09 10:11:07 +01:00
# timeout
timeout = module.params['timeout']
# Build root URI
root_uri = "https://" + module.params['baseuri']
rf_utils = IdracRedfishUtils(creds, root_uri, timeout, module)
# Check that Category is valid
if category not in CATEGORY_COMMANDS_ALL:
module.fail_json(msg=to_native("Invalid Category '%s'. Valid Categories = %s" % (category, list(CATEGORY_COMMANDS_ALL.keys()))))
2020-03-09 10:11:07 +01:00
# Check 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=to_native("Invalid Command '%s'. Valid Commands = %s" % (cmd, CATEGORY_COMMANDS_ALL[category])))
# Organize by Categories / Commands
if category == "Manager":
# execute only if we find a Manager resource
result = rf_utils._find_managers_resource()
if result['ret'] is False:
module.fail_json(msg=to_native(result['msg']))
for command in command_list:
if command == "GetManagerAttributes":
result = rf_utils.get_manager_attributes()
# Return data back or fail with proper message
if result['ret'] is True:
del result['ret']
module.exit_json(redfish_facts=result)
2020-03-09 10:11:07 +01:00
else:
module.fail_json(msg=to_native(result['msg']))
if __name__ == '__main__':
main()