blob: 1bf219ccd0117b0e0c0d2fa081052fbb895773bc [file] [log] [blame]
Anusha Dathatri88ccaff2020-02-07 05:17:53 -06001*** Settings ***
George Keishing87dc4422023-10-20 12:56:30 +05302Documentation Validate IPMI sensor IDs using Redfish.
Anusha Dathatri88ccaff2020-02-07 05:17:53 -06003
4Resource ../lib/ipmi_client.robot
5Resource ../lib/openbmc_ffdc.robot
George Keishing6f395fd2021-08-18 02:18:53 -05006Resource ../lib/boot_utils.robot
Sushma M Md4d13f02020-02-13 03:42:41 -06007Library ../lib/ipmi_utils.py
Sushma M Mfd2f4282020-03-18 04:12:47 -05008Variables ../data/ipmi_raw_cmd_table.py
Anusha Dathatri88ccaff2020-02-07 05:17:53 -06009
Sushma M Mfd2f4282020-03-18 04:12:47 -050010Test Setup Redfish.Login
11Test Teardown Run Keywords FFDC On Test Case Fail AND
12... Redfish.Logout
Anusha Dathatri88ccaff2020-02-07 05:17:53 -060013
Matt Fischer6fb70d92023-10-24 19:06:33 -060014Test Tags IPMI_Sensor
Sushma M Mbe808b92020-02-03 23:12:14 -060015
16*** Variables ***
George Keishing87dc4422023-10-20 12:56:30 +053017
Sushma M M84e98d92020-04-15 04:47:10 -050018${allowed_temp_diff} ${2}
Sushma M Md4d13f02020-02-13 03:42:41 -060019${allowed_power_diff} ${10}
Sushma M Mbe808b92020-02-03 23:12:14 -060020
21
Anusha Dathatri88ccaff2020-02-07 05:17:53 -060022*** Test Cases ***
Anusha Dathatri88ccaff2020-02-07 05:17:53 -060023Verify IPMI Temperature Readings using Redfish
24 [Documentation] Verify temperatures from IPMI sensor reading command using Redfish.
25 [Tags] Verify_IPMI_Temperature_Readings_using_Redfish
26 [Template] Get Temperature Reading And Verify In Redfish
27
28 # command_type sensor_id member_id
srichn2873d8bbe2022-10-27 11:51:55 -050029 IPMI PCIE PCIE
30 IPMI Ambient Ambient
Anusha Dathatri88ccaff2020-02-07 05:17:53 -060031
32
33Verify DCMI Temperature Readings using Redfish
34 [Documentation] Verify temperatures from DCMI sensor reading command using Redfish.
35 [Tags] Verify_DCMI_Temperature_Readings_using_Redfish
36 [Template] Get Temperature Reading And Verify In Redfish
37
38 # command_type sensor_id member_id
srichn2873d8bbe2022-10-27 11:51:55 -050039 DCMI PCIE PCIE
40 DCMI Ambient Ambient
Anusha Dathatri88ccaff2020-02-07 05:17:53 -060041
Sushma M Mbe808b92020-02-03 23:12:14 -060042
43Test Ambient Temperature Via IPMI
44 [Documentation] Test ambient temperature via IPMI and verify using Redfish.
45 [Tags] Test_Ambient_Temperature_Via_IPMI
46
47 # Example of IPMI dcmi get_temp_reading output:
48 # Entity ID Entity Instance Temp. Readings
srichn28b9121662022-09-27 08:01:42 -050049 # Inlet air temperature(40h) 1 +22 C
50 # Inlet air temperature(40h) 2 +23 C
51 # Inlet air temperature(40h) 3 +22 C
52 # CPU temperature sensors(41h) 0 +0 C
53 # Baseboard temperature sensors(42h) 1 +26 C
54 # Baseboard temperature sensors(42h) 2 +27 C
Sushma M Mbe808b92020-02-03 23:12:14 -060055
56 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
57 Should Contain ${temp_reading} Inlet air temperature
58 ... msg="Unable to get inlet temperature via DCMI".
59
60 ${ambient_temp_line}=
61 ... Get Lines Containing String ${temp_reading}
62 ... Inlet air temperature case-insensitive
63
srichn28b9121662022-09-27 08:01:42 -050064 ${ambient_temp_line}= Split To Lines ${ambient_temp_line}
65 ${ipmi_temp_list}= Create List
66 FOR ${line} IN @{ambient_temp_line}
67 ${ambient_temp_ipmi}= Set Variable ${line.split('+')[1].strip(' C')}
68 Append To List ${ipmi_temp_list} ${ambient_temp_ipmi}
69 END
70 ${list_length}= Get Length ${ipmi_temp_list}
Sushma M Mbe808b92020-02-03 23:12:14 -060071
srichn28b9121662022-09-27 08:01:42 -050072 # Getting temperature readings from Redfish.
73 ${ambient_temp_redfish}= Get Temperature Reading From Redfish Ambient
74 ${ambient_temp_redfish}= Get Dictionary Values ${ambient_temp_redfish} sort_keys=True
75 FOR ${index} IN RANGE ${list_length}
76 ${ipmi_redfish_temp_diff}=
77 ... Evaluate abs(${ambient_temp_redfish[${index}]} - ${ipmi_temp_list[${index}]})
Sushma M Mbe808b92020-02-03 23:12:14 -060078
srichn28b9121662022-09-27 08:01:42 -050079 Should Be True ${ipmi_redfish_temp_diff} <= ${allowed_temp_diff}
80 ... msg=Ambient temperature above allowed threshold ${allowed_temp_diff}.
81 END
Sushma M Mbe808b92020-02-03 23:12:14 -060082
83
Sushma M Md4d13f02020-02-13 03:42:41 -060084Test Power Reading Via IPMI With Host Off
85 [Documentation] Verify power reading via IPMI with host in off state
86 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Off
87
88 Redfish Power Off stack_mode=skip
89
90 ${ipmi_reading}= Get IPMI Power Reading
91
92 Should Be Equal ${ipmi_reading['instantaneous_power_reading']} 0
93 ... msg=Power reading not zero when power is off.
94
95
96Test Power Reading Via IPMI With Host Booted
97 [Documentation] Test power reading via IPMI with host in booted state and
98 ... verify using Redfish.
99 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Booted
100
101 IPMI Power On stack_mode=skip
102
103 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading Using IPMI And Redfish
104
105
Sushma M M85dbd9c2020-03-20 15:58:28 -0500106Test Baseboard Temperature Via IPMI
107 [Documentation] Test baseboard temperature via IPMI and verify using Redfish.
108 [Tags] Test_Baseboard_Temperature_Via_IPMI
109
110 # Example of IPMI dcmi get_temp_reading output:
111 # Entity ID Entity Instance Temp. Readings
srichn28334438b2022-09-21 08:41:25 -0500112 # Inlet air temperature(40h) 1 +22 C
113 # Inlet air temperature(40h) 2 +23 C
114 # Inlet air temperature(40h) 3 +22 C
115 # CPU temperature sensors(41h) 0 +0 C
116 # Baseboard temperature sensors(42h) 1 +26 C
117 # Baseboard temperature sensors(42h) 2 +27 C
Sushma M M85dbd9c2020-03-20 15:58:28 -0500118
119 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
120 Should Contain ${temp_reading} Baseboard temperature sensors
121 ... msg="Unable to get baseboard temperature via DCMI".
srichn28334438b2022-09-21 08:41:25 -0500122 ${baseboard_temp_lines}=
Sushma M M85dbd9c2020-03-20 15:58:28 -0500123 ... Get Lines Containing String ${temp_reading}
124 ... Baseboard temperature case-insensitive=True
srichn28334438b2022-09-21 08:41:25 -0500125 ${lines}= Split To Lines ${baseboard_temp_lines}
Sushma M M85dbd9c2020-03-20 15:58:28 -0500126
srichn28334438b2022-09-21 08:41:25 -0500127 ${ipmi_temp_list}= Create List
128 FOR ${line} IN @{lines}
129 ${baseboard_temp_ipmi}= Set Variable ${line.split('+')[1].strip(' C')}
George Keishinga91601b2023-03-21 09:35:49 +0530130 Append To List ${ipmi_temp_list} ${baseboard_temp_ipmi}
srichn28334438b2022-09-21 08:41:25 -0500131 END
132 ${list_length}= Get Length ${ipmi_temp_list}
Sushma M M85dbd9c2020-03-20 15:58:28 -0500133
srichn28334438b2022-09-21 08:41:25 -0500134 # Getting temperature readings from Redfish.
135 ${baseboard_temp_redfish}= Get Temperature Reading From Redfish PCIE
136 ${baseboard_temp_redfish}= Get Dictionary Values ${baseboard_temp_redfish} sort_keys=True
Sushma M M85dbd9c2020-03-20 15:58:28 -0500137
srichn28334438b2022-09-21 08:41:25 -0500138 FOR ${index} IN RANGE ${list_length}
139 ${baseboard_temp_diff}= Evaluate abs(${baseboard_temp_redfish[${index}]} - ${ipmi_temp_list[${index}]})
140 Should Be True
141 ... ${baseboard_temp_diff} <= ${allowed_temp_diff}
142 ... msg=Baseboard temperature above allowed threshold ${allowed_temp_diff}.
143 END
Sushma M M85dbd9c2020-03-20 15:58:28 -0500144
Sushma M Mfd2f4282020-03-18 04:12:47 -0500145Test Power Reading Via IPMI Raw Command
146 [Documentation] Test power reading via IPMI raw command and verify
147 ... using Redfish.
148 [Tags] Test_Power_Reading_Via_IPMI_Raw_Command
149
150 IPMI Power On stack_mode=skip
151
152 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading Via Raw Command
153
154
Sushma M M89882ce2020-03-31 17:21:37 -0500155Verify CPU Present
156 [Documentation] Verify the IPMI sensor for CPU present using Redfish.
157 [Tags] Verify_CPU_Present
srichn284c7d4462022-08-22 03:40:49 -0500158 [Template] Set Present Bit Via IPMI and Verify Using Redfish
Sushma M M89882ce2020-03-31 17:21:37 -0500159
srichn284c7d4462022-08-22 03:40:49 -0500160 # component state
161 cpu Enabled
Sushma M M89882ce2020-03-31 17:21:37 -0500162
163
164Verify CPU Not Present
165 [Documentation] Verify the IPMI sensor for CPU not present using Redfish.
166 [Tags] Verify_CPU_Not_Present
srichn284c7d4462022-08-22 03:40:49 -0500167 [Template] Set Present Bit Via IPMI and Verify Using Redfish
Sushma M M89882ce2020-03-31 17:21:37 -0500168
srichn284c7d4462022-08-22 03:40:49 -0500169 # component state
170 cpu Absent
Sushma M M89882ce2020-03-31 17:21:37 -0500171
172
173Verify GPU Present
174 [Documentation] Verify the IPMI sensor for GPU present using Redfish.
175 [Tags] Verify_GPU_Present
George Keishinge24838e2022-09-26 22:46:45 -0500176 [Template] Set Present Bit Via IPMI and Verify Using Redfish
Sushma M M89882ce2020-03-31 17:21:37 -0500177
178 # sensor_id component
179 0xC5 gv100card0
180
181
182Verify GPU Not Present
183 [Documentation] Verify the IPMI sensor for GPU not present using Redfish.
184 [Tags] Verify_GPU_Not_Present
George Keishinge24838e2022-09-26 22:46:45 -0500185 [Template] Set Present Bit Via IPMI and Verify Using Redfish
Sushma M M89882ce2020-03-31 17:21:37 -0500186
187 # sensor_id component
188 0xC5 gv100card0
189
190
Sushma M Mc69a3d32020-06-10 18:13:08 -0500191Test Sensor Threshold Via IPMI
192 [Documentation] Test sensor threshold via IPMI and verify using Redfish.
193 [Tags] Test_Sensor_Threshold_Via_IPMI
194 [Template] Verify Power Supply Sensor Threshold
195
196 # threshold_id component
197 Upper Non-Critical UpperThresholdNonCritical
198 Upper Critical UpperThresholdCritical
199 Lower Non-Critical LowerThresholdNonCritical
200 Lower Critical LowerThresholdCritical
201
202
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600203*** Keywords ***
204
205Get Temperature Reading And Verify In Redfish
206 [Documentation] Get IPMI or DCMI sensor reading and verify in Redfish.
207 [Arguments] ${command_type} ${sensor_id} ${member_id}
208
209 # Description of argument(s):
210 # command_type Type of command used to get sensor data (eg. IPMI, DCMI).
211 # sensor_id Sensor id used to get reading in IPMI or DCMI.
212 # member_id Member id of sensor data in Redfish.
213
214 ${ipmi_value}= Run Keyword If '${command_type}' == 'IPMI' Get IPMI Sensor Reading ${sensor_id}
215 ... ELSE Get DCMI Sensor Reading ${sensor_id}
216
217 ${redfish_value}= Get Temperature Reading From Redfish ${member_id}
218
srichn2873d8bbe2022-10-27 11:51:55 -0500219 ${keys}= Get Dictionary Keys ${ipmi_value}
220 FOR ${index} IN @{keys}
221 ${value_diff}= Evaluate abs(${redfish_value["${index}"]} - ${ipmi_value["${index}"]})
222 Should Be True ${value_diff} <= ${allowed_temp_diff}
223 END
224
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600225
226
227Get IPMI Sensor Reading
srichn2873d8bbe2022-10-27 11:51:55 -0500228 [Documentation] Get IPMI sensor readings as a dictionary.
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600229 [Arguments] ${sensor_id}
230
231 # Description of argument(s):
232 # sensor_id Sensor id used to get reading in IPMI.
233
srichn2873d8bbe2022-10-27 11:51:55 -0500234 ${sensor_list}= Get Available Sensors ${sensor_id}
235 ${sensor_value_dict}= Create Dictionary
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600236
srichn2873d8bbe2022-10-27 11:51:55 -0500237 FOR ${ids} IN @{sensor_list}
238 ${data}= Run IPMI Standard Command sensor reading ${ids}
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600239
srichn2873d8bbe2022-10-27 11:51:55 -0500240 # Example reading:
241 # PCIE_0_Temp | 5Ch | ok | 41.1 | 27 degrees C
242
243 ${sensor_key}= Set Variable ${data.split('| ')[0].strip()}
244 ${sensor_value}= Set Variable ${data.split('| ')[1].strip()}
245 Set To Dictionary ${sensor_value_dict} ${sensor_key} ${sensor_value}
246 END
247
George Keishing409df052024-01-17 22:36:14 +0530248 RETURN ${sensor_value_dict}
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600249
250
251Get DCMI Sensor Reading
srichn2873d8bbe2022-10-27 11:51:55 -0500252 [Documentation] Get DCMI sensor readings as a dictionary.
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600253 [Arguments] ${sensor_id}
254
255 # Description of argument(s):
256 # sensor_id Sensor id used to get reading in DCMI.
257
258 ${data}= Run IPMI Standard Command dcmi sensors
srichn2873d8bbe2022-10-27 11:51:55 -0500259 ${sensor_data}= Get Lines Containing String ${data} ${sensor_id} case_insensitive
260 ${sensor_lines}= Split To Lines ${sensor_data}
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600261
262 # Example reading:
srichn2873d8bbe2022-10-27 11:51:55 -0500263 # Record ID 0x005c: PCIE_0_Temp | 27 degrees C | ok
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600264
srichn2873d8bbe2022-10-27 11:51:55 -0500265 ${sensor_value_dict}= Create Dictionary
266
267 FOR ${line} IN @{sensor_lines}
268 ${sensor}= Set Variable ${line.split(' | ')}
269 ${sensor_key}= Set Variable ${sensor[0].split(':')[1].strip()}
270 ${sensor_value}= Set Variable ${sensor[1].split()[0].strip()}
271 ${contains}= Evaluate """disabled""" in "${sensor_value}"
272
273 Run Keyword IF "${contains}" != """True"""
274 ... Set To Dictionary ${sensor_value_dict} ${sensor_key} ${sensor_value}
275 END
276
George Keishing409df052024-01-17 22:36:14 +0530277 RETURN ${sensor_value_dict}
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600278
279
280Get Temperature Reading From Redfish
281 [Documentation] Get temperature reading from Redfish.
282 [Arguments] ${member_id}
283
284 # Description of argument(s):
285 # member_id Member id of temperature.
286
srichn28334438b2022-09-21 08:41:25 -0500287 @{thermal_uri}= redfish_utils.Get Member List /redfish/v1/Chassis/
George Keishinga91601b2023-03-21 09:35:49 +0530288 @{redfish_readings}= redfish_utils.Get Attribute
289 ... ${thermal_uri[0]}/${THERMAL_METRICS} TemperatureReadingsCelsius
srichn28334438b2022-09-21 08:41:25 -0500290
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600291
srichn28334438b2022-09-21 08:41:25 -0500292 # Example of Baseboard temperature via Redfish
293
294 # "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics",
295 # "@odata.type": "#ThermalMetrics.v1_0_0.ThermalMetrics",
296 # "Id": "ThermalMetrics",
297 # "Name": "Chassis Thermal Metrics",
298 # "TemperatureReadingsCelsius": [
299 # {
300 # "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp",
301 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp",
302 # "DeviceName": "PCIE_0_Temp",
303 # "Reading": 23.75
304 # },
305
306 ${redfish_value_dict}= Create Dictionary
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600307 FOR ${data} IN @{redfish_readings}
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600308 ${keys}= Get Dictionary Keys ${data}
srichn28334438b2022-09-21 08:41:25 -0500309 ${reading}= Set Variable ${data}[Reading]
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600310 ${is_device_name_present}= Evaluate "DeviceName" in @{keys}
311 IF ${is_device_name_present}
312 ${contains}= Evaluate "${member_id}" in """${data}[DeviceName]"""
313 Run Keyword IF "${contains}" == "True"
314 ... Set To Dictionary ${redfish_value_dict} ${data}[DeviceName] ${reading}
315 ELSE
316 ${data_source_id}= Evaluate ("${data}[DataSourceUri]").split('temperature_')
317 # Example format:
318 #
319 # {
320 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_dimm17_dram_temp",
321 # "Reading": 32.0
322 # }
323 ${contains}= Evaluate "${member_id}" in "${data_source_id[1]}"
324 IF ${contains}
325 Set To Dictionary ${redfish_value_dict} ${data_source_id[1]} ${reading}
326 END
327 END
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600328 END
srichn28334438b2022-09-21 08:41:25 -0500329
George Keishing409df052024-01-17 22:36:14 +0530330 RETURN ${redfish_value_dict}
Sushma M Md4d13f02020-02-13 03:42:41 -0600331
332
333Verify Power Reading Using IPMI And Redfish
334 [Documentation] Verify power reading using IPMI and Redfish.
335
336 # Example of power reading command output via IPMI.
337 # Instantaneous power reading: 235 Watts
338 # Minimum during sampling period: 235 Watts
339 # Maximum during sampling period: 235 Watts
340 # Average power reading over sample period: 235 Watts
341 # IPMI timestamp: Thu Jan 1 00:00:00 1970
342 # Sampling period: 00000000 Seconds.
343 # Power reading state is: deactivated
344
345 ${ipmi_reading}= Get IPMI Power Reading
Rahul Maheshwaria3692b62022-11-23 03:20:02 -0600346 ${redfish_power_reading}= redfish_utils.Get Attribute
Nandish-Matti77367ad2023-04-05 02:29:12 -0500347 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors/power_total_power Reading
Sushma M Md4d13f02020-02-13 03:42:41 -0600348
Rahul Maheshwaria3692b62022-11-23 03:20:02 -0600349 ${ipmi_redfish_power_diff}=
350 ... Evaluate abs(${redfish_power_reading} - ${ipmi_reading['instantaneous_power_reading']})
351 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
352 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
Sushma M Mfd2f4282020-03-18 04:12:47 -0500353
354
355Verify Power Reading Via Raw Command
356 [Documentation] Get dcmi power reading via IPMI raw command.
357
358 ${ipmi_raw_output}= Run IPMI Standard Command
359 ... raw ${IPMI_RAW_CMD['power_reading']['Get'][0]}
360
361 ${power_reading_ipmi}= Set Variable ${ipmi_raw_output.split()[1]}
362 ${power_reading_ipmi}=
363 ... Convert To Integer 0x${power_reading_ipmi}
364
365 # Example of power reading via Redfish
366 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0",
367 # "@odata.type": "#Power.v1_0_0.PowerControl",
368 # "MemberId": "0",
369 # "Name": "Chassis Power Control",
370 # "PowerConsumedWatts": 145.0,
371
Jorge Cisneros187f1772022-08-22 14:03:08 +0000372 ${power}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}/Power
Sushma M Mfd2f4282020-03-18 04:12:47 -0500373 ${redfish_reading}= Set Variable ${power['PowerControl'][0]['PowerConsumedWatts']}
374
375 ${ipmi_redfish_power_diff}=
376 ... Evaluate abs(${redfish_reading} - ${power_reading_ipmi})
377
378 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
Sushma M M89882ce2020-03-31 17:21:37 -0500379 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
380
381
srichn284c7d4462022-08-22 03:40:49 -0500382Set Present Bit Via IPMI and Verify Using Redfish
383 [Documentation] Set present bit of sensor via IPMI and verify using Redfish.
384 [Arguments] ${component} ${status}
Sushma M M89882ce2020-03-31 17:21:37 -0500385
386 # Description of argument(s):
Sushma M M89882ce2020-03-31 17:21:37 -0500387 # component The Redfish component of IPMI sensor.
srichn284c7d4462022-08-22 03:40:49 -0500388 # status Status of the bit to be set(e.g. Absent, Present).
Sushma M M89882ce2020-03-31 17:21:37 -0500389
srichn284c7d4462022-08-22 03:40:49 -0500390 ${sensor_list}= Get Available Sensors ${component}
391 ${sensor_name}= Set Variable ${sensor_list[0]}
392 ${sensor_id}= Get Sensor Id For Sensor ${sensor_name}
Sushma M M89882ce2020-03-31 17:21:37 -0500393
srichn284c7d4462022-08-22 03:40:49 -0500394 Run Keyword If '${status}' == 'Absent'
395 ... Run IPMI Command
396 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x00 0x00 0x80 0x00 0x00 0x20 0x00
397 ... ELSE IF '${status}' == 'Enabled'
398 ... Run IPMI Command
399 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x80 0x00 0x00 0x00 0x00 0x20 0x00
Sushma M Mc4cabd52020-04-08 09:32:37 -0500400
srichn284c7d4462022-08-22 03:40:49 -0500401 # Redfish cpu components have "-" instead of "_" (e.g.: dcm0-cpu0).
402 ${cpu_name}= Replace String ${sensor_name} _ -
Yi Huc32434a2024-01-11 17:33:10 -0800403 ${sensor_properties}= Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/Processors/${cpu_name}
Sushma M M89882ce2020-03-31 17:21:37 -0500404
srichn284c7d4462022-08-22 03:40:49 -0500405 # Example of CPU state via Redfish
George Keishing52eb7c22022-03-11 10:58:53 -0600406
srichn284c7d4462022-08-22 03:40:49 -0500407 # "ProcessorType": "CPU",
408 # "SerialNumber": "YA1936422499",
409 # "Socket": "",
410 # "SparePartNumber": "F210110",
411 # "Status": {
412 # "Health": "OK",
413 # "State": "Absent"
414 # }
Sushma M M89882ce2020-03-31 17:21:37 -0500415
srichn284c7d4462022-08-22 03:40:49 -0500416 Should Be True '${sensor_properties['Status']['State']}' == '${status}'
Sushma M Mc69a3d32020-06-10 18:13:08 -0500417
418
419Verify Power Supply Sensor Threshold
420 [Documentation] Get power supply sensor threshold value via IPMI and verify using Redfish.
421 [Arguments] ${ipmi_threshold_id} ${redfish_threshold_id}
422
423 # Description of argument(s):
424 # ipmi_threshold_id The sensor threshold component of IPMI sensor.
425 # redfish_threshold_id The sensor threshold component of Redfish sensor.
426
427
428 # Example of ipmi sensor output
429 # Locating sensor record...
430 # Sensor ID : ps0_input_voltag (0xf7)
431 # Entity ID : 10.19
432 # Sensor Type (Threshold) : Voltage
433 # Sensor Reading : 208 (+/- 0) Volts
434 # Status : ok
435 # Lower Non-Recoverable : na
436 # Lower Critical : 180.000
437 # Lower Non-Critical : 200.000
438 # Upper Non-Critical : 290.000
439 # Upper Critical : 300.000
440 # Upper Non-Recoverable : na
441 # Positive Hysteresis : Unspecified
442 # Negative Hysteresis : Unspecified
443
444
445 ${ipmi_sensor_output}= Run External IPMI Standard Command sensor get ps0_input_voltag
446 ${ipmi_threshold_output}= Get Lines Containing String ${ipmi_sensor_output} ${ipmi_threshold_id}
447 ${ipmi_threshold_reading}= Fetch From Right ${ipmi_threshold_output} :${SPACE}
448
449 ${ipmi_threshold_reading}= Set Variable If '${ipmi_threshold_reading}' == 'na'
450 ... ${0} ${ipmi_threshold_reading}
451
452 # Example of redfish sensor output
453 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/Voltages/0",
454 # "@odata.type": "#Power.v1_0_0.Voltage",
455 # "LowerThresholdCritical": 180.0,
456 # "LowerThresholdNonCritical": 200.0,
457 # "MaxReadingRange": 0.0,
458 # "MemberId": "ps0_input_voltage",
459 # "MinReadingRange": 0.0,
460 # "Name": "ps0 input voltage",
461 # "ReadingVolts": 209.5,
462 # "Status": {
463 # "Health": "OK",
464 # "State": "Enabled"
465 # },
466 # "UpperThresholdCritical": 300.0,
467 # "UpperThresholdNonCritical": 290.0
468
Jorge Cisneros187f1772022-08-22 14:03:08 +0000469 @{redfish_readings}= Redfish.Get Attribute /redfish/v1/Chassis/${CHASSIS_ID}/Power Voltages
Sushma M Mc69a3d32020-06-10 18:13:08 -0500470 FOR ${data} IN @{redfish_readings}
471 Run keyword if '${data}[MemberId]' == 'ps0_input_voltage'
472 ... Should Be Equal As Numbers ${data['${redfish_threshold_id}']} ${ipmi_threshold_reading}
473 END
srichn28a9df5402022-08-17 07:44:11 -0500474
475
476Get Available Sensors
477 [Documentation] Get all the available sensors for the required component.
478 ... Returns a list of available sensors.
479 [Arguments] ${sensor_component}
480
481 # Description of argument(s):
482 # sensor_component sensor component name.(e.g.:cpu)
483
484 ${resp}= Run IPMI Standard Command sdr elist
485 ${sensor_list}= Create List
srichn2873d8bbe2022-10-27 11:51:55 -0500486 ${sensors}= Get Lines Containing String ${resp} ${sensor_component} case-insensitive
srichn28a9df5402022-08-17 07:44:11 -0500487 ${sensors}= Split To Lines ${sensors}
488
489 # Example of IPMI sdr elist command.
490
491 # dcm0_cpu0 | 41h | ok | 3.1 | Presence detected
492 # dcm0_cpu1 | 42h | ok | 3.2 | Presence detected, Disabled
493 # dcm1_cpu0 | 43h | ok | 3.3 | Presence detected
494 # dcm1_cpu1 | 44h | ok | 3.4 | Presence detected, Disabled
495 # dcm2_cpu0 | 45h | ns | 3.5 | Disabled
496 # dcm2_cpu1 | 46h | ns | 3.6 | Disabled
497 # dcm3_cpu0 | 47h | ns | 3.7 | Disabled
498 # dcm3_cpu1 | 48h | ns | 3.8 | Disabled
499
500 FOR ${line} IN @{sensors}
501 ${sensor_name}= Set Variable ${line.split('|')[0].strip()}
502
503 # Adding sensors to the list whose presence is detected.
srichn2873d8bbe2022-10-27 11:51:55 -0500504 ${contains}= Evaluate "Presence detected" in "${line}" or "ok" in "${line}"
srichn28a9df5402022-08-17 07:44:11 -0500505 Run Keyword IF "${contains}" == "True"
506 ... Append To List ${sensor_list} ${sensor_name}
507 END
508
509 # Example of output for ${sensor_list}
510 # ['dcm0_cpu0', 'dcm0_cpu1', 'dcm1_cpu0', 'dcm1_cpu1']
511
George Keishing409df052024-01-17 22:36:14 +0530512 RETURN ${sensor_list}
srichn28a9df5402022-08-17 07:44:11 -0500513
514
515Get Sensor Id For Sensor
516 [Documentation] Returns the sensor ID value for the given sensor.
517 [Arguments] ${sensor_name}
518
519 # Description of argument(s):
520 # sensor_name Name of sensor whose ID is required(e.g.: dcm0_cpu0, dcm0_cpu1 etc).
521
522 ${get_resp}= Run IPMI Standard Command sensor get ${sensor_name}
523
524 # Example of sensor get command.
525
526 # Locating sensor record...
527 # Sensor ID : dcm0_cpu0 (0x41)
528 # Entity ID : 3.1
529 # Sensor Type (Discrete): Processor
530 # States Asserted : Processor
531 # [Presence detected]
532
533 ${line}= Get Lines Containing String ${get_resp} Sensor ID
534 ${sensor_id}= Set Variable ${line[-5:-1]}
535
536 # Example of output for ${sensor_id} is 0x41.
537
George Keishing409df052024-01-17 22:36:14 +0530538 RETURN ${sensor_id}
srichn28a9df5402022-08-17 07:44:11 -0500539