xref: /openbmc/openbmc-test-automation/lib/common_utils.robot (revision 20ccfc7186271c9621ce864235e62edb6e6b027c)
1f60cbcfbSSteven Sombar*** Settings ***
2f60cbcfbSSteven Sombar
3f60cbcfbSSteven SombarDocumentation  Utilities for Robot keywords that do not use REST.
4f60cbcfbSSteven Sombar
5839a0c27SSandhya SomashekarResource                ../lib/resource.robot
6f60cbcfbSSteven SombarResource                ../lib/connection_client.robot
7f60cbcfbSSteven SombarResource                ../lib/boot_utils.robot
8f60cbcfbSSteven SombarLibrary                 String
9f60cbcfbSSteven SombarLibrary                 DateTime
10f60cbcfbSSteven SombarLibrary                 Process
11f60cbcfbSSteven SombarLibrary                 OperatingSystem
12f60cbcfbSSteven SombarLibrary                 gen_print.py
13f60cbcfbSSteven SombarLibrary                 gen_robot_print.py
14f60cbcfbSSteven SombarLibrary                 gen_cmd.py
1507ed7944SMichael WalshLibrary                 gen_robot_valid.py
16f60cbcfbSSteven SombarLibrary                 gen_robot_keyword.py
17f60cbcfbSSteven SombarLibrary                 bmc_ssh_utils.py
18f60cbcfbSSteven SombarLibrary                 utils.py
19f60cbcfbSSteven SombarLibrary                 var_funcs.py
20f60cbcfbSSteven SombarLibrary                 SCPLibrary  WITH NAME  scp
21f60cbcfbSSteven Sombar
22f60cbcfbSSteven Sombar*** Variables ***
23f60cbcfbSSteven Sombar
24f60cbcfbSSteven Sombar${pflash_cmd}             /usr/sbin/pflash -r /dev/stdout -P VERSION
25f60cbcfbSSteven Sombar
26f60cbcfbSSteven Sombar${dbuscmdBase}
27f60cbcfbSSteven Sombar...  dbus-send --system --print-reply --dest=${OPENBMC_BASE_DBUS}.settings.Host
28f60cbcfbSSteven Sombar${dbuscmdGet}
29f60cbcfbSSteven Sombar...  ${SETTINGS_URI}host0  org.freedesktop.DBus.Properties.Get
30f60cbcfbSSteven Sombar${dbuscmdString}=  string:"xyz.openbmc_project.settings.Host" string:
31f60cbcfbSSteven Sombar
32f60cbcfbSSteven Sombar# Assign default value to QUIET for programs which may not define it.
33f60cbcfbSSteven Sombar${QUIET}  ${0}
34f60cbcfbSSteven Sombar
35f60cbcfbSSteven Sombar${bmc_mem_free_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
36f60cbcfbSSteven Sombar${bmc_mem_total_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
37f60cbcfbSSteven Sombar${bmc_cpu_usage_cmd}=   top -n 1  | grep CPU: | cut -c 7-9
38f60cbcfbSSteven Sombar${HOST_SETTING}    ${SETTINGS_URI}host0
39f60cbcfbSSteven Sombar
40f60cbcfbSSteven Sombar# /run/initramfs/ro associate filesystem  should be 100% full always
41f60cbcfbSSteven Sombar${bmc_file_system_usage_cmd}=  df -h | cut -c 52-54 | grep 100 | wc -l
42f60cbcfbSSteven Sombar${total_pnor_ro_file_system_cmd}=  df -h | grep /media/pnor-ro | wc -l
43f60cbcfbSSteven Sombar${total_bmc_ro_file_system_cmd}=  df -h | grep /media/rofs | wc -l
44f60cbcfbSSteven Sombar
45f60cbcfbSSteven Sombar${BOOT_TIME}     ${0}
46f60cbcfbSSteven Sombar${BOOT_COUNT}    ${0}
47f60cbcfbSSteven Sombar${count}  ${0}
48f60cbcfbSSteven Sombar${devicetree_base}  /sys/firmware/devicetree/base/model
49f60cbcfbSSteven Sombar
50f60cbcfbSSteven Sombar# Initialize default debug value to 0.
51f60cbcfbSSteven Sombar${DEBUG}         ${0}
52f60cbcfbSSteven Sombar
53f60cbcfbSSteven Sombar${probe_cpu_tool_path}     ${EXECDIR}/tools/ras/probe_cpus.sh
54f60cbcfbSSteven Sombar${scom_addrs_tool_path}    ${EXECDIR}/tools/ras/scom_addr_p9.sh
55f60cbcfbSSteven Sombar${target_file_path}        /root/
56f60cbcfbSSteven Sombar
57f60cbcfbSSteven Sombar${default_tarball}  ${EXECDIR}/obmc-phosphor-debug-tarball-witherspoon.tar.xz
58f60cbcfbSSteven Sombar
59f60cbcfbSSteven Sombar# These variables are used to straddle between new and old methods of setting
60f60cbcfbSSteven Sombar# values.
61f60cbcfbSSteven Sombar${bmc_power_policy_method}        ${EMPTY}
62f60cbcfbSSteven Sombar@{valid_power_policy_vars}        RESTORE_LAST_STATE  ALWAYS_POWER_ON
63f60cbcfbSSteven Sombar...                               ALWAYS_POWER_OFF
64f60cbcfbSSteven Sombar
65b9f3f776SGeorge Keishing${check_performance}              ${1}
66b9f3f776SGeorge Keishing
67f60cbcfbSSteven Sombar
68f60cbcfbSSteven Sombar*** Keywords ***
69f60cbcfbSSteven Sombar
70f60cbcfbSSteven SombarCheck BMC Performance
71f60cbcfbSSteven Sombar    [Documentation]  Check BMC basic CPU Mem File system performance.
72f60cbcfbSSteven Sombar
73b9f3f776SGeorge Keishing    Return From Keyword If   not ${check_performance}
74b9f3f776SGeorge Keishing
75f60cbcfbSSteven Sombar    Check BMC CPU Performance
76f60cbcfbSSteven Sombar    Check BMC Mem Performance
77f60cbcfbSSteven Sombar    Check BMC File System Performance
78f60cbcfbSSteven Sombar
79f60cbcfbSSteven Sombar
80f60cbcfbSSteven SombarVerify PNOR Update
81f60cbcfbSSteven Sombar    [Documentation]  Verify that the PNOR is not corrupted.
82f60cbcfbSSteven Sombar    # Example:
83f60cbcfbSSteven Sombar    # FFS: Flash header not found. Code: 100
84f60cbcfbSSteven Sombar    # Error 100 opening ffs !
85f60cbcfbSSteven Sombar
86f60cbcfbSSteven Sombar    ${stdout}  ${stderr}  ${rc}=
87f60cbcfbSSteven Sombar    ...  BMC Execute Command  /usr/sbin/pflash -h | egrep -q skip
88f60cbcfbSSteven Sombar    ...  ignore_err=${1}
89f60cbcfbSSteven Sombar    ${pflash_cmd}=  Set Variable If  ${rc} == ${0}  ${pflash_cmd} --skip=4096
90f60cbcfbSSteven Sombar    ...  ${pflash_cmd}
91f60cbcfbSSteven Sombar    ${pnor_info}=  BMC Execute Command  ${pflash_cmd}
92f60cbcfbSSteven Sombar    Should Not Contain Any  ${pnor_info}  Flash header not found  Error
93f60cbcfbSSteven Sombar
94f60cbcfbSSteven Sombar
95f60cbcfbSSteven SombarGet BMC System Model
96f60cbcfbSSteven Sombar    [Documentation]  Get the BMC model from the device tree and return it.
97f60cbcfbSSteven Sombar
98f60cbcfbSSteven Sombar    ${bmc_model}  ${stderr}  ${rc}=  BMC Execute Command
99f60cbcfbSSteven Sombar    ...  cat ${devicetree_base} | cut -d " " -f 1  return_stderr=True
100f60cbcfbSSteven Sombar    ...  test_mode=0
101f60cbcfbSSteven Sombar    Should Be Empty  ${stderr}
102f60cbcfbSSteven Sombar    Should Not Be Empty  ${bmc_model}  msg=BMC model is empty.
103f60cbcfbSSteven Sombar    [Return]  ${bmc_model}
104f60cbcfbSSteven Sombar
105f60cbcfbSSteven Sombar
106f60cbcfbSSteven SombarVerify BMC System Model
107f60cbcfbSSteven Sombar    [Documentation]  Verify the BMC model with ${OPENBMC_MODEL}.
108f60cbcfbSSteven Sombar    [Arguments]  ${bmc_model}
109f60cbcfbSSteven Sombar
110f60cbcfbSSteven Sombar    # Description of argument(s):
111f60cbcfbSSteven Sombar    # bmc_model System model (e.g. "witherspoon").
112f60cbcfbSSteven Sombar
113f60cbcfbSSteven Sombar    ${tmp_bmc_model}=  Fetch From Right  ${OPENBMC_MODEL}  /
114f60cbcfbSSteven Sombar    ${tmp_bmc_model}=  Fetch From Left  ${tmp_bmc_model}  .
115f60cbcfbSSteven Sombar    ${ret}=  Run Keyword And Return Status  Should Contain  ${bmc_model}
116f60cbcfbSSteven Sombar    ...  ${tmp_bmc_model}  ignore_case=True
117f60cbcfbSSteven Sombar    [Return]  ${ret}
118f60cbcfbSSteven Sombar
119f60cbcfbSSteven Sombar
120f60cbcfbSSteven SombarWait For Host To Ping
121f60cbcfbSSteven Sombar    [Documentation]  Wait for the given host to ping.
122f60cbcfbSSteven Sombar    [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
123f60cbcfbSSteven Sombar    ...          ${interval}=5 sec
124f60cbcfbSSteven Sombar
125f60cbcfbSSteven Sombar    # Description of argument(s):
126f60cbcfbSSteven Sombar    # host      The host name or IP of the host to ping.
127f60cbcfbSSteven Sombar    # timeout   The amount of time after which ping attempts cease.
128f60cbcfbSSteven Sombar    #           This should be expressed in Robot Framework's time format
129f60cbcfbSSteven Sombar    #           (e.g. "10 seconds").
130f60cbcfbSSteven Sombar    # interval  The amount of time in between attempts to ping.
131f60cbcfbSSteven Sombar    #           This should be expressed in Robot Framework's time format
132f60cbcfbSSteven Sombar    #           (e.g. "5 seconds").
133f60cbcfbSSteven Sombar
134f60cbcfbSSteven Sombar    Wait Until Keyword Succeeds  ${timeout}  ${interval}  Ping Host  ${host}
135f60cbcfbSSteven Sombar
136f60cbcfbSSteven Sombar
137f60cbcfbSSteven SombarPing Host
138f60cbcfbSSteven Sombar    [Documentation]  Ping the given host.
139f60cbcfbSSteven Sombar    [Arguments]     ${host}
140f60cbcfbSSteven Sombar
141f60cbcfbSSteven Sombar    # Description of argument(s):
142f60cbcfbSSteven Sombar    # host      The host name or IP of the host to ping.
143f60cbcfbSSteven Sombar
144f60cbcfbSSteven Sombar    Should Not Be Empty    ${host}   msg=No host provided
145f60cbcfbSSteven Sombar    ${RC}   ${output}=     Run and return RC and Output    ping -c 4 ${host}
146f60cbcfbSSteven Sombar    Log     RC: ${RC}\nOutput:\n${output}
147f60cbcfbSSteven Sombar    Should be equal     ${RC}   ${0}
148f60cbcfbSSteven Sombar
149f60cbcfbSSteven Sombar
150f60cbcfbSSteven SombarCheck OS
151f60cbcfbSSteven Sombar    [Documentation]  Attempts to ping the host OS and then checks that the host
152f60cbcfbSSteven Sombar    ...              OS is up by running an SSH command.
153f60cbcfbSSteven Sombar
154f60cbcfbSSteven Sombar    [Arguments]  ${os_host}=${OS_HOST}  ${os_username}=${OS_USERNAME}
155f60cbcfbSSteven Sombar    ...          ${os_password}=${OS_PASSWORD}  ${quiet}=${QUIET}
156f60cbcfbSSteven Sombar    ...          ${print_string}=${EMPTY}
157f60cbcfbSSteven Sombar    [Teardown]  SSHLibrary.Close Connection
158f60cbcfbSSteven Sombar
159f60cbcfbSSteven Sombar    # Description of argument(s):
160f60cbcfbSSteven Sombar    # os_host           The DNS name/IP of the OS host associated with our BMC.
161f60cbcfbSSteven Sombar    # os_username       The username to be used to sign on to the OS host.
162f60cbcfbSSteven Sombar    # os_password       The password to be used to sign on to the OS host.
163f60cbcfbSSteven Sombar    # quiet             Indicates whether this keyword should write to console.
164f60cbcfbSSteven Sombar    # print_string      A string to be printed before checking the OS.
165f60cbcfbSSteven Sombar
166c108e429SMichael Walsh    Log To Console  ${print_string}  no_newline=True
167f60cbcfbSSteven Sombar
168f60cbcfbSSteven Sombar    # Attempt to ping the OS. Store the return code to check later.
169f60cbcfbSSteven Sombar    ${ping_rc}=  Run Keyword and Return Status  Ping Host  ${os_host}
170f60cbcfbSSteven Sombar
171f60cbcfbSSteven Sombar    SSHLibrary.Open connection  ${os_host}
172f60cbcfbSSteven Sombar
1733075166eSGeorge Keishing    ${status}  ${msg}=  Run Keyword And Ignore Error  SSHLibrary.Login  ${os_username}
174f60cbcfbSSteven Sombar    ...  ${os_password}
175f60cbcfbSSteven Sombar    ${err_msg1}=  Sprint Error  ${msg}
176f60cbcfbSSteven Sombar    ${err_msg}=  Catenate  SEPARATOR=  \n  ${err_msg1}
177f60cbcfbSSteven Sombar    Run Keyword If  '${status}' == 'FAIL'  Fail  msg=${err_msg}
178f60cbcfbSSteven Sombar    ${output}  ${stderr}  ${rc}=  Execute Command  uptime  return_stderr=True
179f60cbcfbSSteven Sombar    ...        return_rc=True
180f60cbcfbSSteven Sombar
181f60cbcfbSSteven Sombar    ${temp_msg}=  Catenate  Could not execute a command on the operating
182f60cbcfbSSteven Sombar    ...  system.\n
183f60cbcfbSSteven Sombar    ${err_msg1}=  Sprint Error  ${temp_msg}
184f60cbcfbSSteven Sombar    ${err_msg}=  Catenate  SEPARATOR=  \n  ${err_msg1}
185f60cbcfbSSteven Sombar
186f60cbcfbSSteven Sombar    # If the return code returned by "Execute Command" is non-zero, this
187f60cbcfbSSteven Sombar    # keyword will fail.
188f60cbcfbSSteven Sombar    Should Be Equal  ${rc}  ${0}  msg=${err_msg}
189f60cbcfbSSteven Sombar    # We will likewise fail if there is any stderr data.
190f60cbcfbSSteven Sombar    Should Be Empty  ${stderr}
191f60cbcfbSSteven Sombar
192f60cbcfbSSteven Sombar    ${temp_msg}=  Set Variable  Could not ping the operating system.\n
193f60cbcfbSSteven Sombar    ${err_msg1}=  Sprint Error  ${temp_msg}
194f60cbcfbSSteven Sombar    ${err_msg}=  Catenate  SEPARATOR=  \n  ${err_msg1}
195f60cbcfbSSteven Sombar    # We will likewise fail if the OS did not ping, as we could SSH but not
196f60cbcfbSSteven Sombar    # ping
197f60cbcfbSSteven Sombar    Should Be Equal As Strings  ${ping_rc}  ${TRUE}  msg=${err_msg}
198f60cbcfbSSteven Sombar
199f60cbcfbSSteven Sombar
200f60cbcfbSSteven SombarWait for OS
201f60cbcfbSSteven Sombar    [Documentation]  Waits for the host OS to come up via calls to "Check OS".
202f60cbcfbSSteven Sombar    [Arguments]  ${os_host}=${OS_HOST}  ${os_username}=${OS_USERNAME}
203f60cbcfbSSteven Sombar    ...          ${os_password}=${OS_PASSWORD}  ${timeout}=${OS_WAIT_TIMEOUT}
204f60cbcfbSSteven Sombar    ...          ${quiet}=${0}
205c108e429SMichael Walsh    [Teardown]  Printn
206f60cbcfbSSteven Sombar
207f60cbcfbSSteven Sombar    # Description of argument(s):
208f60cbcfbSSteven Sombar    # os_host           The DNS name or IP of the OS host associated with our
209f60cbcfbSSteven Sombar    #                   BMC.
210f60cbcfbSSteven Sombar    # os_username       The username to be used to sign on to the OS host.
211f60cbcfbSSteven Sombar    # os_password       The password to be used to sign on to the OS host.
212f60cbcfbSSteven Sombar    # timeout           The timeout in seconds indicating how long you're
213f60cbcfbSSteven Sombar    #                   willing to wait for the OS to respond.
214f60cbcfbSSteven Sombar    # quiet             Indicates whether this keyword should write to console.
215f60cbcfbSSteven Sombar
216f60cbcfbSSteven Sombar    # The interval to be used between calls to "Check OS".
217f60cbcfbSSteven Sombar    ${interval}=  Set Variable  5
218f60cbcfbSSteven Sombar
219f60cbcfbSSteven Sombar    ${message}=  Catenate  Checking every ${interval} seconds for up to
220f60cbcfbSSteven Sombar    ...  ${timeout} seconds for the operating system to communicate.
221c108e429SMichael Walsh    Qprint Timen  ${message}
222f60cbcfbSSteven Sombar
223f60cbcfbSSteven Sombar    Wait Until Keyword Succeeds  ${timeout} sec  ${interval}  Check OS
224f60cbcfbSSteven Sombar    ...                          ${os_host}  ${os_username}  ${os_password}
225f60cbcfbSSteven Sombar    ...                          print_string=\#
226f60cbcfbSSteven Sombar
227c108e429SMichael Walsh    Qprintn
228f60cbcfbSSteven Sombar
229c108e429SMichael Walsh    Qprint Timen  The operating system is now communicating.
230f60cbcfbSSteven Sombar
231f60cbcfbSSteven Sombar
232f60cbcfbSSteven SombarCopy PNOR to BMC
233f60cbcfbSSteven Sombar    [Documentation]  Copy the PNOR image to the BMC.
234f60cbcfbSSteven Sombar    Import Library      SCPLibrary      WITH NAME       scp
235f60cbcfbSSteven Sombar    Open Connection for SCP
236f60cbcfbSSteven Sombar    Log    Copying ${PNOR_IMAGE_PATH} to /tmp
237f60cbcfbSSteven Sombar    scp.Put File    ${PNOR_IMAGE_PATH}   /tmp
238f60cbcfbSSteven Sombar
239f60cbcfbSSteven Sombar
240f60cbcfbSSteven SombarIs OS Starting
241f60cbcfbSSteven Sombar    [Documentation]  Check if boot progress is OS starting.
242f60cbcfbSSteven Sombar    ${boot_progress}=  Get Boot Progress
243f60cbcfbSSteven Sombar    Should Be Equal  ${boot_progress}  OSStart
244f60cbcfbSSteven Sombar
245f60cbcfbSSteven Sombar
246f60cbcfbSSteven SombarIs OS Off
247f60cbcfbSSteven Sombar    [Documentation]  Check if boot progress is "Off".
248f60cbcfbSSteven Sombar    ${boot_progress}=  Get Boot Progress
249f60cbcfbSSteven Sombar    Should Be Equal  ${boot_progress}  Off
250f60cbcfbSSteven Sombar
251f60cbcfbSSteven Sombar
252f60cbcfbSSteven SombarGet Boot Progress To OS Starting State
253f60cbcfbSSteven Sombar    [Documentation]  Get the system to a boot progress state of 'FW Progress,
254f60cbcfbSSteven Sombar    ...  Starting OS'.
255f60cbcfbSSteven Sombar
256f60cbcfbSSteven Sombar    ${boot_progress}=  Get Boot Progress
257f60cbcfbSSteven Sombar    Run Keyword If  '${boot_progress}' == 'OSStart'
258f60cbcfbSSteven Sombar    ...  Log  Host is already in OS starting state
259f60cbcfbSSteven Sombar    ...  ELSE
260f60cbcfbSSteven Sombar    ...  Run Keywords  Initiate Host PowerOff  AND  Initiate Host Boot
261f60cbcfbSSteven Sombar    ...  AND  Wait Until Keyword Succeeds  10 min  10 sec  Is OS Starting
262f60cbcfbSSteven Sombar
263f60cbcfbSSteven Sombar
264f60cbcfbSSteven SombarCheck If warmReset is Initiated
265f60cbcfbSSteven Sombar    [Documentation]  Ping would be still alive, so try SSH to connect
266f60cbcfbSSteven Sombar    ...              if fails the ports are down indicating reboot
267f60cbcfbSSteven Sombar    ...              is in progress
268f60cbcfbSSteven Sombar
269f60cbcfbSSteven Sombar    # Warm reset adds 3 seconds delay before forcing reboot
270f60cbcfbSSteven Sombar    # To minimize race conditions, we wait for 7 seconds
271f60cbcfbSSteven Sombar    Sleep  7s
272f60cbcfbSSteven Sombar    ${alive}=   Run Keyword and Return Status
273f60cbcfbSSteven Sombar    ...    Open Connection And Log In
274f60cbcfbSSteven Sombar    Return From Keyword If   '${alive}' == '${False}'    ${False}
275f60cbcfbSSteven Sombar    [Return]    ${True}
276f60cbcfbSSteven Sombar
277f60cbcfbSSteven Sombar
278f60cbcfbSSteven SombarInitialize DBUS cmd
279f60cbcfbSSteven Sombar    [Documentation]  Initialize dbus string with property string to extract
280f60cbcfbSSteven Sombar    [Arguments]   ${boot_property}
281f60cbcfbSSteven Sombar
282f60cbcfbSSteven Sombar    # Description of argument(s):
283f60cbcfbSSteven Sombar    # boot_property   Property string.
284f60cbcfbSSteven Sombar
285f60cbcfbSSteven Sombar    ${cmd}=     Catenate  ${dbuscmdBase} ${dbuscmdGet} ${dbuscmdString}
286f60cbcfbSSteven Sombar    ${cmd}=     Catenate  ${cmd}${boot_property}
287f60cbcfbSSteven Sombar    Set Global Variable   ${dbuscmd}     ${cmd}
288f60cbcfbSSteven Sombar
289f60cbcfbSSteven Sombar
290f60cbcfbSSteven SombarCreate OS Console Command String
291f60cbcfbSSteven Sombar    [Documentation]  Return a command string to start OS console logging.
292f60cbcfbSSteven Sombar
293f60cbcfbSSteven Sombar    # First make sure that the ssh_pw program is available.
294f60cbcfbSSteven Sombar    ${cmd}=  Catenate  which ssh_pw 2>/dev/null || find
295f60cbcfbSSteven Sombar    ...  ${EXECDIR} -name 'ssh_pw'
296f60cbcfbSSteven Sombar
297c108e429SMichael Walsh    Dprint Issuing  ${cmd}
298f60cbcfbSSteven Sombar    ${rc}  ${output}=  Run And Return Rc And Output  ${cmd}
299f60cbcfbSSteven Sombar    Rdpvars  rc  output
300f60cbcfbSSteven Sombar
301f60cbcfbSSteven Sombar    Should Be Equal As Integers  0  ${rc}  msg=Could not find ssh_pw.
302f60cbcfbSSteven Sombar
303f60cbcfbSSteven Sombar    ${ssh_pw_file_path}=  Set Variable  ${output}
304f60cbcfbSSteven Sombar
305088166c6SGeorge Keishing    ${cmd}=  Catenate  ${ssh_pw_file_path} ${OPENBMC_PASSWORD} -p ${HOST_SOL_PORT}
306f60cbcfbSSteven Sombar    ...  -o "StrictHostKeyChecking no" ${OPENBMC_USERNAME}@${OPENBMC_HOST}
307f60cbcfbSSteven Sombar
308f60cbcfbSSteven Sombar    [Return]  ${cmd}
309f60cbcfbSSteven Sombar
310f60cbcfbSSteven Sombar
311f60cbcfbSSteven SombarGet SOL Console Pid
312f60cbcfbSSteven Sombar    [Documentation]  Get the pid of the active SOL console job.
31307ed7944SMichael Walsh    [Arguments]  ${expect_running}=${0}  ${log_file_path}=${EMPTY}
314f60cbcfbSSteven Sombar
315f60cbcfbSSteven Sombar    # Description of argument(s):
31607ed7944SMichael Walsh    # expect_running                If set and if no SOL console job is found, print debug info and fail.
31707ed7944SMichael Walsh    # log_file_path                 Needed to print debug info if expect_running is set and no pid is found.
318f60cbcfbSSteven Sombar
319f60cbcfbSSteven Sombar    # Find the pid of the active system console logging session (if any).
320f60cbcfbSSteven Sombar    ${search_string}=  Create OS Console Command String
321f60cbcfbSSteven Sombar    # At least in some cases, ps output does not show double quotes so we must
322f60cbcfbSSteven Sombar    # replace them in our search string with the regexes to indicate that they
323f60cbcfbSSteven Sombar    # are optional.
324f60cbcfbSSteven Sombar    ${search_string}=  Replace String  ${search_string}  "  ["]?
325f60cbcfbSSteven Sombar    ${ps_cmd}=  Catenate  ps axwwo user,pid,cmd
326f60cbcfbSSteven Sombar    ${cmd_buf}=  Catenate  echo $(${ps_cmd} | egrep '${search_string}' |
327f60cbcfbSSteven Sombar    ...  egrep -v grep | cut -c10-14)
328c108e429SMichael Walsh    Dprint Issuing  ${cmd_buf}
329f60cbcfbSSteven Sombar    ${rc}  ${os_con_pid}=  Run And Return Rc And Output  ${cmd_buf}
330f60cbcfbSSteven Sombar    Rdpvars  os_con_pid
331f60cbcfbSSteven Sombar    # If rc is not zero it just means that there is no OS Console process
332f60cbcfbSSteven Sombar    # running.
333f60cbcfbSSteven Sombar
334f60cbcfbSSteven Sombar    Return From Keyword If  '${os_con_pid}' != '${EMPTY}'  ${os_con_pid}
335f60cbcfbSSteven Sombar    Return From Keyword If  '${expect_running}' == '${0}'  ${os_con_pid}
336f60cbcfbSSteven Sombar
337f60cbcfbSSteven Sombar    Cmd Fnc  cat ${log_file_path} ; echo ; ${ps_cmd}  quiet=${0}
338f60cbcfbSSteven Sombar    ...  print_output=${1}  show_err=${1}
33907ed7944SMichael Walsh    Valid Value  os_con_pid
340f60cbcfbSSteven Sombar
341f60cbcfbSSteven Sombar
342f60cbcfbSSteven SombarStop SOL Console Logging
343f60cbcfbSSteven Sombar    [Documentation]  Stop system console logging and return log output.
344f60cbcfbSSteven Sombar    [Arguments]  ${log_file_path}=${EMPTY}
345f60cbcfbSSteven Sombar    ...          ${targ_file_path}=${EXECDIR}${/}logs${/}
346f60cbcfbSSteven Sombar    ...          ${return_data}=${1}
347f60cbcfbSSteven Sombar
348f60cbcfbSSteven Sombar    # If there are muliple system console processes, they will all be stopped.
349f60cbcfbSSteven Sombar    # If there is no existing log file this keyword will return an error
350f60cbcfbSSteven Sombar    # message to that effect (and write that message to targ_file_path, if
351f60cbcfbSSteven Sombar    # specified).
352f60cbcfbSSteven Sombar    # NOTE: This keyword will not fail if there is no running system console
353f60cbcfbSSteven Sombar    # process.
354f60cbcfbSSteven Sombar
355f60cbcfbSSteven Sombar    # Description of arguments:
356f60cbcfbSSteven Sombar    # log_file_path   The file path that was used to call "Start SOL
357f60cbcfbSSteven Sombar    #                 Console Logging".  See that keyword (above) for details.
358f60cbcfbSSteven Sombar    # targ_file_path  If specified, the file path to which the source
359f60cbcfbSSteven Sombar    #                 file path (i.e. "log_file_path") should be copied.
360f60cbcfbSSteven Sombar    # return_data     If this is set to ${1}, this keyword will return the SOL
361f60cbcfbSSteven Sombar    #                 data to the caller as a unicode string.
362f60cbcfbSSteven Sombar
363f60cbcfbSSteven Sombar    ${log_file_path}=  Create OS Console File Path  ${log_file_path}
364f60cbcfbSSteven Sombar
365f60cbcfbSSteven Sombar    ${os_con_pid}=  Get SOL Console Pid
366f60cbcfbSSteven Sombar
367f60cbcfbSSteven Sombar    ${cmd_buf}=  Catenate  kill -9 ${os_con_pid}
368c108e429SMichael Walsh    Run Keyword If  '${os_con_pid}' != '${EMPTY}'  Dprint Issuing  ${cmd_buf}
369f60cbcfbSSteven Sombar    ${rc}  ${output}=  Run Keyword If  '${os_con_pid}' != '${EMPTY}'
370f60cbcfbSSteven Sombar    ...  Run And Return Rc And Output  ${cmd_buf}
371f60cbcfbSSteven Sombar    Run Keyword If  '${os_con_pid}' != '${EMPTY}'  Rdpvars  rc  output
372f60cbcfbSSteven Sombar
373f60cbcfbSSteven Sombar    Run Keyword If  '${targ_file_path}' != '${EMPTY}'
374f60cbcfbSSteven Sombar    ...  Run Keyword And Ignore Error
375f60cbcfbSSteven Sombar    ...  Copy File  ${log_file_path}  ${targ_file_path}
376f60cbcfbSSteven Sombar
377f60cbcfbSSteven Sombar    ${output}=  Set Variable  ${EMPTY}
378f60cbcfbSSteven Sombar    ${loc_quiet}=  Evaluate  ${debug}^1
379f60cbcfbSSteven Sombar    ${rc}  ${output}=  Run Keyword If  '${return_data}' == '${1}'
380f60cbcfbSSteven Sombar    ...  Cmd Fnc  cat ${log_file_path} 2>/dev/null  quiet=${loc_quiet}
381f60cbcfbSSteven Sombar    ...  print_output=${0}  show_err=${0}
382f60cbcfbSSteven Sombar
383f60cbcfbSSteven Sombar    [Return]  ${output}
384f60cbcfbSSteven Sombar
385f60cbcfbSSteven Sombar
386f60cbcfbSSteven SombarStart SOL Console Logging
387f60cbcfbSSteven Sombar    [Documentation]  Start system console log to file.
388f60cbcfbSSteven Sombar    [Arguments]  ${log_file_path}=${EMPTY}  ${return_data}=${1}
389f60cbcfbSSteven Sombar
390f60cbcfbSSteven Sombar    # This keyword will first call "Stop SOL Console Logging".  Only then will
391f60cbcfbSSteven Sombar    # it start SOL console logging.  The data returned by "Stop SOL Console
392f60cbcfbSSteven Sombar    # Logging" will in turn be returned by this keyword.
393f60cbcfbSSteven Sombar
394f60cbcfbSSteven Sombar    # Description of arguments:
395f60cbcfbSSteven Sombar    # log_file_path   The file path to which system console log data should be
396f60cbcfbSSteven Sombar    #                 written.  Note that this path is taken to be a location
397f60cbcfbSSteven Sombar    #                 on the machine where this program is running rather than
398f60cbcfbSSteven Sombar    #                 on the Open BMC system.
399f60cbcfbSSteven Sombar    # return_data     If this is set to ${1}, this keyword will return any SOL
400f60cbcfbSSteven Sombar    #                 data to the caller as a unicode string.
401f60cbcfbSSteven Sombar
402f60cbcfbSSteven Sombar    ${log_file_path}=  Create OS Console File Path  ${log_file_path}
403f60cbcfbSSteven Sombar
404f60cbcfbSSteven Sombar    ${log_output}=  Stop SOL Console Logging  ${log_file_path}
405f60cbcfbSSteven Sombar    ...  return_data=${return_data}
406f60cbcfbSSteven Sombar
407f60cbcfbSSteven Sombar    # Validate by making sure we can create the file.  Problems creating the
408f60cbcfbSSteven Sombar    # file would not be noticed by the subsequent ssh command because we fork
409f60cbcfbSSteven Sombar    # the command.
410f60cbcfbSSteven Sombar    Create File  ${log_file_path}
411f60cbcfbSSteven Sombar    ${sub_cmd_buf}=  Create OS Console Command String
412f60cbcfbSSteven Sombar    # Routing stderr to stdout so that any startup error text will go to the
413f60cbcfbSSteven Sombar    # output file.
414f60cbcfbSSteven Sombar    # TODO: Doesn't work with tox so reverting temporarily.
415f60cbcfbSSteven Sombar    # nohup detaches the process completely from our pty.
416f60cbcfbSSteven Sombar    #${cmd_buf}=  Catenate  nohup ${sub_cmd_buf} &> ${log_file_path} &
417f60cbcfbSSteven Sombar    ${cmd_buf}=  Catenate  ${sub_cmd_buf} > ${log_file_path} 2>&1 &
418c108e429SMichael Walsh    Dprint Issuing  ${cmd_buf}
419f60cbcfbSSteven Sombar    ${rc}  ${output}=  Run And Return Rc And Output  ${cmd_buf}
420f60cbcfbSSteven Sombar    # Because we are forking this command, we essentially will never get a
421f60cbcfbSSteven Sombar    # non-zero return code or any output.
422f60cbcfbSSteven Sombar    Should Be Equal  ${rc}  ${0}
423f60cbcfbSSteven Sombar
424f60cbcfbSSteven Sombar    Wait Until Keyword Succeeds  10 seconds  0 seconds
42507ed7944SMichael Walsh    ...   Get SOL Console Pid  ${1}  ${log_file_path}
426f60cbcfbSSteven Sombar
427f60cbcfbSSteven Sombar    [Return]  ${log_output}
428f60cbcfbSSteven Sombar
429f60cbcfbSSteven Sombar
430f60cbcfbSSteven SombarGet Time Stamp
431f60cbcfbSSteven Sombar    [Documentation]     Get the current time stamp data
432f60cbcfbSSteven Sombar    ${cur_time}=    Get Current Date   result_format=%Y%m%d%H%M%S%f
433f60cbcfbSSteven Sombar    [Return]   ${cur_time}
434f60cbcfbSSteven Sombar
435f60cbcfbSSteven Sombar
436f60cbcfbSSteven SombarStart Journal Log
437f60cbcfbSSteven Sombar    [Documentation]   Start capturing journal log to a file in /tmp using
438f60cbcfbSSteven Sombar    ...               journalctl command. By default journal log is collected
439f60cbcfbSSteven Sombar    ...               at /tmp/journal_log else user input location.
440f60cbcfbSSteven Sombar    ...               The File is appended with datetime.
441f60cbcfbSSteven Sombar    [Arguments]       ${file_path}=/tmp/journal_log  ${filter}=${EMPTY}
442f60cbcfbSSteven Sombar
443f60cbcfbSSteven Sombar    # Description of arguments:
444f60cbcfbSSteven Sombar    # file_path   The file path of the journal file.
445f60cbcfbSSteven Sombar
446f60cbcfbSSteven Sombar    ${cur_time}=    Get Time Stamp
447f60cbcfbSSteven Sombar    Set Global Variable   ${LOG_TIME}   ${cur_time}
448f60cbcfbSSteven Sombar    Open Connection And Log In
449f60cbcfbSSteven Sombar    Start Command
450f60cbcfbSSteven Sombar    ...  journalctl -f ${filter} > ${file_path}-${LOG_TIME}
451f60cbcfbSSteven Sombar    Log    Journal Log Started: ${file_path}-${LOG_TIME}
452f60cbcfbSSteven Sombar
453f60cbcfbSSteven Sombar
454f60cbcfbSSteven SombarStop Journal Log
455f60cbcfbSSteven Sombar    [Documentation]   Stop journalctl process if its running.
456f60cbcfbSSteven Sombar    ...               By default return log from /tmp/journal_log else
457f60cbcfbSSteven Sombar    ...               user input location.
458f60cbcfbSSteven Sombar    [Arguments]       ${file_path}=/tmp/journal_log
459f60cbcfbSSteven Sombar
460f60cbcfbSSteven Sombar    # Description of arguments:
461f60cbcfbSSteven Sombar    # file_path   The file path of the journal file.
462f60cbcfbSSteven Sombar
463f60cbcfbSSteven Sombar    Open Connection And Log In
464f60cbcfbSSteven Sombar
465f60cbcfbSSteven Sombar    ${rc}=
466f60cbcfbSSteven Sombar    ...  Execute Command
467f60cbcfbSSteven Sombar    ...  ps | grep journalctl | grep -v grep
468f60cbcfbSSteven Sombar    ...  return_stdout=False  return_rc=True
469f60cbcfbSSteven Sombar
470f60cbcfbSSteven Sombar    Return From Keyword If   '${rc}' == '${1}'
471f60cbcfbSSteven Sombar    ...   No journal log process running
472f60cbcfbSSteven Sombar
473f60cbcfbSSteven Sombar    ${output}  ${stderr}=
474f60cbcfbSSteven Sombar    ...  Execute Command   killall journalctl
475f60cbcfbSSteven Sombar    ...  return_stderr=True
476f60cbcfbSSteven Sombar    Should Be Empty     ${stderr}
477f60cbcfbSSteven Sombar
478f60cbcfbSSteven Sombar    ${journal_log}  ${stderr}=
479f60cbcfbSSteven Sombar    ...  Execute Command
480f60cbcfbSSteven Sombar    ...  cat ${file_path}-${LOG_TIME}
481f60cbcfbSSteven Sombar    ...  return_stderr=True
482f60cbcfbSSteven Sombar    Should Be Empty     ${stderr}
483f60cbcfbSSteven Sombar
484f60cbcfbSSteven Sombar    Log    ${journal_log}
485f60cbcfbSSteven Sombar
486f60cbcfbSSteven Sombar    Execute Command    rm ${file_path}-${LOG_TIME}
487f60cbcfbSSteven Sombar
488f60cbcfbSSteven Sombar    [Return]    ${journal_log}
489f60cbcfbSSteven Sombar
490f60cbcfbSSteven Sombar
491f60cbcfbSSteven SombarMac Address To Hex String
492f60cbcfbSSteven Sombar    [Documentation]   Converts MAC address into hex format.
493f60cbcfbSSteven Sombar    ...               Example
494f60cbcfbSSteven Sombar    ...               Given the following MAC: 00:01:6C:80:02:78
495f60cbcfbSSteven Sombar    ...               This keyword will return: 0x00 0x01 0x6C 0x80 0x02 0x78
496f60cbcfbSSteven Sombar    ...               Description of arguments:
497f60cbcfbSSteven Sombar    ...               i_macaddress  MAC address in the following format
498f60cbcfbSSteven Sombar    ...               00:01:6C:80:02:78
499f60cbcfbSSteven Sombar    [Arguments]    ${i_macaddress}
500f60cbcfbSSteven Sombar
501f60cbcfbSSteven Sombar    # Description of arguments:
502f60cbcfbSSteven Sombar    # i_macaddress   The MAC address.
503f60cbcfbSSteven Sombar
504f60cbcfbSSteven Sombar    ${mac_hex}=  Catenate  0x${i_macaddress.replace(':', ' 0x')}
505f60cbcfbSSteven Sombar    [Return]    ${mac_hex}
506f60cbcfbSSteven Sombar
507f60cbcfbSSteven Sombar
508f60cbcfbSSteven SombarIP Address To Hex String
509f60cbcfbSSteven Sombar    [Documentation]   Converts IP address into hex format.
510f60cbcfbSSteven Sombar    ...               Example:
511f60cbcfbSSteven Sombar    ...               Given the following IP: 10.3.164.100
512f60cbcfbSSteven Sombar    ...               This keyword will return: 0xa 0x3 0xa4 0xa0
513f60cbcfbSSteven Sombar    [Arguments]    ${i_ipaddress}
514f60cbcfbSSteven Sombar
515f60cbcfbSSteven Sombar    # Description of arguments:
516f60cbcfbSSteven Sombar    # i_macaddress   The IP address in the format 10.10.10.10.
517f60cbcfbSSteven Sombar
518f60cbcfbSSteven Sombar    @{ip}=  Split String  ${i_ipaddress}    .
519f60cbcfbSSteven Sombar    ${index}=  Set Variable  ${0}
520f60cbcfbSSteven Sombar
521*20ccfc71SMarissa Garza    FOR    ${item}     IN      @{ip}
522*20ccfc71SMarissa Garza        ${hex}=  Convert To Hex    ${item}    prefix=0x    lowercase=yes
523*20ccfc71SMarissa Garza        Set List Value    ${ip}    ${index}    ${hex}
524*20ccfc71SMarissa Garza        ${index}=  Set Variable    ${index + 1}
525*20ccfc71SMarissa Garza    END
526f60cbcfbSSteven Sombar    ${ip_hex}=  Catenate    @{ip}
527f60cbcfbSSteven Sombar
528f60cbcfbSSteven Sombar    [Return]    ${ip_hex}
529f60cbcfbSSteven Sombar
530f60cbcfbSSteven Sombar
531f60cbcfbSSteven SombarBMC CPU Performance Check
532f60cbcfbSSteven Sombar   [Documentation]   Minimal 10% of proc should be free in this instance
533f60cbcfbSSteven Sombar
534f60cbcfbSSteven Sombar    ${bmc_cpu_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
535f60cbcfbSSteven Sombar    ...  ${bmc_cpu_usage_cmd}
536f60cbcfbSSteven Sombar    ${bmc_cpu_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
537f60cbcfbSSteven Sombar    ...  ${bmc_cpu_usage_cmd}
538f60cbcfbSSteven Sombar    ${bmc_cpu_percentage}=  Fetch From Left  ${bmc_cpu_usage_output}  %
53914426bcbSSivas SRR    Rprint Vars  bmc_cpu_percentage
540f60cbcfbSSteven Sombar    Should be true  ${bmc_cpu_percentage} < 90
541f60cbcfbSSteven Sombar
542f60cbcfbSSteven Sombar
543f60cbcfbSSteven SombarBMC Mem Performance Check
544f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of memory should be free in this instance
545f60cbcfbSSteven Sombar
546f60cbcfbSSteven Sombar    ${bmc_mem_free_output}  ${stderr}  ${rc}=   BMC Execute Command
547f60cbcfbSSteven Sombar    ...  ${bmc_mem_free_cmd}
548f60cbcfbSSteven Sombar
549f60cbcfbSSteven Sombar    ${bmc_mem_total_output}  ${stderr}  ${rc}=  BMC Execute Command
550f60cbcfbSSteven Sombar    ...  ${bmc_mem_total_cmd}
551f60cbcfbSSteven Sombar    ${bmc_mem_free_output}  ${stderr}  ${rc}=   BMC Execute Command
552f60cbcfbSSteven Sombar    ...  ${bmc_mem_free_cmd}
553f60cbcfbSSteven Sombar
554f60cbcfbSSteven Sombar    ${bmc_mem_total_output}  ${stderr}  ${rc}=  BMC Execute Command
555f60cbcfbSSteven Sombar    ...  ${bmc_mem_total_cmd}
556f60cbcfbSSteven Sombar
557f60cbcfbSSteven Sombar    ${bmc_mem_percentage}=  Evaluate  ${bmc_mem_free_output}*100
558f60cbcfbSSteven Sombar    ${bmc_mem_percentage}=  Evaluate
559f60cbcfbSSteven Sombar    ...   ${bmc_mem_percentage}/${bmc_mem_total_output}
56014426bcbSSivas SRR    Rprint Vars  bmc_mem_percentage
561f60cbcfbSSteven Sombar    Should be true  ${bmc_mem_percentage} > 10
562f60cbcfbSSteven Sombar
563f60cbcfbSSteven Sombar
564f60cbcfbSSteven SombarBMC File System Usage Check
565f60cbcfbSSteven Sombar    [Documentation]   Check the file system space. 4 file system should be
566f60cbcfbSSteven Sombar    ...  100% full which is expected
567f60cbcfbSSteven Sombar    # Filesystem            Size    Used Available Use% Mounted on
568f60cbcfbSSteven Sombar    # /dev/root            14.4M     14.4M       0 100% /
569f60cbcfbSSteven Sombar    # /dev/ubiblock0_0     14.4M     14.4M       0 100% /media/rofs-c9249b0e
570f60cbcfbSSteven Sombar    # /dev/ubiblock8_0     19.6M     19.6M       0 100% /media/pnor-ro-8764baa3
571f60cbcfbSSteven Sombar    # /dev/ubiblock4_0     14.4M     14.4M       0 100% /media/rofs-407816c
572f60cbcfbSSteven Sombar    # /dev/ubiblock8_4     21.1M     21.1M       0 100% /media/pnor-ro-cecc64c4
573f60cbcfbSSteven Sombar    ${bmc_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
574f60cbcfbSSteven Sombar    ...  ${bmc_file_system_usage_cmd}
575f60cbcfbSSteven Sombar    ${bmc_pnor_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
576f60cbcfbSSteven Sombar    ...  ${total_pnor_ro_file_system_cmd}
577f60cbcfbSSteven Sombar    ${bmc_bmc_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
578f60cbcfbSSteven Sombar    ...  ${total_bmc_ro_file_system_cmd}
579f60cbcfbSSteven Sombar    ${total_bmc_pnor_image}=  Evaluate
580f60cbcfbSSteven Sombar    ...  ${bmc_pnor_fs_usage_output}+${bmc_bmc_fs_usage_output}
581f60cbcfbSSteven Sombar    # Considering /dev/root also in total 100% used file system
582f60cbcfbSSteven Sombar    ${total_full_fs}=  Evaluate  ${total_bmc_pnor_image}+1
58314426bcbSSivas SRR    Rprint Vars  bmc_fs_usage_output  bmc_pnor_fs_usage_output  bmc_bmc_fs_usage_output
58414426bcbSSivas SRR    ...  total_full_fs
585f60cbcfbSSteven Sombar    Should Be True  ${bmc_fs_usage_output}==${total_full_fs}
586f60cbcfbSSteven Sombar
587f60cbcfbSSteven Sombar
588f60cbcfbSSteven SombarCheck BMC CPU Performance
589f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of proc should be free in 3 sample
590*20ccfc71SMarissa Garza    FOR  ${var}  IN RANGE  1  4
591*20ccfc71SMarissa Garza        BMC CPU Performance Check
592*20ccfc71SMarissa Garza    END
593f60cbcfbSSteven Sombar
594f60cbcfbSSteven SombarCheck BMC Mem Performance
595f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of memory should be free
596f60cbcfbSSteven Sombar
597*20ccfc71SMarissa Garza    FOR  ${var}  IN RANGE  1  4
598*20ccfc71SMarissa Garza        BMC Mem Performance Check
599*20ccfc71SMarissa Garza    END
600f60cbcfbSSteven Sombar
601f60cbcfbSSteven SombarCheck BMC File System Performance
602f60cbcfbSSteven Sombar    [Documentation]  Check for file system usage for 4 times
603f60cbcfbSSteven Sombar
604*20ccfc71SMarissa Garza    FOR  ${var}  IN RANGE  1  4
605*20ccfc71SMarissa Garza        BMC File System Usage check
606*20ccfc71SMarissa Garza    END
607f60cbcfbSSteven Sombar
608f60cbcfbSSteven SombarGet URL List
609f60cbcfbSSteven Sombar    [Documentation]  Return list of URLs under given URL.
610f60cbcfbSSteven Sombar    [Arguments]  ${openbmc_url}
611f60cbcfbSSteven Sombar
612f60cbcfbSSteven Sombar    # Description of argument(s):
613f60cbcfbSSteven Sombar    # openbmc_url  URL for list operation (e.g.
614f60cbcfbSSteven Sombar    #              /xyz/openbmc_project/inventory).
615f60cbcfbSSteven Sombar
616aaaab222SSteven Sombar    ${url_list}=  Read Properties  ${openbmc_url}list  quiet=${1}
617f60cbcfbSSteven Sombar    Sort List  ${url_list}
618f60cbcfbSSteven Sombar
619f60cbcfbSSteven Sombar    [Return]  ${url_list}
620f60cbcfbSSteven Sombar
621f60cbcfbSSteven Sombar
622f60cbcfbSSteven SombarCheck Zombie Process
623f60cbcfbSSteven Sombar    [Documentation]    Check if any defunct process exist or not on BMC
624f60cbcfbSSteven Sombar    ${count}  ${stderr}  ${rc}=  Execute Command  ps -o stat | grep Z | wc -l
625f60cbcfbSSteven Sombar    ...    return_stderr=True  return_rc=True
626f60cbcfbSSteven Sombar    Should Be True    ${count}==0
627f60cbcfbSSteven Sombar    Should Be Empty    ${stderr}
628f60cbcfbSSteven Sombar
629f60cbcfbSSteven Sombar
630f60cbcfbSSteven SombarPrune Journal Log
631f60cbcfbSSteven Sombar    [Documentation]   Prune archived journal logs.
632f60cbcfbSSteven Sombar    [Arguments]   ${vacuum_size}=1M
633f60cbcfbSSteven Sombar
634f60cbcfbSSteven Sombar    # This keyword can be used to prevent the journal
635f60cbcfbSSteven Sombar    # log from filling up the /run filesystem.
636f60cbcfbSSteven Sombar    # This command will retain only the latest logs
637f60cbcfbSSteven Sombar    # of the user specified size.
638f60cbcfbSSteven Sombar
639f60cbcfbSSteven Sombar    # Description of argument(s):
640f60cbcfbSSteven Sombar    # vacuum_size    Size of journal.
641f60cbcfbSSteven Sombar
642f60cbcfbSSteven Sombar    Open Connection And Log In
643f60cbcfbSSteven Sombar    ${output}  ${stderr}  ${rc}=
644f60cbcfbSSteven Sombar    ...  Execute Command
645f60cbcfbSSteven Sombar    ...  journalctl --vacuum-size=${vacuum_size}
646f60cbcfbSSteven Sombar    ...  return_stderr=True  return_rc=True
647f60cbcfbSSteven Sombar
648f60cbcfbSSteven Sombar    Should Be Equal  ${rc}  ${0}  msg=${stderr}
649f60cbcfbSSteven Sombar
650f60cbcfbSSteven Sombar
651f60cbcfbSSteven SombarGet System Power Policy
652f60cbcfbSSteven Sombar    [Documentation]  Returns the BMC power policy.
653f60cbcfbSSteven Sombar
654f60cbcfbSSteven Sombar    # Set the bmc_power_policy_method to either 'Old' or 'New'.
655f60cbcfbSSteven Sombar    Set Power Policy Method
656f60cbcfbSSteven Sombar    ${cmd_buf}=  Create List  ${bmc_power_policy_method} Get Power Policy
657f60cbcfbSSteven Sombar    # Run the appropriate keyword.
658f60cbcfbSSteven Sombar    ${currentPolicy}=  Run Keyword  @{cmd_buf}
659f60cbcfbSSteven Sombar
660f60cbcfbSSteven Sombar    [Return]  ${currentPolicy}
661f60cbcfbSSteven Sombar
662f60cbcfbSSteven Sombar
663f60cbcfbSSteven SombarSet BMC Reset Reference Time
664f60cbcfbSSteven Sombar    [Documentation]  Set current boot time as a reference and increment
665f60cbcfbSSteven Sombar    ...              boot count.
666f60cbcfbSSteven Sombar
667f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
668f60cbcfbSSteven Sombar    Run Keyword If  ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
669f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
670f60cbcfbSSteven Sombar    ...  ELSE IF  ${cur_btime} > ${BOOT_TIME}
671f60cbcfbSSteven Sombar    ...  Run Keywords  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
672f60cbcfbSSteven Sombar    ...  AND
673f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_COUNT}  ${BOOT_COUNT + 1}
674f60cbcfbSSteven Sombar
675f60cbcfbSSteven Sombar
676f60cbcfbSSteven SombarGet BMC Boot Time
677f60cbcfbSSteven Sombar    [Documentation]  Returns boot time from /proc/stat.
678f60cbcfbSSteven Sombar
679f60cbcfbSSteven Sombar    Open Connection And Log In
680f60cbcfbSSteven Sombar    ${output}  ${stderr}=
681f60cbcfbSSteven Sombar    ...  Execute Command  egrep '^btime ' /proc/stat | cut -f 2 -d ' '
682f60cbcfbSSteven Sombar    ...  return_stderr=True
683f60cbcfbSSteven Sombar    Should Be Empty  ${stderr}
684f60cbcfbSSteven Sombar    ${btime}=  Convert To Integer  ${output}
685f60cbcfbSSteven Sombar    [Return]  ${btime}
686f60cbcfbSSteven Sombar
687f60cbcfbSSteven Sombar
688f60cbcfbSSteven SombarEnable Core Dump On BMC
689f60cbcfbSSteven Sombar    [Documentation]  Enable core dump collection.
690f60cbcfbSSteven Sombar    ${core_pattern}  ${stderr}  ${rc}=  BMC Execute Command
691f60cbcfbSSteven Sombar    ...  echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
692f60cbcfbSSteven Sombar    Should Be Equal As Strings  ${core_pattern}  /tmp/core_%e.%p
693f60cbcfbSSteven Sombar
694f60cbcfbSSteven Sombar
695f60cbcfbSSteven SombarGet Number Of BMC Core Dump Files
696f60cbcfbSSteven Sombar    [Documentation]  Returns number of core dump files on BMC.
697f60cbcfbSSteven Sombar    Open Connection And Log In
698f60cbcfbSSteven Sombar    ${num_of_core_dump}=  Execute Command
699f60cbcfbSSteven Sombar    ...  ls /tmp/core* 2>/dev/null | wc -l
700f60cbcfbSSteven Sombar    [Return]  ${num_of_core_dump}
701f60cbcfbSSteven Sombar
702f60cbcfbSSteven Sombar
703f60cbcfbSSteven SombarSet Core Dump File Size Unlimited
704f60cbcfbSSteven Sombar    [Documentation]  Set core dump file size to unlimited.
705f60cbcfbSSteven Sombar    BMC Execute Command  ulimit -c unlimited
706f60cbcfbSSteven Sombar
707f60cbcfbSSteven Sombar
708f60cbcfbSSteven SombarCheck For Core Dumps
709f60cbcfbSSteven Sombar    [Documentation]  Check for any core dumps exist.
710f60cbcfbSSteven Sombar    ${output}=  Get Number Of BMC Core Dump Files
711f60cbcfbSSteven Sombar    Run Keyword If  ${output} > 0
712f60cbcfbSSteven Sombar    ...  Log  **Warning** BMC core dump files exist  level=WARN
713f60cbcfbSSteven Sombar
714f60cbcfbSSteven Sombar
715f60cbcfbSSteven SombarConfigure Initial Settings
716f60cbcfbSSteven Sombar    [Documentation]  Restore old IP and route.
717f60cbcfbSSteven Sombar    ...  This keyword requires initial settings viz IP address,
718f60cbcfbSSteven Sombar    ...  Network Mask, default gatway and serial console IP and port
719f60cbcfbSSteven Sombar    ...  information which should be provided in command line.
720f60cbcfbSSteven Sombar
721f60cbcfbSSteven Sombar    [Arguments]  ${host}=${OPENBMC_HOST}  ${mask}=${NET_MASK}
722f60cbcfbSSteven Sombar    ...          ${gw_ip}=${GW_IP}
723f60cbcfbSSteven Sombar
724f60cbcfbSSteven Sombar    # Description of arguments:
725f60cbcfbSSteven Sombar    # host  IP address of the OS Host.
726f60cbcfbSSteven Sombar    # mask  Network mask.
727f60cbcfbSSteven Sombar    # gu_ip  Gateway IP address or hostname.
728f60cbcfbSSteven Sombar
729f60cbcfbSSteven Sombar    # Open telnet connection and ignore the error, in case telnet session is
730f60cbcfbSSteven Sombar    # already opened by the program calling this keyword.
731f60cbcfbSSteven Sombar    Run Keyword And Ignore Error  Open Telnet Connection to BMC Serial Console
732f60cbcfbSSteven Sombar    Telnet.write  ifconfig eth0 ${host} netmask ${mask}
733f60cbcfbSSteven Sombar    Telnet.write  route add default gw ${gw_ip}
734f60cbcfbSSteven Sombar
735f60cbcfbSSteven Sombar
736f60cbcfbSSteven SombarInstall Debug Tarball On BMC
737f60cbcfbSSteven Sombar    [Documentation]  Copy the debug tar file to BMC and install.
738f60cbcfbSSteven Sombar    [Arguments]  ${tarball_file_path}=${default_tarball}
739f60cbcfbSSteven Sombar    ...  ${targ_tarball_dir_path}=/tmp/tarball/
740f60cbcfbSSteven Sombar
741f60cbcfbSSteven Sombar    # Description of arguments:
742f60cbcfbSSteven Sombar    # tarball_file_path      Path of the debug tarball file.
743f60cbcfbSSteven Sombar    #                        The tar file is downloaded from the build page
744f60cbcfbSSteven Sombar    #                        https://openpower.xyz/job/openbmc-build/
745f60cbcfbSSteven Sombar    #                        obmc-phosphor-debug-tarball-witherspoon.tar.xz
746f60cbcfbSSteven Sombar    #
747f60cbcfbSSteven Sombar    # targ_tarball_dir_path  The directory path where the tarball is to be
748f60cbcfbSSteven Sombar    #                        installed.
749f60cbcfbSSteven Sombar
750f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${tarball_file_path}
751f60cbcfbSSteven Sombar    ...  msg=${tarball_file_path} doesn't exist.
752f60cbcfbSSteven Sombar
753f60cbcfbSSteven Sombar    # Upload the file to BMC.
754f60cbcfbSSteven Sombar    Import Library  SCPLibrary  WITH NAME  scp
755f60cbcfbSSteven Sombar    Open Connection for SCP
756f60cbcfbSSteven Sombar    scp.Put File  ${tarball_file_path}  /tmp/debug-tarball.tar.xz
757f60cbcfbSSteven Sombar
758f60cbcfbSSteven Sombar    # Create tarball directory and install.
759f60cbcfbSSteven Sombar    BMC Execute Command  mkdir -p ${targ_tarball_dir_path}
760f60cbcfbSSteven Sombar    BMC Execute Command
761f60cbcfbSSteven Sombar    ...  tar -xf /tmp/debug-tarball.tar.xz -C ${targ_tarball_dir_path}
762f60cbcfbSSteven Sombar
763f60cbcfbSSteven Sombar    # Remove the tarball file from BMC.
764f60cbcfbSSteven Sombar    BMC Execute Command  rm -f /tmp/debug-tarball.tar.xz
765f60cbcfbSSteven Sombar
766f60cbcfbSSteven Sombar
767f60cbcfbSSteven SombarGet BMC Boot Count
768f60cbcfbSSteven Sombar    [Documentation]  Returns BMC boot count based on boot time.
769f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
770f60cbcfbSSteven Sombar
771f60cbcfbSSteven Sombar    # Set global variable BOOT_TIME to current boot time if current boot time
772f60cbcfbSSteven Sombar    # is changed. Also increase value of global variable BOOT_COUNT by 1.
773f60cbcfbSSteven Sombar    Run Keyword If  ${cur_btime} > ${BOOT_TIME}
774f60cbcfbSSteven Sombar    ...  Run Keywords  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
775f60cbcfbSSteven Sombar    ...  AND
776f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_COUNT}  ${BOOT_COUNT + 1}
777f60cbcfbSSteven Sombar
778f60cbcfbSSteven Sombar    [Return]  ${BOOT_COUNT}
779f60cbcfbSSteven Sombar
780f60cbcfbSSteven Sombar
781f60cbcfbSSteven SombarSet BMC Boot Count
782f60cbcfbSSteven Sombar    [Documentation]  Set BMC boot count to given value.
783f60cbcfbSSteven Sombar    [Arguments]  ${count}
784f60cbcfbSSteven Sombar
785f60cbcfbSSteven Sombar    # Description of arguments:
786f60cbcfbSSteven Sombar    # count  boot count value.
787f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
788f60cbcfbSSteven Sombar
789f60cbcfbSSteven Sombar    # Set global variable BOOT_COUNT to given value.
790f60cbcfbSSteven Sombar    Set Global Variable  ${BOOT_COUNT}  ${count}
791f60cbcfbSSteven Sombar
792f60cbcfbSSteven Sombar    # Set BOOT_TIME variable to current boot time.
793073fbc0dSTony Lee    Set Global Variable  ${BOOT_TIME}  ${cur_btime}
794f60cbcfbSSteven Sombar
795f60cbcfbSSteven Sombar
796f60cbcfbSSteven SombarDelete Error Log Entry
797f60cbcfbSSteven Sombar    [Documentation]  Delete error log entry.
798f60cbcfbSSteven Sombar    [Arguments]  ${entry_path}
799f60cbcfbSSteven Sombar
800f60cbcfbSSteven Sombar    # Description of argument(s):
801f60cbcfbSSteven Sombar    # entry_path  Delete an error log entry.
802f60cbcfbSSteven Sombar    #             Ex. /xyz/openbmc_project/logging/entry/1
803f60cbcfbSSteven Sombar
804f60cbcfbSSteven Sombar    # Skip delete if entry URI is a callout.
805f60cbcfbSSteven Sombar    # Examples:
806f60cbcfbSSteven Sombar    # /xyz/openbmc_project/logging/entry/1/callout
807f60cbcfbSSteven Sombar    # /xyz/openbmc_project/logging/entry/1/callouts/0
808f60cbcfbSSteven Sombar    ${callout_entry}=  Run Keyword And Return Status
809f60cbcfbSSteven Sombar    ...  Should Match Regexp  ${entry_path}  /callout[s]?(/|$)
810f60cbcfbSSteven Sombar    Return From Keyword If  ${callout_entry}
811f60cbcfbSSteven Sombar
812f60cbcfbSSteven Sombar    ${data}=  Create Dictionary  data=@{EMPTY}
813f60cbcfbSSteven Sombar    ${resp}=  Openbmc Delete Request  ${entry_path}  data=${data}
814f60cbcfbSSteven Sombar    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
815f60cbcfbSSteven Sombar
816f60cbcfbSSteven Sombar
817f60cbcfbSSteven SombarGet BMC Version
818f60cbcfbSSteven Sombar    [Documentation]  Returns BMC version from /etc/os-release.
819f60cbcfbSSteven Sombar    ...              e.g. "v1.99.6-141-ge662190"
820f60cbcfbSSteven Sombar
821f60cbcfbSSteven Sombar    ${cmd}=  Set Variable  grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '='
822f60cbcfbSSteven Sombar    ${output}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
823f60cbcfbSSteven Sombar    [Return]  ${output}
824f60cbcfbSSteven Sombar
825f60cbcfbSSteven Sombar
826f60cbcfbSSteven SombarGet PNOR Version
827f60cbcfbSSteven Sombar    [Documentation]  Returns the PNOR version from the BMC.
828f60cbcfbSSteven Sombar
829f60cbcfbSSteven Sombar    ${pnor_attrs}=  Get PNOR Attributes
830f60cbcfbSSteven Sombar    [Return]  ${pnor_attrs['version']}
831f60cbcfbSSteven Sombar
832f60cbcfbSSteven Sombar
833f60cbcfbSSteven SombarGet PNOR Attributes
834f60cbcfbSSteven Sombar    [Documentation]  Return PNOR software attributes as a dictionary.
835f60cbcfbSSteven Sombar
836f60cbcfbSSteven Sombar    # This keyword parses /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
837f60cbcfbSSteven Sombar    # into key/value pairs.
838f60cbcfbSSteven Sombar
839f60cbcfbSSteven Sombar    ${outbuf}  ${stderr}  ${rc}=  BMC Execute Command
840f60cbcfbSSteven Sombar    ...  cat /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
841f60cbcfbSSteven Sombar    ${pnor_attrs}=  Key Value Outbuf To Dict  ${outbuf}  delim==
842f60cbcfbSSteven Sombar
843f60cbcfbSSteven Sombar    [Return]  ${pnor_attrs}
844f60cbcfbSSteven Sombar
845f60cbcfbSSteven Sombar
84617dae1aeSSivas SRRGET BMC PNOR Version
84717dae1aeSSivas SRR    [Documentation]  Return BMC & PNOR version from openbmc shell.
84817dae1aeSSivas SRR
84917dae1aeSSivas SRR    ${bmc_version}=  GET BMC Version
85017dae1aeSSivas SRR    ${pnor_version}=  GET PNOR Version
85117dae1aeSSivas SRR    Log  ${bmc_version}
85217dae1aeSSivas SRR    Rprint Vars  bmc_version
85317dae1aeSSivas SRR    Log  ${pnor_version}
85417dae1aeSSivas SRR    Rprint Vars  pnor_version
85517dae1aeSSivas SRR
85617dae1aeSSivas SRR    [Return]  ${bmc_version}  ${pnor_version}
85717dae1aeSSivas SRR
85817dae1aeSSivas SRR
8595ea86d02SSushil SinghRedfish Get BMC Version
8605ea86d02SSushil Singh    [Documentation]  Get BMC version via Redfish.
8615ea86d02SSushil Singh
8625ea86d02SSushil Singh    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/bmc  FirmwareVersion
8635ea86d02SSushil Singh    [Return]  ${output}
8645ea86d02SSushil Singh
8655ea86d02SSushil SinghRedfish Get Host Version
8665ea86d02SSushil Singh    [Documentation]  Get host version via Redfish.
8675ea86d02SSushil Singh
8685ea86d02SSushil Singh    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Systems/system  BiosVersion
8695ea86d02SSushil Singh    [Return]  ${output}
8705ea86d02SSushil Singh
8715ea86d02SSushil Singh
872f60cbcfbSSteven SombarCopy Address Translation Utils To HOST OS
873f60cbcfbSSteven Sombar    [Documentation]  Copy address translation utils to host OS.
874f60cbcfbSSteven Sombar
875f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${probe_cpu_tool_path}
876f60cbcfbSSteven Sombar    ...  msg=${probe_cpu_tool_path} doesn't exist.
877f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${probe_cpu_tool_path}
878f60cbcfbSSteven Sombar    ...  msg=${probe_cpu_tool_path} doesn't exist.
879f60cbcfbSSteven Sombar
880f60cbcfbSSteven Sombar    scp.Open connection  ${OS_HOST}  username=${OS_USERNAME}
881f60cbcfbSSteven Sombar    ...  password=${OS_PASSWORD}
882f60cbcfbSSteven Sombar    scp.Put File  ${probe_cpu_tool_path}  ${target_file_path}
883f60cbcfbSSteven Sombar    scp.Put File  ${scom_addrs_tool_path}  ${target_file_path}
884f60cbcfbSSteven Sombar
885f60cbcfbSSteven Sombar
886f60cbcfbSSteven SombarVerify BMC RTC And UTC Time Drift
887f60cbcfbSSteven Sombar    [Documentation]  Verify that the RTC and UTC time difference is less than
888f60cbcfbSSteven Sombar    ...              the given time_drift_max.
889f60cbcfbSSteven Sombar    [Arguments]  ${time_diff_max}=${10}
890f60cbcfbSSteven Sombar
891f60cbcfbSSteven Sombar    # Description of argument(s):
892f60cbcfbSSteven Sombar    # time_diff_max   The max allowable RTC and UTC time difference in seconds.
893f60cbcfbSSteven Sombar
894f60cbcfbSSteven Sombar    # Example:
895f60cbcfbSSteven Sombar    # time_dict:
896f60cbcfbSSteven Sombar    #   [local_time]:               Fri 2017-11-03 152756 UTC
897f60cbcfbSSteven Sombar    #   [local_time_seconds]:       1509740876
898f60cbcfbSSteven Sombar    #   [universal_time]:           Fri 2017-11-03 152756 UTC
899f60cbcfbSSteven Sombar    #   [universal_time_seconds]:   1509740876
900f60cbcfbSSteven Sombar    #   [rtc_time]:                 Fri 2016-05-20 163403
901f60cbcfbSSteven Sombar    #   [rtc_time_seconds]:         1463780043
902f60cbcfbSSteven Sombar    #   [time_zone]:                n/a (UTC, +0000)
903f60cbcfbSSteven Sombar    #   [network_time_on]:          yes
904f60cbcfbSSteven Sombar    #   [ntp_synchronized]:         no
905f60cbcfbSSteven Sombar    #   [rtc_in_local_tz]:          no
906f60cbcfbSSteven Sombar
907f60cbcfbSSteven Sombar    ${time}=  Get BMC Date Time
908f60cbcfbSSteven Sombar    ${time_diff}=  Evaluate
909f60cbcfbSSteven Sombar    ...  ${time['universal_time_seconds']} - ${time['rtc_time_seconds']}
910f60cbcfbSSteven Sombar    Should Be True  ${time_diff} < ${time_diff_max}
911f60cbcfbSSteven Sombar
912f60cbcfbSSteven Sombar
913f60cbcfbSSteven SombarValidate IP On BMC
914f60cbcfbSSteven Sombar    [Documentation]  Validate IP address is present in set of IP addresses.
915f60cbcfbSSteven Sombar    [Arguments]  ${ip_address}  ${ip_data}
916f60cbcfbSSteven Sombar
917f60cbcfbSSteven Sombar    # Description of argument(s):
918f60cbcfbSSteven Sombar    # ip_address  IP address to check (e.g. xx.xx.xx.xx).
919f60cbcfbSSteven Sombar    # ip_data     Set of the IP addresses present.
920f60cbcfbSSteven Sombar
921f60cbcfbSSteven Sombar    Should Contain Match  ${ip_data}  ${ip_address}/*
922f60cbcfbSSteven Sombar    ...  msg=${ip_address} not found in the list provided.
923f60cbcfbSSteven Sombar
924f60cbcfbSSteven Sombar
925f60cbcfbSSteven SombarRemove Journald Logs
926f60cbcfbSSteven Sombar    [Documentation]  Remove all journald logs and restart service.
927f60cbcfbSSteven Sombar
928f60cbcfbSSteven Sombar    ${cmd}=  Catenate  systemctl stop systemd-journald.service &&
929f60cbcfbSSteven Sombar    ...  rm -rf /var/log/journal && systemctl start systemd-journald.service
930f60cbcfbSSteven Sombar
931f60cbcfbSSteven Sombar    BMC Execute Command  ${cmd}
932f60cbcfbSSteven Sombar
933f60cbcfbSSteven Sombar
934f60cbcfbSSteven SombarCheck For Regex In Journald
935f60cbcfbSSteven Sombar    [Documentation]  Parse the journal log and check for regex string.
936f60cbcfbSSteven Sombar    [Arguments]  ${regex}=${ERROR_REGEX}  ${error_check}=${0}  ${boot}=${EMPTY}
937f60cbcfbSSteven Sombar
938f60cbcfbSSteven Sombar    # Description of argument(s):
939f60cbcfbSSteven Sombar    # regex            Strings to be filter.
940f60cbcfbSSteven Sombar    # error_check      Check for errors.
941f60cbcfbSSteven Sombar    # boot             Argument to check current or persistent full boot log
942f60cbcfbSSteven Sombar    #                  (e.g. "-b").
943f60cbcfbSSteven Sombar
944f60cbcfbSSteven Sombar    ${journal_log}  ${stderr}  ${rc}=  BMC Execute Command
945f60cbcfbSSteven Sombar    ...  journalctl --no-pager ${boot} | egrep '${regex}'  ignore_err=1
946f60cbcfbSSteven Sombar
947f60cbcfbSSteven Sombar    Run Keyword If  ${error_check} == ${0}
948f60cbcfbSSteven Sombar    ...    Should Be Empty  ${journal_log}
949f60cbcfbSSteven Sombar    ...  ELSE
950f60cbcfbSSteven Sombar    ...    Should Not Be Empty  ${journal_log}
951f60cbcfbSSteven Sombar
952f60cbcfbSSteven Sombar
953f60cbcfbSSteven SombarGet Service Attribute
954f60cbcfbSSteven Sombar    [Documentation]  Get service attribute policy output.
955f60cbcfbSSteven Sombar    [Arguments]  ${option}  ${servicename}
956f60cbcfbSSteven Sombar
957f60cbcfbSSteven Sombar    # Description of argument(s):
958f60cbcfbSSteven Sombar    # option       systemctl supported options
959f60cbcfbSSteven Sombar    # servicename  Qualified service name
960f60cbcfbSSteven Sombar    ${cmd}=  Set Variable
961f60cbcfbSSteven Sombar    ...  systemctl -p ${option} show ${servicename} | cut -d = -f2
962f60cbcfbSSteven Sombar    ${attr}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
963f60cbcfbSSteven Sombar    [Return]  ${attr}
964eda09492SAnusha Dathatri
965eda09492SAnusha Dathatri
966eda09492SAnusha DathatriVerify Watchdog Enabled
967eda09492SAnusha Dathatri    [Documentation]  Check that watchdog settings are enabled.
968eda09492SAnusha Dathatri
969eda09492SAnusha Dathatri    ${properties}=  Read Properties  /xyz/openbmc_project/watchdog/host0
970eda09492SAnusha Dathatri    Should Be Equal As Strings  ${properties["Enabled"]}  ${True}
971eda09492SAnusha Dathatri    Should Not Be Equal As Strings  ${properties["TimeRemaining"]}  0
972