blob: 1e9a50f709b4866f0e3f9ad37e0d1d7929a339ae [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
Chris Austenb29d2e82016-06-07 12:25:35 -050010
11*** Variables ***
12${SYSTEM_SHUTDOWN_TIME} ${5}
Michael Walsha6723f22016-11-22 11:12:01 -060013${dbuscmdBase}
George Keishing85ca05e2016-11-30 09:47:18 -060014... dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host
Michael Walsha6723f22016-11-22 11:12:01 -060015${dbuscmdGet}
George Keishing9485af92017-01-04 10:21:43 -060016... ${SETTINGS_URI}host0 org.freedesktop.DBus.Properties.Get
George Keishing85ca05e2016-11-30 09:47:18 -060017# Enable when ready with openbmc/openbmc-test-automation#203
18#${dbuscmdString}= string:"xyz.openbmc_project.settings.Host" string:
Michael Walsha6723f22016-11-22 11:12:01 -060019${dbuscmdString}= string:"org.openbmc.settings.Host" string:
20
21# Assign default value to QUIET for programs which may not define it.
22${QUIET} ${0}
Sivas SRRea85d1f2016-11-13 22:44:28 -060023${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
24${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
25${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9
Sridevi Ramesh1699d372016-12-06 00:20:22 -060026${HOST_SETTING} ${SETTINGS_URI}host0
Sivas SRR352bc162017-02-13 22:12:29 -060027# /run/initramfs/ro associate filesystem should be 100% full always
Sivas SRRaca55712016-12-21 04:32:35 -060028${bmc_file_system_usage_cmd}=
Sivas SRR352bc162017-02-13 22:12:29 -060029... df -h | grep -v /run/initramfs/ro | cut -c 52-54 | grep 100 | wc -l
Chris Austenb29d2e82016-06-07 12:25:35 -050030
George Keishingcce9df22017-01-24 06:19:33 -060031${BOOT_TIME} ${0}
32${BOOT_COUNT} ${0}
Sweta Potthuri025e0122017-02-21 00:42:48 -060033${count} ${0}
Sivas SRR8254db62017-02-07 09:39:46 -060034${devicetree_base} /sys/firmware/devicetree/base/model
George Keishingcce9df22017-01-24 06:19:33 -060035
Chris Austenb29d2e82016-06-07 12:25:35 -050036*** Keywords ***
Sridevi Ramesh1699d372016-12-06 00:20:22 -060037
Sivas SRR8254db62017-02-07 09:39:46 -060038Get BMC System Model
39 [Documentation] Get the BMC model from the device tree.
40
Michael Walshb5839d02017-04-12 16:11:20 -050041 Open Connection And Log In
George Keishing90ab1772017-02-24 05:40:55 -060042 ${bmc_model} ${stderr}= Execute Command
43 ... cat ${devicetree_base} | cut -d " " -f 1 return_stderr=True
Sivas SRR8254db62017-02-07 09:39:46 -060044 Should Be Empty ${stderr}
45 Should Not Be Empty ${bmc_model}
46 [Return] ${bmc_model}
47
48Verify BMC System Model
49 [Documentation] Verify the BMC model with ${OPENBMC_MODEL}.
50 [Arguments] ${bmc_model}
51
52 ${tmp_bmc_model}= Fetch From Right ${OPENBMC_MODEL} /
53 ${tmp_bmc_model}= Fetch From Left ${tmp_bmc_model} .
54 ${ret}= Run Keyword And Return Status Should Contain ${bmc_model}
55 ... ${tmp_bmc_model} ignore_case=True
56 [Return] ${ret}
57
Chris Austenb29d2e82016-06-07 12:25:35 -050058Wait For Host To Ping
root442f0ef2016-08-04 20:23:05 +000059 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
60 ... ${interval}=5 sec
61
62 # host The DNS name or IP of the host to ping.
63 # timeout The amount of time after which attempts to ping cease.
64 # interval The amount of time in between attempts to ping.
65
66 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050067
68Ping Host
69 [Arguments] ${host}
George Keishing8a84f952016-08-25 04:54:53 -050070 Should Not Be Empty ${host} msg=No host provided
Michael Walsha6723f22016-11-22 11:12:01 -060071 ${RC} ${output}= Run and return RC and Output ping -c 4 ${host}
Chris Austenb29d2e82016-06-07 12:25:35 -050072 Log RC: ${RC}\nOutput:\n${output}
73 Should be equal ${RC} ${0}
74
75Get Boot Progress
Michael Walsha6723f22016-11-22 11:12:01 -060076 [Arguments] ${quiet}=${QUIET}
77
George Keishing85ca05e2016-11-30 09:47:18 -060078 ${state}= Read Attribute ${OPENBMC_BASE_URI}sensors/host/BootProgress
Michael Walsha6723f22016-11-22 11:12:01 -060079 ... value quiet=${quiet}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060080 [Return] ${state}
Chris Austenb29d2e82016-06-07 12:25:35 -050081
82Is Power On
root442f0ef2016-08-04 20:23:05 +000083 ${state}= Get Power State
84 Should be equal ${state} ${1}
Chris Austenb29d2e82016-06-07 12:25:35 -050085
86Is Power Off
root442f0ef2016-08-04 20:23:05 +000087 ${state}= Get Power State
88 Should be equal ${state} ${0}
Chris Austenb29d2e82016-06-07 12:25:35 -050089
root442f0ef2016-08-04 20:23:05 +000090Initiate Power On
91 [Documentation] Initiates the power on and waits until the Is Power On
92 ... keyword returns that the power state has switched to on.
Michael Walsha6723f22016-11-22 11:12:01 -060093 [Arguments] ${wait}=${1}
94
Chris Austenb29d2e82016-06-07 12:25:35 -050095 @{arglist}= Create List
96 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -060097 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOn
Michael Walsha6723f22016-11-22 11:12:01 -060098 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -050099 should be equal as strings ${resp.status_code} ${HTTP_OK}
Chris Austenb29d2e82016-06-07 12:25:35 -0500100
Michael Walsha6723f22016-11-22 11:12:01 -0600101 # Does caller want to wait for power on status?
102 Run Keyword If '${wait}' == '${0}' Return From Keyword
103 Wait Until Keyword Succeeds 3 min 10 sec Is Power On
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500104
root442f0ef2016-08-04 20:23:05 +0000105Initiate Power Off
106 [Documentation] Initiates the power off and waits until the Is Power Off
107 ... keyword returns that the power state has switched to off.
Chris Austenb29d2e82016-06-07 12:25:35 -0500108 @{arglist}= Create List
109 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600110 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ powerOff
Michael Walsha6723f22016-11-22 11:12:01 -0600111 ... data=${args}
Chris Austenb29d2e82016-06-07 12:25:35 -0500112 should be equal as strings ${resp.status_code} ${HTTP_OK}
Michael Walsha6723f22016-11-22 11:12:01 -0600113 Wait Until Keyword Succeeds 1 min 10 sec Is Power Off
Chris Austenb29d2e82016-06-07 12:25:35 -0500114
Michael Walsh81843772017-03-02 14:44:44 -0600115Initiate OS Host Power Off
116 [Documentation] Initiate an OS reboot.
117 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
118 ... ${os_password}=${OS_PASSWORD}
119
120 # Description of arguments:
121 # os_host The DNS name or IP of the OS.
122 # os_username The username to be used to sign in to the OS.
123 # os_password The password to be used to sign in to the OS.
124
Michael Walshac275512017-03-07 11:39:28 -0600125 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600126 Login ${os_username} ${os_password}
127 ${cmd_buf} Catenate shutdown
128 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600129 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600130
131Initiate OS Host Reboot
132 [Documentation] Initiate an OS reboot.
133 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
134 ... ${os_password}=${OS_PASSWORD}
135
136 # Description of arguments:
137 # os_host The DNS name or IP of the OS.
138 # os_username The username to be used to sign in to the OS.
139 # os_password The password to be used to sign in to the OS.
140
Michael Walshac275512017-03-07 11:39:28 -0600141 SSHLibrary.Open connection ${os_host}
Michael Walsh81843772017-03-02 14:44:44 -0600142 Login ${os_username} ${os_password}
143 ${cmd_buf} Catenate reboot
144 Start Command ${cmd_buf}
Michael Walshac275512017-03-07 11:39:28 -0600145 SSHLibrary.Close Connection
Michael Walsh81843772017-03-02 14:44:44 -0600146
147Initiate Auto Reboot
148 [Documentation] Initiate an auto reboot.
149
150 # Set the auto reboot policy.
151 Set Auto Reboot yes
152
Michael Walshac275512017-03-07 11:39:28 -0600153 SSHLibrary.Open connection ${openbmc_host}
Michael Walsh81843772017-03-02 14:44:44 -0600154 Login ${openbmc_username} ${openbmc_password}
155
156 # Set the watchdog timer. Note: 5000 = milliseconds which is 5 seconds.
157 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
158 ... org.openbmc.Watchdog set i 5000
159 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
160 ... return_stderr=True return_rc=True
161 Should Be Empty ${stderr}
162 Should be equal ${rc} ${0}
163
164 # Start the watchdog.
165 ${cmd_buf}= Catenate /usr/sbin/mapper call /org/openbmc/watchdog/host0
166 ... org.openbmc.Watchdog start
167 ${output} ${stderr} ${rc}= Execute Command ${cmd_buf}
168 ... return_stderr=True return_rc=True
169 Should Be Empty ${stderr}
170 Should be equal ${rc} ${0}
171
Chris Austenb29d2e82016-06-07 12:25:35 -0500172Trigger Warm Reset
173 log to console "Triggering warm reset"
Michael Walsha6723f22016-11-22 11:12:01 -0600174 ${data}= create dictionary data=@{EMPTY}
George Keishing85ca05e2016-11-30 09:47:18 -0600175 ${resp}= openbmc post request
176 ... ${OPENBMC_BASE_URI}control/bmc0/action/warmReset data=${data}
Chris Austenb29d2e82016-06-07 12:25:35 -0500177 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
George Keishingb3700812016-08-31 03:03:30 -0500178 ${session_active}= Check If warmReset is Initiated
179 Run Keyword If '${session_active}' == '${True}'
180 ... Fail msg=warm reset didn't occur
181
Chris Austenb29d2e82016-06-07 12:25:35 -0500182 Sleep ${SYSTEM_SHUTDOWN_TIME}min
Rahul Maheshwari5f253c42017-01-30 05:19:51 -0600183 Check If BMC Is Up
Michael Walsh49ab0f42016-07-20 11:44:33 -0500184
185Check OS
root442f0ef2016-08-04 20:23:05 +0000186 [Documentation] Attempts to ping the host OS and then checks that the host
187 ... OS is up by running an SSH command.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500188
189 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
Michael Walsha6723f22016-11-22 11:12:01 -0600190 ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET}
191 ... ${print_string}=${EMPTY}
Michael Walshac275512017-03-07 11:39:28 -0600192 [Teardown] SSHLibrary.Close Connection
Michael Walsh49ab0f42016-07-20 11:44:33 -0500193
194 # os_host The DNS name/IP of the OS host associated with our BMC.
195 # os_username The username to be used to sign on to the OS host.
196 # os_password The password to be used to sign on to the OS host.
Michael Walsha6723f22016-11-22 11:12:01 -0600197 # quiet Indicates whether this keyword should write to console.
198 # print_string A string to be printed before checking the OS.
199
200 rprint ${print_string}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500201
root442f0ef2016-08-04 20:23:05 +0000202 # Attempt to ping the OS. Store the return code to check later.
203 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
204
Michael Walshac275512017-03-07 11:39:28 -0600205 SSHLibrary.Open connection ${os_host}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500206
Michael Walsha6723f22016-11-22 11:12:01 -0600207 ${status} ${msg}= Run Keyword And Ignore Error Login ${os_username}
208 ... ${os_password}
209 ${err_msg1}= Sprint Error ${msg}
210 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
211 Run Keyword If '${status}' == 'FAIL' Fail msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500212 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
213 ... return_rc=True
214
Michael Walsha6723f22016-11-22 11:12:01 -0600215 ${temp_msg}= Catenate Could not execute a command on the operating
216 ... system.\n
217 ${err_msg1}= Sprint Error ${temp_msg}
218 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
219
220 # If the return code returned by "Execute Command" is non-zero, this
221 # keyword will fail.
222 Should Be Equal ${rc} ${0} msg=${err_msg}
Michael Walsh49ab0f42016-07-20 11:44:33 -0500223 # We will likewise fail if there is any stderr data.
224 Should Be Empty ${stderr}
225
Michael Walsha6723f22016-11-22 11:12:01 -0600226 ${temp_msg}= Set Variable Could not ping the operating system.\n
227 ${err_msg1}= Sprint Error ${temp_msg}
228 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
229 # We will likewise fail if the OS did not ping, as we could SSH but not
230 # ping
231 Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg}
root442f0ef2016-08-04 20:23:05 +0000232
Michael Walsh49ab0f42016-07-20 11:44:33 -0500233Wait for OS
234 [Documentation] Waits for the host OS to come up via calls to "Check OS".
235 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
236 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
Michael Walsha6723f22016-11-22 11:12:01 -0600237 ... ${quiet}=${0}
238 [Teardown] rprintn
Michael Walsh49ab0f42016-07-20 11:44:33 -0500239
240 # os_host The DNS name or IP of the OS host associated with our
241 # BMC.
242 # os_username The username to be used to sign on to the OS host.
243 # os_password The password to be used to sign on to the OS host.
244 # timeout The timeout in seconds indicating how long you're
245 # willing to wait for the OS to respond.
Michael Walsha6723f22016-11-22 11:12:01 -0600246 # quiet Indicates whether this keyword should write to console.
Michael Walsh49ab0f42016-07-20 11:44:33 -0500247
248 # The interval to be used between calls to "Check OS".
249 ${interval}= Set Variable 5
250
Michael Walsha6723f22016-11-22 11:12:01 -0600251 ${message}= Catenate Checking every ${interval} seconds for up to
252 ... ${timeout} seconds for the operating system to communicate.
253 rqprint_timen ${message}
254
Michael Walsh49ab0f42016-07-20 11:44:33 -0500255 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
256 ... ${os_host} ${os_username} ${os_password}
Michael Walsha6723f22016-11-22 11:12:01 -0600257 ... print_string=\#
258
259 rqprintn
260
261 rqprint_timen The operating system is now communicating.
root442f0ef2016-08-04 20:23:05 +0000262
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600263Get BMC State Deprecated
root442f0ef2016-08-04 20:23:05 +0000264 [Documentation] Returns the state of the BMC as a string. (i.e: BMC_READY)
Michael Walsha6723f22016-11-22 11:12:01 -0600265 [Arguments] ${quiet}=${QUIET}
266
root442f0ef2016-08-04 20:23:05 +0000267 @{arglist}= Create List
268 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600269 ${resp}= Call Method ${OPENBMC_BASE_URI}managers/System/ getSystemState
Michael Walsha6723f22016-11-22 11:12:01 -0600270 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000271 Should be equal as strings ${resp.status_code} ${HTTP_OK}
272 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600273 [Return] ${content["data"]}
root442f0ef2016-08-04 20:23:05 +0000274
275Get Power State
276 [Documentation] Returns the power state as an integer. Either 0 or 1.
Michael Walsha6723f22016-11-22 11:12:01 -0600277 [Arguments] ${quiet}=${QUIET}
278
root442f0ef2016-08-04 20:23:05 +0000279 @{arglist}= Create List
280 ${args}= Create Dictionary data=@{arglist}
Michael Walsha6723f22016-11-22 11:12:01 -0600281
George Keishing85ca05e2016-11-30 09:47:18 -0600282 ${resp}= Call Method ${OPENBMC_BASE_URI}control/chassis0/ getPowerState
Michael Walsha6723f22016-11-22 11:12:01 -0600283 ... data=${args} quiet=${quiet}
root442f0ef2016-08-04 20:23:05 +0000284 Should be equal as strings ${resp.status_code} ${HTTP_OK}
285 ${content}= to json ${resp.content}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600286 [Return] ${content["data"]}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500287
288Clear BMC Record Log
289 [Documentation] Clears all the event logs on the BMC. This would be
290 ... equivalent to ipmitool sel clear.
291 @{arglist}= Create List
292 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600293 ${resp}= Call Method
294 ... ${OPENBMC_BASE_URI}records/events/ clear data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500295 should be equal as strings ${resp.status_code} ${HTTP_OK}
296
297Copy PNOR to BMC
298 Import Library SCPLibrary WITH NAME scp
299 Open Connection for SCP
300 Log Copying ${PNOR_IMAGE_PATH} to /tmp
301 scp.Put File ${PNOR_IMAGE_PATH} /tmp
302
303Flash PNOR
304 [Documentation] Calls flash bios update method to flash PNOR image
Gunnar Mills38032802016-12-12 13:43:40 -0600305 [Arguments] ${pnor_image}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500306 @{arglist}= Create List ${pnor_image}
307 ${args}= Create Dictionary data=@{arglist}
George Keishing85ca05e2016-11-30 09:47:18 -0600308 ${resp}= Call Method ${OPENBMC_BASE_URI}control/flash/bios/ update
Michael Walsha6723f22016-11-22 11:12:01 -0600309 ... data=${args}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500310 should be equal as strings ${resp.status_code} ${HTTP_OK}
311 Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
312
313Get Flash BIOS Status
314 [Documentation] Returns the status of the flash BIOS API as a string. For
315 ... example 'Flashing', 'Flash Done', etc
George Keishing85ca05e2016-11-30 09:47:18 -0600316 ${data}= Read Properties ${OPENBMC_BASE_URI}control/flash/bios
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600317 [Return] ${data['status']}
Jay Azurine4c52eb2016-08-16 20:51:10 -0500318
319Is PNOR Flashing
320 [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
321 ... flashing has started.
322 ${status}= Get Flash BIOS Status
323 should be equal as strings ${status} Flashing
324
325Is PNOR Flash Done
326 [Documentation] Get BIOS 'Flash Done' status. This indicates that the
327 ... PNOR flashing has completed.
Leah McNutt9ba32272016-11-17 15:48:39 +0000328 ${status}= Get Flash BIOS Status
Jay Azurine4c52eb2016-08-16 20:51:10 -0500329 should be equal as strings ${status} Flash Done
330
331Is System State Host Booted
332 [Documentation] Checks whether system state is HOST_BOOTED.
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600333 ${state}= Get BMC State Deprecated
Jay Azurine4c52eb2016-08-16 20:51:10 -0500334 should be equal as strings ${state} HOST_BOOTED
George Keishing5e870cd2016-08-24 10:05:47 -0500335
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600336Is OS Starting
337 [Documentation] Check if boot progress is OS starting.
338 ${boot_progress}= Get Boot Progress
339 Should Be Equal ${boot_progress} FW Progress, Starting OS
340
George Keishing0af24412017-03-10 13:33:23 -0600341Is OS Off
342 [Documentation] Check if boot progress is "Off".
343 ${boot_progress}= Get Boot Progress
344 Should Be Equal ${boot_progress} Off
345
George Keishing5e870cd2016-08-24 10:05:47 -0500346Verify Ping and REST Authentication
Michael Walsha6723f22016-11-22 11:12:01 -0600347 ${l_ping}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500348 ... Ping Host ${OPENBMC_HOST}
George Keishingc4d3dc02016-09-19 03:45:55 -0500349 Run Keyword If '${l_ping}' == '${False}'
350 ... Fail msg=Ping Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500351
Michael Walsha6723f22016-11-22 11:12:01 -0600352 ${l_rest}= Run Keyword And Return Status
George Keishing5e870cd2016-08-24 10:05:47 -0500353 ... Initialize OpenBMC
George Keishingc4d3dc02016-09-19 03:45:55 -0500354 Run Keyword If '${l_rest}' == '${False}'
355 ... Fail msg=REST Authentication Failed
George Keishing5e870cd2016-08-24 10:05:47 -0500356
357 # Just to make sure the SSH is working for SCP
358 Open Connection And Log In
359 ${system} ${stderr}= Execute Command hostname return_stderr=True
360 Should Be Empty ${stderr}
361
George Keishingc4d3dc02016-09-19 03:45:55 -0500362Check If BMC is Up
363 [Documentation] Wait for Host to be online. Checks every X seconds
364 ... interval for Y minutes and fails if timed out.
365 ... Default MAX timedout is 10 min, interval 10 seconds.
Gunnar Mills38032802016-12-12 13:43:40 -0600366 [Arguments] ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT} min
George Keishingc4d3dc02016-09-19 03:45:55 -0500367 ... ${interval}=10 sec
368
369 Wait Until Keyword Succeeds
370 ... ${max_timeout} ${interval} Verify Ping and REST Authentication
371
George Keishingb3700812016-08-31 03:03:30 -0500372
373Check If warmReset is Initiated
374 [Documentation] Ping would be still alive, so try SSH to connect
375 ... if fails the ports are down indicating reboot
376 ... is in progress
George Keishing3c05d352016-12-13 06:54:50 -0600377
378 # Warm reset adds 3 seconds delay before forcing reboot
379 # To minimize race conditions, we wait for 7 seconds
380 Sleep 7s
George Keishingb3700812016-08-31 03:03:30 -0500381 ${alive}= Run Keyword and Return Status
382 ... Open Connection And Log In
383 Return From Keyword If '${alive}' == '${False}' ${False}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600384 [Return] ${True}
George Keishingb3700812016-08-31 03:03:30 -0500385
George Keishing06ae4aa2016-08-30 01:41:28 -0500386Flush REST Sessions
387 [Documentation] Removes all the active session objects
388 Delete All Sessions
George Keishingb3700812016-08-31 03:03:30 -0500389
Sivas SRRe1143ae2016-08-26 22:31:02 -0500390Initialize DBUS cmd
391 [Documentation] Initialize dbus string with property string to extract
Gunnar Mills38032802016-12-12 13:43:40 -0600392 [Arguments] ${boot_property}
Michael Walsha6723f22016-11-22 11:12:01 -0600393 ${cmd}= Catenate ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
394 ${cmd}= Catenate ${cmd}${boot_property}
Sivas SRRe1143ae2016-08-26 22:31:02 -0500395 Set Global Variable ${dbuscmd} ${cmd}
396
David Shawba2d2c22017-01-23 16:56:38 -0600397Create OS Console File Path
398 [Documentation] Create OS console file path name and return it.
399 [Arguments] ${log_file_path}=${EMPTY}
George Keishing30c12ff2016-09-02 10:25:29 -0500400
David Shawba2d2c22017-01-23 16:56:38 -0600401 # Description of arguements:
402 # file_path The caller's candidate value. If this value is ${EMPTY}, this
403 # keyword will compose a file path name. Otherwise, this
404 # keyword will use the caller's file_path value. In either
405 # case, the value will be returned.
Gunnar Mills9c760342016-12-08 10:12:06 -0600406
David Shawba2d2c22017-01-23 16:56:38 -0600407 ${default_file_path}= Catenate /tmp/${OPENBMC_HOST}_os_console
408 ${log_file_path}= Set Variable If '${log_file_path}' == '${EMPTY}'
409 ... ${default_file_path} ${log_file_path}
Michael Walsh01bd3682017-01-10 11:21:05 -0600410
David Shawba2d2c22017-01-23 16:56:38 -0600411 [Return] ${log_file_path}
Gunnar Mills9c760342016-12-08 10:12:06 -0600412
David Shawba2d2c22017-01-23 16:56:38 -0600413Create OS Console Command String
414 [Documentation] Return a command string to start OS console logging.
Gunnar Mills9c760342016-12-08 10:12:06 -0600415
David Shawba2d2c22017-01-23 16:56:38 -0600416 # First make sure that the ssh_pw program is available.
417 ${cmd_buf}= Catenate which ssh_pw 2>&1
418 Rdpissuing ${cmd_buf}
419 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
420 Rdpvars rc output
421 Should Be Equal ${rc} ${0} msg=${output}\n
Gunnar Mills9c760342016-12-08 10:12:06 -0600422
David Shawba2d2c22017-01-23 16:56:38 -0600423 ${cmd_buf}= Catenate ssh_pw ${OPENBMC_PASSWORD} -p 2200
424 ... ${OPENBMC_USERNAME}@${OPENBMC_HOST}
George Keishing30c12ff2016-09-02 10:25:29 -0500425
David Shawba2d2c22017-01-23 16:56:38 -0600426 [Return] ${cmd_buf}
George Keishing30c12ff2016-09-02 10:25:29 -0500427
428Stop SOL Console Logging
David Shawba2d2c22017-01-23 16:56:38 -0600429 [Documentation] Stop system console logging and return log output.
430 [Arguments] ${log_file_path}=${EMPTY} ${targ_file_path}=${EMPTY}
431
432 # If there are muliple system console processes, they will all be stopped.
433 # If there is no existing log file this keyword will return an error
434 # message to that effect (and write that message to targ_file_path, if
435 # specified).
436 # NOTE: This keyword will not fail if there is no running system console
437 # process.
Michael Walsh01bd3682017-01-10 11:21:05 -0600438
439 # Description of arguments:
David Shawba2d2c22017-01-23 16:56:38 -0600440 # log_file_path The file path that was used to call "Start SOL
441 # Console Logging". See that keyword (above) for details.
442 # targ_file_path If specified, the file path to which the source
443 # file path (i.e. "log_file_path") should be copied.
George Keishing30c12ff2016-09-02 10:25:29 -0500444
David Shawba2d2c22017-01-23 16:56:38 -0600445 ${log_file_path}= Create OS Console File Path ${log_file_path}
446 # Find the pid of the active system console logging session (if any).
447 ${search_string}= Create OS Console Command String
448 ${cmd_buf}= Catenate echo $(ps -ef | egrep '${search_string}'
449 ... | egrep -v grep | cut -c10-14)
450 Rdpissuing ${cmd_buf}
451 ${rc} ${os_con_pid}= Run And Return Rc And Output ${cmd_buf}
452 Rdpvars os_con_pid
453 # If rc is not zero it just means that there is no OS Console process
454 # running.
George Keishing30c12ff2016-09-02 10:25:29 -0500455
David Shawba2d2c22017-01-23 16:56:38 -0600456 ${cmd_buf}= Catenate kill -9 ${os_con_pid}
457 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpissuing ${cmd_buf}
458 ${rc} ${output}= Run Keyword If '${os_con_pid}' != '${EMPTY}'
459 ... Run And Return Rc And Output ${cmd_buf}
460 Run Keyword If '${os_con_pid}' != '${EMPTY}' Rdpvars rc output
George Keishing30c12ff2016-09-02 10:25:29 -0500461
David Shawba2d2c22017-01-23 16:56:38 -0600462 ${cmd_buf}= Set Variable cat ${log_file_path} 2>&1
463 Rdpissuing ${cmd_buf}
464 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
465 Rdpvars rc
George Keishing30c12ff2016-09-02 10:25:29 -0500466
Michael Walsh01bd3682017-01-10 11:21:05 -0600467 Run Keyword If '${targ_file_path}' != '${EMPTY}'
David Shawba2d2c22017-01-23 16:56:38 -0600468 ... Run Keyword And Ignore Error
469 ... Copy File ${log_file_path} ${targ_file_path}
George Keishing30c12ff2016-09-02 10:25:29 -0500470
David Shawba2d2c22017-01-23 16:56:38 -0600471 [Return] ${output}
472
473Start SOL Console Logging
474 [Documentation] Start system console log to file.
475 [Arguments] ${log_file_path}=${EMPTY}
476
477 # This keyword will first call "Stop SOL Console Logging". Only then will
478 # it start SOL console logging. The data returned by "Stop SOL Console
479 # Logging" will in turn be returned by this keyword.
480
481 # Description of arguments:
482 # log_file_path The file path to which system console log data should be
483 # written. Note that this path is taken to be a location on
484 # the machine where this program is running rather than on
485 # the Open BMC system.
486
487 ${log_file_path}= Create OS Console File Path ${log_file_path}
488
489 ${log_output}= Stop SOL Console Logging ${log_file_path}
490
491 # Validate by making sure we can create the file. Problems creating the
492 # file would not be noticed by the subsequent ssh command because we fork
493 # the command.
494 Create File ${log_file_path}
495 ${sub_cmd_buf}= Create OS Console Command String
496 # Routing stderr to stdout so that any startup error text will go to the
497 # output file.
498 ${cmd_buf}= Catenate ${sub_cmd_buf} > ${log_file_path} 2>&1 &
499 Rdpissuing ${cmd_buf}
500 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
501 # Because we are forking this command, we essentially will never get a
502 # non-zero return code or any output.
503 Should Be Equal ${rc} ${0}
504
505 [Return] ${log_output}
George Keishing30c12ff2016-09-02 10:25:29 -0500506
507Get Time Stamp
508 [Documentation] Get the current time stamp data
509 ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500510 [Return] ${cur_time}
George Keishing30c12ff2016-09-02 10:25:29 -0500511
George Keishing1b150202016-09-29 08:51:58 -0500512
513Verify BMC State
514 [Documentation] Get the BMC state and verify if the current
515 ... BMC state is as expected.
516 [Arguments] ${expected}
517
Rahul Maheshwari2c725042017-01-29 22:55:28 -0600518 ${current}= Get BMC State Deprecated
George Keishing8db0e1b2016-10-20 13:46:54 -0500519 Should Contain ${expected} ${current}
George Keishing1b150202016-09-29 08:51:58 -0500520
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500521Start Journal Log
522 [Documentation] Start capturing journal log to a file in /tmp using
523 ... journalctl command. By default journal log is collected
524 ... at /tmp/journal_log else user input location.
525 ... The File is appended with datetime.
526 [Arguments] ${file_path}=/tmp/journal_log
527
528 Open Connection And Log In
529
530 ${cur_time}= Get Time Stamp
531 Set Global Variable ${LOG_TIME} ${cur_time}
532 Start Command
533 ... journalctl -f > ${file_path}-${LOG_TIME}
534 Log Journal Log Started: ${file_path}-${LOG_TIME}
535
David Shawba2d2c22017-01-23 16:56:38 -0600536
Rahul Maheshwarif684ba72016-10-25 07:24:41 -0500537Stop Journal Log
538 [Documentation] Stop journalctl process if its running.
539 ... By default return log from /tmp/journal_log else
540 ... user input location.
541 [Arguments] ${file_path}=/tmp/journal_log
542
543 Open Connection And Log In
544
545 ${rc}=
546 ... Execute Command
547 ... ps ax | grep journalctl | grep -v grep
548 ... return_stdout=False return_rc=True
549
550 Return From Keyword If '${rc}' == '${1}'
551 ... No journal log process running
552
553 ${output} ${stderr}=
554 ... Execute Command killall journalctl
555 ... return_stderr=True
556 Should Be Empty ${stderr}
557
558 ${journal_log} ${stderr}=
559 ... Execute Command
560 ... cat ${file_path}-${LOG_TIME}
561 ... return_stderr=True
562 Should Be Empty ${stderr}
563
564 Log ${journal_log}
565
566 Execute Command rm ${file_path}-${LOG_TIME}
567
568 [Return] ${journal_log}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500569
570Mac Address To Hex String
571 [Documentation] Converts MAC address into hex format.
572 ... Example
573 ... Given the following MAC: 00:01:6C:80:02:78
574 ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
575 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600576 ... i_macaddress MAC address in the following format
577 ... 00:01:6C:80:02:78
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500578 [Arguments] ${i_macaddress}
579
580 ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600581 [Return] ${mac_hex}
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500582
583IP Address To Hex String
584 [Documentation] Converts IP address into hex format.
585 ... Example:
586 ... Given the following IP: 10.3.164.100
587 ... This keyword will return: 0xa 0x3 0xa4 0xa0
588 ... Description of arguments:
Michael Walsh01bd3682017-01-10 11:21:05 -0600589 ... i_ipaddress IP address in the following format
590 ... 10.10.10.10
Rahul Maheshwari757d80c2016-10-17 01:09:55 -0500591 [Arguments] ${i_ipaddress}
592
593 @{ip}= Split String ${i_ipaddress} .
594 ${index}= Set Variable ${0}
595
596 :FOR ${item} IN @{ip}
597 \ ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes
598 \ Set List Value ${ip} ${index} ${hex}
599 \ ${index}= Set Variable ${index + 1}
600 ${ip_hex}= Catenate @{ip}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600601 [Return] ${ip_hex}
Sivas SRRea85d1f2016-11-13 22:44:28 -0600602
603BMC CPU Performance Check
604 [Documentation] Minimal 10% of proc should be free in this instance
605
606 ${bmc_cpu_usage_output} ${stderr}= Execute Command ${bmc_cpu_usage_cmd}
607 ... return_stderr=True
608 Should be empty ${stderr}
609 ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} %
610 Should be true ${bmc_cpu_percentage} < 90
611
612BMC Mem Performance Check
613 [Documentation] Minimal 10% of memory should be free in this instance
614
615 ${bmc_mem_free_output} ${stderr}= Execute Command ${bmc_mem_free_cmd}
616 ... return_stderr=True
617 Should be empty ${stderr}
618
619 ${bmc_mem_total_output} ${stderr}= Execute Command ${bmc_mem_total_cmd}
620 ... return_stderr=True
621 Should be empty ${stderr}
622
623 ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100
624 ${bmc_mem_percentage}= Evaluate
625 ... ${bmc_mem_percentage}/${bmc_mem_total_output}
626 Should be true ${bmc_mem_percentage} > 10
627
Sivas SRRaca55712016-12-21 04:32:35 -0600628BMC File System Usage Check
629 [Documentation] Check the file system space. None should be 100% full
Sivas SRR352bc162017-02-13 22:12:29 -0600630 ... except /run/initramfs/ro
Sivas SRRaca55712016-12-21 04:32:35 -0600631 ${bmc_fs_usage_output} ${stderr}= Execute Command
632 ... ${bmc_file_system_usage_cmd} return_stderr=True
633 Should Be Empty ${stderr}
634 Should Be True ${bmc_fs_usage_output}==0
635
Sivas SRRea85d1f2016-11-13 22:44:28 -0600636Check BMC CPU Performance
637 [Documentation] Minimal 10% of proc should be free in 3 sample
638 :FOR ${var} IN Range 1 4
639 \ BMC CPU Performance check
640
641Check BMC Mem Performance
642 [Documentation] Minimal 10% of memory should be free
643
644 :FOR ${var} IN Range 1 4
645 \ BMC Mem Performance check
646
Sivas SRRaca55712016-12-21 04:32:35 -0600647Check BMC File System Performance
648 [Documentation] Check for file system usage for 4 times
649
650 :FOR ${var} IN Range 1 4
651 \ BMC File System Usage check
652
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600653Get Endpoint Paths
654 [Documentation] Returns all url paths ending with given endpoint
655 ... Example:
656 ... Given the following endpoint: cpu
Michael Walsh01bd3682017-01-10 11:21:05 -0600657 ... This keyword will return: list of all urls ending with
658 ... cpu -
Rahul Maheshwari9a8d3b12016-12-05 04:06:16 -0600659 ... /org/openbmc/inventory/system/chassis/motherboard/cpu0,
660 ... /org/openbmc/inventory/system/chassis/motherboard/cpu1
661 ... Description of arguments:
662 ... path URL path for enumeration
663 ... endpoint string for which url path ending
664 [Arguments] ${path} ${endpoint}
665
666 ${resp}= Read Properties ${path}/enumerate timeout=30
667 log Dictionary ${resp}
668
669 ${list}= Get Dictionary Keys ${resp}
670 ${resp}= Get Matches ${list} regexp=^.*[0-9a-z_].${endpoint}[0-9]*$
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600671 [Return] ${resp}
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500672
673Check Zombie Process
674 [Documentation] Check if any defunct process exist or not on BMC
Michael Walsh01bd3682017-01-10 11:21:05 -0600675 ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l
Sridevi Rameshb96a0c32016-10-19 05:09:52 -0500676 ... return_stderr=True return_rc=True
677 Should Be True ${count}==0
678 Should Be Empty ${stderr}
George Keishing5327d012016-12-08 08:43:29 -0600679
680Prune Journal Log
681 [Documentation] Prune archived journal logs.
682 [Arguments] ${vacuum_size}=1M
683
684 # This keyword can be used to prevent the journal
685 # log from filling up the /run filesystem.
686 # This command will retain only the latest logs
687 # of the user specified size.
688
689 Open Connection And Log In
690 ${output} ${stderr} ${rc}=
691 ... Execute Command
692 ... journalctl --vacuum-size=${vacuum_size}
693 ... return_stderr=True return_rc=True
694
695 Should Be Equal ${rc} ${0} msg=${stderr}
Sridevi Ramesh1699d372016-12-06 00:20:22 -0600696
697Set BMC Power Policy
698 [Documentation] Set the given BMC power policy.
699 [arguments] ${policy}
700
701 ${valueDict}= create dictionary data=${policy}
702 Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
703 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
704 Should Be Equal ${currentPolicy} ${policy}
George Keishingcce9df22017-01-24 06:19:33 -0600705
George Keishing4d6f3d62017-02-06 09:50:41 -0600706Get System Power Policy
707 [Documentation] Get the BMC power policy.
708 ${currentPolicy}= Read Attribute ${HOST_SETTING} power_policy
709 [Return] ${currentPolicy}
George Keishingcce9df22017-01-24 06:19:33 -0600710
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600711Get Auto Reboot
712 [Documentation] Returns auto reboot setting.
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500713 ${setting}= Read Attribute ${HOST_SETTING} auto_reboot
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600714 [Return] ${setting}
715
716
717Set Auto Reboot
718 [Documentation] Set the given auto reboot setting.
719 [Arguments] ${setting}
720 # setting auto reboot's setting, i.e. yes or no
721
722 ${valueDict}= Set Variable ${setting}
723 ${data}= Create Dictionary data=${valueDict}
Sridevi Ramesh4dbe6592017-04-06 01:47:52 -0500724 Write Attribute ${HOST_SETTING} auto_reboot data=${data}
Rahul Maheshwari1cbf0042017-02-13 05:17:37 -0600725 ${current_setting}= Get Auto Reboot
726 Should Be Equal ${current_setting} ${setting}
727
728
George Keishingcce9df22017-01-24 06:19:33 -0600729Set BMC Reset Reference Time
730 [Documentation] Set current boot time as a reference and increment
George Keishing80dd5af2017-02-08 07:01:25 -0600731 ... boot count.
George Keishingcce9df22017-01-24 06:19:33 -0600732
733 ${cur_btime}= Get BMC Boot Time
George Keishing80dd5af2017-02-08 07:01:25 -0600734 Run Keyword If ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
George Keishingcce9df22017-01-24 06:19:33 -0600735 ... Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishing80dd5af2017-02-08 07:01:25 -0600736 ... ELSE IF ${cur_btime} > ${BOOT_TIME}
737 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
George Keishingcce9df22017-01-24 06:19:33 -0600738 ... AND
739 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
740
George Keishingcce9df22017-01-24 06:19:33 -0600741Get BMC Boot Time
742 [Documentation] Get boot time from /proc/stat.
743
744 Open Connection And Log In
745 ${output} ${stderr}=
746 ... Execute Command egrep '^btime ' /proc/stat | cut -f 2 -d ' '
747 ... return_stderr=True
748 Should Be Empty ${stderr}
749 ${btime}= Convert To Integer ${output}
750 [Return] ${btime}
George Keishingede30002017-02-02 09:33:07 -0600751
George Keishingede30002017-02-02 09:33:07 -0600752Execute Command On BMC
753 [Documentation] Execute given command on BMC and return output.
754 [Arguments] ${command}
755 ${stdout} ${stderr}= Execute Command ${command} return_stderr=True
756 Should Be Empty ${stderr}
757 [Return] ${stdout}
David Shawba2d2c22017-01-23 16:56:38 -0600758
Sridevi Rameshea36b412017-03-09 04:08:02 -0600759
George Keishing7a520222017-02-27 09:44:30 -0600760Enable Core Dump On BMC
761 [Documentation] Enable core dump collection.
762 Open Connection And Log In
763 ${core_pattern}= Execute Command On BMC
764 ... echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
765 Should Be Equal As Strings ${core_pattern} /tmp/core_%e.%p
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600766
Sivas SRR01262bd2017-03-19 10:00:23 -0500767Get Number Of BMC Core Dump Files
768 [Documentation] Get number of core dump files on BMC.
769 Open Connection And Log In
770 ${num_of_core_dump}= Execute Command
771 ... ls /tmp/core* 2>/dev/null | wc -l
772 [Return] ${num_of_core_dump}
773
774Set Core Dump File Size Unlimited
775 [Documentation] Set core dump file size to unlimited.
776 Open Connection And Log In
777 Execute Command On BMC
778 ... ulimit -c unlimited
779
780Check For Core Dumps
781 [Documentation] Check for any core dumps exist.
782 ${output}= Get Number Of BMC Core Dump Files
783 Run Keyword If ${output} > 0
784 ... Log **Warning** BMC core dump files exist level=WARN
785
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600786Trigger Host Watchdog Error
787 [Documentation] Inject host watchdog error using BMC.
788 [Arguments] ${milliseconds}=1000 ${sleep_time}=5s
Michael Walshb5839d02017-04-12 16:11:20 -0500789 # Description of argument(s):
790 # milliseconds The time watchdog timer value in milliseconds (e.g. 1000 =
791 # 1 second).
Rahul Maheshwarie95622c2017-02-24 10:04:29 -0600792 # sleep_time Time delay for host watchdog error to get injected.
793 # Default is 5 seconds.
794
795 Execute Command On BMC
796 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog set i ${milliseconds}
797 Execute Command On BMC
798 ... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog start
799 Sleep ${sleep_time}
Prashanth Kattiae7c2282017-03-15 07:43:46 -0500800
801Login To OS Host
802 [Documentation] Login to OS Host.
803 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
804 ... ${os_password}=${OS_PASSWORD}
805 # Desription of arguments:
806 # ${os_host} IP address of the OS Host.
807 # ${os_username} OS Host Login user name.
808 # ${os_password} OS Host Login passwrd.
809
810 ${os_state}= Run Keyword And Return Status Ping Host ${os_host}
811 Run Keyword If '${os_state}' == 'False'
812 ... Run Keywords Initiate Host Reboot AND
813 ... Is Host Running AND
814 ... Wait for OS ${os_host} ${os_username} ${os_password}
815
816 Open Connection ${os_host}
Sridevi Rameshea36b412017-03-09 04:08:02 -0600817 ${resp}= Login ${os_username} ${os_password}
818 [Return] ${resp}
Prashanth Katti884ee062017-03-16 05:05:03 -0500819
820Configure Initial Settings
821 [Documentation] Restore old IP and route.
822 ... This keyword requires initial settings viz IP address,
823 ... Network Mask, default gatway and serial console IP and port
824 ... information which should be provided in command line.
825
Michael Walshb5839d02017-04-12 16:11:20 -0500826 [Arguments] ${host}=${OPENBMC_HOST} ${mask}=${NET_MASK}
827 ... ${gw_ip}=${GW_IP}
Prashanth Katti884ee062017-03-16 05:05:03 -0500828
Michael Walshb5839d02017-04-12 16:11:20 -0500829 # Open telnet connection and ignore the error, in case telnet session is
830 # already opened by the program calling this keyword.
Prashanth Katti884ee062017-03-16 05:05:03 -0500831
832 Run Keyword And Ignore Error Open Telnet Connection to BMC Serial Console
833 Telnet.write ifconfig eth0 ${host} netmask ${mask}
834 Telnet.write route add default gw ${gw_ip}
George Keishingd05b1082017-03-24 05:27:32 -0500835
836Install Debug Tarball On BMC
837 [Documentation] Copy the tar file to BMC and install in "/usr/".
838 [Arguments] ${tarball_path}
839 # Description of arguments:
840 # tarball_path Absolute path of the debug tarball file.
841 # The tar file is downloaded from the build page
842 # https://openpower.xyz/job/openbmc-build/665/distro=ubuntu,
843 # target=witherspoon/artifact/images/witherspoon/
844 # obmc-phosphor-debug-tarball-witherspoon.tar.xz
845
846 OperatingSystem.File Should Exist ${tarball_path}
847 ... msg=${tarball_path} doesn't exist.
848 Import Library SCPLibrary WITH NAME scp
849 Open Connection for SCP
850 scp.Put File ${tarball_path} /tmp/debug-tarball.tar.xz
851 Open Connection And Log In
852 Execute Command On BMC tar -xf /tmp/debug-tarball.tar.xz -C /usr/
853 # Remove the tarball file from BMC
854 Execute Command On BMC rm /tmp/debug-tarball.tar.xz
855
Sweta Potthuri025e0122017-02-21 00:42:48 -0600856Get BMC Boot Count
857 [Documentation] Get BMC boot count based on boot time.
858 ${cur_btime}= Get BMC Boot Time
859
860 # Set global variable BOOT_TIME to current boot time if current boot time
861 # is changed. Also increase value of global variable BOOT_COUNT by 1.
862 Run Keyword If ${cur_btime} > ${BOOT_TIME}
863 ... Run Keywords Set Global Variable ${BOOT_TIME} ${cur_btime}
864 ... AND
865 ... Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
866 [Return] ${BOOT_COUNT}
867
868Set BMC Boot Count
869 [Documentation] Set BMC boot count to given value.
870 [Arguments] ${count}
871
872 # Description of arguments:
873 # count boot count value.
874 ${cur_btime}= Get BMC Boot Time
875
876 # Set global variable BOOT_COUNT to given value.
877 Set Global Variable ${BOOT_COUNT} ${count}
878
879 # Set BOOT_TIME variable to current boot time.
880 Set Global Variable ${BOOT_COUNT} ${count}
Michael Walsh689fbbe2017-04-04 17:58:03 -0500881
882###############################################################################
883Delete Error logs
884 [Documentation] Delete error logs.
885
886 # The REST method to delete error openbmc/openbmc#1327
887 # until then using logging restart.
888 Open Connection And Log In
889 Execute Command On BMC
890 ... systemctl restart xyz.openbmc_project.Logging.service
891 Sleep 10s reason=Wait for logging service to restart properly.
George Keishingdb34c2f2017-04-18 13:20:25 -0500892
893###############################################################################
894Delete Error log Entry
895 [Documentation] Delete error log entry.
896 [Arguments] ${entry_path}
897
898 # Description of argument(s):
899 # entry_path Delete an error log entry.
900 # Ex. /xyz/openbmc_project/logging/entry/1
901
902 ${data}= Create Dictionary data=@{EMPTY}
903 ${resp}= Openbmc Delete Request ${entry_path} data=${data}
904 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}