2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# Copyright (c) 2017-2018 Dell EMC Inc.
|
2022-08-05 12:28:29 +02:00
|
|
|
# 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: redfish_info
|
|
|
|
short_description: Manages Out-Of-Band controllers using Redfish APIs
|
|
|
|
description:
|
|
|
|
- Builds Redfish URIs locally and sends them to remote OOB controllers to
|
|
|
|
get information back.
|
|
|
|
- Information retrieved is placed in a location specified by the user.
|
2022-11-06 21:16:43 +01:00
|
|
|
extends_documentation_fragment:
|
|
|
|
- community.general.attributes
|
|
|
|
- community.general.attributes.info_module
|
2023-02-20 17:49:31 +01:00
|
|
|
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: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of categories to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
default: ['Systems']
|
|
|
|
type: list
|
2021-02-12 06:47:23 +01:00
|
|
|
elements: str
|
2020-03-09 10:11:07 +01:00
|
|
|
command:
|
|
|
|
required: false
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- List of commands to execute on OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: list
|
2021-02-12 06:47:23 +01:00
|
|
|
elements: str
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri:
|
|
|
|
required: true
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Base URI of OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
username:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Username for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
|
|
|
password:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Password for authenticating to OOB controller.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: str
|
2021-03-19 21:14:33 +01:00
|
|
|
auth_token:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Security token for authenticating to OOB controller.
|
2021-03-19 21:14:33 +01:00
|
|
|
type: str
|
|
|
|
version_added: 2.3.0
|
2024-01-23 07:59:06 +01:00
|
|
|
manager:
|
|
|
|
description:
|
|
|
|
- Name of manager on OOB controller to target.
|
|
|
|
type: str
|
|
|
|
version_added: '8.3.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
timeout:
|
|
|
|
description:
|
2022-05-24 20:07:10 +02:00
|
|
|
- Timeout in seconds for HTTP requests to OOB controller.
|
2023-09-28 21:05:12 +02:00
|
|
|
- The default value for this param is C(10) but that is being deprecated
|
|
|
|
and it will be replaced with C(60) in community.general 9.0.0.
|
2020-03-09 10:11:07 +01:00
|
|
|
type: int
|
2022-11-23 07:46:39 +01:00
|
|
|
update_handle:
|
|
|
|
required: false
|
|
|
|
description:
|
|
|
|
- Handle to check the status of an update in progress.
|
|
|
|
type: str
|
|
|
|
version_added: '6.1.0'
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
author: "Jose Delarosa (@jose-delarosa)"
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: Get CPU inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetCpuInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
|
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts.cpu.entries | to_nice_json }}"
|
|
|
|
|
|
|
|
- name: Get CPU model
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetCpuInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
|
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts.cpu.entries.0.Model }}"
|
|
|
|
|
|
|
|
- name: Get memory inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetMemoryInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Get fan inventory with a timeout of 20 seconds
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Chassis
|
|
|
|
command: GetFanInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
timeout: 20
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Get Virtual Media information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: GetVirtualMedia
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
|
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts.virtual_media.entries | to_nice_json }}"
|
|
|
|
|
2022-08-24 21:36:35 +02:00
|
|
|
- name: Get Virtual Media information from Systems
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Systems
|
|
|
|
command: GetVirtualMedia
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ result.redfish_facts.virtual_media.entries | to_nice_json }}"
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Get Volume Inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetVolumeInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts.volume.entries | to_nice_json }}"
|
|
|
|
|
|
|
|
- name: Get Session information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Sessions
|
|
|
|
command: GetSessions
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
|
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts.session.entries | to_nice_json }}"
|
|
|
|
|
|
|
|
- name: Get default inventory information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
register: result
|
2021-10-01 14:31:04 +02:00
|
|
|
- name: Print fetched information
|
|
|
|
ansible.builtin.debug:
|
2020-03-09 10:11:07 +01:00
|
|
|
msg: "{{ result.redfish_facts | to_nice_json }}"
|
|
|
|
|
|
|
|
- name: Get several inventories
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetNicInventory,GetBiosAttributes
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get default system inventory and user information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems,Accounts
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get default system, user and firmware information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: ["Systems", "Accounts", "Update"]
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get Manager NIC inventory information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: GetManagerNicInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get boot override information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetBootOverride
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get chassis inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Chassis
|
|
|
|
command: GetChassisInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get all information available in the Manager category
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: all
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get firmware update capability information
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Update
|
|
|
|
command: GetFirmwareUpdateCapabilities
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get firmware inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Update
|
|
|
|
command: GetFirmwareInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2024-01-23 07:59:06 +01:00
|
|
|
- name: Get service identification
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Manager
|
|
|
|
command: GetServiceIdentification
|
|
|
|
manager: "{{ manager }}"
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Get software inventory
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Update
|
|
|
|
command: GetSoftwareInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
2022-11-23 07:46:39 +01:00
|
|
|
- name: Get the status of an update operation
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Update
|
|
|
|
command: GetUpdateStatus
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
update_handle: /redfish/v1/TaskService/TaskMonitors/735
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
- name: Get Manager Services
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: GetNetworkProtocols
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get all information available in all categories
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: all
|
|
|
|
command: all
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get system health report
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Systems
|
|
|
|
command: GetHealthReport
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get chassis health report
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Chassis
|
|
|
|
command: GetHealthReport
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get manager health report
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.redfish_info:
|
2020-03-09 10:11:07 +01:00
|
|
|
category: Manager
|
|
|
|
command: GetHealthReport
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2021-11-16 19:46:28 +01:00
|
|
|
|
|
|
|
- name: Get manager Redfish Host Interface inventory
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Manager
|
|
|
|
command: GetHostInterfaces
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2022-06-30 20:35:35 +02:00
|
|
|
|
|
|
|
- name: Get Manager Inventory
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Manager
|
|
|
|
command: GetManagerInventory
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2023-03-25 23:18:21 +01:00
|
|
|
|
|
|
|
- name: Get HPE Thermal Config
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Chassis
|
|
|
|
command: GetHPEThermalConfig
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
|
|
|
|
|
|
|
- name: Get HPE Fan Percent Minimum
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Chassis
|
|
|
|
command: GetHPEFanPercentMin
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2023-10-09 09:14:47 +02:00
|
|
|
|
|
|
|
- name: Get BIOS registry
|
|
|
|
community.general.redfish_info:
|
|
|
|
category: Systems
|
|
|
|
command: GetBiosRegistries
|
|
|
|
baseuri: "{{ baseuri }}"
|
|
|
|
username: "{{ username }}"
|
|
|
|
password: "{{ password }}"
|
2020-03-09 10:11:07 +01:00
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
result:
|
|
|
|
description: different results depending on task
|
|
|
|
returned: always
|
|
|
|
type: dict
|
|
|
|
sample: List of CPUs on system
|
|
|
|
'''
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.redfish_utils import RedfishUtils
|
|
|
|
|
|
|
|
CATEGORY_COMMANDS_ALL = {
|
|
|
|
"Systems": ["GetSystemInventory", "GetPsuInventory", "GetCpuInventory",
|
|
|
|
"GetMemoryInventory", "GetNicInventory", "GetHealthReport",
|
|
|
|
"GetStorageControllerInventory", "GetDiskInventory", "GetVolumeInventory",
|
2023-10-09 09:14:47 +02:00
|
|
|
"GetBiosAttributes", "GetBootOrder", "GetBootOverride", "GetVirtualMedia", "GetBiosRegistries"],
|
2020-03-09 10:11:07 +01:00
|
|
|
"Chassis": ["GetFanInventory", "GetPsuInventory", "GetChassisPower",
|
2023-03-25 23:18:21 +01:00
|
|
|
"GetChassisThermals", "GetChassisInventory", "GetHealthReport", "GetHPEThermalConfig", "GetHPEFanPercentMin"],
|
2020-03-09 10:11:07 +01:00
|
|
|
"Accounts": ["ListUsers"],
|
|
|
|
"Sessions": ["GetSessions"],
|
2022-11-23 07:46:39 +01:00
|
|
|
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory",
|
|
|
|
"GetUpdateStatus"],
|
2020-03-09 10:11:07 +01:00
|
|
|
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols",
|
2024-01-23 07:59:06 +01:00
|
|
|
"GetHealthReport", "GetHostInterfaces", "GetManagerInventory", "GetServiceIdentification"],
|
2020-03-09 10:11:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
CATEGORY_COMMANDS_DEFAULT = {
|
|
|
|
"Systems": "GetSystemInventory",
|
|
|
|
"Chassis": "GetFanInventory",
|
|
|
|
"Accounts": "ListUsers",
|
|
|
|
"Update": "GetFirmwareInventory",
|
|
|
|
"Sessions": "GetSessions",
|
|
|
|
"Manager": "GetManagerNicInventory"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
result = {}
|
|
|
|
category_list = []
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec=dict(
|
2021-02-12 06:47:23 +01:00
|
|
|
category=dict(type='list', elements='str', default=['Systems']),
|
|
|
|
command=dict(type='list', elements='str'),
|
2020-03-09 10:11:07 +01:00
|
|
|
baseuri=dict(required=True),
|
2021-03-19 21:14:33 +01:00
|
|
|
username=dict(),
|
|
|
|
password=dict(no_log=True),
|
|
|
|
auth_token=dict(no_log=True),
|
2023-09-28 21:05:12 +02:00
|
|
|
timeout=dict(type='int'),
|
2022-11-23 07:46:39 +01:00
|
|
|
update_handle=dict(),
|
2024-01-23 07:59:06 +01:00
|
|
|
manager=dict(),
|
2020-03-09 10:11:07 +01:00
|
|
|
),
|
2021-03-19 21:14:33 +01:00
|
|
|
required_together=[
|
|
|
|
('username', 'password'),
|
|
|
|
],
|
|
|
|
required_one_of=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
|
|
|
mutually_exclusive=[
|
|
|
|
('username', 'auth_token'),
|
|
|
|
],
|
2021-07-27 18:24:29 +02:00
|
|
|
supports_check_mode=True,
|
2020-03-09 10:11:07 +01:00
|
|
|
)
|
|
|
|
|
2023-09-28 21:05:12 +02:00
|
|
|
if module.params['timeout'] is None:
|
|
|
|
timeout = 10
|
|
|
|
module.deprecate(
|
|
|
|
'The default value {0} for parameter param1 is being deprecated and it will be replaced by {1}'.format(
|
|
|
|
10, 60
|
|
|
|
),
|
|
|
|
version='9.0.0',
|
|
|
|
collection_name='community.general'
|
|
|
|
)
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# admin credentials used for authentication
|
|
|
|
creds = {'user': module.params['username'],
|
2021-03-19 21:14:33 +01:00
|
|
|
'pswd': module.params['password'],
|
|
|
|
'token': module.params['auth_token']}
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# timeout
|
|
|
|
timeout = module.params['timeout']
|
|
|
|
|
2022-11-23 07:46:39 +01:00
|
|
|
# update handle
|
|
|
|
update_handle = module.params['update_handle']
|
|
|
|
|
2024-01-23 07:59:06 +01:00
|
|
|
# manager
|
|
|
|
manager = module.params['manager']
|
|
|
|
|
2020-03-09 10:11:07 +01:00
|
|
|
# Build root URI
|
|
|
|
root_uri = "https://" + module.params['baseuri']
|
|
|
|
rf_utils = RedfishUtils(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 range(len(CATEGORY_COMMANDS_ALL[category])):
|
|
|
|
command_list.append(CATEGORY_COMMANDS_ALL[category][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 == "Systems":
|
|
|
|
# execute only if we find a Systems resource
|
|
|
|
resource = rf_utils._find_systems_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "GetSystemInventory":
|
|
|
|
result["system"] = rf_utils.get_multi_system_inventory()
|
|
|
|
elif command == "GetCpuInventory":
|
|
|
|
result["cpu"] = rf_utils.get_multi_cpu_inventory()
|
|
|
|
elif command == "GetMemoryInventory":
|
|
|
|
result["memory"] = rf_utils.get_multi_memory_inventory()
|
|
|
|
elif command == "GetNicInventory":
|
|
|
|
result["nic"] = rf_utils.get_multi_nic_inventory(category)
|
|
|
|
elif command == "GetStorageControllerInventory":
|
|
|
|
result["storage_controller"] = rf_utils.get_multi_storage_controller_inventory()
|
|
|
|
elif command == "GetDiskInventory":
|
|
|
|
result["disk"] = rf_utils.get_multi_disk_inventory()
|
|
|
|
elif command == "GetVolumeInventory":
|
|
|
|
result["volume"] = rf_utils.get_multi_volume_inventory()
|
|
|
|
elif command == "GetBiosAttributes":
|
|
|
|
result["bios_attribute"] = rf_utils.get_multi_bios_attributes()
|
|
|
|
elif command == "GetBootOrder":
|
|
|
|
result["boot_order"] = rf_utils.get_multi_boot_order()
|
|
|
|
elif command == "GetBootOverride":
|
|
|
|
result["boot_override"] = rf_utils.get_multi_boot_override()
|
|
|
|
elif command == "GetHealthReport":
|
|
|
|
result["health_report"] = rf_utils.get_multi_system_health_report()
|
2022-08-24 21:36:35 +02:00
|
|
|
elif command == "GetVirtualMedia":
|
|
|
|
result["virtual_media"] = rf_utils.get_multi_virtualmedia(category)
|
2023-10-09 09:14:47 +02:00
|
|
|
elif command == "GetBiosRegistries":
|
|
|
|
result["bios_registries"] = rf_utils.get_bios_registries()
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Chassis":
|
|
|
|
# execute only if we find Chassis resource
|
|
|
|
resource = rf_utils._find_chassis_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "GetFanInventory":
|
|
|
|
result["fan"] = rf_utils.get_fan_inventory()
|
|
|
|
elif command == "GetPsuInventory":
|
|
|
|
result["psu"] = rf_utils.get_psu_inventory()
|
|
|
|
elif command == "GetChassisThermals":
|
|
|
|
result["thermals"] = rf_utils.get_chassis_thermals()
|
|
|
|
elif command == "GetChassisPower":
|
|
|
|
result["chassis_power"] = rf_utils.get_chassis_power()
|
|
|
|
elif command == "GetChassisInventory":
|
|
|
|
result["chassis"] = rf_utils.get_chassis_inventory()
|
|
|
|
elif command == "GetHealthReport":
|
|
|
|
result["health_report"] = rf_utils.get_multi_chassis_health_report()
|
2023-03-25 23:18:21 +01:00
|
|
|
elif command == "GetHPEThermalConfig":
|
|
|
|
result["hpe_thermal_config"] = rf_utils.get_hpe_thermal_config()
|
|
|
|
elif command == "GetHPEFanPercentMin":
|
|
|
|
result["hpe_fan_percent_min"] = rf_utils.get_hpe_fan_percent_min()
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Accounts":
|
|
|
|
# execute only if we find an Account service resource
|
|
|
|
resource = rf_utils._find_accountservice_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "ListUsers":
|
|
|
|
result["user"] = rf_utils.list_users()
|
|
|
|
|
|
|
|
elif category == "Update":
|
|
|
|
# execute only if we find UpdateService resources
|
|
|
|
resource = rf_utils._find_updateservice_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "GetFirmwareInventory":
|
|
|
|
result["firmware"] = rf_utils.get_firmware_inventory()
|
|
|
|
elif command == "GetSoftwareInventory":
|
|
|
|
result["software"] = rf_utils.get_software_inventory()
|
|
|
|
elif command == "GetFirmwareUpdateCapabilities":
|
|
|
|
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()
|
2022-11-23 07:46:39 +01:00
|
|
|
elif command == "GetUpdateStatus":
|
|
|
|
result["update_status"] = rf_utils.get_update_status(update_handle)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
elif category == "Sessions":
|
|
|
|
# execute only if we find SessionService resources
|
|
|
|
resource = rf_utils._find_sessionservice_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "GetSessions":
|
|
|
|
result["session"] = rf_utils.get_sessions()
|
|
|
|
|
|
|
|
elif category == "Manager":
|
|
|
|
# execute only if we find a Manager service resource
|
|
|
|
resource = rf_utils._find_managers_resource()
|
|
|
|
if resource['ret'] is False:
|
|
|
|
module.fail_json(msg=resource['msg'])
|
|
|
|
|
|
|
|
for command in command_list:
|
|
|
|
if command == "GetManagerNicInventory":
|
|
|
|
result["manager_nics"] = rf_utils.get_multi_nic_inventory(category)
|
|
|
|
elif command == "GetVirtualMedia":
|
2022-08-24 21:36:35 +02:00
|
|
|
result["virtual_media"] = rf_utils.get_multi_virtualmedia(category)
|
2020-03-09 10:11:07 +01:00
|
|
|
elif command == "GetLogs":
|
|
|
|
result["log"] = rf_utils.get_logs()
|
|
|
|
elif command == "GetNetworkProtocols":
|
|
|
|
result["network_protocols"] = rf_utils.get_network_protocols()
|
|
|
|
elif command == "GetHealthReport":
|
|
|
|
result["health_report"] = rf_utils.get_multi_manager_health_report()
|
2021-11-16 19:46:28 +01:00
|
|
|
elif command == "GetHostInterfaces":
|
|
|
|
result["host_interfaces"] = rf_utils.get_hostinterfaces()
|
2022-06-30 20:35:35 +02:00
|
|
|
elif command == "GetManagerInventory":
|
|
|
|
result["manager"] = rf_utils.get_multi_manager_inventory()
|
2024-01-23 07:59:06 +01:00
|
|
|
elif command == "GetServiceIdentification":
|
|
|
|
result["service_id"] = rf_utils.get_service_identification(manager)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
# Return data back
|
2021-04-13 13:19:25 +02:00
|
|
|
module.exit_json(redfish_facts=result)
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|