blob: 64afb230861033d1209a6a4fe1b59a29a4b45524 [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
George Keishingb7c9b542017-05-23 08:19:58 -050037# Initialize default debug value to 0.
38${DEBUG} ${0}
39
Chris Austenb29d2e82016-06-07 12:25:35 -050040*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060041
Sivas SRR8254db62017-02-07 09:39:46 -060042Get BMC System Model
43 [Documentation] Get the BMC model from the device tree.
44
Michael Walshb5839d02017-04-12 16:11:20 -050045 Open Connection And Log In
George Keishing90ab1772017-02-24 05:40:55 -060046 ${bmc_model} ${stderr}= Execute Command
47 ... cat ${devicetree_base} | cut -d " " -f 1 return_stderr=True
Sivas SRR8254db62017-02-07 09:39:46 -060048 Should Be Empty ${stderr}
49 Should Not Be Empty ${bmc_model}
50 [Return] ${bmc_model}
51
52Verify BMC System Model
53 [Documentation] Verify the BMC model with ${OPENBMC_MODEL}.
54 [Arguments] ${bmc_model}
55
56 ${tmp_bmc_model}= Fetch From Right ${OPENBMC_MODEL} /
57 ${tmp_bmc_model}= Fetch From Left ${tmp_bmc_model} .
58 ${ret}= Run Keyword And Return Status Should Contain ${bmc_model}
59 ... ${tmp_bmc_model} ignore_case=True
60 [Return] ${ret}
61
Chris Austenb29d2e82016-06-07 12:25:35 -050062Wait For Host To Ping
root442f0ef2016-08-04 20:23:05 +000063 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
64 ... ${interval}=5 sec
65
66 # host The DNS name or IP of the host to ping.
67 # timeout The amount of time after which attempts to ping cease.
68 # interval The amount of time in between attempts to ping.
69
70 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050071
72Ping Host
73 [Arguments] ${host}
George Keishing8a84f952016-08-25 04:54:53 -050074 Should Not Be Empty ${host} msg=No host provided
Michael Walsha6723f22016-11-22 11:12:01 -060075 ${RC} ${output}= Run and return RC and Output ping -c 4 ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050076 Log RC: ${RC}\nOutput:\n${output}
77 Should be equal ${RC} ${0}
78
79Get Boot Progress
Michael Walsha6723f22016-11-22 11:12:01 -060080 [Arguments] ${quiet}=${QUIET}
81
George Keishing85ca05e2016-11-30 09:47:18 -060082 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
Michael Walsha6723f22016-11-22 11:12:01 -060083 ... value quiet=${quiet}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060084 [Return] ${state}
Chris Austenb29d2e82016-06-07 12:25:35 -050085
86Is Power On
root442f0ef2016-08-04 20:23:05 +000087 ${state}= Get Power State
88 Should be equal ${state} ${1}
Chris Austenb29d2e82016-06-07 12:25:35 -050089
90Is Power Off
root442f0ef2016-08-04 20:23:05 +000091 ${state}= Get Power State
92 Should be equal ${state} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050093
root442f0ef2016-08-04 20:23:05 +000094Initiate Power On
95 [Documentation] Initiates the power on and waits until the Is Power On
96 ... keyword returns that the power state has switched to on.
Michael Walsha6723f22016-11-22 11:12:01 -060097 [Arguments] ${wait}=${1}
98
Chris Austenb29d2e82016-06-07 12:25:35 -050099 @{arglist}= Create List
100 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600101 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
Michael Walsha6723f22016-11-22 11:12:01 -0600102 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500103 should be equal as strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -0500104
Michael Walsha6723f22016-11-22 11:12:01 -0600105 # Does caller want to wait for power on status?
106 Run Keyword If '${wait}' == '${0}' Return From Keyword
107 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500108
root442f0ef2016-08-04 20:23:05 +0000109Initiate Power Off
110 [Documentation] Initiates the power off and waits until the Is Power Off
111 ... keyword returns that the power state has switched to off.
Chris Austenb29d2e82016-06-07 12:25:35 -0500112 @{arglist}= Create List
113 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600114 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
Michael Walsha6723f22016-11-22 11:12:01 -0600115 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500116 should be equal as strings ${resp.status_code} ${HTTP_OK}
Michael Walsha6723f22016-11-22 11:12:01 -0600117 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
Chris Austenb29d2e82016-06-07 12:25:35 -0500118
Michael Walsh81843772017-03-02 14:44:44 -0600119Initiate OS Host Power Off
120 [Documentation] Initiate an OS reboot.
121 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
122 ... ${os_password}=${OS_PASSWORD}
123
124 # Description of arguments:
125 # os_host The DNS name or IP of the OS.
126 # os_username The username to be used to sign in to the OS.
127 # os_password The password to be used to sign in to the OS.
128
Michael Walshac275512017-03-07 11:39:28 -0600129 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600130 Login ${os_username} ${os_password}
131 ${cmd_buf} Catenate shutdown
132 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600133 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600134
135Initiate OS Host Reboot
136 [Documentation] Initiate an OS reboot.
137 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
138 ... ${os_password}=${OS_PASSWORD}
139
140 # Description of arguments:
141 # os_host The DNS name or IP of the OS.
142 # os_username The username to be used to sign in to the OS.
143 # os_password The password to be used to sign in to the OS.
144
Michael Walshac275512017-03-07 11:39:28 -0600145 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600146 Login ${os_username} ${os_password}
147 ${cmd_buf} Catenate reboot
148 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600149 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600150
151Initiate Auto Reboot
152 [Documentation] Initiate an auto reboot.
153
154 # Set the auto reboot policy.
155 Set Auto Reboot yes
156
Michael Walshac275512017-03-07 11:39:28 -0600157 SSHLibrary.Open connection ${openbmc_host}
Michael Walsh81843772017-03-02 14:44:44 -0600158 Login ${openbmc_username} ${openbmc_password}
159
160 # Set the watchdog timer. Note: 5000 = milliseconds which is 5 seconds.
161 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
162 ... org.openbmc.Watchdog set i 5000
163 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
164 ... return_stderr=True return_rc=True
165 Should Be Empty ${stderr}
166 Should be equal ${rc} ${0}
167
168 # Start the watchdog.
169 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
170 ... org.openbmc.Watchdog start
171 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
172 ... return_stderr=True return_rc=True
173 Should Be Empty ${stderr}
174 Should be equal ${rc} ${0}
175
Chris Austenb29d2e82016-06-07 12:25:35 -0500176Trigger Warm Reset
177 log to console "Triggering warm reset"
Michael Walsha6723f22016-11-22 11:12:01 -0600178 ${data}= create dictionary data=@{EMPTY}
George Keishing85ca05e2016-11-30 09:47:18 -0600179 ${resp}= openbmc post request
180 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500181 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingb3700812016-08-31 03:03:30 -0500182 ${session_active}= Check If warmReset is Initiated
183 Run Keyword If '${session_active}' == '${True}'
184 ... Fail msg=warm reset didn't occur
185
Chris Austenb29d2e82016-06-07 12:25:35 -0500186 Sleep ${SYSTEM_SHUTDOWN_TIME}min
Rahul Maheshwari5f253c42017-01-30 05:19:51 -0600187 Check If BMC Is Up
Michael Walsh49ab0f42016-07-20 11:44:33 -0500188
189Check OS
root442f0ef2016-08-04 20:23:05 +0000190 [Documentation] Attempts to ping the host OS and then checks that the host
191 ... OS is up by running an SSH command.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500192
193 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
Michael Walsha6723f22016-11-22 11:12:01 -0600194 ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET}
195 ... ${print_string}=${EMPTY}
Michael Walshac275512017-03-07 11:39:28 -0600196 [Teardown] SSHLibrary.Close Connection
Michael Walsh49ab0f42016-07-20 11:44:33 -0500197
198 # os_host The DNS name/IP of the OS host associated with our BMC.
199 # os_username The username to be used to sign on to the OS host.
200 # os_password The password to be used to sign on to the OS host.
Michael Walsha6723f22016-11-22 11:12:01 -0600201 # quiet Indicates whether this keyword should write to console.
202 # print_string A string to be printed before checking the OS.
203
204 rprint ${print_string}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500205
root442f0ef2016-08-04 20:23:05 +0000206 # Attempt to ping the OS. Store the return code to check later.
207 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
208
Michael Walshac275512017-03-07 11:39:28 -0600209 SSHLibrary.Open connection ${os_host}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500210
Michael Walsha6723f22016-11-22 11:12:01 -0600211 ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username}
212 ... ${os_password}
213 ${err_msg1}= Sprint Error ${msg}
214 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
215 Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500216 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
217 ... return_rc=True
218
Michael Walsha6723f22016-11-22 11:12:01 -0600219 ${temp_msg}= Catenate Could not execute a command on the operating
220 ... system.\n
221 ${err_msg1}= Sprint Error ${temp_msg}
222 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
223
224 # If the return code returned by "Execute Command" is non-zero, this
225 # keyword will fail.
226 Should Be Equal ${rc} ${0} msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500227 # We will likewise fail if there is any stderr data.
228 Should Be Empty ${stderr}
229
Michael Walsha6723f22016-11-22 11:12:01 -0600230 ${temp_msg}= Set Variable Could not ping the operating system.\n
231 ${err_msg1}= Sprint Error ${temp_msg}
232 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
233 # We will likewise fail if the OS did not ping, as we could SSH but not
234 # ping
235 Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg}
root442f0ef2016-08-04 20:23:05 +0000236
Michael Walsh49ab0f42016-07-20 11:44:33 -0500237Wait for OS
238 [Documentation] Waits for the host OS to come up via calls to "Check OS".
239 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
240 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
Michael Walsha6723f22016-11-22 11:12:01 -0600241 ... ${quiet}=${0}
242 [Teardown] rprintn
Michael Walsh49ab0f42016-07-20 11:44:33 -0500243
244 # os_host The DNS name or IP of the OS host associated with our
245 # BMC.
246 # os_username The username to be used to sign on to the OS host.
247 # os_password The password to be used to sign on to the OS host.
248 # timeout The timeout in seconds indicating how long you're
249 # willing to wait for the OS to respond.
Michael Walsha6723f22016-11-22 11:12:01 -0600250 # quiet Indicates whether this keyword should write to console.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500251
252 # The interval to be used between calls to "Check OS".
253 ${interval}= Set Variable 5
254
Michael Walsha6723f22016-11-22 11:12:01 -0600255 ${message}= Catenate Checking every ${interval} seconds for up to
256 ... ${timeout} seconds for the operating system to communicate.
257 rqprint_timen ${message}
258
Michael Walsh49ab0f42016-07-20 11:44:33 -0500259 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
260 ... ${os_host} ${os_username} ${os_password}
Michael Walsha6723f22016-11-22 11:12:01 -0600261 ... print_string=\#
262
263 rqprintn
264
265 rqprint_timen The operating system is now communicating.
root442f0ef2016-08-04 20:23:05 +0000266
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600267Get BMC State Deprecated
root442f0ef2016-08-04 20:23:05 +0000268 [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY)
Michael Walsha6723f22016-11-22 11:12:01 -0600269 [Arguments] ${quiet}=${QUIET}
270
root442f0ef2016-08-04 20:23:05 +0000271 @{arglist}= Create List
272 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600273 ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState
Michael Walsha6723f22016-11-22 11:12:01 -0600274 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000275 Should be equal as strings ${resp.status_code} ${HTTP_OK}
276 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600277 [Return] ${content["data"]}
root442f0ef2016-08-04 20:23:05 +0000278
279Get Power State
280 [Documentation] Returns the power state as an integer. Either 0 or 1.
Michael Walsha6723f22016-11-22 11:12:01 -0600281 [Arguments] ${quiet}=${QUIET}
282
root442f0ef2016-08-04 20:23:05 +0000283 @{arglist}= Create List
284 ${args}= Create Dictionary data=@{arglist}
Michael Walsha6723f22016-11-22 11:12:01 -0600285
George Keishing85ca05e2016-11-30 09:47:18 -0600286 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
Michael Walsha6723f22016-11-22 11:12:01 -0600287 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000288 Should be equal as strings ${resp.status_code} ${HTTP_OK}
289 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600290 [Return] ${content["data"]}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500291
292Clear BMC Record Log
293 [Documentation] Clears all the event logs on the BMC. This would be
294 ... equivalent to ipmitool sel clear.
295 @{arglist}= Create List
296 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600297 ${resp}= Call Method
298 ... ${OPENBMC_BASE_URI}records/events/ clear data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500299 should be equal as strings ${resp.status_code} ${HTTP_OK}
300
301Copy PNOR to BMC
302 Import Library SCPLibrary WITH NAME scp
303 Open Connection for SCP
304 Log Copying ${PNOR_IMAGE_PATH} to /tmp
305 scp.Put File ${PNOR_IMAGE_PATH} /tmp
306
307Flash PNOR
308 [Documentation] Calls flash bios update method to flash PNOR image
Gunnar Mills38032802016-12-12 13:43:40 -0600309 [Arguments] ${pnor_image}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500310 @{arglist}= Create List ${pnor_image}
311 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600312 ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update
Michael Walsha6723f22016-11-22 11:12:01 -0600313 ... data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500314 should be equal as strings ${resp.status_code} ${HTTP_OK}
315 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
316
317Get Flash BIOS Status
318 [Documentation] Returns the status of the flash BIOS API as a string. For
319 ... example 'Flashing', 'Flash Done', etc
George Keishing85ca05e2016-11-30 09:47:18 -0600320 ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600321 [Return] ${data['status']}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500322
323Is PNOR Flashing
324 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
325 ... flashing has started.
326 ${status}= Get Flash BIOS Status
Rahul Maheshwari449dfb72017-05-08 02:06:48 -0500327 Should Contain ${status} Flashing
Jay Azurine4c52eb2016-08-16 20:51:10 -0500328
329Is PNOR Flash Done
330 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
331 ... PNOR flashing has completed.
Leah McNutt9ba32272016-11-17 15:48:39 +0000332 ${status}= Get Flash BIOS Status
Jay Azurine4c52eb2016-08-16 20:51:10 -0500333 should be equal as strings ${status} Flash Done
334
335Is System State Host Booted
336 [Documentation] Checks whether system state is HOST_BOOTED.
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600337 ${state}= Get BMC State Deprecated
Jay Azurine4c52eb2016-08-16 20:51:10 -0500338 should be equal as strings ${state} HOST_BOOTED
George Keishing5e870cd2016-08-24 10:05:47 -0500339
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600340Is OS Starting
341 [Documentation] Check if boot progress is OS starting.
342 ${boot_progress}= Get Boot Progress
343 Should Be Equal ${boot_progress} FW Progress, Starting OS
344
George Keishing0af24412017-03-10 13:33:23 -0600345Is OS Off
346 [Documentation] Check if boot progress is "Off".
347 ${boot_progress}= Get Boot Progress
348 Should Be Equal ${boot_progress} Off
349
George Keishing5e870cd2016-08-24 10:05:47 -0500350Verify Ping and REST Authentication
Michael Walsha6723f22016-11-22 11:12:01 -0600351 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500352 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -0500353 Run Keyword If '${l_ping}' == '${False}'
354 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500355
Michael Walsha6723f22016-11-22 11:12:01 -0600356 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500357 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -0500358 Run Keyword If '${l_rest}' == '${False}'
359 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500360
361 # Just to make sure the SSH is working for SCP
362 Open Connection And Log In
363 ${system} ${stderr}= Execute Command hostname return_stderr=True
364 Should Be Empty ${stderr}
365
George Keishingc4d3dc02016-09-19 03:45:55 -0500366Check If BMC is Up
367 [Documentation] Wait for Host to be online. Checks every X seconds
368 ... interval for Y minutes and fails if timed out.
369 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -0600370 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -0500371 ... ${interval}=10 sec
372
373 Wait Until Keyword Succeeds
374 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
375
George Keishingb3700812016-08-31 03:03:30 -0500376
377Check If warmReset is Initiated
378 [Documentation] Ping would be still alive, so try SSH to connect
379 ... if fails the ports are down indicating reboot
380 ... is in progress
George Keishing3c05d352016-12-13 06:54:50 -0600381
382 # Warm reset adds 3 seconds delay before forcing reboot
383 # To minimize race conditions, we wait for 7 seconds
384 Sleep 7s
George Keishingb3700812016-08-31 03:03:30 -0500385 ${alive}= Run Keyword and Return Status
386 ... Open Connection And Log In
387 Return From Keyword If '${alive}' == '${False}' ${False}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600388 [Return] ${True}
George Keishingb3700812016-08-31 03:03:30 -0500389
George Keishing06ae4aa2016-08-30 01:41:28 -0500390Flush REST Sessions
391 [Documentation] Removes all the active session objects
392 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500393
Sivas SRRe1143ae2016-08-26 22:31:02 -0500394Initialize DBUS cmd
395 [Documentation] Initialize dbus string with property string to extract
Gunnar Mills38032802016-12-12 13:43:40 -0600396 [Arguments] ${boot_property}
Michael Walsha6723f22016-11-22 11:12:01 -0600397 ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
398 ${cmd}= Catenate ${cmd}${boot_property}
Sivas SRRe1143ae2016-08-26 22:31:02 -0500399 Set Global Variable ${dbuscmd} ${cmd}
400
David Shawba2d2c22017-01-23 16:56:38 -0600401Create OS Console File Path
402 [Documentation] Create OS console file path name and return it.
403 [Arguments] ${log_file_path}=${EMPTY}
George Keishing30c12ff2016-09-02 10:25:29 -0500404
David Shawba2d2c22017-01-23 16:56:38 -0600405 # Description of arguements:
406 # file_path The caller's candidate value. If this value is ${EMPTY}, this
407 # keyword will compose a file path name. Otherwise, this
408 # keyword will use the caller's file_path value. In either
409 # case, the value will be returned.
Gunnar Mills9c760342016-12-08 10:12:06 -0600410
David Shawba2d2c22017-01-23 16:56:38 -0600411 ${default_file_path}= Catenate /tmp/${OPENBMC_HOST}_os_console
412 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
413 ... ${default_file_path} ${log_file_path}
Michael Walsh01bd3682017-01-10 11:21:05 -0600414
David Shawba2d2c22017-01-23 16:56:38 -0600415 [Return] ${log_file_path}
Gunnar Mills9c760342016-12-08 10:12:06 -0600416
David Shawba2d2c22017-01-23 16:56:38 -0600417Create OS Console Command String
418 [Documentation] Return a command string to start OS console logging.
Gunnar Mills9c760342016-12-08 10:12:06 -0600419
David Shawba2d2c22017-01-23 16:56:38 -0600420 # First make sure that the ssh_pw program is available.
421 ${cmd_buf}= Catenate which ssh_pw 2>&1
422 Rdpissuing ${cmd_buf}
423 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
424 Rdpvars rc output
425 Should Be Equal ${rc} ${0} msg=${output}\n
Gunnar Mills9c760342016-12-08 10:12:06 -0600426
David Shawba2d2c22017-01-23 16:56:38 -0600427 ${cmd_buf}= Catenate ssh_pw ${OPENBMC_PASSWORD} -p 2200
428 ... ${OPENBMC_USERNAME}@${OPENBMC_HOST}
George Keishing30c12ff2016-09-02 10:25:29 -0500429
David Shawba2d2c22017-01-23 16:56:38 -0600430 [Return] ${cmd_buf}
George Keishing30c12ff2016-09-02 10:25:29 -0500431
432Stop SOL Console Logging
David Shawba2d2c22017-01-23 16:56:38 -0600433 [Documentation] Stop system console logging and return log output.
434 [Arguments] ${log_file_path}=${EMPTY} ${targ_file_path}=${EMPTY}
Michael Walsh5f3f4142017-05-22 17:09:47 -0500435 ... ${return_data}=${1}
David Shawba2d2c22017-01-23 16:56:38 -0600436
437 # If there are muliple system console processes, they will all be stopped.
438 # If there is no existing log file this keyword will return an error
439 # message to that effect (and write that message to targ_file_path, if
440 # specified).
441 # NOTE: This keyword will not fail if there is no running system console
442 # process.
Michael Walsh01bd3682017-01-10 11:21:05 -0600443
444 # Description of arguments:
David Shawba2d2c22017-01-23 16:56:38 -0600445 # log_file_path The file path that was used to call "Start SOL
446 # Console Logging". See that keyword (above) for details.
447 # targ_file_path If specified, the file path to which the source
448 # file path (i.e. "log_file_path") should be copied.
Michael Walsh5f3f4142017-05-22 17:09:47 -0500449 # return_data If this is set to ${1}, this keyword will return the SOL
450 # data to the caller as a unicode string.
George Keishing30c12ff2016-09-02 10:25:29 -0500451
David Shawba2d2c22017-01-23 16:56:38 -0600452 ${log_file_path}= Create OS Console File Path ${log_file_path}
453 # Find the pid of the active system console logging session (if any).
454 ${search_string}= Create OS Console Command String
455 ${cmd_buf}= Catenate echo $(ps -ef | egrep '${search_string}'
456 ... | egrep -v grep | cut -c10-14)
457 Rdpissuing ${cmd_buf}
458 ${rc} ${os_con_pid}= Run And Return Rc And Output ${cmd_buf}
459 Rdpvars os_con_pid
460 # If rc is not zero it just means that there is no OS Console process
461 # running.
George Keishing30c12ff2016-09-02 10:25:29 -0500462
David Shawba2d2c22017-01-23 16:56:38 -0600463 ${cmd_buf}= Catenate kill -9 ${os_con_pid}
464 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpissuing ${cmd_buf}
465 ${rc} ${output}= Run Keyword If '${os_con_pid}' != '${EMPTY}'
466 ... Run And Return Rc And Output ${cmd_buf}
467 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpvars rc output
George Keishing30c12ff2016-09-02 10:25:29 -0500468
Michael Walsh01bd3682017-01-10 11:21:05 -0600469 Run Keyword If '${targ_file_path}' != '${EMPTY}'
David Shawba2d2c22017-01-23 16:56:38 -0600470 ... Run Keyword And Ignore Error
471 ... Copy File ${log_file_path} ${targ_file_path}
George Keishing30c12ff2016-09-02 10:25:29 -0500472
Michael Walsh5f3f4142017-05-22 17:09:47 -0500473 ${output}= Set Variable ${EMPTY}
474 ${loc_quiet}= Evaluate ${debug}^1
475 ${rc} ${output}= Run Keyword If '${return_data}' == '${1}'
476 ... Cmd Fnc cat ${log_file_path} quiet=${loc_quiet} print_output=${0}
477
David Shawba2d2c22017-01-23 16:56:38 -0600478 [Return] ${output}
479
480Start SOL Console Logging
481 [Documentation] Start system console log to file.
Michael Walsh5f3f4142017-05-22 17:09:47 -0500482 [Arguments] ${log_file_path}=${EMPTY} ${return_data}=${1}
David Shawba2d2c22017-01-23 16:56:38 -0600483
484 # This keyword will first call "Stop SOL Console Logging". Only then will
485 # it start SOL console logging. The data returned by "Stop SOL Console
486 # Logging" will in turn be returned by this keyword.
487
488 # Description of arguments:
Michael Walsh5f3f4142017-05-22 17:09:47 -0500489 # log_file_path The file path to which system console log data should be
490 # written. Note that this path is taken to be a location
491 # on the machine where this program is running rather than
492 # on the Open BMC system.
493 # return_data If this is set to ${1}, this keyword will return any SOL
494 # data to the caller as a unicode string.
David Shawba2d2c22017-01-23 16:56:38 -0600495
496 ${log_file_path}= Create OS Console File Path ${log_file_path}
497
498 ${log_output}= Stop SOL Console Logging ${log_file_path}
Michael Walsh5f3f4142017-05-22 17:09:47 -0500499 ... return_data=${return_data}
David Shawba2d2c22017-01-23 16:56:38 -0600500
501 # Validate by making sure we can create the file. Problems creating the
502 # file would not be noticed by the subsequent ssh command because we fork
503 # the command.
504 Create File ${log_file_path}
505 ${sub_cmd_buf}= Create OS Console Command String
506 # Routing stderr to stdout so that any startup error text will go to the
507 # output file.
508 ${cmd_buf}= Catenate ${sub_cmd_buf} > ${log_file_path} 2>&1 &
509 Rdpissuing ${cmd_buf}
510 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
511 # Because we are forking this command, we essentially will never get a
512 # non-zero return code or any output.
513 Should Be Equal ${rc} ${0}
514
515 [Return] ${log_output}
George Keishing30c12ff2016-09-02 10:25:29 -0500516
517Get Time Stamp
518 [Documentation] Get the current time stamp data
519 ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500520 [Return] ${cur_time}
George Keishing30c12ff2016-09-02 10:25:29 -0500521
George Keishing1b150202016-09-29 08:51:58 -0500522
523Verify BMC State
524 [Documentation] Get the BMC state and verify if the current
525 ... BMC state is as expected.
526 [Arguments] ${expected}
527
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600528 ${current}= Get BMC State Deprecated
George Keishing8db0e1b2016-10-20 13:46:54 -0500529 Should Contain ${expected} ${current}
George Keishing1b150202016-09-29 08:51:58 -0500530
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500531Start Journal Log
532 [Documentation] Start capturing journal log to a file in /tmp using
533 ... journalctl command. By default journal log is collected
534 ... at /tmp/journal_log else user input location.
535 ... The File is appended with datetime.
536 [Arguments] ${file_path}=/tmp/journal_log
537
538 Open Connection And Log In
539
540 ${cur_time}= Get Time Stamp
541 Set Global Variable ${LOG_TIME} ${cur_time}
542 Start Command
543 ... journalctl -f > ${file_path}-${LOG_TIME}
544 Log Journal Log Started: ${file_path}-${LOG_TIME}
545
David Shawba2d2c22017-01-23 16:56:38 -0600546
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500547Stop Journal Log
548 [Documentation] Stop journalctl process if its running.
549 ... By default return log from /tmp/journal_log else
550 ... user input location.
551 [Arguments] ${file_path}=/tmp/journal_log
552
553 Open Connection And Log In
554
555 ${rc}=
556 ... Execute Command
557 ... ps ax | grep journalctl | grep -v grep
558 ... return_stdout=False return_rc=True
559
560 Return From Keyword If '${rc}' == '${1}'
561 ... No journal log process running
562
563 ${output} ${stderr}=
564 ... Execute Command killall journalctl
565 ... return_stderr=True
566 Should Be Empty ${stderr}
567
568 ${journal_log} ${stderr}=
569 ... Execute Command
570 ... cat ${file_path}-${LOG_TIME}
571 ... return_stderr=True
572 Should Be Empty ${stderr}
573
574 Log ${journal_log}
575
576 Execute Command rm ${file_path}-${LOG_TIME}
577
578 [Return] ${journal_log}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500579
580Mac Address To Hex String
581 [Documentation] Converts MAC address into hex format.
582 ... Example
583 ... Given the following MAC: 00:01:6C:80:02:78
584 ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
585 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600586 ... i_macaddress MAC address in the following format
587 ... 00:01:6C:80:02:78
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500588 [Arguments] ${i_macaddress}
589
590 ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600591 [Return] ${mac_hex}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500592
593IP Address To Hex String
594 [Documentation] Converts IP address into hex format.
595 ... Example:
596 ... Given the following IP: 10.3.164.100
597 ... This keyword will return: 0xa 0x3 0xa4 0xa0
598 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600599 ... i_ipaddress IP address in the following format
600 ... 10.10.10.10
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500601 [Arguments] ${i_ipaddress}
602
603 @{ip}= Split String ${i_ipaddress} .
604 ${index}= Set Variable ${0}
605
606 :FOR ${item} IN @{ip}
607 \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes
608 \ Set List Value ${ip} ${index} ${hex}
609 \ ${index}= Set Variable ${index + 1}
610 ${ip_hex}= Catenate @{ip}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600611 [Return] ${ip_hex}
Sivas SRRea85d1f2016-11-13 22:44:28 -0600612
613BMC CPU Performance Check
614 [Documentation] Minimal 10% of proc should be free in this instance
615
616 ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd}
617 ... return_stderr=True
618 Should be empty ${stderr}
619 ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} %
620 Should be true ${bmc_cpu_percentage} < 90
621
622BMC Mem Performance Check
623 [Documentation] Minimal 10% of memory should be free in this instance
624
625 ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd}
626 ... return_stderr=True
627 Should be empty ${stderr}
628
629 ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd}
630 ... return_stderr=True
631 Should be empty ${stderr}
632
633 ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100
634 ${bmc_mem_percentage}= Evaluate
635 ... ${bmc_mem_percentage}/${bmc_mem_total_output}
636 Should be true ${bmc_mem_percentage} > 10
637
Sivas SRRaca55712016-12-21 04:32:35 -0600638BMC File System Usage Check
639 [Documentation] Check the file system space. None should be 100% full
Sivas SRR352bc162017-02-13 22:12:29 -0600640 ... except /run/initramfs/ro
Sivas SRRaca55712016-12-21 04:32:35 -0600641 ${bmc_fs_usage_output} ${stderr}= Execute Command
642 ... ${bmc_file_system_usage_cmd} return_stderr=True
643 Should Be Empty ${stderr}
644 Should Be True ${bmc_fs_usage_output}==0
645
Sivas SRRea85d1f2016-11-13 22:44:28 -0600646Check BMC CPU Performance
647 [Documentation] Minimal 10% of proc should be free in 3 sample
648 :FOR ${var} IN Range 1 4
649 \ BMC CPU Performance check
650
651Check BMC Mem Performance
652 [Documentation] Minimal 10% of memory should be free
653
654 :FOR ${var} IN Range 1 4
655 \ BMC Mem Performance check
656
Sivas SRRaca55712016-12-21 04:32:35 -0600657Check BMC File System Performance
658 [Documentation] Check for file system usage for 4 times
659
660 :FOR ${var} IN Range 1 4
661 \ BMC File System Usage check
662
Rahul Maheshwari63c105b2017-05-12 05:13:52 -0500663Get URL List
664 [Documentation] Return list of URLs under given URL.
665 [Arguments] ${openbmc_url}
666 # Description of argument(s):
Michael Walsh5f3f4142017-05-22 17:09:47 -0500667 # openbmc_url URL for list operation (e.g.
668 # /xyz/openbmc_project/inventory).
Rahul Maheshwari63c105b2017-05-12 05:13:52 -0500669
670 ${url_list}= Read Properties ${openbmc_url}/list
671 [Return] ${url_list}
672
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600673Get Endpoint Paths
674 [Documentation] Returns all url paths ending with given endpoint
675 ... Example:
676 ... Given the following endpoint: cpu
Michael Walsh01bd3682017-01-10 11:21:05 -0600677 ... This keyword will return: list of all urls ending with
678 ... cpu -
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600679 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
680 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
681 ... Description of arguments:
682 ... path URL path for enumeration
683 ... endpoint string for which url path ending
684 [Arguments] ${path} ${endpoint}
685
686 ${resp}= Read Properties ${path}/enumerate timeout=30
687 log Dictionary ${resp}
688
689 ${list}= Get Dictionary Keys ${resp}
690 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600691 [Return] ${resp}
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500692
693Check Zombie Process
694 [Documentation] Check if any defunct process exist or not on BMC
Michael Walsh01bd3682017-01-10 11:21:05 -0600695 ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500696 ... return_stderr=True return_rc=True
697 Should Be True ${count}==0
698 Should Be Empty ${stderr}
George Keishing5327d012016-12-08 08:43:29 -0600699
700Prune Journal Log
701 [Documentation] Prune archived journal logs.
702 [Arguments] ${vacuum_size}=1M
703
704 # This keyword can be used to prevent the journal
705 # log from filling up the /run filesystem.
706 # This command will retain only the latest logs
707 # of the user specified size.
708
709 Open Connection And Log In
710 ${output} ${stderr} ${rc}=
711 ... Execute Command
712 ... journalctl --vacuum-size=${vacuum_size}
713 ... return_stderr=True return_rc=True
714
715 Should Be Equal ${rc} ${0} msg=${stderr}
Sridevi Ramesh1699d372016-12-06 00:20:22 -0600716
717Set BMC Power Policy
718 [Documentation] Set the given BMC power policy.
719 [arguments] ${policy}
720
721 ${valueDict}= create dictionary data=${policy}
722 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
723 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
724 Should Be Equal ${currentPolicy} ${policy}
George Keishingcce9df22017-01-24 06:19:33 -0600725
George Keishing4d6f3d62017-02-06 09:50:41 -0600726Get System Power Policy
727 [Documentation] Get the BMC power policy.
728 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
729 [Return] ${currentPolicy}
George Keishingcce9df22017-01-24 06:19:33 -0600730
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600731Get Auto Reboot
732 [Documentation] Returns auto reboot setting.
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500733 ${setting}= Read Attribute ${HOST_SETTING} auto_reboot
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600734 [Return] ${setting}
735
736
737Set Auto Reboot
738 [Documentation] Set the given auto reboot setting.
739 [Arguments] ${setting}
740 # setting auto reboot's setting, i.e. yes or no
741
742 ${valueDict}= Set Variable ${setting}
743 ${data}= Create Dictionary data=${valueDict}
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500744 Write Attribute ${HOST_SETTING} auto_reboot data=${data}
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600745 ${current_setting}= Get Auto Reboot
746 Should Be Equal ${current_setting} ${setting}
747
748
George Keishingcce9df22017-01-24 06:19:33 -0600749Set BMC Reset Reference Time
750 [Documentation] Set current boot time as a reference and increment
George Keishing80dd5af2017-02-08 07:01:25 -0600751 ... boot count.
George Keishingcce9df22017-01-24 06:19:33 -0600752
753 ${cur_btime}= Get BMC Boot Time
George Keishing80dd5af2017-02-08 07:01:25 -0600754 Run Keyword If ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
George Keishingcce9df22017-01-24 06:19:33 -0600755 ... Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishing80dd5af2017-02-08 07:01:25 -0600756 ... ELSE IF ${cur_btime} > ${BOOT_TIME}
757 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishingcce9df22017-01-24 06:19:33 -0600758 ... AND
759 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
760
George Keishingcce9df22017-01-24 06:19:33 -0600761Get BMC Boot Time
762 [Documentation] Get boot time from /proc/stat.
763
764 Open Connection And Log In
765 ${output} ${stderr}=
766 ... Execute Command egrep '^btime ' /proc/stat | cut -f 2 -d ' '
767 ... return_stderr=True
768 Should Be Empty ${stderr}
769 ${btime}= Convert To Integer ${output}
770 [Return] ${btime}
George Keishingede30002017-02-02 09:33:07 -0600771
George Keishingede30002017-02-02 09:33:07 -0600772Execute Command On BMC
773 [Documentation] Execute given command on BMC and return output.
774 [Arguments] ${command}
775 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
776 Should Be Empty ${stderr}
777 [Return] ${stdout}
David Shawba2d2c22017-01-23 16:56:38 -0600778
Sridevi Rameshea36b412017-03-09 04:08:02 -0600779
George Keishing7a520222017-02-27 09:44:30 -0600780Enable Core Dump On BMC
781 [Documentation] Enable core dump collection.
782 Open Connection And Log In
783 ${core_pattern}= Execute Command On BMC
784 ... echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
785 Should Be Equal As Strings ${core_pattern} /tmp/core_%e.%p
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600786
Sivas SRR01262bd2017-03-19 10:00:23 -0500787Get Number Of BMC Core Dump Files
788 [Documentation] Get number of core dump files on BMC.
789 Open Connection And Log In
790 ${num_of_core_dump}= Execute Command
791 ... ls /tmp/core* 2>/dev/null | wc -l
792 [Return] ${num_of_core_dump}
793
794Set Core Dump File Size Unlimited
795 [Documentation] Set core dump file size to unlimited.
796 Open Connection And Log In
797 Execute Command On BMC
798 ... ulimit -c unlimited
799
800Check For Core Dumps
801 [Documentation] Check for any core dumps exist.
802 ${output}= Get Number Of BMC Core Dump Files
803 Run Keyword If ${output} > 0
804 ... Log **Warning** BMC core dump files exist level=WARN
805
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600806Trigger Host Watchdog Error
807 [Documentation] Inject host watchdog error using BMC.
808 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Michael Walshb5839d02017-04-12 16:11:20 -0500809 # Description of argument(s):
810 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
811 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600812 # sleep_time Time delay for host watchdog error to get injected.
813 # Default is 5 seconds.
814
815 Execute Command On BMC
816 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog set i ${milliseconds}
817 Execute Command On BMC
818 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog start
819 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500820
821Login To OS Host
822 [Documentation] Login to OS Host.
823 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
824 ... ${os_password}=${OS_PASSWORD}
825 # Desription of arguments:
826 # ${os_host} IP address of the OS Host.
827 # ${os_username} OS Host Login user name.
828 # ${os_password} OS Host Login passwrd.
829
830 ${os_state}= Run Keyword And Return Status Ping Host ${os_host}
831 Run Keyword If '${os_state}' == 'False'
832 ... Run Keywords Initiate Host Reboot AND
833 ... Is Host Running AND
834 ... Wait for OS ${os_host} ${os_username} ${os_password}
835
836 Open Connection ${os_host}
Sridevi Rameshea36b412017-03-09 04:08:02 -0600837 ${resp}= Login ${os_username} ${os_password}
838 [Return] ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500839
840Configure Initial Settings
841 [Documentation] Restore old IP and route.
842 ... This keyword requires initial settings viz IP address,
843 ... Network Mask, default gatway and serial console IP and port
844 ... information which should be provided in command line.
845
Michael Walshb5839d02017-04-12 16:11:20 -0500846 [Arguments] ${host}=${OPENBMC_HOST} ${mask}=${NET_MASK}
847 ... ${gw_ip}=${GW_IP}
Prashanth Katti884ee062017-03-16 05:05:03 -0500848
Michael Walshb5839d02017-04-12 16:11:20 -0500849 # Open telnet connection and ignore the error, in case telnet session is
850 # already opened by the program calling this keyword.
Prashanth Katti884ee062017-03-16 05:05:03 -0500851
852 Run Keyword And Ignore Error Open Telnet Connection to BMC Serial Console
853 Telnet.write ifconfig eth0 ${host} netmask ${mask}
854 Telnet.write route add default gw ${gw_ip}
George Keishingd05b1082017-03-24 05:27:32 -0500855
856Install Debug Tarball On BMC
George Keishing55441822017-05-18 14:17:59 -0500857 [Documentation] Copy the debug tar file to BMC and install.
858 [Arguments] ${tarball_file_path}=${EXECDIR}/obmc-phosphor-debug-tarball-witherspoon.tar.xz
859 ... ${targ_tarball_dir_path}=/home/root/tarball/
George Keishingd05b1082017-03-24 05:27:32 -0500860
George Keishing55441822017-05-18 14:17:59 -0500861 # Description of arguments:
862 # tarball_file_path Path of the debug tarball file.
863 # The tar file is downloaded from the build page
864 # https://openpower.xyz/job/openbmc-build/
865 # obmc-phosphor-debug-tarball-witherspoon.tar.xz
866 #
867 # targ_tarball_dir_path The directory path where the tarball is to be
868 # installed.
869
870 OperatingSystem.File Should Exist ${tarball_file_path}
871 ... msg=${tarball_file_path} doesn't exist.
872
873 # Upload the file to BMC.
George Keishingd05b1082017-03-24 05:27:32 -0500874 Import Library SCPLibrary WITH NAME scp
875 Open Connection for SCP
George Keishing55441822017-05-18 14:17:59 -0500876 scp.Put File ${tarball_file_path} /tmp/debug-tarball.tar.xz
877
878 # Create tarball directory and install.
George Keishingd05b1082017-03-24 05:27:32 -0500879 Open Connection And Log In
George Keishing55441822017-05-18 14:17:59 -0500880 Execute Command On BMC mkdir -p ${targ_tarball_dir_path}
881 Execute Command On BMC
882 ... tar -xf /tmp/debug-tarball.tar.xz -C ${targ_tarball_dir_path}
883
884 # Create symlink to callout-test binary.
885 Execute Command On BMC
886 ... ln -s ${targ_tarball_dir_path}/bin/callout-test /usr/bin/callout-test
887
George Keishingd05b1082017-03-24 05:27:32 -0500888 # Remove the tarball file from BMC
889 Execute Command On BMC rm /tmp/debug-tarball.tar.xz
890
George Keishing55441822017-05-18 14:17:59 -0500891
Sweta Potthuri025e0122017-02-21 00:42:48 -0600892Get BMC Boot Count
893 [Documentation] Get BMC boot count based on boot time.
894 ${cur_btime}= Get BMC Boot Time
895
896 # Set global variable BOOT_TIME to current boot time if current boot time
897 # is changed. Also increase value of global variable BOOT_COUNT by 1.
898 Run Keyword If ${cur_btime} > ${BOOT_TIME}
899 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
900 ... AND
901 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
902 [Return] ${BOOT_COUNT}
903
904Set BMC Boot Count
905 [Documentation] Set BMC boot count to given value.
906 [Arguments] ${count}
907
908 # Description of arguments:
909 # count boot count value.
910 ${cur_btime}= Get BMC Boot Time
911
912 # Set global variable BOOT_COUNT to given value.
913 Set Global Variable ${BOOT_COUNT} ${count}
914
915 # Set BOOT_TIME variable to current boot time.
916 Set Global Variable ${BOOT_COUNT} ${count}
Michael Walsh689fbbe2017-04-04 17:58:03 -0500917
918###############################################################################
919Delete Error logs
920 [Documentation] Delete error logs.
921
922 # The REST method to delete error openbmc/openbmc#1327
923 # until then using logging restart.
924 Open Connection And Log In
925 Execute Command On BMC
926 ... systemctl restart xyz.openbmc_project.Logging.service
927 Sleep 10s reason=Wait for logging service to restart properly.
George Keishingdb34c2f2017-04-18 13:20:25 -0500928
929###############################################################################
930Delete Error log Entry
931 [Documentation] Delete error log entry.
932 [Arguments] ${entry_path}
933
934 # Description of argument(s):
935 # entry_path Delete an error log entry.
936 # Ex. /xyz/openbmc_project/logging/entry/1
937
938 ${data}= Create Dictionary data=@{EMPTY}
939 ${resp}= Openbmc Delete Request ${entry_path} data=${data}
940 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}