Debian Codegraph @

ansible_collections/dellemc/openmanage/plugins/module_utils/idrac_utils/info/subsystem.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2
3 # Dell OpenManage Ansible Modules
4 # Version 9.12.0
5 # Copyright (C) 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
6
7 # Redistribution and use in source and binary forms, with or without modification,
8 # are permitted provided that the following conditions are met:
9
10 # * Redistributions of source code must retain the above copyright notice,
11 # this list of conditions and the following disclaimer.
12
13 # * Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #
27
28
29 GET_IDRAC_CPU_DETAILS_URI_10 = "/redfish/v1/Systems/System.Embedded.1/Processors?$expand=*($levels=1)"
30 GET_IDRAC_LICENSE_DETAILS_URI_10 = "/redfish/v1/LicenseService/Licenses?$expand=*($levels=1)"
31 GET_IDRAC_MEMORY_DETAILS_URI_10 = "/redfish/v1/Systems/System.Embedded.1/Memory?%24expand=*(%24levels%3D1)"
32 GET_IDRAC_POWER_SUPPLY_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/PowerSubsystem/PowerSupplies?$expand=*($levels=1)"
33 GET_IDRAC_SENSOR_VOLTAGE_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Power#/Voltages"
34 GET_IDRAC_DELL_SENSORS_DETAILS_URI_10 = "/redfish/v1/Systems/System.Embedded.1/Oem/Dell/DellSensors"
35 GET_IDRAC_SENSOR_FAN_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Oem/Dell/DellEnclosureFanSensors"
36 GET_IDRAC_SENSOR_INTRUSION_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1?$select=PhysicalSecurity/IntrusionSensor"
37 GET_IDRAC_SENSOR_TEMPERATURE_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Oem/Dell/DellEnclosureTemperatureSensors"
38 GET_IDRAC_STORAGE_DETAILS_URI_10 = "/redfish/v1/Systems/System.Embedded.1/Storage?$expand=*($levels=1)"
39 GET_IDRAC_SENSOR_AMPERAGE_DETAILS_URI_10 = "/redfish/v1/Chassis/System.Embedded.1/Sensors/SystemBoardPwrConsumption"
40 GET_IDRAC_SYSTEM_DETAILS_URI_10 = "/redfish/v1/Systems/System.Embedded.1"
41
42
43 class IDRACSubsystemInfo(object):
44 def __init__(self, idrac):
45 self.idrac = idrac
46 self.sub_system = []
47
48 def get_idrac_cpu_health_status(self):
49 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_CPU_DETAILS_URI_10)
50 output = response.json_data
51 members = output.get("Members", [])
52 if members:
53 health_status = members[0].get("Status", {}).get("Health", "Unknown")
54 else:
55 health_status = "Unknown"
56 return {
57 "Key": "CPU",
58 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
59 }
60
61 def get_idrac_license_health_status(self):
62 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_LICENSE_DETAILS_URI_10)
63 output = response.json_data
64 members = output.get("Members", [])
65 if members:
66 health_status = members[0].get("Status", {}).get("Health", "Unknown")
67 else:
68 health_status = "Unknown"
69 return {
70 "Key": "License",
71 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
72 }
73
74 def get_idrac_memory_health_status(self):
75 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_MEMORY_DETAILS_URI_10)
76 output = response.json_data
77 members = output.get("Members", [])
78 if members:
79 health_status = members[0].get("Status", {}).get("Health", "Unknown")
80 else:
81 health_status = "Unknown"
82 return {
83 "Key": "Memory",
84 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
85 }
86
87 def get_idrac_power_supply_health_status(self):
88 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_POWER_SUPPLY_DETAILS_URI_10)
89 output = response.json_data
90 members = output.get("Members", [])
91 if members:
92 health_status = members[0].get("Status", {}).get("Health", "Unknown")
93 else:
94 health_status = "Unknown"
95 return {
96 "Key": "PowerSupply",
97 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
98 }
99
100 def get_idrac_sensor_voltage_health_status(self):
101 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SENSOR_VOLTAGE_DETAILS_URI_10)
102 output = response.json_data
103 members = output.get("Redundancy", [])
104 if members:
105 health_status = members[0].get("Status", {}).get("Health", "Unknown")
106 else:
107 health_status = "Unknown"
108 return {
109 "Key": "Sensors_Voltage",
110 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
111 }
112
113 def get_idrac_sensor_battery_health_status(self):
114 found = False
115 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_DELL_SENSORS_DETAILS_URI_10)
116 for mem in response.json_data.get("Members", []):
117 if mem.get("ElementName", "") == "System Board CMOS Battery":
118 health_status = mem.get("HealthState")
119 return {
120 "Key": "Sensors_Battery",
121 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
122 }
123
124 if not found:
125 return {
126 "Key": "Sensors_Battery",
127 "PrimaryStatus": "Unknown"
128 }
129
130 def get_idrac_sensor_fan_health_status(self):
131 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SENSOR_FAN_DETAILS_URI_10)
132 output = response.json_data
133 members = output.get("Members", [])
134 if members:
135 health_status = members[0].get("Status", {}).get("Health", "Unknown")
136 else:
137 health_status = "Unknown"
138 return {
139 "Key": "Sensors_Fan",
140 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
141 }
142
143 def get_idrac_sensor_intrusion_health_status(self):
144 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SENSOR_INTRUSION_DETAILS_URI_10)
145 output = response.json_data
146 health_status = output["PhysicalSecurity"].get("IntrusionSensor", "Unknown")
147 return {
148 "Key": "Sensors_Intrusion",
149 "PrimaryStatus": "Healthy" if health_status == "Normal" else health_status
150 }
151
152 def get_idrac_sensor_temperature_health_status(self):
153 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SENSOR_TEMPERATURE_DETAILS_URI_10)
154 output = response.json_data
155 members = output.get("Members", [])
156 if members:
157 health_status = members[0].get("Status", {}).get("Health", "Unknown")
158 else:
159 health_status = "Unknown"
160 return {
161 "Key": "Sensors_Temperature",
162 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
163 }
164
165 def get_idrac_system_health_status(self):
166 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SYSTEM_DETAILS_URI_10)
167 output = response.json_data
168 health_status = output["Status"].get("Health", "Unknown")
169 return {
170 "Key": "System",
171 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
172 }
173
174 def get_idrac_vflash_health_status(self):
175 # Hardcoding value, since no api is available
176 return {
177 "Key": "VFlash",
178 "PrimaryStatus": "Unknown"
179 }
180
181 def get_idrac_sensor_amperage_health_status(self):
182 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_SENSOR_AMPERAGE_DETAILS_URI_10)
183 output = response.json_data
184 health_status = output["Status"].get("Health", "Unknown")
185 return {
186 "Key": "Sensors_Amperage",
187 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
188 }
189
190 def get_storage_health_status_data(self, uri):
191 response = self.idrac.invoke_request(method='GET', uri=uri)
192 output = response.json_data
193 health_status = output["Status"].get("Health", "Unknown") or "Unknown"
194 return health_status
195
196 def get_idrac_storage_health_status(self):
197 response = self.idrac.invoke_request(method='GET', uri=GET_IDRAC_STORAGE_DETAILS_URI_10)
198 output = response.json_data
199 members = output.get("Members", [])
200 health_status = "Unknown"
201 if members:
202 URI = members[0].get("@odata.id", "")
203 health_status = self.get_storage_health_status_data(uri=URI)
204 return {
205 "Key": "Storage",
206 "PrimaryStatus": "Healthy" if health_status == "OK" else health_status
207 }
208
209 def get_subsystem_info(self):
210 self.sub_system.append(self.get_idrac_system_health_status())
211 self.sub_system.append(self.get_idrac_memory_health_status())
212 self.sub_system.append(self.get_idrac_cpu_health_status())
213 self.sub_system.append(self.get_idrac_sensor_fan_health_status())
214 self.sub_system.append(self.get_idrac_power_supply_health_status())
215 self.sub_system.append(self.get_idrac_storage_health_status())
216 self.sub_system.append(self.get_idrac_license_health_status())
217 self.sub_system.append(self.get_idrac_sensor_voltage_health_status())
218 self.sub_system.append(self.get_idrac_sensor_temperature_health_status())
219 self.sub_system.append(self.get_idrac_sensor_battery_health_status())
220 self.sub_system.append(self.get_idrac_vflash_health_status())
221 self.sub_system.append(self.get_idrac_sensor_intrusion_health_status())
222 self.sub_system.append(self.get_idrac_sensor_amperage_health_status())
223 return self.sub_system