| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
from __future__ import (absolute_import, division, print_function) |
| 14 |
__metaclass__ = type |
| 15 |
|
| 16 |
DOCUMENTATION = """ |
| 17 |
--- |
| 18 |
module: idrac_system_info |
| 19 |
short_description: Get the PowerEdge Server System Inventory |
| 20 |
version_added: "3.0.0" |
| 21 |
description: |
| 22 |
- Get the PowerEdge Server System Inventory. |
| 23 |
extends_documentation_fragment: |
| 24 |
- dellemc.openmanage.idrac_auth_options |
| 25 |
|
| 26 |
requirements: |
| 27 |
- "omsdk >= 1.2.488" |
| 28 |
- "python >= 3.9.6" |
| 29 |
author: |
| 30 |
- "Rajeev Arakkal (@rajeevarakkal)" |
| 31 |
- "Kritika Bhateja (@Kritika-Bhateja-03)" |
| 32 |
- "Abhishek Sinha (@ABHISHEK-SINHA10)" |
| 33 |
- "Saksham Nautiyal (@Saksham-Nautiyal)" |
| 34 |
- "Mangirish Kenkare(@MangirishK)" |
| 35 |
notes: |
| 36 |
- Run this module from a system that has direct access to Dell iDRAC. |
| 37 |
- This module supports both IPv4 and IPv6 address for I(idrac_ip). |
| 38 |
- This module supports C(check_mode). |
| 39 |
- The functionality to get I(temperature_sensors), I(fan_sensors), |
| 40 |
I(controller_sensor), I(controller_battery), I(system_metrics), |
| 41 |
I(system_board_metrics), I(sensors_amperage) and I(video) component |
| 42 |
is not available through iDRAC10. |
| 43 |
""" |
| 44 |
|
| 45 |
EXAMPLES = """ |
| 46 |
--- |
| 47 |
- name: Get System Inventory |
| 48 |
dellemc.openmanage.idrac_system_info: |
| 49 |
idrac_ip: "192.168.0.1" |
| 50 |
idrac_user: "user_name" |
| 51 |
idrac_password: "user_password" |
| 52 |
ca_path: "/path/to/ca_cert.pem" |
| 53 |
""" |
| 54 |
|
| 55 |
RETURN = r''' |
| 56 |
--- |
| 57 |
msg: |
| 58 |
description: "Overall system inventory information status." |
| 59 |
returned: always |
| 60 |
type: str |
| 61 |
sample: "Successfully fetched the system inventory details." |
| 62 |
system_info: |
| 63 |
type: dict |
| 64 |
description: Details of the PowerEdge Server System Inventory. |
| 65 |
returned: success |
| 66 |
sample: { |
| 67 |
"BIOS": [ |
| 68 |
{ |
| 69 |
"BIOSReleaseDate": "11/26/2019", |
| 70 |
"FQDD": "BIOS.Setup.1-1", |
| 71 |
"InstanceID": "DCIM:INSTALLED#741__BIOS.Setup.1-1", |
| 72 |
"Key": "DCIM:INSTALLED#741__BIOS.Setup.1-1", |
| 73 |
"SMBIOSPresent": "True", |
| 74 |
"VersionString": "2.4.8" |
| 75 |
} |
| 76 |
] |
| 77 |
} |
| 78 |
error_info: |
| 79 |
description: Details of the HTTP Error. |
| 80 |
returned: on HTTP error |
| 81 |
type: dict |
| 82 |
sample: { |
| 83 |
"error": { |
| 84 |
"code": "Base.1.0.GeneralError", |
| 85 |
"message": "A general error has occurred. See ExtendedInfo for more information.", |
| 86 |
"@Message.ExtendedInfo": [ |
| 87 |
{ |
| 88 |
"MessageId": "GEN1234", |
| 89 |
"RelatedProperties": [], |
| 90 |
"Message": "Unable to process the request because an error occurred.", |
| 91 |
"MessageArgs": [], |
| 92 |
"Severity": "Critical", |
| 93 |
"Resolution": "Retry the operation. If the issue persists, contact your system administrator." |
| 94 |
} |
| 95 |
] |
| 96 |
} |
| 97 |
} |
| 98 |
''' |
| 99 |
|
| 100 |
import json |
| 101 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idrac import iDRACConnection, idrac_auth_params |
| 102 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.firmware import IDRACFirmwareInfo |
| 103 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.bios import IDRACBiosInfo |
| 104 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.cpu import IDRACCpuInfo |
| 105 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.controller_enclosure import IDRACEnclosureInfo |
| 106 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.fan import IDRACFanInfo |
| 107 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.nic import IDRACNICInfo |
| 108 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.fc import IDRACFCInfo |
| 109 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.sensors_battery import IDRACSensorsBatteryInfo |
| 110 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.sensors_fan import IDRACSensorsFanInfo |
| 111 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.sensors_intrusion import IDRACSensorsIntrusionInfo |
| 112 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.sensors_voltage import IDRACSensorsVoltageInfo |
| 113 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.system import IDRACSystemInfo |
| 114 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.video import IDRACVideoInfo |
| 115 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.subsystem import IDRACSubsystemInfo |
| 116 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.sensors_temperature import IDRACSensorsTemperatureInfo |
| 117 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.controller_sensor import IDRACControllerSensorInfo |
| 118 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.system_metrics import IDRACSystemMetricsInfo |
| 119 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_utils.info.system_board_metrics import IDRACSystemBoardMetricsInfo |
| 120 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 121 |
idrac_utils.info.license import IDRACLicenseInfo |
| 122 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 123 |
idrac_utils.info.memory import IDRACMemoryInfo |
| 124 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 125 |
idrac_utils.info.idrac import IDRACInfo |
| 126 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 127 |
idrac_utils.info.powersupply import IDRACPowerSupplyInfo |
| 128 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 129 |
idrac_utils.info.pcidevice import IDRACPCIDeviceInfo |
| 130 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 131 |
idrac_utils.info.controller import IDRACControllerInfo |
| 132 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 133 |
idrac_utils.info.physical_disk import IDRACPhysicalDiskInfo |
| 134 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 135 |
idrac_utils.info.controller_battery import IDRACControllerBatteryInfo |
| 136 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 137 |
idrac_utils.info.sensor_amperage import IDRACSensorAmperageInfo |
| 138 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.\ |
| 139 |
idrac_utils.info.chassis_sensor_util import IDRACChassisSensors |
| 140 |
from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish import iDRACRedfishAPI, IdracAnsibleModule |
| 141 |
from ansible.module_utils.basic import AnsibleModule |
| 142 |
from urllib.error import URLError, HTTPError |
| 143 |
from ansible.module_utils.urls import ConnectionError, SSLValidationError |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
def main(): |
| 148 |
specs = {} |
| 149 |
specs.update(idrac_auth_params) |
| 150 |
module = AnsibleModule( |
| 151 |
argument_spec=specs, |
| 152 |
supports_check_mode=True) |
| 153 |
idrac_redfish_module = IdracAnsibleModule( |
| 154 |
argument_spec=specs, |
| 155 |
supports_check_mode=True |
| 156 |
) |
| 157 |
try: |
| 158 |
with iDRACRedfishAPI(idrac_redfish_module.params) as idrac: |
| 159 |
firmware_obj = IDRACFirmwareInfo(idrac) |
| 160 |
system_info_dict = { |
| 161 |
"BIOS": "", |
| 162 |
"CPU": "", |
| 163 |
"Enclosure": "", |
| 164 |
"EnclosureSensor": "", |
| 165 |
"License": "", |
| 166 |
"Memory": "", |
| 167 |
"iDRACNIC": "", |
| 168 |
"PCIDevice": "", |
| 169 |
"PowerSupply": "", |
| 170 |
"ControllerBattery": "", |
| 171 |
"Sensors_Temperature": "", |
| 172 |
"Sensors_Battery": "", |
| 173 |
"Sensors_Fan": "", |
| 174 |
"Sensors_Intrusion": "", |
| 175 |
"Sensors_Voltage": "", |
| 176 |
"Sensors_Amperage": "", |
| 177 |
"NIC": "", |
| 178 |
"FC": "", |
| 179 |
"Fan": "", |
| 180 |
"System": "", |
| 181 |
"SystemBoardMetrics": "", |
| 182 |
"SystemMetrics": "", |
| 183 |
"Subsystem": "", |
| 184 |
"Controller": "", |
| 185 |
"ControllerSensor": "", |
| 186 |
"PhysicalDisk": "", |
| 187 |
"Video": "", |
| 188 |
"iDRAC": "" |
| 189 |
} |
| 190 |
if not firmware_obj.is_omsdk_required(): |
| 191 |
chassis_sensors = IDRACChassisSensors(idrac) |
| 192 |
system_info_dict["BIOS"] = IDRACBiosInfo(idrac).get_bios_system_info() |
| 193 |
system_info_dict["CPU"] = IDRACCpuInfo(idrac).get_cpu_system_info() |
| 194 |
system_info_dict["Enclosure"] = IDRACEnclosureInfo(idrac).get_enclosure_system_info() |
| 195 |
system_info_dict["EnclosureSensor"] = IDRACEnclosureInfo(idrac).get_controller_enclosure_sensor_info(system_info_dict["Enclosure"]) |
| 196 |
system_info_dict["Sensors_Battery"] = IDRACSensorsBatteryInfo(idrac).get_sensors_battery_info() |
| 197 |
system_info_dict["Sensors_Intrusion"] = IDRACSensorsIntrusionInfo(idrac).get_sensors_intrusion_info() |
| 198 |
system_info_dict["Sensors_Voltage"] = IDRACSensorsVoltageInfo(idrac).get_sensors_voltage_info() |
| 199 |
system_info_dict["Sensors_Amperage"] = IDRACSensorAmperageInfo(idrac, chassis_sensors).get_sensor_amperage_info() |
| 200 |
system_info_dict["Sensors_Fan"] = IDRACSensorsFanInfo(idrac).get_sensors_fan_info() |
| 201 |
system_info_dict["Fan"] = IDRACFanInfo(idrac).get_fan_info() |
| 202 |
system_info_dict["NIC"] = IDRACNICInfo(idrac).get_nic_info() |
| 203 |
system_info_dict["FC"] = IDRACFCInfo(idrac).get_fc_info() |
| 204 |
system_info_dict["System"] = IDRACSystemInfo(idrac).get_system_info() |
| 205 |
system_info_dict["SystemBoardMetrics"] = IDRACSystemBoardMetricsInfo(idrac, chassis_sensors).get_system_board_metrics_info() |
| 206 |
system_info_dict["SystemMetrics"] = IDRACSystemMetricsInfo(idrac, chassis_sensors).get_system_metrics_info() |
| 207 |
system_info_dict["Video"] = IDRACVideoInfo(idrac).get_idrac_video_details() |
| 208 |
system_info_dict["Subsystem"] = IDRACSubsystemInfo(idrac).get_subsystem_info() |
| 209 |
system_info_dict["License"] = IDRACLicenseInfo(idrac).get_license_info() |
| 210 |
system_info_dict["Memory"] = IDRACMemoryInfo(idrac).get_memory_info() |
| 211 |
system_info_dict["iDRAC"] = IDRACInfo(idrac).get_idrac_info_details() |
| 212 |
system_info_dict["PowerSupply"] = IDRACPowerSupplyInfo(idrac).get_power_supply_info() |
| 213 |
system_info_dict["iDRACNIC"] = IDRACInfo(idrac).get_idrac_nic_info() |
| 214 |
system_info_dict["PCIDevice"] = IDRACPCIDeviceInfo(idrac).get_pcidevice_info() |
| 215 |
system_info_dict["Controller"] = IDRACControllerInfo(idrac).get_controller_system_info() |
| 216 |
system_info_dict["PhysicalDisk"] = IDRACPhysicalDiskInfo(idrac).get_physical_disk_info() |
| 217 |
system_info_dict["Sensors_Temperature"] = IDRACSensorsTemperatureInfo(idrac).get_sensors_temperature_info() |
| 218 |
system_info_dict["ControllerSensor"] = IDRACControllerSensorInfo(idrac).get_controller_sensor_info() |
| 219 |
system_info_dict["ControllerBattery"] = IDRACControllerBatteryInfo(idrac).get_controller_battery_info() |
| 220 |
|
| 221 |
else: |
| 222 |
with iDRACConnection(module.params) as idrac: |
| 223 |
idrac.get_entityjson() |
| 224 |
system_info_dict = idrac.get_json_device() |
| 225 |
except HTTPError as err: |
| 226 |
module.exit_json(msg=str(err), error_info=json.load(err), failed=True) |
| 227 |
except URLError as err: |
| 228 |
module.exit_json(msg=str(err), unreachable=True) |
| 229 |
except (RuntimeError, SSLValidationError, IOError, ValueError, TypeError, ConnectionError) as e: |
| 230 |
module.exit_json(msg=str(e), failed=True) |
| 231 |
|
| 232 |
module.exit_json(msg="Successfully fetched the system inventory details.", |
| 233 |
system_info=system_info_dict) |
| 234 |
|
| 235 |
|
| 236 |
if __name__ == '__main__': |
| 237 |
main() |