blob: 9ce0e4c5f3168872cb98105223e853c794a41e3b [file] [log] [blame]
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -05001*** Settings ***
2Documentation This suite is for testing general IPMI functions.
3
4Resource ../../lib/ipmi_client.robot
5Resource ../../lib/openbmc_ffdc.robot
George Keishing0825a112018-03-30 10:48:07 -05006Resource ../../lib/boot_utils.robot
George Keishing78ce8dc2018-03-30 11:49:06 -05007Resource ../../lib/utils.robot
Sweta Potthurif39022d2018-02-06 03:40:07 -06008Resource ../../lib/bmc_network_utils.robot
George Keishingd6273802018-09-07 07:06:53 -05009Resource ../../lib/logging_utils.robot
George Keishing78ce8dc2018-03-30 11:49:06 -050010Library ../../lib/ipmi_utils.py
George Keishing0825a112018-03-30 10:48:07 -050011Variables ../../data/ipmi_raw_cmd_table.py
Rahul Maheshwaridf6f05d2018-09-04 03:48:37 -050012Library ../../lib/gen_misc.py
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050013
Michael Walshc9eb34e2019-01-23 11:08:43 -060014Test Setup Log to Console ${EMPTY}
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050015Test Teardown FFDC On Test Case Fail
16
17*** Variables ***
18
Rahul Maheshwari901dcde2018-02-06 03:14:31 -060019${allowed_temp_diff}= ${1}
Rahul Maheshwari615da152018-02-13 23:53:36 -060020${allowed_power_diff}= ${10}
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -060021
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050022*** Test Cases ***
23
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050024Set Asset Tag With Valid String Length Via REST
25 [Documentation] Set valid asset tag via REST and verify.
26 [Tags] Set_Asset_Tag_With_Valid_String_Length_Via_REST
27
28 ${random_string}= Generate Random String 63
29 ${args}= Create Dictionary data=${random_string}
30 Write Attribute /xyz/openbmc_project/inventory/system AssetTag
31 ... data=${args}
32
33 ${asset_tag}= Read Attribute /xyz/openbmc_project/inventory/system
34 ... AssetTag
35 Should Be Equal As Strings ${asset_tag} ${random_string}
36
Sweta Potthurif39022d2018-02-06 03:40:07 -060037
Sweta Potthuri0cc60502018-01-24 00:36:17 -060038Verify Chassis Identify via IPMI
39 [Documentation] Verify "chassis identify" using IPMI command.
40 [Tags] Verify_Chassis_Identify_via_IPMI
41
42 # Set to default "chassis identify" and verify that LED blinks for 15s.
43 Run IPMI Standard Command chassis identify
Alvin Wang32f7b3d2019-07-25 02:05:39 -050044 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060045
46 Sleep 15s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050047 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060048
49 # Set "chassis identify" to 10s and verify that the LED blinks for 10s.
50 Run IPMI Standard Command chassis identify 10
Alvin Wang32f7b3d2019-07-25 02:05:39 -050051 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060052
53 Sleep 10s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050054 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060055
Sweta Potthurif39022d2018-02-06 03:40:07 -060056
Sweta Potthuri0cc60502018-01-24 00:36:17 -060057Verify Chassis Identify Off And Force Identify On via IPMI
58 [Documentation] Verify "chassis identify" off
59 ... and "force identify on" via IPMI.
60 [Tags] Verify_Chassis_Identify_Off_And_Force_Identify_On_via_IPMI
61
62 # Set the LED to "Force Identify On".
63 Run IPMI Standard Command chassis identify force
Alvin Wang32f7b3d2019-07-25 02:05:39 -050064 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060065
66 # Set "chassis identify" to 0 and verify that the LED turns off.
67 Run IPMI Standard Command chassis identify 0
Alvin Wang32f7b3d2019-07-25 02:05:39 -050068 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060069
Sweta Potthurif39022d2018-02-06 03:40:07 -060070
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060071Test Watchdog Reset Via IPMI And Verify Using REST
72 [Documentation] Test watchdog reset via IPMI and verify using REST.
73 [Tags] Test_Watchdog_Reset_Via_IPMI_And_Verify_Using_REST
74
75 Initiate Host Boot
76
77 Set Watchdog Enabled Using REST ${1}
78
79 Watchdog Object Should Exist
80
81 # Resetting the watchdog via IPMI.
82 Run IPMI Standard Command mc watchdog reset
83
84 # Verify the watchdog is reset using REST after an interval of 1000ms.
85 Sleep 1000ms
86 ${watchdog_time_left}=
87 ... Read Attribute ${HOST_WATCHDOG_URI} TimeRemaining
88 Should Be True
89 ... ${watchdog_time_left}<${1200000} and ${watchdog_time_left}>${2000}
90 ... msg=Watchdog timer didn't reset.
91
Sweta Potthurif39022d2018-02-06 03:40:07 -060092
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060093Test Watchdog Off Via IPMI And Verify Using REST
94 [Documentation] Test watchdog off via IPMI and verify using REST.
95 [Tags] Test_Watchdog_Off_Via_IPMI_And_Verify_Using_REST
96
97 Initiate Host Boot
98
99 Set Watchdog Enabled Using REST ${1}
100
101 Watchdog Object Should Exist
102
103 # Turn off the watchdog via IPMI.
104 Run IPMI Standard Command mc watchdog off
105
106 # Verify the watchdog is off using REST
107 ${watchdog_state}= Read Attribute ${HOST_WATCHDOG_URI} Enabled
108 Should Be Equal ${watchdog_state} ${0}
109 ... msg=msg=Verification failed for watchdog off check.
Rahul Maheshwari901dcde2018-02-06 03:14:31 -0600110
111
112Test Ambient Temperature Via IPMI
113 [Documentation] Test ambient temperature via IPMI and verify using REST.
114 [Tags] Test_Ambient_Temperature_Via_IPMI
115
116 # Entity ID Entity Instance Temp. Readings
117 # Inlet air temperature(40h) 1 +19 C
118 # CPU temperature sensors(41h) 5 +51 C
119 # CPU temperature sensors(41h) 6 +50 C
120 # CPU temperature sensors(41h) 7 +50 C
121 # CPU temperature sensors(41h) 8 +50 C
122 # CPU temperature sensors(41h) 9 +50 C
123 # CPU temperature sensors(41h) 10 +48 C
124 # CPU temperature sensors(41h) 11 +49 C
125 # CPU temperature sensors(41h) 12 +47 C
126 # CPU temperature sensors(41h) 8 +50 C
127 # CPU temperature sensors(41h) 16 +51 C
128 # CPU temperature sensors(41h) 24 +50 C
129 # CPU temperature sensors(41h) 32 +43 C
130 # CPU temperature sensors(41h) 40 +43 C
131 # Baseboard temperature sensors(42h) 1 +35 C
132
133 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
George Keishing77f1ad22018-07-23 12:39:28 -0500134 Should Contain ${temp_reading} Inlet air temperature
135 ... msg="Unable to get inlet temperature via DCMI".
Rahul Maheshwari901dcde2018-02-06 03:14:31 -0600136 ${ambient_temp_line}=
137 ... Get Lines Containing String ${temp_reading}
138 ... Inlet air temperature case-insensitive
139
140 ${ambient_temp_ipmi}= Fetch From Right ${ambient_temp_line} +
141 ${ambient_temp_ipmi}= Remove String ${ambient_temp_ipmi} ${SPACE}C
142
143 ${ambient_temp_rest}= Read Attribute
144 ... ${SENSORS_URI}temperature/ambient Value
145
146 # Example of ambient temperature via REST
147 # "CriticalAlarmHigh": 0,
148 # "CriticalAlarmLow": 0,
149 # "CriticalHigh": 35000,
150 # "CriticalLow": 0,
151 # "Scale": -3,
152 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.DegreesC",
153 # "Value": 21775,
154 # "WarningAlarmHigh": 0,
155 # "WarningAlarmLow": 0,
156 # "WarningHigh": 25000,
157 # "WarningLow": 0
158
159 # Get temperature value based on scale i.e. Value * (10 power Scale Value)
160 # e.g. from above case 21775 * (10 power -3) = 21775/1000
161
162 ${ambient_temp_rest}= Evaluate ${ambient_temp_rest}/1000
163 ${ipmi_rest_temp_diff}=
164 ... Evaluate abs(${ambient_temp_rest} - ${ambient_temp_ipmi})
165
166 Should Be True ${ipmi_rest_temp_diff} <= ${allowed_temp_diff}
167 ... msg=Ambient temperature above allowed threshold ${allowed_temp_diff}.
168
169
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600170Test Power Reading Via IPMI With Host Off
171 [Documentation] Test power reading via IPMI with host off state and
172 ... verify using REST.
173 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Off
Rahul Maheshwari615da152018-02-13 23:53:36 -0600174
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600175 REST Power Off stack_mode=skip quiet=1
Rahul Maheshwari615da152018-02-13 23:53:36 -0600176
George Keishing04bf06c2018-10-05 08:28:50 -0500177 Wait Until Keyword Succeeds 1 min 30 sec Verify Power Reading
George Keishinge78f1fd2018-09-04 13:34:59 -0500178
179
180Test Power Reading Via IPMI With Host Booted
181 [Documentation] Test power reading via IPMI with host booted state and
182 ... verify using REST.
183 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Booted
184
185 REST Power On stack_mode=skip quiet=1
186
187 # For a good power reading take a 3 samples for 15 seconds interval and
188 # average it out.
189
George Keishing04bf06c2018-10-05 08:28:50 -0500190 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading
Rahul Maheshwari615da152018-02-13 23:53:36 -0600191
192
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600193Test Power Reading Via IPMI Raw Command
194 [Documentation] Test power reading via IPMI raw command and verify
195 ... using REST.
196 [Tags] Test_Power_Reading_Via_IPMI_Raw_Command
197
198 # Response data structure of power reading command output via IPMI.
199 # 1 Completion Code. Refer to section 8, DCMI Completion Codes.
200 # 2 Group Extension Identification = DCh
201 # 3:4 Current Power in watts
202
George Keishinge78f1fd2018-09-04 13:34:59 -0500203 REST Power On stack_mode=skip quiet=1
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600204
George Keishing04bf06c2018-10-05 08:28:50 -0500205 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading Via Raw Command
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600206
207
Rahul Maheshwari91a18ef2018-02-15 04:54:59 -0600208Test Baseboard Temperature Via IPMI
209 [Documentation] Test baseboard temperature via IPMI and verify using REST.
210 [Tags] Test_Baseboard_Temperature_Via_IPMI
211
212 # Example of IPMI dcmi get_temp_reading output:
213 # Entity ID Entity Instance Temp. Readings
214 # Inlet air temperature(40h) 1 +19 C
215 # CPU temperature sensors(41h) 5 +51 C
216 # CPU temperature sensors(41h) 6 +50 C
217 # CPU temperature sensors(41h) 7 +50 C
218 # CPU temperature sensors(41h) 8 +50 C
219 # CPU temperature sensors(41h) 9 +50 C
220 # CPU temperature sensors(41h) 10 +48 C
221 # CPU temperature sensors(41h) 11 +49 C
222 # CPU temperature sensors(41h) 12 +47 C
223 # CPU temperature sensors(41h) 8 +50 C
224 # CPU temperature sensors(41h) 16 +51 C
225 # CPU temperature sensors(41h) 24 +50 C
226 # CPU temperature sensors(41h) 32 +43 C
227 # CPU temperature sensors(41h) 40 +43 C
228 # Baseboard temperature sensors(42h) 1 +35 C
229
230 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
George Keishing77f1ad22018-07-23 12:39:28 -0500231 Should Contain ${temp_reading} Baseboard temperature sensors
232 ... msg="Unable to get baseboard temperature via DCMI".
Rahul Maheshwari91a18ef2018-02-15 04:54:59 -0600233 ${baseboard_temp_line}=
234 ... Get Lines Containing String ${temp_reading}
235 ... Baseboard temperature case-insensitive=True
236
237 ${baseboard_temp_ipmi}= Fetch From Right ${baseboard_temp_line} +
238 ${baseboard_temp_ipmi}= Remove String ${baseboard_temp_ipmi} ${SPACE}C
239
240 ${baseboard_temp_rest}= Read Attribute
241 ... /xyz/openbmc_project/sensors/temperature/pcie Value
242 ${baseboard_temp_rest}= Evaluate ${baseboard_temp_rest}/1000
243
244 Should Be True
245 ... ${baseboard_temp_rest} - ${baseboard_temp_ipmi} <= ${allowed_temp_diff}
246 ... msg=Baseboard temperature above allowed threshold ${allowed_temp_diff}.
247
248
Sweta Potthurif39022d2018-02-06 03:40:07 -0600249Retrieve Network Mode Via IPMI And Verify Using REST
250 [Documentation] Retrieve network mode from LAN print using IPMI.
251 [Tags] Retrieve_Network_Mode_Via_IPMI_And_Verify_Using_REST
252
253 # Fetch "Mode" from IPMI LAN print.
254 ${network_mode_ipmi}= Fetch Details From LAN Print Source
255
256 # Verify "Mode" using REST.
257 ${network_mode_rest}= Read Attribute
Steven Sombara8800da2018-12-18 16:19:05 -0600258 ... ${NETWORK_MANAGER}eth0 DHCPEnabled
Sweta Potthurif39022d2018-02-06 03:40:07 -0600259 Run Keyword If '${network_mode_ipmi}' == 'Static Address'
260 ... Should Be Equal ${network_mode_rest} ${0}
261 ... msg=Verification of network setting failed.
262 ... ELSE IF '${network_mode_ipmi}' == 'DHCP'
263 ... Should Be Equal ${network_mode_rest} ${1}
264 ... msg=Verification of network setting failed.
265
266
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600267Verify Get Device ID
268 [Documentation] Verify get device ID command output.
269 [Tags] Verify_Get_Device_ID
270
271 # Example of get device ID command output:
272 # Device ID : 0
273 # Device Revision : 0
274 # Firmware Revision : 2.01
275 # IPMI Version : 2.0
276 # Manufacturer ID : 42817
277 # Manufacturer Name : Unknown (0xA741)
278 # Product ID : 16975 (0x424f)
279 # Product Name : Unknown (0x424F)
280 # Device Available : yes
281 # Provides Device SDRs : yes
282 # Additional Device Support :
283 # Sensor Device
284 # SEL Device
285 # FRU Inventory Device
286 # Chassis Device
287 # Aux Firmware Rev Info :
George Keishing3511a3f2018-04-19 10:38:30 -0500288 # 0x04
289 # 0x38
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600290 # 0x00
George Keishing3511a3f2018-04-19 10:38:30 -0500291 # 0x03
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600292
293 ${mc_info}= Get MC Info
294
295 Should Be Equal ${mc_info['device_id']} 0
296 Should Be Equal ${mc_info['device_revision']} 0
297
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500298 # Get firmware revision from mc info command output i.e. 2.01
299 ${ipmi_fw_major_version} ${ipmi_fw_minor_version}=
300 ... Split String ${mc_info['firmware_revision']} .
301 # Convert minor firmware version from BCD format to integer. i.e. 01 to 1
302 ${ipmi_fw_minor_version}= Convert To Integer ${ipmi_fw_minor_version}
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600303
George Keishinge0a81282018-06-08 10:02:30 -0500304 # Get BMC version from BMC CLI i.e. 2.2 from "v2.2-253-g00050f1"
George Keishing3511a3f2018-04-19 10:38:30 -0500305 ${bmc_version_full}= Get BMC Version
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500306 ${bmc_version}=
George Keishing3511a3f2018-04-19 10:38:30 -0500307 ... Remove String Using Regexp ${bmc_version_full} ^[^0-9]+ [^0-9\.].*
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500308
309 # Get major and minor version from BMC version i.e. 2 and 1 from 2.1
George Keishingc95e9982019-01-14 09:27:45 -0600310 @{major_minor_version}= Split String ${bmc_version} .
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500311
George Keishingc95e9982019-01-14 09:27:45 -0600312 Should Be Equal As Strings ${ipmi_fw_major_version} ${major_minor_version[0]}
George Keishing2ee2f002019-02-16 09:36:02 -0600313 ... msg=Major version mismatch.
George Keishingc95e9982019-01-14 09:27:45 -0600314 Should Be Equal As Strings ${ipmi_fw_minor_version} ${major_minor_version[1]}
George Keishing2ee2f002019-02-16 09:36:02 -0600315 ... msg=Minor version mismatch.
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500316
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600317 Should Be Equal ${mc_info['ipmi_version']} 2.0
318
Gunnar Mills917ba1a2018-04-08 16:42:12 -0500319 # TODO: Verify Manufacturer and Product IDs directly from json file.
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600320 # Reference : openbmc/openbmc-test-automation#1244
321 Should Be Equal ${mc_info['manufacturer_id']} 42817
322 Should Be Equal ${mc_info['product_id']} 16975 (0x424f)
323
324 Should Be Equal ${mc_info['device_available']} yes
325 Should Be Equal ${mc_info['provides_device_sdrs']} yes
326 Should Contain ${mc_info['additional_device_support']} Sensor Device
327 Should Contain ${mc_info['additional_device_support']} SEL Device
328 Should Contain
329 ... ${mc_info['additional_device_support']} FRU Inventory Device
330 Should Contain ${mc_info['additional_device_support']} Chassis Device
George Keishingb746d3f2018-04-19 10:53:10 -0500331
George Keishing3511a3f2018-04-19 10:38:30 -0500332 # Auxiliary revision data verification.
333 ${aux_version}= Get Aux Version ${bmc_version_full}
334
335 # From aux_firmware_rev_info field ['0x04', '0x38', '0x00', '0x03']
336 ${bmc_aux_version}= Catenate
337 ... SEPARATOR=
338 ... ${mc_info['aux_firmware_rev_info'][0][2:]}
339 ... ${mc_info['aux_firmware_rev_info'][1][2:]}
340 ... ${mc_info['aux_firmware_rev_info'][2][2:]}
341 ... ${mc_info['aux_firmware_rev_info'][3][2:]}
342
343 Should Be Equal As Integers
344 ... ${bmc_aux_version} ${aux_version}
345 ... msg=BMC aux version ${bmc_aux_version} does not match expected value of ${aux_version}.
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600346
347
George Keishinge85113a2019-06-07 08:21:51 -0500348Test IPMI Restriction Mode
349 [Documentation] Set restricition mode via REST and verify IPMI operation.
350 [Tags] Test_IPMI_Restriction_Mode
351 # Forego normal test setup:
352 [Setup] No Operation
353 [Teardown] Run Keywords FFDC On Test Case Fail AND
354 ... Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None
355
356 # By default no IPMI operations are restricted.
357 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
358 # {
359 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None",
360 # "message": "200 OK",
361 # "status": "ok"
362 # }
363
364 # Refer to: #openbmc/phosphor-host-ipmid/blob/master/host-ipmid-whitelist.conf
365 # Set the restriction mode to Whitelist IPMI commands only:
366 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
367 # {
368 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist",
369 # "message": "200 OK",
370 # "status": "ok"
371 # }
372
373 Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist
374
375 # Attempt white-listed operation expecting success.
376 IPMI Power On
377
378 # Attempt non white-listed operation expecting failure.
379 Run Keyword And Expect Error *Insufficient privilege level*
380 ... Run Inband IPMI Standard Command mc reset cold
381
382
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -0500383*** Keywords ***
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -0600384
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600385Set Watchdog Enabled Using REST
386 [Documentation] Set watchdog Enabled field using REST.
387 [Arguments] ${value}
388
389 # Description of argument(s):
390 # value Integer value (eg. "0-Disabled", "1-Enabled").
391
392 ${value_dict}= Create Dictionary data=${value}
Steven Sombaraaaab222018-12-19 13:16:23 -0600393 ${resp}= OpenBMC Put Request ${HOST_WATCHDOG_URI}attr/Enabled
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600394 ... data=${value_dict}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600395
396
Sweta Potthurif39022d2018-02-06 03:40:07 -0600397Fetch Details From LAN Print
398 [Documentation] Fetch details from LAN print.
399 [Arguments] ${field_name}
400
401 # Description of argument(s):
402 # ${field_name} Field name to be fetched from LAN print
403 # (e.g. "MAC Address", "Source").
404
Rahul Maheshwarid8037d32018-12-17 00:59:57 -0600405 ${stdout}= Run IPMI Standard Command lan print
Sweta Potthurif39022d2018-02-06 03:40:07 -0600406 ${fetch_value}= Get Lines Containing String ${stdout} ${field_name}
407 ${value_fetch}= Fetch From Right ${fetch_value} :${SPACE}
408 [Return] ${value_fetch}
409
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600410
411Verify Power Reading
412 [Documentation] Get dcmi power reading via IPMI.
413
414 # Example of power reading command output via IPMI.
415 # Instantaneous power reading: 235 Watts
416 # Minimum during sampling period: 235 Watts
417 # Maximum during sampling period: 235 Watts
418 # Average power reading over sample period: 235 Watts
419 # IPMI timestamp: Thu Jan 1 00:00:00 1970
420 # Sampling period: 00000000 Seconds.
421 # Power reading state is: deactivated
422
423 ${power_reading}= Get IPMI Power Reading
424
425 ${host_state}= Get Host State
426 Run Keyword If '${host_state}' == 'Off'
George Keishing51314872018-03-31 13:24:35 -0500427 ... Should Be Equal ${power_reading['instantaneous_power_reading']} 0
428 ... msg=Power reading not zero when power is off.
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600429
George Keishing51314872018-03-31 13:24:35 -0500430 Run Keyword If '${power_reading['instantaneous_power_reading']}' != '0'
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600431 ... Verify Power Reading Using REST ${power_reading['instantaneous_power_reading']}
432
433
George Keishinge78f1fd2018-09-04 13:34:59 -0500434Verify Power Reading Via Raw Command
435 [Documentation] Get dcmi power reading via IPMI raw command.
436
437 ${ipmi_raw_output}= Run IPMI Standard Command
438 ... raw ${IPMI_RAW_CMD['power_reading']['Get'][0]}
439
440 @{raw_output_list}= Split String ${ipmi_raw_output} ${SPACE}
441
442 # On successful execution of raw IPMI power reading command, completion
443 # code does not come in output. So current power value will start from 2
444 # byte instead of 3.
445
446 ${power_reading_ipmi_raw_3_item}= Get From List ${raw_output_list} 2
447 ${power_reading_ipmi_raw_3_item}=
448 ... Convert To Integer 0x${power_reading_ipmi_raw_3_item}
449
450 ${power_reading_rest}= Read Attribute
451 ... ${SENSORS_URI}power/total_power Value
452
453 # Example of power reading via REST
454 # "CriticalAlarmHigh": 0,
455 # "CriticalAlarmLow": 0,
456 # "CriticalHigh": 3100000000,
457 # "CriticalLow": 0,
458 # "Scale": -6,
459 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.Watts",
460 # "Value": 228000000,
461 # "WarningAlarmHigh": 0,
462 # "WarningAlarmLow": 0,
463 # "WarningHigh": 3050000000,
464 # "WarningLow": 0
465
466 # Get power value based on scale i.e. Value * (10 power Scale Value)
467 # e.g. from above case 228000000 * (10 power -6) = 228000000/1000000
468
469 ${power_reading_rest}= Evaluate ${power_reading_rest}/1000000
470 ${ipmi_rest_power_diff}=
471 ... Evaluate abs(${power_reading_rest} - ${power_reading_ipmi_raw_3_item})
472
473 Should Be True ${ipmi_rest_power_diff} <= ${allowed_power_diff}
474 ... msg=Power Reading above allowed threshold ${allowed_power_diff}.
475
476
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600477Verify Power Reading Using REST
478 [Documentation] Verify power reading using REST.
479 [Arguments] ${power_reading}
480
Gunnar Mills948e2e22018-03-23 12:54:27 -0500481 # Description of argument(s):
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600482 # power_reading IPMI Power reading
483
484 ${power_reading_rest}= Read Attribute
485 ... ${SENSORS_URI}power/total_power Value
486
487 # Example of power reading via REST
488 # "CriticalAlarmHigh": 0,
489 # "CriticalAlarmLow": 0,
490 # "CriticalHigh": 3100000000,
491 # "CriticalLow": 0,
492 # "Scale": -6,
493 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.Watts",
494 # "Value": 228000000,
495 # "WarningAlarmHigh": 0,
496 # "WarningAlarmLow": 0,
497 # "WarningHigh": 3050000000,
498 # "WarningLow": 0
499
500 # Get power value based on scale i.e. Value * (10 power Scale Value)
501 # e.g. from above case 228000000 * (10 power -6) = 228000000/1000000
502 ${power_reading_rest}= Evaluate ${power_reading_rest}/1000000
503 ${ipmi_rest_power_diff}=
504 ... Evaluate abs(${power_reading_rest} - ${power_reading})
505
506 Should Be True ${ipmi_rest_power_diff} <= ${allowed_power_diff}
507 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
George Keishing02651f02018-04-11 02:07:16 -0500508
509
George Keishinge85113a2019-06-07 08:21:51 -0500510Set IPMI Restriction Mode
511 [Documentation] Set the IPMI restriction mode.
512 [Arguments] ${restriction_mode}
513
514 # Description of argument(s):
515 # restriction_mode IPMI valid restriction modes.
516
517 ${valueDict}= Create Dictionary data=${restriction_mode}
518
519 Write Attribute ${CONTROL_HOST_URI}restriction_mode/
520 ... RestrictionMode data=${valueDict}