blob: 566d7a96c30ee654b533282fb582d93a2af3ad94 [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
George Keishing0628c4f2025-06-24 23:58:47 +0530273 IF "${contains}" != """True"""
274 Set To Dictionary ${sensor_value_dict} ${sensor_key} ${sensor_value}
275 END
srichn2873d8bbe2022-10-27 11:51:55 -0500276 END
277
George Keishing409df052024-01-17 22:36:14 +0530278 RETURN ${sensor_value_dict}
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600279
280
281Get Temperature Reading From Redfish
282 [Documentation] Get temperature reading from Redfish.
283 [Arguments] ${member_id}
284
285 # Description of argument(s):
286 # member_id Member id of temperature.
287
srichn28334438b2022-09-21 08:41:25 -0500288 @{thermal_uri}= redfish_utils.Get Member List /redfish/v1/Chassis/
George Keishinga91601b2023-03-21 09:35:49 +0530289 @{redfish_readings}= redfish_utils.Get Attribute
290 ... ${thermal_uri[0]}/${THERMAL_METRICS} TemperatureReadingsCelsius
srichn28334438b2022-09-21 08:41:25 -0500291
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600292
srichn28334438b2022-09-21 08:41:25 -0500293 # Example of Baseboard temperature via Redfish
294
295 # "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics",
296 # "@odata.type": "#ThermalMetrics.v1_0_0.ThermalMetrics",
297 # "Id": "ThermalMetrics",
298 # "Name": "Chassis Thermal Metrics",
299 # "TemperatureReadingsCelsius": [
300 # {
301 # "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp",
302 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp",
303 # "DeviceName": "PCIE_0_Temp",
304 # "Reading": 23.75
305 # },
306
307 ${redfish_value_dict}= Create Dictionary
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600308 FOR ${data} IN @{redfish_readings}
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600309 ${keys}= Get Dictionary Keys ${data}
srichn28334438b2022-09-21 08:41:25 -0500310 ${reading}= Set Variable ${data}[Reading]
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600311 ${is_device_name_present}= Evaluate "DeviceName" in @{keys}
312 IF ${is_device_name_present}
313 ${contains}= Evaluate "${member_id}" in """${data}[DeviceName]"""
George Keishing0628c4f2025-06-24 23:58:47 +0530314 IF "${contains}" == "True"
315 Set To Dictionary ${redfish_value_dict} ${data}[DeviceName] ${reading}
316 END
Sridevi Ramesh138a9cb2025-02-03 23:55:26 -0600317 ELSE
318 ${data_source_id}= Evaluate ("${data}[DataSourceUri]").split('temperature_')
319 # Example format:
320 #
321 # {
322 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_dimm17_dram_temp",
323 # "Reading": 32.0
324 # }
325 ${contains}= Evaluate "${member_id}" in "${data_source_id[1]}"
326 IF ${contains}
327 Set To Dictionary ${redfish_value_dict} ${data_source_id[1]} ${reading}
328 END
329 END
Anusha Dathatri88ccaff2020-02-07 05:17:53 -0600330 END
srichn28334438b2022-09-21 08:41:25 -0500331
George Keishing409df052024-01-17 22:36:14 +0530332 RETURN ${redfish_value_dict}
Sushma M Md4d13f02020-02-13 03:42:41 -0600333
334
335Verify Power Reading Using IPMI And Redfish
336 [Documentation] Verify power reading using IPMI and Redfish.
337
338 # Example of power reading command output via IPMI.
339 # Instantaneous power reading: 235 Watts
340 # Minimum during sampling period: 235 Watts
341 # Maximum during sampling period: 235 Watts
342 # Average power reading over sample period: 235 Watts
343 # IPMI timestamp: Thu Jan 1 00:00:00 1970
344 # Sampling period: 00000000 Seconds.
345 # Power reading state is: deactivated
346
347 ${ipmi_reading}= Get IPMI Power Reading
Rahul Maheshwaria3692b62022-11-23 03:20:02 -0600348 ${redfish_power_reading}= redfish_utils.Get Attribute
Nandish-Matti77367ad2023-04-05 02:29:12 -0500349 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors/power_total_power Reading
Sushma M Md4d13f02020-02-13 03:42:41 -0600350
Rahul Maheshwaria3692b62022-11-23 03:20:02 -0600351 ${ipmi_redfish_power_diff}=
352 ... Evaluate abs(${redfish_power_reading} - ${ipmi_reading['instantaneous_power_reading']})
353 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
354 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
Sushma M Mfd2f4282020-03-18 04:12:47 -0500355
356
357Verify Power Reading Via Raw Command
358 [Documentation] Get dcmi power reading via IPMI raw command.
359
360 ${ipmi_raw_output}= Run IPMI Standard Command
361 ... raw ${IPMI_RAW_CMD['power_reading']['Get'][0]}
362
363 ${power_reading_ipmi}= Set Variable ${ipmi_raw_output.split()[1]}
364 ${power_reading_ipmi}=
365 ... Convert To Integer 0x${power_reading_ipmi}
366
367 # Example of power reading via Redfish
368 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0",
369 # "@odata.type": "#Power.v1_0_0.PowerControl",
370 # "MemberId": "0",
371 # "Name": "Chassis Power Control",
372 # "PowerConsumedWatts": 145.0,
373
Jorge Cisneros187f1772022-08-22 14:03:08 +0000374 ${power}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}/Power
Sushma M Mfd2f4282020-03-18 04:12:47 -0500375 ${redfish_reading}= Set Variable ${power['PowerControl'][0]['PowerConsumedWatts']}
376
377 ${ipmi_redfish_power_diff}=
378 ... Evaluate abs(${redfish_reading} - ${power_reading_ipmi})
379
380 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
Sushma M M89882ce2020-03-31 17:21:37 -0500381 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
382
383
srichn284c7d4462022-08-22 03:40:49 -0500384Set Present Bit Via IPMI and Verify Using Redfish
385 [Documentation] Set present bit of sensor via IPMI and verify using Redfish.
386 [Arguments] ${component} ${status}
Sushma M M89882ce2020-03-31 17:21:37 -0500387
388 # Description of argument(s):
Sushma M M89882ce2020-03-31 17:21:37 -0500389 # component The Redfish component of IPMI sensor.
srichn284c7d4462022-08-22 03:40:49 -0500390 # status Status of the bit to be set(e.g. Absent, Present).
Sushma M M89882ce2020-03-31 17:21:37 -0500391
srichn284c7d4462022-08-22 03:40:49 -0500392 ${sensor_list}= Get Available Sensors ${component}
393 ${sensor_name}= Set Variable ${sensor_list[0]}
394 ${sensor_id}= Get Sensor Id For Sensor ${sensor_name}
Sushma M M89882ce2020-03-31 17:21:37 -0500395
George Keishing3a15f822025-06-17 22:17:48 +0530396 IF '${status}' == 'Absent'
397 Run IPMI Command
398 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x00 0x00 0x80 0x00 0x00 0x20 0x00
399 ELSE IF '${status}' == 'Enabled'
400 Run IPMI Command
401 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x80 0x00 0x00 0x00 0x00 0x20 0x00
402 END
Sushma M Mc4cabd52020-04-08 09:32:37 -0500403
srichn284c7d4462022-08-22 03:40:49 -0500404 # Redfish cpu components have "-" instead of "_" (e.g.: dcm0-cpu0).
405 ${cpu_name}= Replace String ${sensor_name} _ -
Yi Huc32434a2024-01-11 17:33:10 -0800406 ${sensor_properties}= Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/Processors/${cpu_name}
Sushma M M89882ce2020-03-31 17:21:37 -0500407
srichn284c7d4462022-08-22 03:40:49 -0500408 # Example of CPU state via Redfish
George Keishing52eb7c22022-03-11 10:58:53 -0600409
srichn284c7d4462022-08-22 03:40:49 -0500410 # "ProcessorType": "CPU",
411 # "SerialNumber": "YA1936422499",
412 # "Socket": "",
413 # "SparePartNumber": "F210110",
414 # "Status": {
415 # "Health": "OK",
416 # "State": "Absent"
417 # }
Sushma M M89882ce2020-03-31 17:21:37 -0500418
srichn284c7d4462022-08-22 03:40:49 -0500419 Should Be True '${sensor_properties['Status']['State']}' == '${status}'
Sushma M Mc69a3d32020-06-10 18:13:08 -0500420
421
422Verify Power Supply Sensor Threshold
423 [Documentation] Get power supply sensor threshold value via IPMI and verify using Redfish.
424 [Arguments] ${ipmi_threshold_id} ${redfish_threshold_id}
425
426 # Description of argument(s):
427 # ipmi_threshold_id The sensor threshold component of IPMI sensor.
428 # redfish_threshold_id The sensor threshold component of Redfish sensor.
429
430
431 # Example of ipmi sensor output
432 # Locating sensor record...
433 # Sensor ID : ps0_input_voltag (0xf7)
434 # Entity ID : 10.19
435 # Sensor Type (Threshold) : Voltage
436 # Sensor Reading : 208 (+/- 0) Volts
437 # Status : ok
438 # Lower Non-Recoverable : na
439 # Lower Critical : 180.000
440 # Lower Non-Critical : 200.000
441 # Upper Non-Critical : 290.000
442 # Upper Critical : 300.000
443 # Upper Non-Recoverable : na
444 # Positive Hysteresis : Unspecified
445 # Negative Hysteresis : Unspecified
446
447
448 ${ipmi_sensor_output}= Run External IPMI Standard Command sensor get ps0_input_voltag
449 ${ipmi_threshold_output}= Get Lines Containing String ${ipmi_sensor_output} ${ipmi_threshold_id}
450 ${ipmi_threshold_reading}= Fetch From Right ${ipmi_threshold_output} :${SPACE}
451
452 ${ipmi_threshold_reading}= Set Variable If '${ipmi_threshold_reading}' == 'na'
453 ... ${0} ${ipmi_threshold_reading}
454
455 # Example of redfish sensor output
456 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/Voltages/0",
457 # "@odata.type": "#Power.v1_0_0.Voltage",
458 # "LowerThresholdCritical": 180.0,
459 # "LowerThresholdNonCritical": 200.0,
460 # "MaxReadingRange": 0.0,
461 # "MemberId": "ps0_input_voltage",
462 # "MinReadingRange": 0.0,
463 # "Name": "ps0 input voltage",
464 # "ReadingVolts": 209.5,
465 # "Status": {
466 # "Health": "OK",
467 # "State": "Enabled"
468 # },
469 # "UpperThresholdCritical": 300.0,
470 # "UpperThresholdNonCritical": 290.0
471
Jorge Cisneros187f1772022-08-22 14:03:08 +0000472 @{redfish_readings}= Redfish.Get Attribute /redfish/v1/Chassis/${CHASSIS_ID}/Power Voltages
Sushma M Mc69a3d32020-06-10 18:13:08 -0500473 FOR ${data} IN @{redfish_readings}
George Keishing0628c4f2025-06-24 23:58:47 +0530474 IF '${data}[MemberId]' == 'ps0_input_voltage'
475 Should Be Equal As Numbers ${data['${redfish_threshold_id}']} ${ipmi_threshold_reading}
476 END
Sushma M Mc69a3d32020-06-10 18:13:08 -0500477 END
srichn28a9df5402022-08-17 07:44:11 -0500478
479
480Get Available Sensors
481 [Documentation] Get all the available sensors for the required component.
482 ... Returns a list of available sensors.
483 [Arguments] ${sensor_component}
484
485 # Description of argument(s):
486 # sensor_component sensor component name.(e.g.:cpu)
487
488 ${resp}= Run IPMI Standard Command sdr elist
489 ${sensor_list}= Create List
srichn2873d8bbe2022-10-27 11:51:55 -0500490 ${sensors}= Get Lines Containing String ${resp} ${sensor_component} case-insensitive
srichn28a9df5402022-08-17 07:44:11 -0500491 ${sensors}= Split To Lines ${sensors}
492
493 # Example of IPMI sdr elist command.
494
495 # dcm0_cpu0 | 41h | ok | 3.1 | Presence detected
496 # dcm0_cpu1 | 42h | ok | 3.2 | Presence detected, Disabled
497 # dcm1_cpu0 | 43h | ok | 3.3 | Presence detected
498 # dcm1_cpu1 | 44h | ok | 3.4 | Presence detected, Disabled
499 # dcm2_cpu0 | 45h | ns | 3.5 | Disabled
500 # dcm2_cpu1 | 46h | ns | 3.6 | Disabled
501 # dcm3_cpu0 | 47h | ns | 3.7 | Disabled
502 # dcm3_cpu1 | 48h | ns | 3.8 | Disabled
503
504 FOR ${line} IN @{sensors}
505 ${sensor_name}= Set Variable ${line.split('|')[0].strip()}
506
507 # Adding sensors to the list whose presence is detected.
srichn2873d8bbe2022-10-27 11:51:55 -0500508 ${contains}= Evaluate "Presence detected" in "${line}" or "ok" in "${line}"
George Keishing0628c4f2025-06-24 23:58:47 +0530509 IF "${contains}" == "True"
510 Append To List ${sensor_list} ${sensor_name}
511 END
srichn28a9df5402022-08-17 07:44:11 -0500512 END
513
514 # Example of output for ${sensor_list}
515 # ['dcm0_cpu0', 'dcm0_cpu1', 'dcm1_cpu0', 'dcm1_cpu1']
516
George Keishing409df052024-01-17 22:36:14 +0530517 RETURN ${sensor_list}
srichn28a9df5402022-08-17 07:44:11 -0500518
519
520Get Sensor Id For Sensor
521 [Documentation] Returns the sensor ID value for the given sensor.
522 [Arguments] ${sensor_name}
523
524 # Description of argument(s):
525 # sensor_name Name of sensor whose ID is required(e.g.: dcm0_cpu0, dcm0_cpu1 etc).
526
527 ${get_resp}= Run IPMI Standard Command sensor get ${sensor_name}
528
529 # Example of sensor get command.
530
531 # Locating sensor record...
532 # Sensor ID : dcm0_cpu0 (0x41)
533 # Entity ID : 3.1
534 # Sensor Type (Discrete): Processor
535 # States Asserted : Processor
536 # [Presence detected]
537
538 ${line}= Get Lines Containing String ${get_resp} Sensor ID
539 ${sensor_id}= Set Variable ${line[-5:-1]}
540
541 # Example of output for ${sensor_id} is 0x41.
542
George Keishing409df052024-01-17 22:36:14 +0530543 RETURN ${sensor_id}
srichn28a9df5402022-08-17 07:44:11 -0500544