blob: 8875305137dbba6b7d388c1e3c8745fddb0dfa9f [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
Tony Lee9bca44b2019-12-13 09:34:26 +080013Library ../../lib/gen_robot_valid.py
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050014
Michael Walshc9eb34e2019-01-23 11:08:43 -060015Test Setup Log to Console ${EMPTY}
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050016Test Teardown FFDC On Test Case Fail
17
18*** Variables ***
19
Rahul Maheshwari901dcde2018-02-06 03:14:31 -060020${allowed_temp_diff}= ${1}
Rahul Maheshwari615da152018-02-13 23:53:36 -060021${allowed_power_diff}= ${10}
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -060022
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -050023*** Test Cases ***
24
Sweta Potthuri0cc60502018-01-24 00:36:17 -060025Verify Chassis Identify via IPMI
26 [Documentation] Verify "chassis identify" using IPMI command.
27 [Tags] Verify_Chassis_Identify_via_IPMI
28
29 # Set to default "chassis identify" and verify that LED blinks for 15s.
30 Run IPMI Standard Command chassis identify
Alvin Wang32f7b3d2019-07-25 02:05:39 -050031 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060032
33 Sleep 15s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050034 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060035
36 # Set "chassis identify" to 10s and verify that the LED blinks for 10s.
37 Run IPMI Standard Command chassis identify 10
Alvin Wang32f7b3d2019-07-25 02:05:39 -050038 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060039
40 Sleep 10s
Alvin Wang32f7b3d2019-07-25 02:05:39 -050041 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060042
Sweta Potthurif39022d2018-02-06 03:40:07 -060043
Sweta Potthuri0cc60502018-01-24 00:36:17 -060044Verify Chassis Identify Off And Force Identify On via IPMI
45 [Documentation] Verify "chassis identify" off
46 ... and "force identify on" via IPMI.
47 [Tags] Verify_Chassis_Identify_Off_And_Force_Identify_On_via_IPMI
48
49 # Set the LED to "Force Identify On".
50 Run IPMI Standard Command chassis identify force
Alvin Wang32f7b3d2019-07-25 02:05:39 -050051 Verify Identify LED State ${1}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060052
53 # Set "chassis identify" to 0 and verify that the LED turns off.
54 Run IPMI Standard Command chassis identify 0
Alvin Wang32f7b3d2019-07-25 02:05:39 -050055 Verify Identify LED State ${0}
Sweta Potthuri0cc60502018-01-24 00:36:17 -060056
Sweta Potthurif39022d2018-02-06 03:40:07 -060057
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060058Test Watchdog Reset Via IPMI And Verify Using REST
59 [Documentation] Test watchdog reset via IPMI and verify using REST.
60 [Tags] Test_Watchdog_Reset_Via_IPMI_And_Verify_Using_REST
61
62 Initiate Host Boot
63
64 Set Watchdog Enabled Using REST ${1}
65
66 Watchdog Object Should Exist
67
68 # Resetting the watchdog via IPMI.
69 Run IPMI Standard Command mc watchdog reset
70
71 # Verify the watchdog is reset using REST after an interval of 1000ms.
72 Sleep 1000ms
73 ${watchdog_time_left}=
74 ... Read Attribute ${HOST_WATCHDOG_URI} TimeRemaining
75 Should Be True
76 ... ${watchdog_time_left}<${1200000} and ${watchdog_time_left}>${2000}
77 ... msg=Watchdog timer didn't reset.
78
Sweta Potthurif39022d2018-02-06 03:40:07 -060079
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -060080Test Watchdog Off Via IPMI And Verify Using REST
81 [Documentation] Test watchdog off via IPMI and verify using REST.
82 [Tags] Test_Watchdog_Off_Via_IPMI_And_Verify_Using_REST
83
84 Initiate Host Boot
85
86 Set Watchdog Enabled Using REST ${1}
87
88 Watchdog Object Should Exist
89
90 # Turn off the watchdog via IPMI.
91 Run IPMI Standard Command mc watchdog off
92
93 # Verify the watchdog is off using REST
94 ${watchdog_state}= Read Attribute ${HOST_WATCHDOG_URI} Enabled
95 Should Be Equal ${watchdog_state} ${0}
96 ... msg=msg=Verification failed for watchdog off check.
Rahul Maheshwari901dcde2018-02-06 03:14:31 -060097
98
99Test Ambient Temperature Via IPMI
100 [Documentation] Test ambient temperature via IPMI and verify using REST.
101 [Tags] Test_Ambient_Temperature_Via_IPMI
102
103 # Entity ID Entity Instance Temp. Readings
104 # Inlet air temperature(40h) 1 +19 C
105 # CPU temperature sensors(41h) 5 +51 C
106 # CPU temperature sensors(41h) 6 +50 C
107 # CPU temperature sensors(41h) 7 +50 C
108 # CPU temperature sensors(41h) 8 +50 C
109 # CPU temperature sensors(41h) 9 +50 C
110 # CPU temperature sensors(41h) 10 +48 C
111 # CPU temperature sensors(41h) 11 +49 C
112 # CPU temperature sensors(41h) 12 +47 C
113 # CPU temperature sensors(41h) 8 +50 C
114 # CPU temperature sensors(41h) 16 +51 C
115 # CPU temperature sensors(41h) 24 +50 C
116 # CPU temperature sensors(41h) 32 +43 C
117 # CPU temperature sensors(41h) 40 +43 C
118 # Baseboard temperature sensors(42h) 1 +35 C
119
120 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
George Keishing77f1ad22018-07-23 12:39:28 -0500121 Should Contain ${temp_reading} Inlet air temperature
122 ... msg="Unable to get inlet temperature via DCMI".
Rahul Maheshwari901dcde2018-02-06 03:14:31 -0600123 ${ambient_temp_line}=
124 ... Get Lines Containing String ${temp_reading}
125 ... Inlet air temperature case-insensitive
126
127 ${ambient_temp_ipmi}= Fetch From Right ${ambient_temp_line} +
128 ${ambient_temp_ipmi}= Remove String ${ambient_temp_ipmi} ${SPACE}C
129
130 ${ambient_temp_rest}= Read Attribute
131 ... ${SENSORS_URI}temperature/ambient Value
132
133 # Example of ambient temperature via REST
134 # "CriticalAlarmHigh": 0,
135 # "CriticalAlarmLow": 0,
136 # "CriticalHigh": 35000,
137 # "CriticalLow": 0,
138 # "Scale": -3,
139 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.DegreesC",
140 # "Value": 21775,
141 # "WarningAlarmHigh": 0,
142 # "WarningAlarmLow": 0,
143 # "WarningHigh": 25000,
144 # "WarningLow": 0
145
146 # Get temperature value based on scale i.e. Value * (10 power Scale Value)
147 # e.g. from above case 21775 * (10 power -3) = 21775/1000
148
149 ${ambient_temp_rest}= Evaluate ${ambient_temp_rest}/1000
150 ${ipmi_rest_temp_diff}=
151 ... Evaluate abs(${ambient_temp_rest} - ${ambient_temp_ipmi})
152
153 Should Be True ${ipmi_rest_temp_diff} <= ${allowed_temp_diff}
154 ... msg=Ambient temperature above allowed threshold ${allowed_temp_diff}.
155
156
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600157Test Power Reading Via IPMI With Host Off
158 [Documentation] Test power reading via IPMI with host off state and
159 ... verify using REST.
160 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Off
Rahul Maheshwari615da152018-02-13 23:53:36 -0600161
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600162 REST Power Off stack_mode=skip quiet=1
Rahul Maheshwari615da152018-02-13 23:53:36 -0600163
George Keishing04bf06c2018-10-05 08:28:50 -0500164 Wait Until Keyword Succeeds 1 min 30 sec Verify Power Reading
George Keishinge78f1fd2018-09-04 13:34:59 -0500165
166
167Test Power Reading Via IPMI With Host Booted
168 [Documentation] Test power reading via IPMI with host booted state and
169 ... verify using REST.
170 [Tags] Test_Power_Reading_Via_IPMI_With_Host_Booted
171
172 REST Power On stack_mode=skip quiet=1
173
174 # For a good power reading take a 3 samples for 15 seconds interval and
175 # average it out.
176
George Keishing04bf06c2018-10-05 08:28:50 -0500177 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading
Rahul Maheshwari615da152018-02-13 23:53:36 -0600178
179
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600180Test Power Reading Via IPMI Raw Command
181 [Documentation] Test power reading via IPMI raw command and verify
182 ... using REST.
183 [Tags] Test_Power_Reading_Via_IPMI_Raw_Command
184
185 # Response data structure of power reading command output via IPMI.
186 # 1 Completion Code. Refer to section 8, DCMI Completion Codes.
187 # 2 Group Extension Identification = DCh
188 # 3:4 Current Power in watts
189
George Keishinge78f1fd2018-09-04 13:34:59 -0500190 REST Power On stack_mode=skip quiet=1
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600191
George Keishing04bf06c2018-10-05 08:28:50 -0500192 Wait Until Keyword Succeeds 2 min 30 sec Verify Power Reading Via Raw Command
Rahul Maheshwariabe13af2018-02-15 22:42:08 -0600193
194
Rahul Maheshwari91a18ef2018-02-15 04:54:59 -0600195Test Baseboard Temperature Via IPMI
196 [Documentation] Test baseboard temperature via IPMI and verify using REST.
197 [Tags] Test_Baseboard_Temperature_Via_IPMI
198
199 # Example of IPMI dcmi get_temp_reading output:
200 # Entity ID Entity Instance Temp. Readings
201 # Inlet air temperature(40h) 1 +19 C
202 # CPU temperature sensors(41h) 5 +51 C
203 # CPU temperature sensors(41h) 6 +50 C
204 # CPU temperature sensors(41h) 7 +50 C
205 # CPU temperature sensors(41h) 8 +50 C
206 # CPU temperature sensors(41h) 9 +50 C
207 # CPU temperature sensors(41h) 10 +48 C
208 # CPU temperature sensors(41h) 11 +49 C
209 # CPU temperature sensors(41h) 12 +47 C
210 # CPU temperature sensors(41h) 8 +50 C
211 # CPU temperature sensors(41h) 16 +51 C
212 # CPU temperature sensors(41h) 24 +50 C
213 # CPU temperature sensors(41h) 32 +43 C
214 # CPU temperature sensors(41h) 40 +43 C
215 # Baseboard temperature sensors(42h) 1 +35 C
216
217 ${temp_reading}= Run IPMI Standard Command dcmi get_temp_reading -N 10
George Keishing77f1ad22018-07-23 12:39:28 -0500218 Should Contain ${temp_reading} Baseboard temperature sensors
219 ... msg="Unable to get baseboard temperature via DCMI".
Rahul Maheshwari91a18ef2018-02-15 04:54:59 -0600220 ${baseboard_temp_line}=
221 ... Get Lines Containing String ${temp_reading}
222 ... Baseboard temperature case-insensitive=True
223
224 ${baseboard_temp_ipmi}= Fetch From Right ${baseboard_temp_line} +
225 ${baseboard_temp_ipmi}= Remove String ${baseboard_temp_ipmi} ${SPACE}C
226
227 ${baseboard_temp_rest}= Read Attribute
228 ... /xyz/openbmc_project/sensors/temperature/pcie Value
229 ${baseboard_temp_rest}= Evaluate ${baseboard_temp_rest}/1000
230
231 Should Be True
232 ... ${baseboard_temp_rest} - ${baseboard_temp_ipmi} <= ${allowed_temp_diff}
233 ... msg=Baseboard temperature above allowed threshold ${allowed_temp_diff}.
234
235
Sweta Potthurif39022d2018-02-06 03:40:07 -0600236Retrieve Network Mode Via IPMI And Verify Using REST
237 [Documentation] Retrieve network mode from LAN print using IPMI.
238 [Tags] Retrieve_Network_Mode_Via_IPMI_And_Verify_Using_REST
239
240 # Fetch "Mode" from IPMI LAN print.
241 ${network_mode_ipmi}= Fetch Details From LAN Print Source
242
243 # Verify "Mode" using REST.
244 ${network_mode_rest}= Read Attribute
Steven Sombara8800da2018-12-18 16:19:05 -0600245 ... ${NETWORK_MANAGER}eth0 DHCPEnabled
Sweta Potthurif39022d2018-02-06 03:40:07 -0600246 Run Keyword If '${network_mode_ipmi}' == 'Static Address'
247 ... Should Be Equal ${network_mode_rest} ${0}
248 ... msg=Verification of network setting failed.
Tony Lee3b045532019-12-09 14:43:50 +0800249 ... ELSE IF '${network_mode_ipmi}' == 'DHCP'
Sweta Potthurif39022d2018-02-06 03:40:07 -0600250 ... Should Be Equal ${network_mode_rest} ${1}
251 ... msg=Verification of network setting failed.
252
253
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600254Verify Get Device ID
255 [Documentation] Verify get device ID command output.
256 [Tags] Verify_Get_Device_ID
257
258 # Example of get device ID command output:
259 # Device ID : 0
260 # Device Revision : 0
261 # Firmware Revision : 2.01
262 # IPMI Version : 2.0
263 # Manufacturer ID : 42817
264 # Manufacturer Name : Unknown (0xA741)
265 # Product ID : 16975 (0x424f)
266 # Product Name : Unknown (0x424F)
267 # Device Available : yes
268 # Provides Device SDRs : yes
269 # Additional Device Support :
270 # Sensor Device
271 # SEL Device
272 # FRU Inventory Device
273 # Chassis Device
274 # Aux Firmware Rev Info :
George Keishing3511a3f2018-04-19 10:38:30 -0500275 # 0x04
276 # 0x38
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600277 # 0x00
George Keishing3511a3f2018-04-19 10:38:30 -0500278 # 0x03
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600279
Tony Lee9bca44b2019-12-13 09:34:26 +0800280 # Verify Manufacturer and Product IDs, etc. directly from json file.
281 ${device_id_config}= Get Device Id Config
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600282 ${mc_info}= Get MC Info
283
Tony Lee9bca44b2019-12-13 09:34:26 +0800284 Rprint Vars device_id_config mc_info
285 Valid Value ${mc_info['device_id']} [${device_id_config['id']}]
286 Valid Value ${mc_info['device_revision']} [${device_id_config['device_revision']}]
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600287
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500288 # Get firmware revision from mc info command output i.e. 2.01
289 ${ipmi_fw_major_version} ${ipmi_fw_minor_version}=
290 ... Split String ${mc_info['firmware_revision']} .
291 # Convert minor firmware version from BCD format to integer. i.e. 01 to 1
292 ${ipmi_fw_minor_version}= Convert To Integer ${ipmi_fw_minor_version}
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600293
George Keishinge0a81282018-06-08 10:02:30 -0500294 # Get BMC version from BMC CLI i.e. 2.2 from "v2.2-253-g00050f1"
George Keishing3511a3f2018-04-19 10:38:30 -0500295 ${bmc_version_full}= Get BMC Version
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500296 ${bmc_version}=
George Keishing3511a3f2018-04-19 10:38:30 -0500297 ... Remove String Using Regexp ${bmc_version_full} ^[^0-9]+ [^0-9\.].*
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500298
299 # Get major and minor version from BMC version i.e. 2 and 1 from 2.1
George Keishingc95e9982019-01-14 09:27:45 -0600300 @{major_minor_version}= Split String ${bmc_version} .
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500301
George Keishingc95e9982019-01-14 09:27:45 -0600302 Should Be Equal As Strings ${ipmi_fw_major_version} ${major_minor_version[0]}
George Keishing2ee2f002019-02-16 09:36:02 -0600303 ... msg=Major version mismatch.
George Keishingc95e9982019-01-14 09:27:45 -0600304 Should Be Equal As Strings ${ipmi_fw_minor_version} ${major_minor_version[1]}
George Keishing2ee2f002019-02-16 09:36:02 -0600305 ... msg=Minor version mismatch.
Rahul Maheshwaribb9e2572018-04-02 05:24:37 -0500306
Tony Lee9bca44b2019-12-13 09:34:26 +0800307 Valid Value mc_info['ipmi_version'] ['2.0']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600308
Tony Lee9bca44b2019-12-13 09:34:26 +0800309 Valid Value ${mc_info['manufacturer_id']} [${device_id_config['manuf_id']}]
310 ${product_id_hex} = Convert To Hex ${device_id_config['prod_id']} lowercase=True
311 Valid Value mc_info['product_id'] ['${device_id_config['prod_id']} (0x${product_id_hex})']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600312
Tony Lee9bca44b2019-12-13 09:34:26 +0800313 Valid Value mc_info['device_available'] ['yes']
314 Valid Value mc_info['provides_device_sdrs'] ['yes']
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600315 Should Contain ${mc_info['additional_device_support']} Sensor Device
316 Should Contain ${mc_info['additional_device_support']} SEL Device
317 Should Contain
318 ... ${mc_info['additional_device_support']} FRU Inventory Device
319 Should Contain ${mc_info['additional_device_support']} Chassis Device
George Keishingb746d3f2018-04-19 10:53:10 -0500320
George Keishing3511a3f2018-04-19 10:38:30 -0500321 # Auxiliary revision data verification.
322 ${aux_version}= Get Aux Version ${bmc_version_full}
323
324 # From aux_firmware_rev_info field ['0x04', '0x38', '0x00', '0x03']
325 ${bmc_aux_version}= Catenate
326 ... SEPARATOR=
327 ... ${mc_info['aux_firmware_rev_info'][0][2:]}
328 ... ${mc_info['aux_firmware_rev_info'][1][2:]}
329 ... ${mc_info['aux_firmware_rev_info'][2][2:]}
330 ... ${mc_info['aux_firmware_rev_info'][3][2:]}
331
332 Should Be Equal As Integers
333 ... ${bmc_aux_version} ${aux_version}
334 ... msg=BMC aux version ${bmc_aux_version} does not match expected value of ${aux_version}.
Rahul Maheshwarife8639b2018-02-05 22:42:24 -0600335
336
George Keishinge85113a2019-06-07 08:21:51 -0500337Test IPMI Restriction Mode
338 [Documentation] Set restricition mode via REST and verify IPMI operation.
339 [Tags] Test_IPMI_Restriction_Mode
340 # Forego normal test setup:
341 [Setup] No Operation
342 [Teardown] Run Keywords FFDC On Test Case Fail AND
343 ... Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None
344
345 # By default no IPMI operations are restricted.
346 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
347 # {
348 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.None",
349 # "message": "200 OK",
350 # "status": "ok"
351 # }
352
353 # Refer to: #openbmc/phosphor-host-ipmid/blob/master/host-ipmid-whitelist.conf
354 # Set the restriction mode to Whitelist IPMI commands only:
355 # /xyz/openbmc_project/control/host0/restriction_mode/attr/RestrictionMode
356 # {
357 # "data": "xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist",
358 # "message": "200 OK",
359 # "status": "ok"
360 # }
361
362 Set IPMI Restriction Mode xyz.openbmc_project.Control.Security.RestrictionMode.Modes.Whitelist
363
364 # Attempt white-listed operation expecting success.
365 IPMI Power On
366
367 # Attempt non white-listed operation expecting failure.
368 Run Keyword And Expect Error *Insufficient privilege level*
Rahul Maheshwari40193982019-10-11 00:55:08 -0500369 ... Run Inband IPMI Standard Command lan set 1 access on
George Keishinge85113a2019-06-07 08:21:51 -0500370
371
Rahul Maheshwarifdd5ff62017-08-01 04:15:03 -0500372*** Keywords ***
Sweta Potthuri5c6c72e2018-01-23 05:48:35 -0600373
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600374Set Watchdog Enabled Using REST
375 [Documentation] Set watchdog Enabled field using REST.
376 [Arguments] ${value}
377
378 # Description of argument(s):
379 # value Integer value (eg. "0-Disabled", "1-Enabled").
380
381 ${value_dict}= Create Dictionary data=${value}
Steven Sombaraaaab222018-12-19 13:16:23 -0600382 ${resp}= OpenBMC Put Request ${HOST_WATCHDOG_URI}attr/Enabled
Sweta Potthuri7d3af3c2018-01-29 03:07:07 -0600383 ... data=${value_dict}
Sweta Potthurif39022d2018-02-06 03:40:07 -0600384
385
Sweta Potthurif39022d2018-02-06 03:40:07 -0600386Fetch Details From LAN Print
387 [Documentation] Fetch details from LAN print.
388 [Arguments] ${field_name}
389
390 # Description of argument(s):
391 # ${field_name} Field name to be fetched from LAN print
392 # (e.g. "MAC Address", "Source").
393
Rahul Maheshwarid8037d32018-12-17 00:59:57 -0600394 ${stdout}= Run IPMI Standard Command lan print
Sweta Potthurif39022d2018-02-06 03:40:07 -0600395 ${fetch_value}= Get Lines Containing String ${stdout} ${field_name}
396 ${value_fetch}= Fetch From Right ${fetch_value} :${SPACE}
397 [Return] ${value_fetch}
398
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600399
400Verify Power Reading
401 [Documentation] Get dcmi power reading via IPMI.
402
403 # Example of power reading command output via IPMI.
404 # Instantaneous power reading: 235 Watts
405 # Minimum during sampling period: 235 Watts
406 # Maximum during sampling period: 235 Watts
407 # Average power reading over sample period: 235 Watts
408 # IPMI timestamp: Thu Jan 1 00:00:00 1970
409 # Sampling period: 00000000 Seconds.
410 # Power reading state is: deactivated
411
412 ${power_reading}= Get IPMI Power Reading
413
414 ${host_state}= Get Host State
415 Run Keyword If '${host_state}' == 'Off'
George Keishing51314872018-03-31 13:24:35 -0500416 ... Should Be Equal ${power_reading['instantaneous_power_reading']} 0
417 ... msg=Power reading not zero when power is off.
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600418
George Keishing51314872018-03-31 13:24:35 -0500419 Run Keyword If '${power_reading['instantaneous_power_reading']}' != '0'
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600420 ... Verify Power Reading Using REST ${power_reading['instantaneous_power_reading']}
421
422
George Keishinge78f1fd2018-09-04 13:34:59 -0500423Verify Power Reading Via Raw Command
424 [Documentation] Get dcmi power reading via IPMI raw command.
425
426 ${ipmi_raw_output}= Run IPMI Standard Command
427 ... raw ${IPMI_RAW_CMD['power_reading']['Get'][0]}
428
429 @{raw_output_list}= Split String ${ipmi_raw_output} ${SPACE}
430
431 # On successful execution of raw IPMI power reading command, completion
432 # code does not come in output. So current power value will start from 2
433 # byte instead of 3.
434
435 ${power_reading_ipmi_raw_3_item}= Get From List ${raw_output_list} 2
436 ${power_reading_ipmi_raw_3_item}=
437 ... Convert To Integer 0x${power_reading_ipmi_raw_3_item}
438
439 ${power_reading_rest}= Read Attribute
440 ... ${SENSORS_URI}power/total_power Value
441
442 # Example of power reading via REST
443 # "CriticalAlarmHigh": 0,
444 # "CriticalAlarmLow": 0,
445 # "CriticalHigh": 3100000000,
446 # "CriticalLow": 0,
447 # "Scale": -6,
448 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.Watts",
449 # "Value": 228000000,
450 # "WarningAlarmHigh": 0,
451 # "WarningAlarmLow": 0,
452 # "WarningHigh": 3050000000,
453 # "WarningLow": 0
454
455 # Get power value based on scale i.e. Value * (10 power Scale Value)
456 # e.g. from above case 228000000 * (10 power -6) = 228000000/1000000
457
458 ${power_reading_rest}= Evaluate ${power_reading_rest}/1000000
459 ${ipmi_rest_power_diff}=
460 ... Evaluate abs(${power_reading_rest} - ${power_reading_ipmi_raw_3_item})
461
462 Should Be True ${ipmi_rest_power_diff} <= ${allowed_power_diff}
463 ... msg=Power Reading above allowed threshold ${allowed_power_diff}.
464
465
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600466Verify Power Reading Using REST
467 [Documentation] Verify power reading using REST.
468 [Arguments] ${power_reading}
469
Gunnar Mills948e2e22018-03-23 12:54:27 -0500470 # Description of argument(s):
Sweta Potthuri78dd1e12018-02-21 00:03:33 -0600471 # power_reading IPMI Power reading
472
473 ${power_reading_rest}= Read Attribute
474 ... ${SENSORS_URI}power/total_power Value
475
476 # Example of power reading via REST
477 # "CriticalAlarmHigh": 0,
478 # "CriticalAlarmLow": 0,
479 # "CriticalHigh": 3100000000,
480 # "CriticalLow": 0,
481 # "Scale": -6,
482 # "Unit": "xyz.openbmc_project.Sensor.Value.Unit.Watts",
483 # "Value": 228000000,
484 # "WarningAlarmHigh": 0,
485 # "WarningAlarmLow": 0,
486 # "WarningHigh": 3050000000,
487 # "WarningLow": 0
488
489 # Get power value based on scale i.e. Value * (10 power Scale Value)
490 # e.g. from above case 228000000 * (10 power -6) = 228000000/1000000
491 ${power_reading_rest}= Evaluate ${power_reading_rest}/1000000
492 ${ipmi_rest_power_diff}=
493 ... Evaluate abs(${power_reading_rest} - ${power_reading})
494
495 Should Be True ${ipmi_rest_power_diff} <= ${allowed_power_diff}
496 ... msg=Power reading above allowed threshold ${allowed_power_diff}.
George Keishing02651f02018-04-11 02:07:16 -0500497
498
George Keishinge85113a2019-06-07 08:21:51 -0500499Set IPMI Restriction Mode
500 [Documentation] Set the IPMI restriction mode.
501 [Arguments] ${restriction_mode}
502
503 # Description of argument(s):
504 # restriction_mode IPMI valid restriction modes.
505
506 ${valueDict}= Create Dictionary data=${restriction_mode}
507
508 Write Attribute ${CONTROL_HOST_URI}restriction_mode/
509 ... RestrictionMode data=${valueDict}