blob: b3532488cf243a7dac5aa5da7ddb1a2dbeb3faed [file] [log] [blame]
Steven Sombarf60cbcf2018-12-07 08:12:18 -06001*** Settings ***
2
3Documentation Utilities for Robot keywords that do not use REST.
4
Sandhya Somashekar839a0c22019-01-31 05:05:43 -06005Resource ../lib/resource.robot
Steven Sombarf60cbcf2018-12-07 08:12:18 -06006Resource ../lib/connection_client.robot
7Resource ../lib/boot_utils.robot
8Library String
9Library DateTime
10Library Process
11Library OperatingSystem
12Library gen_print.py
13Library gen_robot_print.py
14Library gen_cmd.py
Michael Walsh07ed7942019-11-08 14:41:30 -060015Library gen_robot_valid.py
Steven Sombarf60cbcf2018-12-07 08:12:18 -060016Library gen_robot_keyword.py
17Library bmc_ssh_utils.py
18Library utils.py
19Library var_funcs.py
George Keishingb5c119e2025-03-25 20:45:03 +053020Library SCPLibrary AS scp
Steven Sombarf60cbcf2018-12-07 08:12:18 -060021
22*** Variables ***
23
24${pflash_cmd} /usr/sbin/pflash -r /dev/stdout -P VERSION
25
Steven Sombarf60cbcf2018-12-07 08:12:18 -060026# Assign default value to QUIET for programs which may not define it.
27${QUIET} ${0}
28
29${bmc_mem_free_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
30${bmc_mem_total_cmd}= free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
31${bmc_cpu_usage_cmd}= top -n 1 | grep CPU: | cut -c 7-9
32${HOST_SETTING} ${SETTINGS_URI}host0
33
34# /run/initramfs/ro associate filesystem should be 100% full always
35${bmc_file_system_usage_cmd}= df -h | cut -c 52-54 | grep 100 | wc -l
36${total_pnor_ro_file_system_cmd}= df -h | grep /media/pnor-ro | wc -l
37${total_bmc_ro_file_system_cmd}= df -h | grep /media/rofs | wc -l
38
39${BOOT_TIME} ${0}
40${BOOT_COUNT} ${0}
41${count} ${0}
42${devicetree_base} /sys/firmware/devicetree/base/model
43
44# Initialize default debug value to 0.
45${DEBUG} ${0}
46
47${probe_cpu_tool_path} ${EXECDIR}/tools/ras/probe_cpus.sh
48${scom_addrs_tool_path} ${EXECDIR}/tools/ras/scom_addr_p9.sh
49${target_file_path} /root/
50
51${default_tarball} ${EXECDIR}/obmc-phosphor-debug-tarball-witherspoon.tar.xz
52
53# These variables are used to straddle between new and old methods of setting
54# values.
55${bmc_power_policy_method} ${EMPTY}
56@{valid_power_policy_vars} RESTORE_LAST_STATE ALWAYS_POWER_ON
57... ALWAYS_POWER_OFF
58
George Keishingb9f3f772020-01-15 23:23:08 -060059${check_performance} ${1}
60
Steven Sombarf60cbcf2018-12-07 08:12:18 -060061
62*** Keywords ***
63
64Check BMC Performance
65 [Documentation] Check BMC basic CPU Mem File system performance.
66
George Keishingb9f3f772020-01-15 23:23:08 -060067 Return From Keyword If not ${check_performance}
68
Steven Sombarf60cbcf2018-12-07 08:12:18 -060069 Check BMC CPU Performance
70 Check BMC Mem Performance
71 Check BMC File System Performance
72
73
74Verify PNOR Update
75 [Documentation] Verify that the PNOR is not corrupted.
76 # Example:
77 # FFS: Flash header not found. Code: 100
78 # Error 100 opening ffs !
79
80 ${stdout} ${stderr} ${rc}=
81 ... BMC Execute Command /usr/sbin/pflash -h | egrep -q skip
82 ... ignore_err=${1}
83 ${pflash_cmd}= Set Variable If ${rc} == ${0} ${pflash_cmd} --skip=4096
84 ... ${pflash_cmd}
85 ${pnor_info}= BMC Execute Command ${pflash_cmd}
86 Should Not Contain Any ${pnor_info} Flash header not found Error
87
88
89Get BMC System Model
90 [Documentation] Get the BMC model from the device tree and return it.
91
92 ${bmc_model} ${stderr} ${rc}= BMC Execute Command
93 ... cat ${devicetree_base} | cut -d " " -f 1 return_stderr=True
94 ... test_mode=0
95 Should Be Empty ${stderr}
96 Should Not Be Empty ${bmc_model} msg=BMC model is empty.
George Keishing409df052024-01-17 22:36:14 +053097 RETURN ${bmc_model}
Steven Sombarf60cbcf2018-12-07 08:12:18 -060098
99
100Verify BMC System Model
101 [Documentation] Verify the BMC model with ${OPENBMC_MODEL}.
102 [Arguments] ${bmc_model}
103
104 # Description of argument(s):
105 # bmc_model System model (e.g. "witherspoon").
106
107 ${tmp_bmc_model}= Fetch From Right ${OPENBMC_MODEL} /
108 ${tmp_bmc_model}= Fetch From Left ${tmp_bmc_model} .
109 ${ret}= Run Keyword And Return Status Should Contain ${bmc_model}
110 ... ${tmp_bmc_model} ignore_case=True
George Keishing409df052024-01-17 22:36:14 +0530111 RETURN ${ret}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600112
113
114Wait For Host To Ping
115 [Documentation] Wait for the given host to ping.
116 [Arguments] ${host} ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
Sushil Singh7d5a4302023-08-20 23:55:48 -0500117 ... ${interval}=5 sec ${expected_rc}=${0}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600118
119 # Description of argument(s):
Sushil Singh7d5a4302023-08-20 23:55:48 -0500120 # host The host name or IP of the host to ping.
121 # timeout The amount of time after which ping attempts cease.
122 # This should be expressed in Robot Framework's time format
123 # (e.g. "10 seconds").
124 # interval The amount of time in between attempts to ping.
125 # This should be expressed in Robot Framework's time format
126 # (e.g. "5 seconds").
127 # expected_rc Expected return code of ping command.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600128
Sushil Singh7d5a4302023-08-20 23:55:48 -0500129 Wait Until Keyword Succeeds ${timeout} ${interval} Ping Host ${host} ${expected_rc}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600130
131
132Ping Host
133 [Documentation] Ping the given host.
Sushil Singh7d5a4302023-08-20 23:55:48 -0500134 [Arguments] ${host} ${expected_rc}=${0}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600135
136 # Description of argument(s):
Sushil Singh7d5a4302023-08-20 23:55:48 -0500137 # host The host name or IP of the host to ping.
138 # expected_rc Expected return code of ping command.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600139
140 Should Not Be Empty ${host} msg=No host provided
Sushil Singh7d5a4302023-08-20 23:55:48 -0500141 ${rc} ${output}= Run and return RC and Output ping -c 4 ${host}
142 Log RC: ${rc}\nOutput:\n${output}
143 Should be equal ${rc} ${expected_rc}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600144
145
146Check OS
147 [Documentation] Attempts to ping the host OS and then checks that the host
148 ... OS is up by running an SSH command.
149
150 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
151 ... ${os_password}=${OS_PASSWORD} ${quiet}=${QUIET}
152 ... ${print_string}=${EMPTY}
153 [Teardown] SSHLibrary.Close Connection
154
155 # Description of argument(s):
156 # os_host The DNS name/IP of the OS host associated with our BMC.
157 # os_username The username to be used to sign on to the OS host.
158 # os_password The password to be used to sign on to the OS host.
159 # quiet Indicates whether this keyword should write to console.
160 # print_string A string to be printed before checking the OS.
161
Michael Walshc108e422019-03-28 12:27:18 -0500162 Log To Console ${print_string} no_newline=True
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600163
164 # Attempt to ping the OS. Store the return code to check later.
165 ${ping_rc}= Run Keyword and Return Status Ping Host ${os_host}
166
167 SSHLibrary.Open connection ${os_host}
168
George Keishing30751662019-03-05 06:35:55 -0600169 ${status} ${msg}= Run Keyword And Ignore Error SSHLibrary.Login ${os_username}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600170 ... ${os_password}
171 ${err_msg1}= Sprint Error ${msg}
172 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500173 IF '${status}' == 'FAIL' Fail msg=${err_msg}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600174 ${output} ${stderr} ${rc}= Execute Command uptime return_stderr=True
175 ... return_rc=True
176
177 ${temp_msg}= Catenate Could not execute a command on the operating
178 ... system.\n
179 ${err_msg1}= Sprint Error ${temp_msg}
180 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
181
182 # If the return code returned by "Execute Command" is non-zero, this
183 # keyword will fail.
184 Should Be Equal ${rc} ${0} msg=${err_msg}
185 # We will likewise fail if there is any stderr data.
186 Should Be Empty ${stderr}
187
188 ${temp_msg}= Set Variable Could not ping the operating system.\n
189 ${err_msg1}= Sprint Error ${temp_msg}
190 ${err_msg}= Catenate SEPARATOR= \n ${err_msg1}
191 # We will likewise fail if the OS did not ping, as we could SSH but not
192 # ping
193 Should Be Equal As Strings ${ping_rc} ${TRUE} msg=${err_msg}
194
195
196Wait for OS
197 [Documentation] Waits for the host OS to come up via calls to "Check OS".
198 [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
199 ... ${os_password}=${OS_PASSWORD} ${timeout}=${OS_WAIT_TIMEOUT}
200 ... ${quiet}=${0}
Michael Walshc108e422019-03-28 12:27:18 -0500201 [Teardown] Printn
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600202
203 # Description of argument(s):
204 # os_host The DNS name or IP of the OS host associated with our
205 # BMC.
206 # os_username The username to be used to sign on to the OS host.
207 # os_password The password to be used to sign on to the OS host.
208 # timeout The timeout in seconds indicating how long you're
209 # willing to wait for the OS to respond.
210 # quiet Indicates whether this keyword should write to console.
211
212 # The interval to be used between calls to "Check OS".
213 ${interval}= Set Variable 5
214
215 ${message}= Catenate Checking every ${interval} seconds for up to
216 ... ${timeout} seconds for the operating system to communicate.
Michael Walshc108e422019-03-28 12:27:18 -0500217 Qprint Timen ${message}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600218
219 Wait Until Keyword Succeeds ${timeout} sec ${interval} Check OS
220 ... ${os_host} ${os_username} ${os_password}
221 ... print_string=\#
222
Michael Walshc108e422019-03-28 12:27:18 -0500223 Qprintn
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600224
Michael Walshc108e422019-03-28 12:27:18 -0500225 Qprint Timen The operating system is now communicating.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600226
227
228Copy PNOR to BMC
229 [Documentation] Copy the PNOR image to the BMC.
George Keishingb5c119e2025-03-25 20:45:03 +0530230 Import Library SCPLibrary AS scp
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600231 Open Connection for SCP
232 Log Copying ${PNOR_IMAGE_PATH} to /tmp
233 scp.Put File ${PNOR_IMAGE_PATH} /tmp
234
235
236Is OS Starting
237 [Documentation] Check if boot progress is OS starting.
238 ${boot_progress}= Get Boot Progress
239 Should Be Equal ${boot_progress} OSStart
240
241
242Is OS Off
243 [Documentation] Check if boot progress is "Off".
244 ${boot_progress}= Get Boot Progress
245 Should Be Equal ${boot_progress} Off
246
247
248Get Boot Progress To OS Starting State
249 [Documentation] Get the system to a boot progress state of 'FW Progress,
250 ... Starting OS'.
251
252 ${boot_progress}= Get Boot Progress
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500253 Log To Console ${boot_progress}
254 IF '${boot_progress}' == 'OSStart'
255 Log Host is already in OS starting state
256 ELSE
257 Initiate Host PowerOff AND Initiate Host Boot
258 Wait Until Keyword Succeeds 10 min 10 sec Is OS Starting
259 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600260
261Check If warmReset is Initiated
262 [Documentation] Ping would be still alive, so try SSH to connect
263 ... if fails the ports are down indicating reboot
264 ... is in progress
265
266 # Warm reset adds 3 seconds delay before forcing reboot
267 # To minimize race conditions, we wait for 7 seconds
268 Sleep 7s
269 ${alive}= Run Keyword and Return Status
270 ... Open Connection And Log In
271 Return From Keyword If '${alive}' == '${False}' ${False}
George Keishing409df052024-01-17 22:36:14 +0530272 RETURN ${True}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600273
274
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600275Create OS Console Command String
276 [Documentation] Return a command string to start OS console logging.
277
278 # First make sure that the ssh_pw program is available.
279 ${cmd}= Catenate which ssh_pw 2>/dev/null || find
280 ... ${EXECDIR} -name 'ssh_pw'
281
Michael Walshc108e422019-03-28 12:27:18 -0500282 Dprint Issuing ${cmd}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600283 ${rc} ${output}= Run And Return Rc And Output ${cmd}
284 Rdpvars rc output
285
286 Should Be Equal As Integers 0 ${rc} msg=Could not find ssh_pw.
287
288 ${ssh_pw_file_path}= Set Variable ${output}
289
George Keishing088166c2019-12-13 08:11:28 -0600290 ${cmd}= Catenate ${ssh_pw_file_path} ${OPENBMC_PASSWORD} -p ${HOST_SOL_PORT}
Jorge Cisnerosf196b242022-09-09 15:46:15 +0000291 ... -o "StrictHostKeyChecking no" ${OPENBMC_USERNAME}@${OPENBMC_HOST} ${OPENBMC_CONSOLE_CLIENT}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600292
George Keishing409df052024-01-17 22:36:14 +0530293 RETURN ${cmd.strip()}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600294
295
296Get SOL Console Pid
297 [Documentation] Get the pid of the active SOL console job.
Michael Walsh07ed7942019-11-08 14:41:30 -0600298 [Arguments] ${expect_running}=${0} ${log_file_path}=${EMPTY}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600299
300 # Description of argument(s):
Michael Walsh07ed7942019-11-08 14:41:30 -0600301 # expect_running If set and if no SOL console job is found, print debug info and fail.
302 # log_file_path Needed to print debug info if expect_running is set and no pid is found.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600303
304 # Find the pid of the active system console logging session (if any).
305 ${search_string}= Create OS Console Command String
306 # At least in some cases, ps output does not show double quotes so we must
307 # replace them in our search string with the regexes to indicate that they
308 # are optional.
309 ${search_string}= Replace String ${search_string} " ["]?
310 ${ps_cmd}= Catenate ps axwwo user,pid,cmd
311 ${cmd_buf}= Catenate echo $(${ps_cmd} | egrep '${search_string}' |
312 ... egrep -v grep | cut -c10-14)
Michael Walshc108e422019-03-28 12:27:18 -0500313 Dprint Issuing ${cmd_buf}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600314 ${rc} ${os_con_pid}= Run And Return Rc And Output ${cmd_buf}
315 Rdpvars os_con_pid
316 # If rc is not zero it just means that there is no OS Console process
317 # running.
318
319 Return From Keyword If '${os_con_pid}' != '${EMPTY}' ${os_con_pid}
320 Return From Keyword If '${expect_running}' == '${0}' ${os_con_pid}
321
322 Cmd Fnc cat ${log_file_path} ; echo ; ${ps_cmd} quiet=${0}
323 ... print_output=${1} show_err=${1}
Michael Walsh07ed7942019-11-08 14:41:30 -0600324 Valid Value os_con_pid
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600325
326
327Stop SOL Console Logging
328 [Documentation] Stop system console logging and return log output.
329 [Arguments] ${log_file_path}=${EMPTY}
330 ... ${targ_file_path}=${EXECDIR}${/}logs${/}
331 ... ${return_data}=${1}
332
George Keishinge16f1582022-12-15 07:32:21 -0600333 # If there are multiple system console processes, they will all be stopped.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600334 # If there is no existing log file this keyword will return an error
335 # message to that effect (and write that message to targ_file_path, if
336 # specified).
337 # NOTE: This keyword will not fail if there is no running system console
338 # process.
339
340 # Description of arguments:
341 # log_file_path The file path that was used to call "Start SOL
342 # Console Logging". See that keyword (above) for details.
343 # targ_file_path If specified, the file path to which the source
344 # file path (i.e. "log_file_path") should be copied.
345 # return_data If this is set to ${1}, this keyword will return the SOL
346 # data to the caller as a unicode string.
347
348 ${log_file_path}= Create OS Console File Path ${log_file_path}
349
350 ${os_con_pid}= Get SOL Console Pid
351
352 ${cmd_buf}= Catenate kill -9 ${os_con_pid}
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500353 IF '${os_con_pid}' != '${EMPTY}' Dprint Issuing ${cmd_buf}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600354
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500355 IF '${os_con_pid}' != '${EMPTY}'
356 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
357 END
358
359 IF '${os_con_pid}' != '${EMPTY}' Rdpvars rc output
360
361 IF '${targ_file_path}' != '${EMPTY}'
362 Run Keyword And Ignore Error
363 ... Copy File ${log_file_path} ${targ_file_path}
364 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600365
366 ${output}= Set Variable ${EMPTY}
367 ${loc_quiet}= Evaluate ${debug}^1
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500368 IF '${return_data}' == '${1}'
369 ${rc} ${output}= Cmd Fnc cat ${log_file_path} 2>/dev/null quiet=${loc_quiet}
370 ... print_output=${0} show_err=${0}
371 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600372
George Keishing409df052024-01-17 22:36:14 +0530373 RETURN ${output}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600374
375
376Start SOL Console Logging
377 [Documentation] Start system console log to file.
378 [Arguments] ${log_file_path}=${EMPTY} ${return_data}=${1}
379
380 # This keyword will first call "Stop SOL Console Logging". Only then will
381 # it start SOL console logging. The data returned by "Stop SOL Console
382 # Logging" will in turn be returned by this keyword.
383
384 # Description of arguments:
385 # log_file_path The file path to which system console log data should be
386 # written. Note that this path is taken to be a location
387 # on the machine where this program is running rather than
388 # on the Open BMC system.
389 # return_data If this is set to ${1}, this keyword will return any SOL
390 # data to the caller as a unicode string.
391
392 ${log_file_path}= Create OS Console File Path ${log_file_path}
393
394 ${log_output}= Stop SOL Console Logging ${log_file_path}
395 ... return_data=${return_data}
396
397 # Validate by making sure we can create the file. Problems creating the
398 # file would not be noticed by the subsequent ssh command because we fork
399 # the command.
400 Create File ${log_file_path}
401 ${sub_cmd_buf}= Create OS Console Command String
402 # Routing stderr to stdout so that any startup error text will go to the
403 # output file.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600404 ${cmd_buf}= Catenate ${sub_cmd_buf} > ${log_file_path} 2>&1 &
Michael Walshc108e422019-03-28 12:27:18 -0500405 Dprint Issuing ${cmd_buf}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600406 ${rc} ${output}= Run And Return Rc And Output ${cmd_buf}
407 # Because we are forking this command, we essentially will never get a
408 # non-zero return code or any output.
409 Should Be Equal ${rc} ${0}
410
411 Wait Until Keyword Succeeds 10 seconds 0 seconds
Michael Walsh07ed7942019-11-08 14:41:30 -0600412 ... Get SOL Console Pid ${1} ${log_file_path}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600413
George Keishing409df052024-01-17 22:36:14 +0530414 RETURN ${log_output}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600415
416
417Get Time Stamp
418 [Documentation] Get the current time stamp data
419 ${cur_time}= Get Current Date result_format=%Y%m%d%H%M%S%f
George Keishing409df052024-01-17 22:36:14 +0530420 RETURN ${cur_time}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600421
422
423Start Journal Log
424 [Documentation] Start capturing journal log to a file in /tmp using
425 ... journalctl command. By default journal log is collected
426 ... at /tmp/journal_log else user input location.
427 ... The File is appended with datetime.
428 [Arguments] ${file_path}=/tmp/journal_log ${filter}=${EMPTY}
429
430 # Description of arguments:
431 # file_path The file path of the journal file.
432
433 ${cur_time}= Get Time Stamp
434 Set Global Variable ${LOG_TIME} ${cur_time}
435 Open Connection And Log In
436 Start Command
437 ... journalctl -f ${filter} > ${file_path}-${LOG_TIME}
438 Log Journal Log Started: ${file_path}-${LOG_TIME}
439
440
441Stop Journal Log
442 [Documentation] Stop journalctl process if its running.
443 ... By default return log from /tmp/journal_log else
444 ... user input location.
445 [Arguments] ${file_path}=/tmp/journal_log
446
447 # Description of arguments:
448 # file_path The file path of the journal file.
449
450 Open Connection And Log In
451
452 ${rc}=
453 ... Execute Command
454 ... ps | grep journalctl | grep -v grep
455 ... return_stdout=False return_rc=True
456
457 Return From Keyword If '${rc}' == '${1}'
458 ... No journal log process running
459
460 ${output} ${stderr}=
461 ... Execute Command killall journalctl
462 ... return_stderr=True
463 Should Be Empty ${stderr}
464
465 ${journal_log} ${stderr}=
466 ... Execute Command
467 ... cat ${file_path}-${LOG_TIME}
468 ... return_stderr=True
469 Should Be Empty ${stderr}
470
471 Log ${journal_log}
472
473 Execute Command rm ${file_path}-${LOG_TIME}
474
George Keishing409df052024-01-17 22:36:14 +0530475 RETURN ${journal_log}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600476
477
478Mac Address To Hex String
479 [Documentation] Converts MAC address into hex format.
480 ... Example
481 ... Given the following MAC: 00:01:6C:80:02:78
482 ... This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
483 ... Description of arguments:
484 ... i_macaddress MAC address in the following format
485 ... 00:01:6C:80:02:78
486 [Arguments] ${i_macaddress}
487
488 # Description of arguments:
489 # i_macaddress The MAC address.
490
491 ${mac_hex}= Catenate 0x${i_macaddress.replace(':', ' 0x')}
George Keishing409df052024-01-17 22:36:14 +0530492 RETURN ${mac_hex}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600493
494
495IP Address To Hex String
496 [Documentation] Converts IP address into hex format.
497 ... Example:
498 ... Given the following IP: 10.3.164.100
499 ... This keyword will return: 0xa 0x3 0xa4 0xa0
500 [Arguments] ${i_ipaddress}
501
502 # Description of arguments:
503 # i_macaddress The IP address in the format 10.10.10.10.
504
505 @{ip}= Split String ${i_ipaddress} .
506 ${index}= Set Variable ${0}
507
Marissa Garza20ccfc72020-06-19 12:51:10 -0500508 FOR ${item} IN @{ip}
509 ${hex}= Convert To Hex ${item} prefix=0x lowercase=yes
510 Set List Value ${ip} ${index} ${hex}
511 ${index}= Set Variable ${index + 1}
512 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600513 ${ip_hex}= Catenate @{ip}
514
George Keishing409df052024-01-17 22:36:14 +0530515 RETURN ${ip_hex}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600516
517
518BMC CPU Performance Check
519 [Documentation] Minimal 10% of proc should be free in this instance
520
521 ${bmc_cpu_usage_output} ${stderr} ${rc}= BMC Execute Command
522 ... ${bmc_cpu_usage_cmd}
523 ${bmc_cpu_usage_output} ${stderr} ${rc}= BMC Execute Command
524 ... ${bmc_cpu_usage_cmd}
525 ${bmc_cpu_percentage}= Fetch From Left ${bmc_cpu_usage_output} %
Sivas SRR14426bc2019-04-10 10:14:46 -0500526 Rprint Vars bmc_cpu_percentage
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600527 Should be true ${bmc_cpu_percentage} < 90
528
529
530BMC Mem Performance Check
531 [Documentation] Minimal 10% of memory should be free in this instance
532
533 ${bmc_mem_free_output} ${stderr} ${rc}= BMC Execute Command
534 ... ${bmc_mem_free_cmd}
535
536 ${bmc_mem_total_output} ${stderr} ${rc}= BMC Execute Command
537 ... ${bmc_mem_total_cmd}
538 ${bmc_mem_free_output} ${stderr} ${rc}= BMC Execute Command
539 ... ${bmc_mem_free_cmd}
540
541 ${bmc_mem_total_output} ${stderr} ${rc}= BMC Execute Command
542 ... ${bmc_mem_total_cmd}
543
544 ${bmc_mem_percentage}= Evaluate ${bmc_mem_free_output}*100
545 ${bmc_mem_percentage}= Evaluate
546 ... ${bmc_mem_percentage}/${bmc_mem_total_output}
Sivas SRR14426bc2019-04-10 10:14:46 -0500547 Rprint Vars bmc_mem_percentage
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600548 Should be true ${bmc_mem_percentage} > 10
549
550
551BMC File System Usage Check
552 [Documentation] Check the file system space. 4 file system should be
553 ... 100% full which is expected
554 # Filesystem Size Used Available Use% Mounted on
555 # /dev/root 14.4M 14.4M 0 100% /
556 # /dev/ubiblock0_0 14.4M 14.4M 0 100% /media/rofs-c9249b0e
557 # /dev/ubiblock8_0 19.6M 19.6M 0 100% /media/pnor-ro-8764baa3
558 # /dev/ubiblock4_0 14.4M 14.4M 0 100% /media/rofs-407816c
559 # /dev/ubiblock8_4 21.1M 21.1M 0 100% /media/pnor-ro-cecc64c4
560 ${bmc_fs_usage_output} ${stderr} ${rc}= BMC Execute Command
561 ... ${bmc_file_system_usage_cmd}
562 ${bmc_pnor_fs_usage_output} ${stderr} ${rc}= BMC Execute Command
563 ... ${total_pnor_ro_file_system_cmd}
564 ${bmc_bmc_fs_usage_output} ${stderr} ${rc}= BMC Execute Command
565 ... ${total_bmc_ro_file_system_cmd}
566 ${total_bmc_pnor_image}= Evaluate
567 ... ${bmc_pnor_fs_usage_output}+${bmc_bmc_fs_usage_output}
568 # Considering /dev/root also in total 100% used file system
569 ${total_full_fs}= Evaluate ${total_bmc_pnor_image}+1
Sivas SRR14426bc2019-04-10 10:14:46 -0500570 Rprint Vars bmc_fs_usage_output bmc_pnor_fs_usage_output bmc_bmc_fs_usage_output
571 ... total_full_fs
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600572 Should Be True ${bmc_fs_usage_output}==${total_full_fs}
573
574
575Check BMC CPU Performance
576 [Documentation] Minimal 10% of proc should be free in 3 sample
Marissa Garza20ccfc72020-06-19 12:51:10 -0500577 FOR ${var} IN RANGE 1 4
578 BMC CPU Performance Check
579 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600580
581Check BMC Mem Performance
582 [Documentation] Minimal 10% of memory should be free
583
Marissa Garza20ccfc72020-06-19 12:51:10 -0500584 FOR ${var} IN RANGE 1 4
585 BMC Mem Performance Check
586 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600587
588Check BMC File System Performance
589 [Documentation] Check for file system usage for 4 times
590
Marissa Garza20ccfc72020-06-19 12:51:10 -0500591 FOR ${var} IN RANGE 1 4
592 BMC File System Usage check
593 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600594
595Get URL List
596 [Documentation] Return list of URLs under given URL.
597 [Arguments] ${openbmc_url}
598
599 # Description of argument(s):
600 # openbmc_url URL for list operation (e.g.
601 # /xyz/openbmc_project/inventory).
602
Steven Sombaraaaab222018-12-19 13:16:23 -0600603 ${url_list}= Read Properties ${openbmc_url}list quiet=${1}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600604 Sort List ${url_list}
605
George Keishing409df052024-01-17 22:36:14 +0530606 RETURN ${url_list}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600607
608
609Check Zombie Process
610 [Documentation] Check if any defunct process exist or not on BMC
611 ${count} ${stderr} ${rc}= Execute Command ps -o stat | grep Z | wc -l
612 ... return_stderr=True return_rc=True
613 Should Be True ${count}==0
614 Should Be Empty ${stderr}
615
616
617Prune Journal Log
618 [Documentation] Prune archived journal logs.
619 [Arguments] ${vacuum_size}=1M
620
621 # This keyword can be used to prevent the journal
622 # log from filling up the /run filesystem.
623 # This command will retain only the latest logs
624 # of the user specified size.
625
626 # Description of argument(s):
627 # vacuum_size Size of journal.
628
629 Open Connection And Log In
630 ${output} ${stderr} ${rc}=
631 ... Execute Command
632 ... journalctl --vacuum-size=${vacuum_size}
633 ... return_stderr=True return_rc=True
634
635 Should Be Equal ${rc} ${0} msg=${stderr}
636
637
638Get System Power Policy
639 [Documentation] Returns the BMC power policy.
640
641 # Set the bmc_power_policy_method to either 'Old' or 'New'.
642 Set Power Policy Method
643 ${cmd_buf}= Create List ${bmc_power_policy_method} Get Power Policy
644 # Run the appropriate keyword.
645 ${currentPolicy}= Run Keyword @{cmd_buf}
646
George Keishing409df052024-01-17 22:36:14 +0530647 RETURN ${currentPolicy}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600648
649
650Set BMC Reset Reference Time
651 [Documentation] Set current boot time as a reference and increment
652 ... boot count.
653
654 ${cur_btime}= Get BMC Boot Time
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500655 IF ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
656 Set Global Variable ${BOOT_TIME} ${cur_btime}
657 ELSE IF ${cur_btime} > ${BOOT_TIME}
658 Set Global Variable ${BOOT_TIME} ${cur_btime}
659 Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
660 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600661
662Get BMC Boot Time
663 [Documentation] Returns boot time from /proc/stat.
664
665 Open Connection And Log In
666 ${output} ${stderr}=
667 ... Execute Command egrep '^btime ' /proc/stat | cut -f 2 -d ' '
668 ... return_stderr=True
669 Should Be Empty ${stderr}
670 ${btime}= Convert To Integer ${output}
George Keishing409df052024-01-17 22:36:14 +0530671 RETURN ${btime}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600672
673
674Enable Core Dump On BMC
675 [Documentation] Enable core dump collection.
676 ${core_pattern} ${stderr} ${rc}= BMC Execute Command
677 ... echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
678 Should Be Equal As Strings ${core_pattern} /tmp/core_%e.%p
679
680
681Get Number Of BMC Core Dump Files
682 [Documentation] Returns number of core dump files on BMC.
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500683
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600684 Open Connection And Log In
685 ${num_of_core_dump}= Execute Command
686 ... ls /tmp/core* 2>/dev/null | wc -l
George Keishing409df052024-01-17 22:36:14 +0530687 RETURN ${num_of_core_dump}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600688
689
690Set Core Dump File Size Unlimited
691 [Documentation] Set core dump file size to unlimited.
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500692
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600693 BMC Execute Command ulimit -c unlimited
694
695
696Check For Core Dumps
697 [Documentation] Check for any core dumps exist.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600698
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500699 ${output}= Get Number Of BMC Core Dump Files
700 IF ${output} > 0
701 Log **Warning** BMC core dump files exist level=WARN
702 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600703
704Configure Initial Settings
705 [Documentation] Restore old IP and route.
706 ... This keyword requires initial settings viz IP address,
George Keishing16b3c7b2021-01-28 09:23:37 -0600707 ... Network Mask, default gateway and serial console IP and port
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600708 ... information which should be provided in command line.
709
710 [Arguments] ${host}=${OPENBMC_HOST} ${mask}=${NET_MASK}
711 ... ${gw_ip}=${GW_IP}
712
713 # Description of arguments:
714 # host IP address of the OS Host.
715 # mask Network mask.
716 # gu_ip Gateway IP address or hostname.
717
718 # Open telnet connection and ignore the error, in case telnet session is
719 # already opened by the program calling this keyword.
720 Run Keyword And Ignore Error Open Telnet Connection to BMC Serial Console
721 Telnet.write ifconfig eth0 ${host} netmask ${mask}
722 Telnet.write route add default gw ${gw_ip}
723
724
725Install Debug Tarball On BMC
726 [Documentation] Copy the debug tar file to BMC and install.
727 [Arguments] ${tarball_file_path}=${default_tarball}
728 ... ${targ_tarball_dir_path}=/tmp/tarball/
729
730 # Description of arguments:
731 # tarball_file_path Path of the debug tarball file.
732 # The tar file is downloaded from the build page
George Keishinged616122020-07-02 00:57:15 -0500733 # https://jenkins.openbmc.org/job/latest-master/
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600734 # obmc-phosphor-debug-tarball-witherspoon.tar.xz
735 #
736 # targ_tarball_dir_path The directory path where the tarball is to be
737 # installed.
738
739 OperatingSystem.File Should Exist ${tarball_file_path}
740 ... msg=${tarball_file_path} doesn't exist.
741
742 # Upload the file to BMC.
George Keishingb5c119e2025-03-25 20:45:03 +0530743 Import Library SCPLibrary AS scp
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600744 Open Connection for SCP
745 scp.Put File ${tarball_file_path} /tmp/debug-tarball.tar.xz
746
747 # Create tarball directory and install.
748 BMC Execute Command mkdir -p ${targ_tarball_dir_path}
749 BMC Execute Command
750 ... tar -xf /tmp/debug-tarball.tar.xz -C ${targ_tarball_dir_path}
751
752 # Remove the tarball file from BMC.
753 BMC Execute Command rm -f /tmp/debug-tarball.tar.xz
754
755
756Get BMC Boot Count
757 [Documentation] Returns BMC boot count based on boot time.
758 ${cur_btime}= Get BMC Boot Time
759
760 # Set global variable BOOT_TIME to current boot time if current boot time
761 # is changed. Also increase value of global variable BOOT_COUNT by 1.
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500762 IF ${cur_btime} > ${BOOT_TIME}
763 Set Global Variable ${BOOT_TIME} ${cur_btime}
764 Set Global Variable ${BOOT_COUNT} ${BOOT_COUNT + 1}
765 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600766
George Keishing409df052024-01-17 22:36:14 +0530767 RETURN ${BOOT_COUNT}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600768
769
770Set BMC Boot Count
771 [Documentation] Set BMC boot count to given value.
772 [Arguments] ${count}
773
774 # Description of arguments:
775 # count boot count value.
776 ${cur_btime}= Get BMC Boot Time
777
778 # Set global variable BOOT_COUNT to given value.
779 Set Global Variable ${BOOT_COUNT} ${count}
780
781 # Set BOOT_TIME variable to current boot time.
Tony Lee073fbc02020-05-12 15:12:16 +0800782 Set Global Variable ${BOOT_TIME} ${cur_btime}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600783
784
785Delete Error Log Entry
786 [Documentation] Delete error log entry.
Michael Sheposcc490b42020-08-26 12:53:01 -0500787 [Arguments] ${entry_path} ${quiet}=${0}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600788
789 # Description of argument(s):
Michael Sheposcc490b42020-08-26 12:53:01 -0500790 # quiet If enabled, turns off logging to console.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600791 # entry_path Delete an error log entry.
792 # Ex. /xyz/openbmc_project/logging/entry/1
793
794 # Skip delete if entry URI is a callout.
795 # Examples:
796 # /xyz/openbmc_project/logging/entry/1/callout
797 # /xyz/openbmc_project/logging/entry/1/callouts/0
798 ${callout_entry}= Run Keyword And Return Status
799 ... Should Match Regexp ${entry_path} /callout[s]?(/|$)
800 Return From Keyword If ${callout_entry}
801
802 ${data}= Create Dictionary data=@{EMPTY}
Michael Sheposcc490b42020-08-26 12:53:01 -0500803 ${resp}= Openbmc Delete Request ${entry_path} data=${data} quiet=${quiet}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600804 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
805
806
807Get BMC Version
808 [Documentation] Returns BMC version from /etc/os-release.
809 ... e.g. "v1.99.6-141-ge662190"
810
811 ${cmd}= Set Variable grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '='
812 ${output} ${stderr} ${rc}= BMC Execute Command ${cmd}
George Keishing409df052024-01-17 22:36:14 +0530813 RETURN ${output}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600814
815
816Get PNOR Version
817 [Documentation] Returns the PNOR version from the BMC.
818
819 ${pnor_attrs}= Get PNOR Attributes
George Keishing409df052024-01-17 22:36:14 +0530820 RETURN ${pnor_attrs['version']}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600821
822
823Get PNOR Attributes
824 [Documentation] Return PNOR software attributes as a dictionary.
825
826 # This keyword parses /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
827 # into key/value pairs.
828
829 ${outbuf} ${stderr} ${rc}= BMC Execute Command
830 ... cat /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
831 ${pnor_attrs}= Key Value Outbuf To Dict ${outbuf} delim==
832
George Keishing409df052024-01-17 22:36:14 +0530833 RETURN ${pnor_attrs}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600834
835
Sivas SRR17dae1a2019-03-24 23:52:02 -0500836GET BMC PNOR Version
837 [Documentation] Return BMC & PNOR version from openbmc shell.
838
839 ${bmc_version}= GET BMC Version
840 ${pnor_version}= GET PNOR Version
841 Log ${bmc_version}
842 Rprint Vars bmc_version
843 Log ${pnor_version}
844 Rprint Vars pnor_version
845
George Keishing409df052024-01-17 22:36:14 +0530846 RETURN ${bmc_version} ${pnor_version}
Sivas SRR17dae1a2019-03-24 23:52:02 -0500847
848
Sushil Singh5ea86d02019-07-11 02:05:16 -0500849Redfish Get BMC Version
850 [Documentation] Get BMC version via Redfish.
851
ganesanb4d430282023-04-27 14:33:23 +0000852 ${output}= Redfish.Get Attribute ${REDFISH_BASE_URI}Managers/${MANAGER_ID} FirmwareVersion
George Keishing409df052024-01-17 22:36:14 +0530853 RETURN ${output}
Sushil Singh5ea86d02019-07-11 02:05:16 -0500854
855Redfish Get Host Version
856 [Documentation] Get host version via Redfish.
857
Yi Huc32434a2024-01-11 17:33:10 -0800858 ${output}= Redfish.Get Attribute ${REDFISH_BASE_URI}Systems/${SYSTEM_ID} BiosVersion
George Keishing409df052024-01-17 22:36:14 +0530859 RETURN ${output}
Sushil Singh5ea86d02019-07-11 02:05:16 -0500860
861
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600862Copy Address Translation Utils To HOST OS
863 [Documentation] Copy address translation utils to host OS.
864
865 OperatingSystem.File Should Exist ${probe_cpu_tool_path}
866 ... msg=${probe_cpu_tool_path} doesn't exist.
867 OperatingSystem.File Should Exist ${probe_cpu_tool_path}
868 ... msg=${probe_cpu_tool_path} doesn't exist.
869
870 scp.Open connection ${OS_HOST} username=${OS_USERNAME}
871 ... password=${OS_PASSWORD}
872 scp.Put File ${probe_cpu_tool_path} ${target_file_path}
873 scp.Put File ${scom_addrs_tool_path} ${target_file_path}
874
875
876Verify BMC RTC And UTC Time Drift
877 [Documentation] Verify that the RTC and UTC time difference is less than
878 ... the given time_drift_max.
879 [Arguments] ${time_diff_max}=${10}
880
881 # Description of argument(s):
882 # time_diff_max The max allowable RTC and UTC time difference in seconds.
883
884 # Example:
885 # time_dict:
886 # [local_time]: Fri 2017-11-03 152756 UTC
887 # [local_time_seconds]: 1509740876
888 # [universal_time]: Fri 2017-11-03 152756 UTC
889 # [universal_time_seconds]: 1509740876
890 # [rtc_time]: Fri 2016-05-20 163403
891 # [rtc_time_seconds]: 1463780043
892 # [time_zone]: n/a (UTC, +0000)
893 # [network_time_on]: yes
894 # [ntp_synchronized]: no
895 # [rtc_in_local_tz]: no
896
897 ${time}= Get BMC Date Time
898 ${time_diff}= Evaluate
899 ... ${time['universal_time_seconds']} - ${time['rtc_time_seconds']}
900 Should Be True ${time_diff} < ${time_diff_max}
901
902
903Validate IP On BMC
904 [Documentation] Validate IP address is present in set of IP addresses.
905 [Arguments] ${ip_address} ${ip_data}
906
907 # Description of argument(s):
908 # ip_address IP address to check (e.g. xx.xx.xx.xx).
909 # ip_data Set of the IP addresses present.
910
911 Should Contain Match ${ip_data} ${ip_address}/*
912 ... msg=${ip_address} not found in the list provided.
913
914
915Remove Journald Logs
916 [Documentation] Remove all journald logs and restart service.
917
918 ${cmd}= Catenate systemctl stop systemd-journald.service &&
919 ... rm -rf /var/log/journal && systemctl start systemd-journald.service
920
921 BMC Execute Command ${cmd}
922
923
924Check For Regex In Journald
925 [Documentation] Parse the journal log and check for regex string.
926 [Arguments] ${regex}=${ERROR_REGEX} ${error_check}=${0} ${boot}=${EMPTY}
George Keishing140351f2022-03-10 08:10:01 -0600927 ... ${filter_string}=${EMPTY}
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600928
929 # Description of argument(s):
930 # regex Strings to be filter.
931 # error_check Check for errors.
932 # boot Argument to check current or persistent full boot log
933 # (e.g. "-b").
George Keishing140351f2022-03-10 08:10:01 -0600934 # filter_string String to be stripped out.
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600935
George Keishing140351f2022-03-10 08:10:01 -0600936
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500937 ${cmd} = Set Variable If '${filter_string}' == '${EMPTY}'
George Keishing140351f2022-03-10 08:10:01 -0600938 ... Catenate journalctl --no-pager ${boot} | egrep '${regex}'
939 ... ELSE
940 ... Catenate journalctl --no-pager ${boot} | egrep '${regex}' | sed '/${filter_string}/d'
941
942 ${journal_log} ${stderr} ${rc}= BMC Execute Command ${cmd} ignore_err=1
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600943
Sridevi Rameshf2437c92025-10-22 04:13:05 -0500944 IF ${error_check} == ${0}
945 Should Be Empty ${journal_log}
946 ELSE
947 Should Not Be Empty ${journal_log}
948 END
Steven Sombarf60cbcf2018-12-07 08:12:18 -0600949
950Get Service Attribute
951 [Documentation] Get service attribute policy output.
952 [Arguments] ${option} ${servicename}
953
954 # Description of argument(s):
955 # option systemctl supported options
956 # servicename Qualified service name
957 ${cmd}= Set Variable
958 ... systemctl -p ${option} show ${servicename} | cut -d = -f2
959 ${attr} ${stderr} ${rc}= BMC Execute Command ${cmd}
George Keishing409df052024-01-17 22:36:14 +0530960 RETURN ${attr}
Anusha Dathatrieda09492019-02-26 08:30:13 -0600961
962
963Verify Watchdog Enabled
964 [Documentation] Check that watchdog settings are enabled.
965
966 ${properties}= Read Properties /xyz/openbmc_project/watchdog/host0
967 Should Be Equal As Strings ${properties["Enabled"]} ${True}
968 Should Not Be Equal As Strings ${properties["TimeRemaining"]} 0
Ashwini Chandrappa233d9652021-08-04 09:56:30 -0500969
970
971Is BMC Unpingable
972 [Documentation] Check if BMC is unpingable.
973
974 ${RC} ${output}= Run and return RC and Output ping -c 4 ${OPENBMC_HOST}
975 Log RC: ${RC}\nOutput:\n${output}
976 Should be equal ${RC} ${1}
Sushil Singh6d170ad2022-11-28 07:04:50 -0600977
Sushil Singh84c80152023-02-06 02:02:48 -0600978
Nagarjun B011c5f32023-07-17 17:14:59 +0530979Is Host Unpingable
980 [Documentation] Check if Given IP is unpingable.
981 [Arguments] ${ip}
982
983 # Description of argument(s):
984 # ip HostOS IP address (e.g. "10.7.7.7").
985
986 ${RC} ${output}= Run and return RC and Output ping -c 4 ${ip}
987 Log RC: ${RC}\nOutput:\n${output}
988 Should be equal ${RC} ${1}
989
990
Sushil Singh84c80152023-02-06 02:02:48 -0600991Redfish BMC Match States
992 [Documentation] Verify the BMC match state.
993 [Arguments] ${match_state}
994
995 # Description of argument(s):
996 # match_state Match the state of BMC.
997
998 ${bmc_state}= Redfish Get BMC State
999 Should Be Equal As Strings ${match_state} ${bmc_state}
1000
1001
Sushil Singh6d170ad2022-11-28 07:04:50 -06001002Kernel Panic BMC Reset Operation
1003 [Documentation] Create kernel panic to reset BMC.
1004
1005 ${kernel_panic_cmd_file}= Set Variable /bin/sh -c "echo c > /proc/sysrq-trigger"
Sushil Singha83bba02023-01-18 08:43:45 -06001006 ${status}= Run Keyword And Return Status BMC Execute Command ${kernel_panic_cmd_file} time_out=20
Sushil Singh6d170ad2022-11-28 07:04:50 -06001007
George Keishing409df052024-01-17 22:36:14 +05301008 RETURN ${status}
Sushil Singh6d170ad2022-11-28 07:04:50 -06001009
Anusha Dathatrie444dcd2023-11-20 05:04:55 -06001010
1011Get Property Value Of Systemd Service In BMC
1012 [Documentation] Get property of systemd service in BMC.
1013 [Arguments] ${service_name} ${property_name}
1014
1015 # Description of argument(s):
1016 # service_name Systemd service name. E.g. bmcweb etc.
1017 # property_name Property name. E.g. MainPID etc.
1018
1019 # ~# systemctl show --property MainPID --value bmcweb
1020 # 1273
1021
1022 ${stdout} ${stderr} ${rc}= BMC Execute Command
1023 ... systemctl show --property ${property_name} --value ${service_name}
1024
George Keishing409df052024-01-17 22:36:14 +05301025 RETURN ${stdout}