blob: 1a7dd1ab12ddb600182c0008f3d7f3262eca4482 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
2Resource ../lib/resource.txt
3Resource ../lib/rest_client.robot
George Keishing5e870cd2016-08-24 10:05:47 -05004Resource ../lib/connection_client.robot
George Keishing30c12ff2016-09-02 10:25:29 -05005Library DateTime
6Library Process
Chris Austenb29d2e82016-06-07 12:25:35 -05007Library OperatingSystem
Michael Walsha6723f22016-11-22 11:12:01 -06008Library gen_print.py
9Library gen_robot_print.py
Michael Walsh5f3f4142017-05-22 17:09:47 -050010Library gen_cmd.py
Chris Austenb29d2e82016-06-07 12:25:35 -050011
12*** Variables ***
13${SYSTEM_SHUTDOWN_TIME} ${5}
Michael Walsha6723f22016-11-22 11:12:01 -060014${dbuscmdBase}
George Keishing85ca05e2016-11-30 09:47:18 -060015... dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host
Michael Walsha6723f22016-11-22 11:12:01 -060016${dbuscmdGet}
George Keishing9485af92017-01-04 10:21:43 -060017... ${SETTINGS_URI}host0 org.freedesktop.DBus.Properties.Get
George Keishing85ca05e2016-11-30 09:47:18 -060018# Enable when ready with openbmc/openbmc-test-automation#203
19#${dbuscmdString}= string:"xyz.openbmc_project.settings.Host" string:
Michael Walsha6723f22016-11-22 11:12:01 -060020${dbuscmdString}= string:"org.openbmc.settings.Host" string:
21
22# Assign default value to QUIET for programs which may not define it.
23${QUIET} ${0}
Sivas SRRea85d1f2016-11-13 22:44:28 -060024${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
25${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
26${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9
Sridevi Ramesh1699d372016-12-06 00:20:22 -060027${HOST_SETTING} ${SETTINGS_URI}host0
Sivas SRR352bc162017-02-13 22:12:29 -060028# /run/initramfs/ro associate filesystem should be 100% full always
Sivas SRRaca55712016-12-21 04:32:35 -060029${bmc_file_system_usage_cmd}=
Sivas SRR352bc162017-02-13 22:12:29 -060030... df -h | grep -v /run/initramfs/ro | cut -c 52-54 | grep 100 | wc -l
Chris Austenb29d2e82016-06-07 12:25:35 -050031
George Keishingcce9df22017-01-24 06:19:33 -060032${BOOT_TIME} ${0}
33${BOOT_COUNT} ${0}
Sweta Potthuri025e0122017-02-21 00:42:48 -060034${count} ${0}
Sivas SRR8254db62017-02-07 09:39:46 -060035${devicetree_base} /sys/firmware/devicetree/base/model
George Keishingcce9df22017-01-24 06:19:33 -060036
Chris Austenb29d2e82016-06-07 12:25:35 -050037*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060038
Sivas SRR8254db62017-02-07 09:39:46 -060039Get BMC System Model
40 [Documentation] Get the BMC model from the device tree.
41
Michael Walshb5839d02017-04-12 16:11:20 -050042 Open Connection And Log In
George Keishing90ab1772017-02-24 05:40:55 -060043 ${bmc_model} ${stderr}= Execute Command
44 ... cat ${devicetree_base} | cut -d " " -f 1 return_stderr=True
Sivas SRR8254db62017-02-07 09:39:46 -060045 Should Be Empty ${stderr}
46 Should Not Be Empty ${bmc_model}
47 [Return] ${bmc_model}
48
49Verify BMC System Model
50 [Documentation] Verify the BMC model with ${OPENBMC_MODEL}.
51 [Arguments] ${bmc_model}
52
53 ${tmp_bmc_model}= Fetch From Right ${OPENBMC_MODEL} /
54 ${tmp_bmc_model}= Fetch From Left ${tmp_bmc_model} .
55 ${ret}= Run Keyword And Return Status Should Contain ${bmc_model}
56 ... ${tmp_bmc_model} ignore_case=True
57 [Return] ${ret}
58
Chris Austenb29d2e82016-06-07 12:25:35 -050059Wait For Host To Ping
root442f0ef2016-08-04 20:23:05 +000060 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
61 ... ${interval}=5 sec
62
63 # host The DNS name or IP of the host to ping.
64 # timeout The amount of time after which attempts to ping cease.
65 # interval The amount of time in between attempts to ping.
66
67 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050068
69Ping Host
70 [Arguments] ${host}
George Keishing8a84f952016-08-25 04:54:53 -050071 Should Not Be Empty ${host} msg=No host provided
Michael Walsha6723f22016-11-22 11:12:01 -060072 ${RC} ${output}= Run and return RC and Output ping -c 4 ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050073 Log RC: ${RC}\nOutput:\n${output}
74 Should be equal ${RC} ${0}
75
76Get Boot Progress
Michael Walsha6723f22016-11-22 11:12:01 -060077 [Arguments] ${quiet}=${QUIET}
78
George Keishing85ca05e2016-11-30 09:47:18 -060079 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
Michael Walsha6723f22016-11-22 11:12:01 -060080 ... value quiet=${quiet}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060081 [Return] ${state}
Chris Austenb29d2e82016-06-07 12:25:35 -050082
83Is Power On
root442f0ef2016-08-04 20:23:05 +000084 ${state}= Get Power State
85 Should be equal ${state} ${1}
Chris Austenb29d2e82016-06-07 12:25:35 -050086
87Is Power Off
root442f0ef2016-08-04 20:23:05 +000088 ${state}= Get Power State
89 Should be equal ${state} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050090
root442f0ef2016-08-04 20:23:05 +000091Initiate Power On
92 [Documentation] Initiates the power on and waits until the Is Power On
93 ... keyword returns that the power state has switched to on.
Michael Walsha6723f22016-11-22 11:12:01 -060094 [Arguments] ${wait}=${1}
95
Chris Austenb29d2e82016-06-07 12:25:35 -050096 @{arglist}= Create List
97 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -060098 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
Michael Walsha6723f22016-11-22 11:12:01 -060099 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500100 should be equal as strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -0500101
Michael Walsha6723f22016-11-22 11:12:01 -0600102 # Does caller want to wait for power on status?
103 Run Keyword If '${wait}' == '${0}' Return From Keyword
104 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500105
root442f0ef2016-08-04 20:23:05 +0000106Initiate Power Off
107 [Documentation] Initiates the power off and waits until the Is Power Off
108 ... keyword returns that the power state has switched to off.
Chris Austenb29d2e82016-06-07 12:25:35 -0500109 @{arglist}= Create List
110 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600111 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
Michael Walsha6723f22016-11-22 11:12:01 -0600112 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500113 should be equal as strings ${resp.status_code} ${HTTP_OK}
Michael Walsha6723f22016-11-22 11:12:01 -0600114 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
Chris Austenb29d2e82016-06-07 12:25:35 -0500115
Michael Walsh81843772017-03-02 14:44:44 -0600116Initiate OS Host Power Off
117 [Documentation] Initiate an OS reboot.
118 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
119 ... ${os_password}=${OS_PASSWORD}
120
121 # Description of arguments:
122 # os_host The DNS name or IP of the OS.
123 # os_username The username to be used to sign in to the OS.
124 # os_password The password to be used to sign in to the OS.
125
Michael Walshac275512017-03-07 11:39:28 -0600126 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600127 Login ${os_username} ${os_password}
128 ${cmd_buf} Catenate shutdown
129 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600130 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600131
132Initiate OS Host Reboot
133 [Documentation] Initiate an OS reboot.
134 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
135 ... ${os_password}=${OS_PASSWORD}
136
137 # Description of arguments:
138 # os_host The DNS name or IP of the OS.
139 # os_username The username to be used to sign in to the OS.
140 # os_password The password to be used to sign in to the OS.
141
Michael Walshac275512017-03-07 11:39:28 -0600142 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600143 Login ${os_username} ${os_password}
144 ${cmd_buf} Catenate reboot
145 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600146 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600147
148Initiate Auto Reboot
149 [Documentation] Initiate an auto reboot.
150
151 # Set the auto reboot policy.
152 Set Auto Reboot yes
153
Michael Walshac275512017-03-07 11:39:28 -0600154 SSHLibrary.Open connection ${openbmc_host}
Michael Walsh81843772017-03-02 14:44:44 -0600155 Login ${openbmc_username} ${openbmc_password}
156
157 # Set the watchdog timer. Note: 5000 = milliseconds which is 5 seconds.
158 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
159 ... org.openbmc.Watchdog set i 5000
160 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
161 ... return_stderr=True return_rc=True
162 Should Be Empty ${stderr}
163 Should be equal ${rc} ${0}
164
165 # Start the watchdog.
166 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
167 ... org.openbmc.Watchdog start
168 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
169 ... return_stderr=True return_rc=True
170 Should Be Empty ${stderr}
171 Should be equal ${rc} ${0}
172
Chris Austenb29d2e82016-06-07 12:25:35 -0500173Trigger Warm Reset
174 log to console "Triggering warm reset"
Michael Walsha6723f22016-11-22 11:12:01 -0600175 ${data}= create dictionary data=@{EMPTY}
George Keishing85ca05e2016-11-30 09:47:18 -0600176 ${resp}= openbmc post request
177 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500178 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingb3700812016-08-31 03:03:30 -0500179 ${session_active}= Check If warmReset is Initiated
180 Run Keyword If '${session_active}' == '${True}'
181 ... Fail msg=warm reset didn't occur
182
Chris Austenb29d2e82016-06-07 12:25:35 -0500183 Sleep ${SYSTEM_SHUTDOWN_TIME}min
Rahul Maheshwari5f253c42017-01-30 05:19:51 -0600184 Check If BMC Is Up
Michael Walsh49ab0f42016-07-20 11:44:33 -0500185
186Check OS
root442f0ef2016-08-04 20:23:05 +0000187 [Documentation] Attempts to ping the host OS and then checks that the host
188 ... OS is up by running an SSH command.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500189
190 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
Michael Walsha6723f22016-11-22 11:12:01 -0600191 ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET}
192 ... ${print_string}=${EMPTY}
Michael Walshac275512017-03-07 11:39:28 -0600193 [Teardown] SSHLibrary.Close Connection
Michael Walsh49ab0f42016-07-20 11:44:33 -0500194
195 # os_host The DNS name/IP of the OS host associated with our BMC.
196 # os_username The username to be used to sign on to the OS host.
197 # os_password The password to be used to sign on to the OS host.
Michael Walsha6723f22016-11-22 11:12:01 -0600198 # quiet Indicates whether this keyword should write to console.
199 # print_string A string to be printed before checking the OS.
200
201 rprint ${print_string}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500202
root442f0ef2016-08-04 20:23:05 +0000203 # Attempt to ping the OS. Store the return code to check later.
204 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
205
Michael Walshac275512017-03-07 11:39:28 -0600206 SSHLibrary.Open connection ${os_host}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500207
Michael Walsha6723f22016-11-22 11:12:01 -0600208 ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username}
209 ... ${os_password}
210 ${err_msg1}= Sprint Error ${msg}
211 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
212 Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500213 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
214 ... return_rc=True
215
Michael Walsha6723f22016-11-22 11:12:01 -0600216 ${temp_msg}= Catenate Could not execute a command on the operating
217 ... system.\n
218 ${err_msg1}= Sprint Error ${temp_msg}
219 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
220
221 # If the return code returned by "Execute Command" is non-zero, this
222 # keyword will fail.
223 Should Be Equal ${rc} ${0} msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500224 # We will likewise fail if there is any stderr data.
225 Should Be Empty ${stderr}
226
Michael Walsha6723f22016-11-22 11:12:01 -0600227 ${temp_msg}= Set Variable Could not ping the operating system.\n
228 ${err_msg1}= Sprint Error ${temp_msg}
229 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
230 # We will likewise fail if the OS did not ping, as we could SSH but not
231 # ping
232 Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg}
root442f0ef2016-08-04 20:23:05 +0000233
Michael Walsh49ab0f42016-07-20 11:44:33 -0500234Wait for OS
235 [Documentation] Waits for the host OS to come up via calls to "Check OS".
236 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
237 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
Michael Walsha6723f22016-11-22 11:12:01 -0600238 ... ${quiet}=${0}
239 [Teardown] rprintn
Michael Walsh49ab0f42016-07-20 11:44:33 -0500240
241 # os_host The DNS name or IP of the OS host associated with our
242 # BMC.
243 # os_username The username to be used to sign on to the OS host.
244 # os_password The password to be used to sign on to the OS host.
245 # timeout The timeout in seconds indicating how long you're
246 # willing to wait for the OS to respond.
Michael Walsha6723f22016-11-22 11:12:01 -0600247 # quiet Indicates whether this keyword should write to console.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500248
249 # The interval to be used between calls to "Check OS".
250 ${interval}= Set Variable 5
251
Michael Walsha6723f22016-11-22 11:12:01 -0600252 ${message}= Catenate Checking every ${interval} seconds for up to
253 ... ${timeout} seconds for the operating system to communicate.
254 rqprint_timen ${message}
255
Michael Walsh49ab0f42016-07-20 11:44:33 -0500256 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
257 ... ${os_host} ${os_username} ${os_password}
Michael Walsha6723f22016-11-22 11:12:01 -0600258 ... print_string=\#
259
260 rqprintn
261
262 rqprint_timen The operating system is now communicating.
root442f0ef2016-08-04 20:23:05 +0000263
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600264Get BMC State Deprecated
root442f0ef2016-08-04 20:23:05 +0000265 [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY)
Michael Walsha6723f22016-11-22 11:12:01 -0600266 [Arguments] ${quiet}=${QUIET}
267
root442f0ef2016-08-04 20:23:05 +0000268 @{arglist}= Create List
269 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600270 ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState
Michael Walsha6723f22016-11-22 11:12:01 -0600271 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000272 Should be equal as strings ${resp.status_code} ${HTTP_OK}
273 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600274 [Return] ${content["data"]}
root442f0ef2016-08-04 20:23:05 +0000275
276Get Power State
277 [Documentation] Returns the power state as an integer. Either 0 or 1.
Michael Walsha6723f22016-11-22 11:12:01 -0600278 [Arguments] ${quiet}=${QUIET}
279
root442f0ef2016-08-04 20:23:05 +0000280 @{arglist}= Create List
281 ${args}= Create Dictionary data=@{arglist}
Michael Walsha6723f22016-11-22 11:12:01 -0600282
George Keishing85ca05e2016-11-30 09:47:18 -0600283 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
Michael Walsha6723f22016-11-22 11:12:01 -0600284 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000285 Should be equal as strings ${resp.status_code} ${HTTP_OK}
286 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600287 [Return] ${content["data"]}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500288
289Clear BMC Record Log
290 [Documentation] Clears all the event logs on the BMC. This would be
291 ... equivalent to ipmitool sel clear.
292 @{arglist}= Create List
293 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600294 ${resp}= Call Method
295 ... ${OPENBMC_BASE_URI}records/events/ clear data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500296 should be equal as strings ${resp.status_code} ${HTTP_OK}
297
298Copy PNOR to BMC
299 Import Library SCPLibrary WITH NAME scp
300 Open Connection for SCP
301 Log Copying ${PNOR_IMAGE_PATH} to /tmp
302 scp.Put File ${PNOR_IMAGE_PATH} /tmp
303
304Flash PNOR
305 [Documentation] Calls flash bios update method to flash PNOR image
Gunnar Mills38032802016-12-12 13:43:40 -0600306 [Arguments] ${pnor_image}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500307 @{arglist}= Create List ${pnor_image}
308 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600309 ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update
Michael Walsha6723f22016-11-22 11:12:01 -0600310 ... data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500311 should be equal as strings ${resp.status_code} ${HTTP_OK}
312 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
313
314Get Flash BIOS Status
315 [Documentation] Returns the status of the flash BIOS API as a string. For
316 ... example 'Flashing', 'Flash Done', etc
George Keishing85ca05e2016-11-30 09:47:18 -0600317 ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600318 [Return] ${data['status']}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500319
320Is PNOR Flashing
321 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
322 ... flashing has started.
323 ${status}= Get Flash BIOS Status
Rahul Maheshwari449dfb72017-05-08 02:06:48 -0500324 Should Contain ${status} Flashing
Jay Azurine4c52eb2016-08-16 20:51:10 -0500325
326Is PNOR Flash Done
327 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
328 ... PNOR flashing has completed.
Leah McNutt9ba32272016-11-17 15:48:39 +0000329 ${status}= Get Flash BIOS Status
Jay Azurine4c52eb2016-08-16 20:51:10 -0500330 should be equal as strings ${status} Flash Done
331
332Is System State Host Booted
333 [Documentation] Checks whether system state is HOST_BOOTED.
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600334 ${state}= Get BMC State Deprecated
Jay Azurine4c52eb2016-08-16 20:51:10 -0500335 should be equal as strings ${state} HOST_BOOTED
George Keishing5e870cd2016-08-24 10:05:47 -0500336
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600337Is OS Starting
338 [Documentation] Check if boot progress is OS starting.
339 ${boot_progress}= Get Boot Progress
340 Should Be Equal ${boot_progress} FW Progress, Starting OS
341
George Keishing0af24412017-03-10 13:33:23 -0600342Is OS Off
343 [Documentation] Check if boot progress is "Off".
344 ${boot_progress}= Get Boot Progress
345 Should Be Equal ${boot_progress} Off
346
George Keishing5e870cd2016-08-24 10:05:47 -0500347Verify Ping and REST Authentication
Michael Walsha6723f22016-11-22 11:12:01 -0600348 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500349 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -0500350 Run Keyword If '${l_ping}' == '${False}'
351 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500352
Michael Walsha6723f22016-11-22 11:12:01 -0600353 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500354 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -0500355 Run Keyword If '${l_rest}' == '${False}'
356 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500357
358 # Just to make sure the SSH is working for SCP
359 Open Connection And Log In
360 ${system} ${stderr}= Execute Command hostname return_stderr=True
361 Should Be Empty ${stderr}
362
George Keishingc4d3dc02016-09-19 03:45:55 -0500363Check If BMC is Up
364 [Documentation] Wait for Host to be online. Checks every X seconds
365 ... interval for Y minutes and fails if timed out.
366 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -0600367 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -0500368 ... ${interval}=10 sec
369
370 Wait Until Keyword Succeeds
371 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
372
George Keishingb3700812016-08-31 03:03:30 -0500373
374Check If warmReset is Initiated
375 [Documentation] Ping would be still alive, so try SSH to connect
376 ... if fails the ports are down indicating reboot
377 ... is in progress
George Keishing3c05d352016-12-13 06:54:50 -0600378
379 # Warm reset adds 3 seconds delay before forcing reboot
380 # To minimize race conditions, we wait for 7 seconds
381 Sleep 7s
George Keishingb3700812016-08-31 03:03:30 -0500382 ${alive}= Run Keyword and Return Status
383 ... Open Connection And Log In
384 Return From Keyword If '${alive}' == '${False}' ${False}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600385 [Return] ${True}
George Keishingb3700812016-08-31 03:03:30 -0500386
George Keishing06ae4aa2016-08-30 01:41:28 -0500387Flush REST Sessions
388 [Documentation] Removes all the active session objects
389 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500390
Sivas SRRe1143ae2016-08-26 22:31:02 -0500391Initialize DBUS cmd
392 [Documentation] Initialize dbus string with property string to extract
Gunnar Mills38032802016-12-12 13:43:40 -0600393 [Arguments] ${boot_property}
Michael Walsha6723f22016-11-22 11:12:01 -0600394 ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
395 ${cmd}= Catenate ${cmd}${boot_property}
Sivas SRRe1143ae2016-08-26 22:31:02 -0500396 Set Global Variable ${dbuscmd} ${cmd}
397
David Shawba2d2c22017-01-23 16:56:38 -0600398Create OS Console File Path
399 [Documentation] Create OS console file path name and return it.
400 [Arguments] ${log_file_path}=${EMPTY}
George Keishing30c12ff2016-09-02 10:25:29 -0500401
David Shawba2d2c22017-01-23 16:56:38 -0600402 # Description of arguements:
403 # file_path The caller's candidate value. If this value is ${EMPTY}, this
404 # keyword will compose a file path name. Otherwise, this
405 # keyword will use the caller's file_path value. In either
406 # case, the value will be returned.
Gunnar Mills9c760342016-12-08 10:12:06 -0600407
David Shawba2d2c22017-01-23 16:56:38 -0600408 ${default_file_path}= Catenate /tmp/${OPENBMC_HOST}_os_console
409 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
410 ... ${default_file_path} ${log_file_path}
Michael Walsh01bd3682017-01-10 11:21:05 -0600411
David Shawba2d2c22017-01-23 16:56:38 -0600412 [Return] ${log_file_path}
Gunnar Mills9c760342016-12-08 10:12:06 -0600413
David Shawba2d2c22017-01-23 16:56:38 -0600414Create OS Console Command String
415 [Documentation] Return a command string to start OS console logging.
Gunnar Mills9c760342016-12-08 10:12:06 -0600416
David Shawba2d2c22017-01-23 16:56:38 -0600417 # First make sure that the ssh_pw program is available.
418 ${cmd_buf}= Catenate which ssh_pw 2>&1
419 Rdpissuing ${cmd_buf}
420 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
421 Rdpvars rc output
422 Should Be Equal ${rc} ${0} msg=${output}\n
Gunnar Mills9c760342016-12-08 10:12:06 -0600423
David Shawba2d2c22017-01-23 16:56:38 -0600424 ${cmd_buf}= Catenate ssh_pw ${OPENBMC_PASSWORD} -p 2200
425 ... ${OPENBMC_USERNAME}@${OPENBMC_HOST}
George Keishing30c12ff2016-09-02 10:25:29 -0500426
David Shawba2d2c22017-01-23 16:56:38 -0600427 [Return] ${cmd_buf}
George Keishing30c12ff2016-09-02 10:25:29 -0500428
429Stop SOL Console Logging
David Shawba2d2c22017-01-23 16:56:38 -0600430 [Documentation] Stop system console logging and return log output.
431 [Arguments] ${log_file_path}=${EMPTY} ${targ_file_path}=${EMPTY}
Michael Walsh5f3f4142017-05-22 17:09:47 -0500432 ... ${return_data}=${1}
David Shawba2d2c22017-01-23 16:56:38 -0600433
434 # If there are muliple system console processes, they will all be stopped.
435 # If there is no existing log file this keyword will return an error
436 # message to that effect (and write that message to targ_file_path, if
437 # specified).
438 # NOTE: This keyword will not fail if there is no running system console
439 # process.
Michael Walsh01bd3682017-01-10 11:21:05 -0600440
441 # Description of arguments:
David Shawba2d2c22017-01-23 16:56:38 -0600442 # log_file_path The file path that was used to call "Start SOL
443 # Console Logging". See that keyword (above) for details.
444 # targ_file_path If specified, the file path to which the source
445 # file path (i.e. "log_file_path") should be copied.
Michael Walsh5f3f4142017-05-22 17:09:47 -0500446 # return_data If this is set to ${1}, this keyword will return the SOL
447 # data to the caller as a unicode string.
George Keishing30c12ff2016-09-02 10:25:29 -0500448
David Shawba2d2c22017-01-23 16:56:38 -0600449 ${log_file_path}= Create OS Console File Path ${log_file_path}
450 # Find the pid of the active system console logging session (if any).
451 ${search_string}= Create OS Console Command String
452 ${cmd_buf}= Catenate echo $(ps -ef | egrep '${search_string}'
453 ... | egrep -v grep | cut -c10-14)
454 Rdpissuing ${cmd_buf}
455 ${rc} ${os_con_pid}= Run And Return Rc And Output ${cmd_buf}
456 Rdpvars os_con_pid
457 # If rc is not zero it just means that there is no OS Console process
458 # running.
George Keishing30c12ff2016-09-02 10:25:29 -0500459
David Shawba2d2c22017-01-23 16:56:38 -0600460 ${cmd_buf}= Catenate kill -9 ${os_con_pid}
461 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpissuing ${cmd_buf}
462 ${rc} ${output}= Run Keyword If '${os_con_pid}' != '${EMPTY}'
463 ... Run And Return Rc And Output ${cmd_buf}
464 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpvars rc output
George Keishing30c12ff2016-09-02 10:25:29 -0500465
Michael Walsh01bd3682017-01-10 11:21:05 -0600466 Run Keyword If '${targ_file_path}' != '${EMPTY}'
David Shawba2d2c22017-01-23 16:56:38 -0600467 ... Run Keyword And Ignore Error
468 ... Copy File ${log_file_path} ${targ_file_path}
George Keishing30c12ff2016-09-02 10:25:29 -0500469
Michael Walsh5f3f4142017-05-22 17:09:47 -0500470 ${output}= Set Variable ${EMPTY}
471 ${loc_quiet}= Evaluate ${debug}^1
472 ${rc} ${output}= Run Keyword If '${return_data}' == '${1}'
473 ... Cmd Fnc cat ${log_file_path} quiet=${loc_quiet} print_output=${0}
474
David Shawba2d2c22017-01-23 16:56:38 -0600475 [Return] ${output}
476
477Start SOL Console Logging
478 [Documentation] Start system console log to file.
Michael Walsh5f3f4142017-05-22 17:09:47 -0500479 [Arguments] ${log_file_path}=${EMPTY} ${return_data}=${1}
David Shawba2d2c22017-01-23 16:56:38 -0600480
481 # This keyword will first call "Stop SOL Console Logging". Only then will
482 # it start SOL console logging. The data returned by "Stop SOL Console
483 # Logging" will in turn be returned by this keyword.
484
485 # Description of arguments:
Michael Walsh5f3f4142017-05-22 17:09:47 -0500486 # log_file_path The file path to which system console log data should be
487 # written. Note that this path is taken to be a location
488 # on the machine where this program is running rather than
489 # on the Open BMC system.
490 # return_data If this is set to ${1}, this keyword will return any SOL
491 # data to the caller as a unicode string.
David Shawba2d2c22017-01-23 16:56:38 -0600492
493 ${log_file_path}= Create OS Console File Path ${log_file_path}
494
495 ${log_output}= Stop SOL Console Logging ${log_file_path}
Michael Walsh5f3f4142017-05-22 17:09:47 -0500496 ... return_data=${return_data}
David Shawba2d2c22017-01-23 16:56:38 -0600497
498 # Validate by making sure we can create the file. Problems creating the
499 # file would not be noticed by the subsequent ssh command because we fork
500 # the command.
501 Create File ${log_file_path}
502 ${sub_cmd_buf}= Create OS Console Command String
503 # Routing stderr to stdout so that any startup error text will go to the
504 # output file.
505 ${cmd_buf}= Catenate ${sub_cmd_buf} > ${log_file_path} 2>&1 &
506 Rdpissuing ${cmd_buf}
507 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
508 # Because we are forking this command, we essentially will never get a
509 # non-zero return code or any output.
510 Should Be Equal ${rc} ${0}
511
512 [Return] ${log_output}
George Keishing30c12ff2016-09-02 10:25:29 -0500513
514Get Time Stamp
515 [Documentation] Get the current time stamp data
516 ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500517 [Return] ${cur_time}
George Keishing30c12ff2016-09-02 10:25:29 -0500518
George Keishing1b150202016-09-29 08:51:58 -0500519
520Verify BMC State
521 [Documentation] Get the BMC state and verify if the current
522 ... BMC state is as expected.
523 [Arguments] ${expected}
524
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600525 ${current}= Get BMC State Deprecated
George Keishing8db0e1b2016-10-20 13:46:54 -0500526 Should Contain ${expected} ${current}
George Keishing1b150202016-09-29 08:51:58 -0500527
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500528Start Journal Log
529 [Documentation] Start capturing journal log to a file in /tmp using
530 ... journalctl command. By default journal log is collected
531 ... at /tmp/journal_log else user input location.
532 ... The File is appended with datetime.
533 [Arguments] ${file_path}=/tmp/journal_log
534
535 Open Connection And Log In
536
537 ${cur_time}= Get Time Stamp
538 Set Global Variable ${LOG_TIME} ${cur_time}
539 Start Command
540 ... journalctl -f > ${file_path}-${LOG_TIME}
541 Log Journal Log Started: ${file_path}-${LOG_TIME}
542
David Shawba2d2c22017-01-23 16:56:38 -0600543
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500544Stop Journal Log
545 [Documentation] Stop journalctl process if its running.
546 ... By default return log from /tmp/journal_log else
547 ... user input location.
548 [Arguments] ${file_path}=/tmp/journal_log
549
550 Open Connection And Log In
551
552 ${rc}=
553 ... Execute Command
554 ... ps ax | grep journalctl | grep -v grep
555 ... return_stdout=False return_rc=True
556
557 Return From Keyword If '${rc}' == '${1}'
558 ... No journal log process running
559
560 ${output} ${stderr}=
561 ... Execute Command killall journalctl
562 ... return_stderr=True
563 Should Be Empty ${stderr}
564
565 ${journal_log} ${stderr}=
566 ... Execute Command
567 ... cat ${file_path}-${LOG_TIME}
568 ... return_stderr=True
569 Should Be Empty ${stderr}
570
571 Log ${journal_log}
572
573 Execute Command rm ${file_path}-${LOG_TIME}
574
575 [Return] ${journal_log}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500576
577Mac Address To Hex String
578 [Documentation] Converts MAC address into hex format.
579 ... Example
580 ... Given the following MAC: 00:01:6C:80:02:78
581 ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
582 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600583 ... i_macaddress MAC address in the following format
584 ... 00:01:6C:80:02:78
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500585 [Arguments] ${i_macaddress}
586
587 ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600588 [Return] ${mac_hex}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500589
590IP Address To Hex String
591 [Documentation] Converts IP address into hex format.
592 ... Example:
593 ... Given the following IP: 10.3.164.100
594 ... This keyword will return: 0xa 0x3 0xa4 0xa0
595 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600596 ... i_ipaddress IP address in the following format
597 ... 10.10.10.10
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500598 [Arguments] ${i_ipaddress}
599
600 @{ip}= Split String ${i_ipaddress} .
601 ${index}= Set Variable ${0}
602
603 :FOR ${item} IN @{ip}
604 \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes
605 \ Set List Value ${ip} ${index} ${hex}
606 \ ${index}= Set Variable ${index + 1}
607 ${ip_hex}= Catenate @{ip}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600608 [Return] ${ip_hex}
Sivas SRRea85d1f2016-11-13 22:44:28 -0600609
610BMC CPU Performance Check
611 [Documentation] Minimal 10% of proc should be free in this instance
612
613 ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd}
614 ... return_stderr=True
615 Should be empty ${stderr}
616 ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} %
617 Should be true ${bmc_cpu_percentage} < 90
618
619BMC Mem Performance Check
620 [Documentation] Minimal 10% of memory should be free in this instance
621
622 ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd}
623 ... return_stderr=True
624 Should be empty ${stderr}
625
626 ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd}
627 ... return_stderr=True
628 Should be empty ${stderr}
629
630 ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100
631 ${bmc_mem_percentage}= Evaluate
632 ... ${bmc_mem_percentage}/${bmc_mem_total_output}
633 Should be true ${bmc_mem_percentage} > 10
634
Sivas SRRaca55712016-12-21 04:32:35 -0600635BMC File System Usage Check
636 [Documentation] Check the file system space. None should be 100% full
Sivas SRR352bc162017-02-13 22:12:29 -0600637 ... except /run/initramfs/ro
Sivas SRRaca55712016-12-21 04:32:35 -0600638 ${bmc_fs_usage_output} ${stderr}= Execute Command
639 ... ${bmc_file_system_usage_cmd} return_stderr=True
640 Should Be Empty ${stderr}
641 Should Be True ${bmc_fs_usage_output}==0
642
Sivas SRRea85d1f2016-11-13 22:44:28 -0600643Check BMC CPU Performance
644 [Documentation] Minimal 10% of proc should be free in 3 sample
645 :FOR ${var} IN Range 1 4
646 \ BMC CPU Performance check
647
648Check BMC Mem Performance
649 [Documentation] Minimal 10% of memory should be free
650
651 :FOR ${var} IN Range 1 4
652 \ BMC Mem Performance check
653
Sivas SRRaca55712016-12-21 04:32:35 -0600654Check BMC File System Performance
655 [Documentation] Check for file system usage for 4 times
656
657 :FOR ${var} IN Range 1 4
658 \ BMC File System Usage check
659
Rahul Maheshwari63c105b2017-05-12 05:13:52 -0500660Get URL List
661 [Documentation] Return list of URLs under given URL.
662 [Arguments] ${openbmc_url}
663 # Description of argument(s):
Michael Walsh5f3f4142017-05-22 17:09:47 -0500664 # openbmc_url URL for list operation (e.g.
665 # /xyz/openbmc_project/inventory).
Rahul Maheshwari63c105b2017-05-12 05:13:52 -0500666
667 ${url_list}= Read Properties ${openbmc_url}/list
668 [Return] ${url_list}
669
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600670Get Endpoint Paths
671 [Documentation] Returns all url paths ending with given endpoint
672 ... Example:
673 ... Given the following endpoint: cpu
Michael Walsh01bd3682017-01-10 11:21:05 -0600674 ... This keyword will return: list of all urls ending with
675 ... cpu -
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600676 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
677 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
678 ... Description of arguments:
679 ... path URL path for enumeration
680 ... endpoint string for which url path ending
681 [Arguments] ${path} ${endpoint}
682
683 ${resp}= Read Properties ${path}/enumerate timeout=30
684 log Dictionary ${resp}
685
686 ${list}= Get Dictionary Keys ${resp}
687 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600688 [Return] ${resp}
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500689
690Check Zombie Process
691 [Documentation] Check if any defunct process exist or not on BMC
Michael Walsh01bd3682017-01-10 11:21:05 -0600692 ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500693 ... return_stderr=True return_rc=True
694 Should Be True ${count}==0
695 Should Be Empty ${stderr}
George Keishing5327d012016-12-08 08:43:29 -0600696
697Prune Journal Log
698 [Documentation] Prune archived journal logs.
699 [Arguments] ${vacuum_size}=1M
700
701 # This keyword can be used to prevent the journal
702 # log from filling up the /run filesystem.
703 # This command will retain only the latest logs
704 # of the user specified size.
705
706 Open Connection And Log In
707 ${output} ${stderr} ${rc}=
708 ... Execute Command
709 ... journalctl --vacuum-size=${vacuum_size}
710 ... return_stderr=True return_rc=True
711
712 Should Be Equal ${rc} ${0} msg=${stderr}
Sridevi Ramesh1699d372016-12-06 00:20:22 -0600713
714Set BMC Power Policy
715 [Documentation] Set the given BMC power policy.
716 [arguments] ${policy}
717
718 ${valueDict}= create dictionary data=${policy}
719 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
720 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
721 Should Be Equal ${currentPolicy} ${policy}
George Keishingcce9df22017-01-24 06:19:33 -0600722
George Keishing4d6f3d62017-02-06 09:50:41 -0600723Get System Power Policy
724 [Documentation] Get the BMC power policy.
725 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
726 [Return] ${currentPolicy}
George Keishingcce9df22017-01-24 06:19:33 -0600727
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600728Get Auto Reboot
729 [Documentation] Returns auto reboot setting.
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500730 ${setting}= Read Attribute ${HOST_SETTING} auto_reboot
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600731 [Return] ${setting}
732
733
734Set Auto Reboot
735 [Documentation] Set the given auto reboot setting.
736 [Arguments] ${setting}
737 # setting auto reboot's setting, i.e. yes or no
738
739 ${valueDict}= Set Variable ${setting}
740 ${data}= Create Dictionary data=${valueDict}
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500741 Write Attribute ${HOST_SETTING} auto_reboot data=${data}
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600742 ${current_setting}= Get Auto Reboot
743 Should Be Equal ${current_setting} ${setting}
744
745
George Keishingcce9df22017-01-24 06:19:33 -0600746Set BMC Reset Reference Time
747 [Documentation] Set current boot time as a reference and increment
George Keishing80dd5af2017-02-08 07:01:25 -0600748 ... boot count.
George Keishingcce9df22017-01-24 06:19:33 -0600749
750 ${cur_btime}= Get BMC Boot Time
George Keishing80dd5af2017-02-08 07:01:25 -0600751 Run Keyword If ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
George Keishingcce9df22017-01-24 06:19:33 -0600752 ... Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishing80dd5af2017-02-08 07:01:25 -0600753 ... ELSE IF ${cur_btime} > ${BOOT_TIME}
754 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishingcce9df22017-01-24 06:19:33 -0600755 ... AND
756 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
757
George Keishingcce9df22017-01-24 06:19:33 -0600758Get BMC Boot Time
759 [Documentation] Get boot time from /proc/stat.
760
761 Open Connection And Log In
762 ${output} ${stderr}=
763 ... Execute Command egrep '^btime ' /proc/stat | cut -f 2 -d ' '
764 ... return_stderr=True
765 Should Be Empty ${stderr}
766 ${btime}= Convert To Integer ${output}
767 [Return] ${btime}
George Keishingede30002017-02-02 09:33:07 -0600768
George Keishingede30002017-02-02 09:33:07 -0600769Execute Command On BMC
770 [Documentation] Execute given command on BMC and return output.
771 [Arguments] ${command}
772 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
773 Should Be Empty ${stderr}
774 [Return] ${stdout}
David Shawba2d2c22017-01-23 16:56:38 -0600775
Sridevi Rameshea36b412017-03-09 04:08:02 -0600776
George Keishing7a520222017-02-27 09:44:30 -0600777Enable Core Dump On BMC
778 [Documentation] Enable core dump collection.
779 Open Connection And Log In
780 ${core_pattern}= Execute Command On BMC
781 ... echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
782 Should Be Equal As Strings ${core_pattern} /tmp/core_%e.%p
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600783
Sivas SRR01262bd2017-03-19 10:00:23 -0500784Get Number Of BMC Core Dump Files
785 [Documentation] Get number of core dump files on BMC.
786 Open Connection And Log In
787 ${num_of_core_dump}= Execute Command
788 ... ls /tmp/core* 2>/dev/null | wc -l
789 [Return] ${num_of_core_dump}
790
791Set Core Dump File Size Unlimited
792 [Documentation] Set core dump file size to unlimited.
793 Open Connection And Log In
794 Execute Command On BMC
795 ... ulimit -c unlimited
796
797Check For Core Dumps
798 [Documentation] Check for any core dumps exist.
799 ${output}= Get Number Of BMC Core Dump Files
800 Run Keyword If ${output} > 0
801 ... Log **Warning** BMC core dump files exist level=WARN
802
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600803Trigger Host Watchdog Error
804 [Documentation] Inject host watchdog error using BMC.
805 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Michael Walshb5839d02017-04-12 16:11:20 -0500806 # Description of argument(s):
807 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
808 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600809 # sleep_time Time delay for host watchdog error to get injected.
810 # Default is 5 seconds.
811
812 Execute Command On BMC
813 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog set i ${milliseconds}
814 Execute Command On BMC
815 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog start
816 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500817
818Login To OS Host
819 [Documentation] Login to OS Host.
820 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
821 ... ${os_password}=${OS_PASSWORD}
822 # Desription of arguments:
823 # ${os_host} IP address of the OS Host.
824 # ${os_username} OS Host Login user name.
825 # ${os_password} OS Host Login passwrd.
826
827 ${os_state}= Run Keyword And Return Status Ping Host ${os_host}
828 Run Keyword If '${os_state}' == 'False'
829 ... Run Keywords Initiate Host Reboot AND
830 ... Is Host Running AND
831 ... Wait for OS ${os_host} ${os_username} ${os_password}
832
833 Open Connection ${os_host}
Sridevi Rameshea36b412017-03-09 04:08:02 -0600834 ${resp}= Login ${os_username} ${os_password}
835 [Return] ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500836
837Configure Initial Settings
838 [Documentation] Restore old IP and route.
839 ... This keyword requires initial settings viz IP address,
840 ... Network Mask, default gatway and serial console IP and port
841 ... information which should be provided in command line.
842
Michael Walshb5839d02017-04-12 16:11:20 -0500843 [Arguments] ${host}=${OPENBMC_HOST} ${mask}=${NET_MASK}
844 ... ${gw_ip}=${GW_IP}
Prashanth Katti884ee062017-03-16 05:05:03 -0500845
Michael Walshb5839d02017-04-12 16:11:20 -0500846 # Open telnet connection and ignore the error, in case telnet session is
847 # already opened by the program calling this keyword.
Prashanth Katti884ee062017-03-16 05:05:03 -0500848
849 Run Keyword And Ignore Error Open Telnet Connection to BMC Serial Console
850 Telnet.write ifconfig eth0 ${host} netmask ${mask}
851 Telnet.write route add default gw ${gw_ip}
George Keishingd05b1082017-03-24 05:27:32 -0500852
853Install Debug Tarball On BMC
George Keishing55441822017-05-18 14:17:59 -0500854 [Documentation] Copy the debug tar file to BMC and install.
855 [Arguments] ${tarball_file_path}=${EXECDIR}/obmc-phosphor-debug-tarball-witherspoon.tar.xz
856 ... ${targ_tarball_dir_path}=/home/root/tarball/
George Keishingd05b1082017-03-24 05:27:32 -0500857
George Keishing55441822017-05-18 14:17:59 -0500858 # Description of arguments:
859 # tarball_file_path Path of the debug tarball file.
860 # The tar file is downloaded from the build page
861 # https://openpower.xyz/job/openbmc-build/
862 # obmc-phosphor-debug-tarball-witherspoon.tar.xz
863 #
864 # targ_tarball_dir_path The directory path where the tarball is to be
865 # installed.
866
867 OperatingSystem.File Should Exist ${tarball_file_path}
868 ... msg=${tarball_file_path} doesn't exist.
869
870 # Upload the file to BMC.
George Keishingd05b1082017-03-24 05:27:32 -0500871 Import Library SCPLibrary WITH NAME scp
872 Open Connection for SCP
George Keishing55441822017-05-18 14:17:59 -0500873 scp.Put File ${tarball_file_path} /tmp/debug-tarball.tar.xz
874
875 # Create tarball directory and install.
George Keishingd05b1082017-03-24 05:27:32 -0500876 Open Connection And Log In
George Keishing55441822017-05-18 14:17:59 -0500877 Execute Command On BMC mkdir -p ${targ_tarball_dir_path}
878 Execute Command On BMC
879 ... tar -xf /tmp/debug-tarball.tar.xz -C ${targ_tarball_dir_path}
880
881 # Create symlink to callout-test binary.
882 Execute Command On BMC
883 ... ln -s ${targ_tarball_dir_path}/bin/callout-test /usr/bin/callout-test
884
George Keishingd05b1082017-03-24 05:27:32 -0500885 # Remove the tarball file from BMC
886 Execute Command On BMC rm /tmp/debug-tarball.tar.xz
887
George Keishing55441822017-05-18 14:17:59 -0500888
Sweta Potthuri025e0122017-02-21 00:42:48 -0600889Get BMC Boot Count
890 [Documentation] Get BMC boot count based on boot time.
891 ${cur_btime}= Get BMC Boot Time
892
893 # Set global variable BOOT_TIME to current boot time if current boot time
894 # is changed. Also increase value of global variable BOOT_COUNT by 1.
895 Run Keyword If ${cur_btime} > ${BOOT_TIME}
896 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
897 ... AND
898 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
899 [Return] ${BOOT_COUNT}
900
901Set BMC Boot Count
902 [Documentation] Set BMC boot count to given value.
903 [Arguments] ${count}
904
905 # Description of arguments:
906 # count boot count value.
907 ${cur_btime}= Get BMC Boot Time
908
909 # Set global variable BOOT_COUNT to given value.
910 Set Global Variable ${BOOT_COUNT} ${count}
911
912 # Set BOOT_TIME variable to current boot time.
913 Set Global Variable ${BOOT_COUNT} ${count}
Michael Walsh689fbbe2017-04-04 17:58:03 -0500914
915###############################################################################
916Delete Error logs
917 [Documentation] Delete error logs.
918
919 # The REST method to delete error openbmc/openbmc#1327
920 # until then using logging restart.
921 Open Connection And Log In
922 Execute Command On BMC
923 ... systemctl restart xyz.openbmc_project.Logging.service
924 Sleep 10s reason=Wait for logging service to restart properly.
George Keishingdb34c2f2017-04-18 13:20:25 -0500925
926###############################################################################
927Delete Error log Entry
928 [Documentation] Delete error log entry.
929 [Arguments] ${entry_path}
930
931 # Description of argument(s):
932 # entry_path Delete an error log entry.
933 # Ex. /xyz/openbmc_project/logging/entry/1
934
935 ${data}= Create Dictionary data=@{EMPTY}
936 ${resp}= Openbmc Delete Request ${entry_path} data=${data}
937 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}