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 202Verify Get SDR Info With Invalid Data Length 203 [Documentation] Verify Get SDR Info With Invalid Data Length 204 [Tags] Verify_Get_SDR_Info_With_Invalid_Data_Length 205 [Template] Verify Invalid IPMI Command 206 207 # Invalid data length Expected error code 208 ${IPMI_RAW_CMD['SDR_Info']['get'][1]} 0xc7 209 ${IPMI_RAW_CMD['SDR_Info']['get'][2]} 0xc7 210 211*** Keywords *** 212 213Get Temperature Reading And Verify In Redfish 214 [Documentation] Get IPMI or DCMI sensor reading and verify in Redfish. 215 [Arguments] ${command_type} ${sensor_id} ${member_id} 216 217 # Description of argument(s): 218 # command_type Type of command used to get sensor data (eg. IPMI, DCMI). 219 # sensor_id Sensor id used to get reading in IPMI or DCMI. 220 # member_id Member id of sensor data in Redfish. 221 222 ${ipmi_value}= Set Variable If '${command_type}' == 'IPMI' Get IPMI Sensor Reading ${sensor_id} 223 ... ELSE Get DCMI Sensor Reading ${sensor_id} 224 225 ${redfish_value}= Get Temperature Reading From Redfish ${member_id} 226 227 ${keys}= Get Dictionary Keys ${ipmi_value} 228 FOR ${index} IN @{keys} 229 ${value_diff}= Evaluate abs(${redfish_value["${index}"]} - ${ipmi_value["${index}"]}) 230 Should Be True ${value_diff} <= ${allowed_temp_diff} 231 END 232 233 234 235Get IPMI Sensor Reading 236 [Documentation] Get IPMI sensor readings as a dictionary. 237 [Arguments] ${sensor_id} 238 239 # Description of argument(s): 240 # sensor_id Sensor id used to get reading in IPMI. 241 242 ${sensor_list}= Get Available Sensors ${sensor_id} 243 ${sensor_value_dict}= Create Dictionary 244 245 FOR ${ids} IN @{sensor_list} 246 ${data}= Run IPMI Standard Command sensor reading ${ids} 247 248 # Example reading: 249 # PCIE_0_Temp | 5Ch | ok | 41.1 | 27 degrees C 250 251 ${sensor_key}= Set Variable ${data.split('| ')[0].strip()} 252 ${sensor_value}= Set Variable ${data.split('| ')[1].strip()} 253 Set To Dictionary ${sensor_value_dict} ${sensor_key} ${sensor_value} 254 END 255 256 RETURN ${sensor_value_dict} 257 258 259Get DCMI Sensor Reading 260 [Documentation] Get DCMI sensor readings as a dictionary. 261 [Arguments] ${sensor_id} 262 263 # Description of argument(s): 264 # sensor_id Sensor id used to get reading in DCMI. 265 266 ${data}= Run IPMI Standard Command dcmi sensors 267 ${sensor_data}= Get Lines Containing String ${data} ${sensor_id} case_insensitive 268 ${sensor_lines}= Split To Lines ${sensor_data} 269 270 # Example reading: 271 # Record ID 0x005c: PCIE_0_Temp | 27 degrees C | ok 272 273 ${sensor_value_dict}= Create Dictionary 274 275 FOR ${line} IN @{sensor_lines} 276 ${sensor}= Set Variable ${line.split(' | ')} 277 ${sensor_key}= Set Variable ${sensor[0].split(':')[1].strip()} 278 ${sensor_value}= Set Variable ${sensor[1].split()[0].strip()} 279 ${contains}= Evaluate """disabled""" in "${sensor_value}" 280 281 IF "${contains}" != """True""" 282 Set To Dictionary ${sensor_value_dict} ${sensor_key} ${sensor_value} 283 END 284 END 285 286 RETURN ${sensor_value_dict} 287 288 289Get Temperature Reading From Redfish 290 [Documentation] Get temperature reading from Redfish. 291 [Arguments] ${member_id} 292 293 # Description of argument(s): 294 # member_id Member id of temperature. 295 296 @{thermal_uri}= redfish_utils.Get Member List /redfish/v1/Chassis/ 297 @{redfish_readings}= redfish_utils.Get Attribute 298 ... ${thermal_uri[0]}/${THERMAL_METRICS} TemperatureReadingsCelsius 299 300 301 # Example of Baseboard temperature via Redfish 302 303 # "@odata.id": "/redfish/v1/Chassis/chassis/ThermalSubsystem/ThermalMetrics", 304 # "@odata.type": "#ThermalMetrics.v1_0_0.ThermalMetrics", 305 # "Id": "ThermalMetrics", 306 # "Name": "Chassis Thermal Metrics", 307 # "TemperatureReadingsCelsius": [ 308 # { 309 # "@odata.id": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp", 310 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/PCIE_0_Temp", 311 # "DeviceName": "PCIE_0_Temp", 312 # "Reading": 23.75 313 # }, 314 315 ${redfish_value_dict}= Create Dictionary 316 FOR ${data} IN @{redfish_readings} 317 ${keys}= Get Dictionary Keys ${data} 318 ${reading}= Set Variable ${data}[Reading] 319 ${is_device_name_present}= Evaluate "DeviceName" in @{keys} 320 IF ${is_device_name_present} 321 ${contains}= Evaluate "${member_id}" in """${data}[DeviceName]""" 322 IF "${contains}" == "True" 323 Set To Dictionary ${redfish_value_dict} ${data}[DeviceName] ${reading} 324 END 325 ELSE 326 ${data_source_id}= Evaluate ("${data}[DataSourceUri]").split('temperature_') 327 # Example format: 328 # 329 # { 330 # "DataSourceUri": "/redfish/v1/Chassis/chassis/Sensors/temperature_dimm17_dram_temp", 331 # "Reading": 32.0 332 # } 333 ${contains}= Evaluate "${member_id}" in "${data_source_id[1]}" 334 IF ${contains} 335 Set To Dictionary ${redfish_value_dict} ${data_source_id[1]} ${reading} 336 END 337 END 338 END 339 340 RETURN ${redfish_value_dict} 341 342 343Verify Power Reading Using IPMI And Redfish 344 [Documentation] Verify power reading using IPMI and Redfish. 345 346 # Example of power reading command output via IPMI. 347 # Instantaneous power reading: 235 Watts 348 # Minimum during sampling period: 235 Watts 349 # Maximum during sampling period: 235 Watts 350 # Average power reading over sample period: 235 Watts 351 # IPMI timestamp: Thu Jan 1 00:00:00 1970 352 # Sampling period: 00000000 Seconds. 353 # Power reading state is: deactivated 354 355 ${ipmi_reading}= Get IPMI Power Reading 356 ${redfish_power_reading}= redfish_utils.Get Attribute 357 ... /redfish/v1/Chassis/${CHASSIS_ID}/Sensors/power_total_power Reading 358 359 ${ipmi_redfish_power_diff}= 360 ... Evaluate abs(${redfish_power_reading} - ${ipmi_reading['instantaneous_power_reading']}) 361 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff} 362 ... msg=Power reading above allowed threshold ${allowed_power_diff}. 363 364 365Verify Power Reading Via Raw Command 366 [Documentation] Get dcmi power reading via IPMI raw command. 367 368 ${ipmi_raw_output}= Run IPMI Standard Command 369 ... raw ${IPMI_RAW_CMD['power_reading']['Get'][0]} 370 371 ${power_reading_ipmi}= Set Variable ${ipmi_raw_output.split()[1]} 372 ${power_reading_ipmi}= 373 ... Convert To Integer 0x${power_reading_ipmi} 374 375 # Example of power reading via Redfish 376 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0", 377 # "@odata.type": "#Power.v1_0_0.PowerControl", 378 # "MemberId": "0", 379 # "Name": "Chassis Power Control", 380 # "PowerConsumedWatts": 145.0, 381 382 ${power}= Redfish.Get Properties /redfish/v1/Chassis/${CHASSIS_ID}/Power 383 ${redfish_reading}= Set Variable ${power['PowerControl'][0]['PowerConsumedWatts']} 384 385 ${ipmi_redfish_power_diff}= 386 ... Evaluate abs(${redfish_reading} - ${power_reading_ipmi}) 387 388 Should Be True ${ipmi_redfish_power_diff} <= ${allowed_power_diff} 389 ... msg=Power reading above allowed threshold ${allowed_power_diff}. 390 391 392Set Present Bit Via IPMI and Verify Using Redfish 393 [Documentation] Set present bit of sensor via IPMI and verify using Redfish. 394 [Arguments] ${component} ${status} 395 396 # Description of argument(s): 397 # component The Redfish component of IPMI sensor. 398 # status Status of the bit to be set(e.g. Absent, Present). 399 400 ${sensor_list}= Get Available Sensors ${component} 401 ${sensor_name}= Set Variable ${sensor_list[0]} 402 ${sensor_id}= Get Sensor Id For Sensor ${sensor_name} 403 404 IF '${status}' == 'Absent' 405 Run IPMI Command 406 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x00 0x00 0x80 0x00 0x00 0x20 0x00 407 ELSE IF '${status}' == 'Enabled' 408 Run IPMI Command 409 ... 0x04 0x30 ${sensor_id} 0xa9 0x00 0x80 0x00 0x00 0x00 0x00 0x20 0x00 410 END 411 412 # Redfish cpu components have "-" instead of "_" (e.g.: dcm0-cpu0). 413 ${cpu_name}= Replace String ${sensor_name} _ - 414 ${sensor_properties}= Redfish.Get Properties /redfish/v1/Systems/${SYSTEM_ID}/Processors/${cpu_name} 415 416 # Example of CPU state via Redfish 417 418 # "ProcessorType": "CPU", 419 # "SerialNumber": "YA1936422499", 420 # "Socket": "", 421 # "SparePartNumber": "F210110", 422 # "Status": { 423 # "Health": "OK", 424 # "State": "Absent" 425 # } 426 427 Should Be True '${sensor_properties['Status']['State']}' == '${status}' 428 429 430Verify Power Supply Sensor Threshold 431 [Documentation] Get power supply sensor threshold value via IPMI and verify using Redfish. 432 [Arguments] ${ipmi_threshold_id} ${redfish_threshold_id} 433 434 # Description of argument(s): 435 # ipmi_threshold_id The sensor threshold component of IPMI sensor. 436 # redfish_threshold_id The sensor threshold component of Redfish sensor. 437 438 439 # Example of ipmi sensor output 440 # Locating sensor record... 441 # Sensor ID : ps0_input_voltag (0xf7) 442 # Entity ID : 10.19 443 # Sensor Type (Threshold) : Voltage 444 # Sensor Reading : 208 (+/- 0) Volts 445 # Status : ok 446 # Lower Non-Recoverable : na 447 # Lower Critical : 180.000 448 # Lower Non-Critical : 200.000 449 # Upper Non-Critical : 290.000 450 # Upper Critical : 300.000 451 # Upper Non-Recoverable : na 452 # Positive Hysteresis : Unspecified 453 # Negative Hysteresis : Unspecified 454 455 456 ${ipmi_sensor_output}= Run External IPMI Standard Command sensor get ps0_input_voltag 457 ${ipmi_threshold_output}= Get Lines Containing String ${ipmi_sensor_output} ${ipmi_threshold_id} 458 ${ipmi_threshold_reading}= Fetch From Right ${ipmi_threshold_output} :${SPACE} 459 460 ${ipmi_threshold_reading}= Set Variable If '${ipmi_threshold_reading}' == 'na' 461 ... ${0} ${ipmi_threshold_reading} 462 463 # Example of redfish sensor output 464 # "@odata.id": "/redfish/v1/Chassis/chassis/Power#/Voltages/0", 465 # "@odata.type": "#Power.v1_0_0.Voltage", 466 # "LowerThresholdCritical": 180.0, 467 # "LowerThresholdNonCritical": 200.0, 468 # "MaxReadingRange": 0.0, 469 # "MemberId": "ps0_input_voltage", 470 # "MinReadingRange": 0.0, 471 # "Name": "ps0 input voltage", 472 # "ReadingVolts": 209.5, 473 # "Status": { 474 # "Health": "OK", 475 # "State": "Enabled" 476 # }, 477 # "UpperThresholdCritical": 300.0, 478 # "UpperThresholdNonCritical": 290.0 479 480 @{redfish_readings}= Redfish.Get Attribute /redfish/v1/Chassis/${CHASSIS_ID}/Power Voltages 481 FOR ${data} IN @{redfish_readings} 482 IF '${data}[MemberId]' == 'ps0_input_voltage' 483 Should Be Equal As Numbers ${data['${redfish_threshold_id}']} ${ipmi_threshold_reading} 484 END 485 END 486 487 488Get Available Sensors 489 [Documentation] Get all the available sensors for the required component. 490 ... Returns a list of available sensors. 491 [Arguments] ${sensor_component} 492 493 # Description of argument(s): 494 # sensor_component sensor component name.(e.g.:cpu) 495 496 ${resp}= Run IPMI Standard Command sdr elist 497 ${sensor_list}= Create List 498 ${sensors}= Get Lines Containing String ${resp} ${sensor_component} case-insensitive 499 ${sensors}= Split To Lines ${sensors} 500 501 # Example of IPMI sdr elist command. 502 503 # dcm0_cpu0 | 41h | ok | 3.1 | Presence detected 504 # dcm0_cpu1 | 42h | ok | 3.2 | Presence detected, Disabled 505 # dcm1_cpu0 | 43h | ok | 3.3 | Presence detected 506 # dcm1_cpu1 | 44h | ok | 3.4 | Presence detected, Disabled 507 # dcm2_cpu0 | 45h | ns | 3.5 | Disabled 508 # dcm2_cpu1 | 46h | ns | 3.6 | Disabled 509 # dcm3_cpu0 | 47h | ns | 3.7 | Disabled 510 # dcm3_cpu1 | 48h | ns | 3.8 | Disabled 511 512 FOR ${line} IN @{sensors} 513 ${sensor_name}= Set Variable ${line.split('|')[0].strip()} 514 515 # Adding sensors to the list whose presence is detected. 516 ${contains}= Evaluate "Presence detected" in "${line}" or "ok" in "${line}" 517 IF "${contains}" == "True" 518 Append To List ${sensor_list} ${sensor_name} 519 END 520 END 521 522 # Example of output for ${sensor_list} 523 # ['dcm0_cpu0', 'dcm0_cpu1', 'dcm1_cpu0', 'dcm1_cpu1'] 524 525 RETURN ${sensor_list} 526 527 528Get Sensor Id For Sensor 529 [Documentation] Returns the sensor ID value for the given sensor. 530 [Arguments] ${sensor_name} 531 532 # Description of argument(s): 533 # sensor_name Name of sensor whose ID is required(e.g.: dcm0_cpu0, dcm0_cpu1 etc). 534 535 ${get_resp}= Run IPMI Standard Command sensor get ${sensor_name} 536 537 # Example of sensor get command. 538 539 # Locating sensor record... 540 # Sensor ID : dcm0_cpu0 (0x41) 541 # Entity ID : 3.1 542 # Sensor Type (Discrete): Processor 543 # States Asserted : Processor 544 # [Presence detected] 545 546 ${line}= Get Lines Containing String ${get_resp} Sensor ID 547 ${sensor_id}= Set Variable ${line[-5:-1]} 548 549 # Example of output for ${sensor_id} is 0x41. 550 551 RETURN ${sensor_id} 552 553