1*** Settings *** 2Documentation Validate IPMI sensor IDs using Redfish. 3 4Resource ../lib/ipmi_client.robot 5Resource ../lib/openbmc_ffdc.robot 6Resource ../lib/boot_utils.robot 7Library ../lib/ipmi_utils.py 8Variables ../data/ipmi_raw_cmd_table.py 9 10Test Setup Redfish.Login 11Test Teardown Run Keywords FFDC On Test Case Fail AND 12... Redfish.Logout 13 14Test Tags IPMI_Sensor 15 16*** Variables *** 17 18${allowed_temp_diff} ${2} 19${allowed_power_diff} ${10} 20 21 22*** Test Cases *** 23Verify 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 29 IPMI PCIE PCIE 30 IPMI Ambient Ambient 31 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 39 DCMI PCIE PCIE 40 DCMI Ambient Ambient 41 42 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 49 # 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 55 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 64 ${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} 71 72 # 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}]}) 78 79 Should Be True ${ipmi_redfish_temp_diff} <= ${allowed_temp_diff} 80 ... msg=Ambient temperature above allowed threshold ${allowed_temp_diff}. 81 END 82 83 84Test 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 106Test 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 112 # 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 118 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". 122 ${baseboard_temp_lines}= 123 ... Get Lines Containing String ${temp_reading} 124 ... Baseboard temperature case-insensitive=True 125 ${lines}= Split To Lines ${baseboard_temp_lines} 126 127 ${ipmi_temp_list}= Create List 128 FOR ${line} IN @{lines} 129 ${baseboard_temp_ipmi}= Set Variable ${line.split('+')[1].strip(' C')} 130 Append To List ${ipmi_temp_list} ${baseboard_temp_ipmi} 131 END 132 ${list_length}= Get Length ${ipmi_temp_list} 133 134 # 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 137 138 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 144 145Test 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 155Verify CPU Present 156 [Documentation] Verify the IPMI sensor for CPU present using Redfish. 157 [Tags] Verify_CPU_Present 158 [Template] Set Present Bit Via IPMI and Verify Using Redfish 159 160 # component state 161 cpu Enabled 162 163 164Verify CPU Not Present 165 [Documentation] Verify the IPMI sensor for CPU not present using Redfish. 166 [Tags] Verify_CPU_Not_Present 167 [Template] Set Present Bit Via IPMI and Verify Using Redfish 168 169 # component state 170 cpu Absent 171 172 173Verify GPU Present 174 [Documentation] Verify the IPMI sensor for GPU present using Redfish. 175 [Tags] Verify_GPU_Present 176 [Template] Set Present Bit Via IPMI and Verify Using Redfish 177 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 185 [Template] Set Present Bit Via IPMI and Verify Using Redfish 186 187 # sensor_id component 188 0xC5 gv100card0 189 190 191Test 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 203*** 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 219 ${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 225 226 227Get IPMI Sensor Reading 228 [Documentation] Get IPMI sensor readings as a dictionary. 229 [Arguments] ${sensor_id} 230 231 # Description of argument(s): 232 # sensor_id Sensor id used to get reading in IPMI. 233 234 ${sensor_list}= Get Available Sensors ${sensor_id} 235 ${sensor_value_dict}= Create Dictionary 236 237 FOR ${ids} IN @{sensor_list} 238 ${data}= Run IPMI Standard Command sensor reading ${ids} 239 240 # 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 248 RETURN ${sensor_value_dict} 249 250 251Get DCMI Sensor Reading 252 [Documentation] Get DCMI sensor readings as a dictionary. 253 [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 259 ${sensor_data}= Get Lines Containing String ${data} ${sensor_id} case_insensitive 260 ${sensor_lines}= Split To Lines ${sensor_data} 261 262 # Example reading: 263 # Record ID 0x005c: PCIE_0_Temp | 27 degrees C | ok 264 265 ${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 277 RETURN ${sensor_value_dict} 278 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 287 @{thermal_uri}= redfish_utils.Get Member List /redfish/v1/Chassis/ 288 @{redfish_readings}= redfish_utils.Get Attribute 289 ... ${thermal_uri[0]}/${THERMAL_METRICS} TemperatureReadingsCelsius 290 291 292 # 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 307 FOR ${data} IN @{redfish_readings} 308 ${keys}= Get Dictionary Keys ${data} 309 ${reading}= Set Variable ${data}[Reading] 310 ${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 328 END 329 330 RETURN ${redfish_value_dict} 331 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 346 ${redfish_power_reading}= redfish_utils.Get Attribute 347 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors/power_total_power Reading 348 349 ${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}. 353 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 372 ${power}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}/Power 373 ${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} 379 ... msg=Power reading above allowed threshold ${allowed_power_diff}. 380 381 382Set 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} 385 386 # Description of argument(s): 387 # component The Redfish component of IPMI sensor. 388 # status Status of the bit to be set(e.g. Absent, Present). 389 390 ${sensor_list}= Get Available Sensors ${component} 391 ${sensor_name}= Set Variable ${sensor_list[0]} 392 ${sensor_id}= Get Sensor Id For Sensor ${sensor_name} 393 394 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 400 END 401 402 # Redfish cpu components have "-" instead of "_" (e.g.: dcm0-cpu0). 403 ${cpu_name}= Replace String ${sensor_name} _ - 404 ${sensor_properties}= Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/Processors/${cpu_name} 405 406 # Example of CPU state via Redfish 407 408 # "ProcessorType": "CPU", 409 # "SerialNumber": "YA1936422499", 410 # "Socket": "", 411 # "SparePartNumber": "F210110", 412 # "Status": { 413 # "Health": "OK", 414 # "State": "Absent" 415 # } 416 417 Should Be True '${sensor_properties['Status']['State']}' == '${status}' 418 419 420Verify Power Supply Sensor Threshold 421 [Documentation] Get power supply sensor threshold value via IPMI and verify using Redfish. 422 [Arguments] ${ipmi_threshold_id} ${redfish_threshold_id} 423 424 # Description of argument(s): 425 # ipmi_threshold_id The sensor threshold component of IPMI sensor. 426 # redfish_threshold_id The sensor threshold component of Redfish sensor. 427 428 429 # Example of ipmi sensor output 430 # Locating sensor record... 431 # Sensor ID : ps0_input_voltag (0xf7) 432 # Entity ID : 10.19 433 # Sensor Type (Threshold) : Voltage 434 # Sensor Reading : 208 (+/- 0) Volts 435 # Status : ok 436 # Lower Non-Recoverable : na 437 # Lower Critical : 180.000 438 # Lower Non-Critical : 200.000 439 # Upper Non-Critical : 290.000 440 # Upper Critical : 300.000 441 # Upper Non-Recoverable : na 442 # Positive Hysteresis : Unspecified 443 # Negative Hysteresis : Unspecified 444 445 446 ${ipmi_sensor_output}= Run External IPMI Standard Command sensor get ps0_input_voltag 447 ${ipmi_threshold_output}= Get Lines Containing String ${ipmi_sensor_output} ${ipmi_threshold_id} 448 ${ipmi_threshold_reading}= Fetch From Right ${ipmi_threshold_output} :${SPACE} 449 450 ${ipmi_threshold_reading}= Set Variable If '${ipmi_threshold_reading}' == 'na' 451 ... ${0} ${ipmi_threshold_reading} 452 453 # Example of redfish sensor output 454 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/Voltages/0", 455 # "@odata.type": "#Power.v1_0_0.Voltage", 456 # "LowerThresholdCritical": 180.0, 457 # "LowerThresholdNonCritical": 200.0, 458 # "MaxReadingRange": 0.0, 459 # "MemberId": "ps0_input_voltage", 460 # "MinReadingRange": 0.0, 461 # "Name": "ps0 input voltage", 462 # "ReadingVolts": 209.5, 463 # "Status": { 464 # "Health": "OK", 465 # "State": "Enabled" 466 # }, 467 # "UpperThresholdCritical": 300.0, 468 # "UpperThresholdNonCritical": 290.0 469 470 @{redfish_readings}= Redfish.Get Attribute /redfish/v1/Chassis/${CHASSIS_ID}/Power Voltages 471 FOR ${data} IN @{redfish_readings} 472 Run keyword if '${data}[MemberId]' == 'ps0_input_voltage' 473 ... Should Be Equal As Numbers ${data['${redfish_threshold_id}']} ${ipmi_threshold_reading} 474 END 475 476 477Get Available Sensors 478 [Documentation] Get all the available sensors for the required component. 479 ... Returns a list of available sensors. 480 [Arguments] ${sensor_component} 481 482 # Description of argument(s): 483 # sensor_component sensor component name.(e.g.:cpu) 484 485 ${resp}= Run IPMI Standard Command sdr elist 486 ${sensor_list}= Create List 487 ${sensors}= Get Lines Containing String ${resp} ${sensor_component} case-insensitive 488 ${sensors}= Split To Lines ${sensors} 489 490 # Example of IPMI sdr elist command. 491 492 # dcm0_cpu0 | 41h | ok | 3.1 | Presence detected 493 # dcm0_cpu1 | 42h | ok | 3.2 | Presence detected, Disabled 494 # dcm1_cpu0 | 43h | ok | 3.3 | Presence detected 495 # dcm1_cpu1 | 44h | ok | 3.4 | Presence detected, Disabled 496 # dcm2_cpu0 | 45h | ns | 3.5 | Disabled 497 # dcm2_cpu1 | 46h | ns | 3.6 | Disabled 498 # dcm3_cpu0 | 47h | ns | 3.7 | Disabled 499 # dcm3_cpu1 | 48h | ns | 3.8 | Disabled 500 501 FOR ${line} IN @{sensors} 502 ${sensor_name}= Set Variable ${line.split('|')[0].strip()} 503 504 # Adding sensors to the list whose presence is detected. 505 ${contains}= Evaluate "Presence detected" in "${line}" or "ok" in "${line}" 506 Run Keyword IF "${contains}" == "True" 507 ... Append To List ${sensor_list} ${sensor_name} 508 END 509 510 # Example of output for ${sensor_list} 511 # ['dcm0_cpu0', 'dcm0_cpu1', 'dcm1_cpu0', 'dcm1_cpu1'] 512 513 RETURN ${sensor_list} 514 515 516Get Sensor Id For Sensor 517 [Documentation] Returns the sensor ID value for the given sensor. 518 [Arguments] ${sensor_name} 519 520 # Description of argument(s): 521 # sensor_name Name of sensor whose ID is required(e.g.: dcm0_cpu0, dcm0_cpu1 etc). 522 523 ${get_resp}= Run IPMI Standard Command sensor get ${sensor_name} 524 525 # Example of sensor get command. 526 527 # Locating sensor record... 528 # Sensor ID : dcm0_cpu0 (0x41) 529 # Entity ID : 3.1 530 # Sensor Type (Discrete): Processor 531 # States Asserted : Processor 532 # [Presence detected] 533 534 ${line}= Get Lines Containing String ${get_resp} Sensor ID 535 ${sensor_id}= Set Variable ${line[-5:-1]} 536 537 # Example of output for ${sensor_id} is 0x41. 538 539 RETURN ${sensor_id} 540 541