xref: /openbmc/openbmc-test-automation/lib/common_utils.robot (revision b9f3f7762beea1106310330dfe71d5e37393ae42)
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
65*b9f3f776SGeorge Keishing${check_performance}              ${1}
66*b9f3f776SGeorge 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
73*b9f3f776SGeorge Keishing    Return From Keyword If   not ${check_performance}
74*b9f3f776SGeorge 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
521f60cbcfbSSteven Sombar    :FOR    ${item}     IN      @{ip}
522f60cbcfbSSteven Sombar    \   ${hex}=  Convert To Hex    ${item}    prefix=0x    lowercase=yes
523f60cbcfbSSteven Sombar    \   Set List Value    ${ip}    ${index}    ${hex}
524f60cbcfbSSteven Sombar    \   ${index}=  Set Variable    ${index + 1}
525f60cbcfbSSteven Sombar    ${ip_hex}=  Catenate    @{ip}
526f60cbcfbSSteven Sombar
527f60cbcfbSSteven Sombar    [Return]    ${ip_hex}
528f60cbcfbSSteven Sombar
529f60cbcfbSSteven Sombar
530f60cbcfbSSteven SombarBMC CPU Performance Check
531f60cbcfbSSteven Sombar   [Documentation]   Minimal 10% of proc should be free in this instance
532f60cbcfbSSteven Sombar
533f60cbcfbSSteven Sombar    ${bmc_cpu_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
534f60cbcfbSSteven Sombar    ...  ${bmc_cpu_usage_cmd}
535f60cbcfbSSteven Sombar    ${bmc_cpu_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
536f60cbcfbSSteven Sombar    ...  ${bmc_cpu_usage_cmd}
537f60cbcfbSSteven Sombar    ${bmc_cpu_percentage}=  Fetch From Left  ${bmc_cpu_usage_output}  %
53814426bcbSSivas SRR    Rprint Vars  bmc_cpu_percentage
539f60cbcfbSSteven Sombar    Should be true  ${bmc_cpu_percentage} < 90
540f60cbcfbSSteven Sombar
541f60cbcfbSSteven Sombar
542f60cbcfbSSteven SombarBMC Mem Performance Check
543f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of memory should be free in this instance
544f60cbcfbSSteven Sombar
545f60cbcfbSSteven Sombar    ${bmc_mem_free_output}  ${stderr}  ${rc}=   BMC Execute Command
546f60cbcfbSSteven Sombar    ...  ${bmc_mem_free_cmd}
547f60cbcfbSSteven Sombar
548f60cbcfbSSteven Sombar    ${bmc_mem_total_output}  ${stderr}  ${rc}=  BMC Execute Command
549f60cbcfbSSteven Sombar    ...  ${bmc_mem_total_cmd}
550f60cbcfbSSteven Sombar    ${bmc_mem_free_output}  ${stderr}  ${rc}=   BMC Execute Command
551f60cbcfbSSteven Sombar    ...  ${bmc_mem_free_cmd}
552f60cbcfbSSteven Sombar
553f60cbcfbSSteven Sombar    ${bmc_mem_total_output}  ${stderr}  ${rc}=  BMC Execute Command
554f60cbcfbSSteven Sombar    ...  ${bmc_mem_total_cmd}
555f60cbcfbSSteven Sombar
556f60cbcfbSSteven Sombar    ${bmc_mem_percentage}=  Evaluate  ${bmc_mem_free_output}*100
557f60cbcfbSSteven Sombar    ${bmc_mem_percentage}=  Evaluate
558f60cbcfbSSteven Sombar    ...   ${bmc_mem_percentage}/${bmc_mem_total_output}
55914426bcbSSivas SRR    Rprint Vars  bmc_mem_percentage
560f60cbcfbSSteven Sombar    Should be true  ${bmc_mem_percentage} > 10
561f60cbcfbSSteven Sombar
562f60cbcfbSSteven Sombar
563f60cbcfbSSteven SombarBMC File System Usage Check
564f60cbcfbSSteven Sombar    [Documentation]   Check the file system space. 4 file system should be
565f60cbcfbSSteven Sombar    ...  100% full which is expected
566f60cbcfbSSteven Sombar    # Filesystem            Size    Used Available Use% Mounted on
567f60cbcfbSSteven Sombar    # /dev/root            14.4M     14.4M       0 100% /
568f60cbcfbSSteven Sombar    # /dev/ubiblock0_0     14.4M     14.4M       0 100% /media/rofs-c9249b0e
569f60cbcfbSSteven Sombar    # /dev/ubiblock8_0     19.6M     19.6M       0 100% /media/pnor-ro-8764baa3
570f60cbcfbSSteven Sombar    # /dev/ubiblock4_0     14.4M     14.4M       0 100% /media/rofs-407816c
571f60cbcfbSSteven Sombar    # /dev/ubiblock8_4     21.1M     21.1M       0 100% /media/pnor-ro-cecc64c4
572f60cbcfbSSteven Sombar    ${bmc_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
573f60cbcfbSSteven Sombar    ...  ${bmc_file_system_usage_cmd}
574f60cbcfbSSteven Sombar    ${bmc_pnor_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
575f60cbcfbSSteven Sombar    ...  ${total_pnor_ro_file_system_cmd}
576f60cbcfbSSteven Sombar    ${bmc_bmc_fs_usage_output}  ${stderr}  ${rc}=  BMC Execute Command
577f60cbcfbSSteven Sombar    ...  ${total_bmc_ro_file_system_cmd}
578f60cbcfbSSteven Sombar    ${total_bmc_pnor_image}=  Evaluate
579f60cbcfbSSteven Sombar    ...  ${bmc_pnor_fs_usage_output}+${bmc_bmc_fs_usage_output}
580f60cbcfbSSteven Sombar    # Considering /dev/root also in total 100% used file system
581f60cbcfbSSteven Sombar    ${total_full_fs}=  Evaluate  ${total_bmc_pnor_image}+1
58214426bcbSSivas SRR    Rprint Vars  bmc_fs_usage_output  bmc_pnor_fs_usage_output  bmc_bmc_fs_usage_output
58314426bcbSSivas SRR    ...  total_full_fs
584f60cbcfbSSteven Sombar    Should Be True  ${bmc_fs_usage_output}==${total_full_fs}
585f60cbcfbSSteven Sombar
586f60cbcfbSSteven Sombar
587f60cbcfbSSteven SombarCheck BMC CPU Performance
588f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of proc should be free in 3 sample
5899a08944dSGeorge Keishing    :FOR  ${var}  IN RANGE  1  4
590*b9f3f776SGeorge Keishing    \     BMC CPU Performance Check
591f60cbcfbSSteven Sombar
592f60cbcfbSSteven Sombar
593f60cbcfbSSteven SombarCheck BMC Mem Performance
594f60cbcfbSSteven Sombar    [Documentation]   Minimal 10% of memory should be free
595f60cbcfbSSteven Sombar
5969a08944dSGeorge Keishing    :FOR  ${var}  IN RANGE  1  4
597*b9f3f776SGeorge Keishing    \     BMC Mem Performance Check
598f60cbcfbSSteven Sombar
599f60cbcfbSSteven Sombar
600f60cbcfbSSteven SombarCheck BMC File System Performance
601f60cbcfbSSteven Sombar    [Documentation]  Check for file system usage for 4 times
602f60cbcfbSSteven Sombar
6039a08944dSGeorge Keishing    :FOR  ${var}  IN RANGE  1  4
604f60cbcfbSSteven Sombar    \     BMC File System Usage check
605f60cbcfbSSteven Sombar
606f60cbcfbSSteven Sombar
607f60cbcfbSSteven SombarGet URL List
608f60cbcfbSSteven Sombar    [Documentation]  Return list of URLs under given URL.
609f60cbcfbSSteven Sombar    [Arguments]  ${openbmc_url}
610f60cbcfbSSteven Sombar
611f60cbcfbSSteven Sombar    # Description of argument(s):
612f60cbcfbSSteven Sombar    # openbmc_url  URL for list operation (e.g.
613f60cbcfbSSteven Sombar    #              /xyz/openbmc_project/inventory).
614f60cbcfbSSteven Sombar
615aaaab222SSteven Sombar    ${url_list}=  Read Properties  ${openbmc_url}list  quiet=${1}
616f60cbcfbSSteven Sombar    Sort List  ${url_list}
617f60cbcfbSSteven Sombar
618f60cbcfbSSteven Sombar    [Return]  ${url_list}
619f60cbcfbSSteven Sombar
620f60cbcfbSSteven Sombar
621f60cbcfbSSteven SombarCheck Zombie Process
622f60cbcfbSSteven Sombar    [Documentation]    Check if any defunct process exist or not on BMC
623f60cbcfbSSteven Sombar    ${count}  ${stderr}  ${rc}=  Execute Command  ps -o stat | grep Z | wc -l
624f60cbcfbSSteven Sombar    ...    return_stderr=True  return_rc=True
625f60cbcfbSSteven Sombar    Should Be True    ${count}==0
626f60cbcfbSSteven Sombar    Should Be Empty    ${stderr}
627f60cbcfbSSteven Sombar
628f60cbcfbSSteven Sombar
629f60cbcfbSSteven SombarPrune Journal Log
630f60cbcfbSSteven Sombar    [Documentation]   Prune archived journal logs.
631f60cbcfbSSteven Sombar    [Arguments]   ${vacuum_size}=1M
632f60cbcfbSSteven Sombar
633f60cbcfbSSteven Sombar    # This keyword can be used to prevent the journal
634f60cbcfbSSteven Sombar    # log from filling up the /run filesystem.
635f60cbcfbSSteven Sombar    # This command will retain only the latest logs
636f60cbcfbSSteven Sombar    # of the user specified size.
637f60cbcfbSSteven Sombar
638f60cbcfbSSteven Sombar    # Description of argument(s):
639f60cbcfbSSteven Sombar    # vacuum_size    Size of journal.
640f60cbcfbSSteven Sombar
641f60cbcfbSSteven Sombar    Open Connection And Log In
642f60cbcfbSSteven Sombar    ${output}  ${stderr}  ${rc}=
643f60cbcfbSSteven Sombar    ...  Execute Command
644f60cbcfbSSteven Sombar    ...  journalctl --vacuum-size=${vacuum_size}
645f60cbcfbSSteven Sombar    ...  return_stderr=True  return_rc=True
646f60cbcfbSSteven Sombar
647f60cbcfbSSteven Sombar    Should Be Equal  ${rc}  ${0}  msg=${stderr}
648f60cbcfbSSteven Sombar
649f60cbcfbSSteven Sombar
650f60cbcfbSSteven SombarGet System Power Policy
651f60cbcfbSSteven Sombar    [Documentation]  Returns the BMC power policy.
652f60cbcfbSSteven Sombar
653f60cbcfbSSteven Sombar    # Set the bmc_power_policy_method to either 'Old' or 'New'.
654f60cbcfbSSteven Sombar    Set Power Policy Method
655f60cbcfbSSteven Sombar    ${cmd_buf}=  Create List  ${bmc_power_policy_method} Get Power Policy
656f60cbcfbSSteven Sombar    # Run the appropriate keyword.
657f60cbcfbSSteven Sombar    ${currentPolicy}=  Run Keyword  @{cmd_buf}
658f60cbcfbSSteven Sombar
659f60cbcfbSSteven Sombar    [Return]  ${currentPolicy}
660f60cbcfbSSteven Sombar
661f60cbcfbSSteven Sombar
662f60cbcfbSSteven SombarSet BMC Reset Reference Time
663f60cbcfbSSteven Sombar    [Documentation]  Set current boot time as a reference and increment
664f60cbcfbSSteven Sombar    ...              boot count.
665f60cbcfbSSteven Sombar
666f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
667f60cbcfbSSteven Sombar    Run Keyword If  ${BOOT_TIME} == ${0} and ${BOOT_COUNT} == ${0}
668f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
669f60cbcfbSSteven Sombar    ...  ELSE IF  ${cur_btime} > ${BOOT_TIME}
670f60cbcfbSSteven Sombar    ...  Run Keywords  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
671f60cbcfbSSteven Sombar    ...  AND
672f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_COUNT}  ${BOOT_COUNT + 1}
673f60cbcfbSSteven Sombar
674f60cbcfbSSteven Sombar
675f60cbcfbSSteven SombarGet BMC Boot Time
676f60cbcfbSSteven Sombar    [Documentation]  Returns boot time from /proc/stat.
677f60cbcfbSSteven Sombar
678f60cbcfbSSteven Sombar    Open Connection And Log In
679f60cbcfbSSteven Sombar    ${output}  ${stderr}=
680f60cbcfbSSteven Sombar    ...  Execute Command  egrep '^btime ' /proc/stat | cut -f 2 -d ' '
681f60cbcfbSSteven Sombar    ...  return_stderr=True
682f60cbcfbSSteven Sombar    Should Be Empty  ${stderr}
683f60cbcfbSSteven Sombar    ${btime}=  Convert To Integer  ${output}
684f60cbcfbSSteven Sombar    [Return]  ${btime}
685f60cbcfbSSteven Sombar
686f60cbcfbSSteven Sombar
687f60cbcfbSSteven SombarEnable Core Dump On BMC
688f60cbcfbSSteven Sombar    [Documentation]  Enable core dump collection.
689f60cbcfbSSteven Sombar    ${core_pattern}  ${stderr}  ${rc}=  BMC Execute Command
690f60cbcfbSSteven Sombar    ...  echo '/tmp/core_%e.%p' | tee /proc/sys/kernel/core_pattern
691f60cbcfbSSteven Sombar    Should Be Equal As Strings  ${core_pattern}  /tmp/core_%e.%p
692f60cbcfbSSteven Sombar
693f60cbcfbSSteven Sombar
694f60cbcfbSSteven SombarGet Number Of BMC Core Dump Files
695f60cbcfbSSteven Sombar    [Documentation]  Returns number of core dump files on BMC.
696f60cbcfbSSteven Sombar    Open Connection And Log In
697f60cbcfbSSteven Sombar    ${num_of_core_dump}=  Execute Command
698f60cbcfbSSteven Sombar    ...  ls /tmp/core* 2>/dev/null | wc -l
699f60cbcfbSSteven Sombar    [Return]  ${num_of_core_dump}
700f60cbcfbSSteven Sombar
701f60cbcfbSSteven Sombar
702f60cbcfbSSteven SombarSet Core Dump File Size Unlimited
703f60cbcfbSSteven Sombar    [Documentation]  Set core dump file size to unlimited.
704f60cbcfbSSteven Sombar    BMC Execute Command  ulimit -c unlimited
705f60cbcfbSSteven Sombar
706f60cbcfbSSteven Sombar
707f60cbcfbSSteven SombarCheck For Core Dumps
708f60cbcfbSSteven Sombar    [Documentation]  Check for any core dumps exist.
709f60cbcfbSSteven Sombar    ${output}=  Get Number Of BMC Core Dump Files
710f60cbcfbSSteven Sombar    Run Keyword If  ${output} > 0
711f60cbcfbSSteven Sombar    ...  Log  **Warning** BMC core dump files exist  level=WARN
712f60cbcfbSSteven Sombar
713f60cbcfbSSteven Sombar
714f60cbcfbSSteven SombarConfigure Initial Settings
715f60cbcfbSSteven Sombar    [Documentation]  Restore old IP and route.
716f60cbcfbSSteven Sombar    ...  This keyword requires initial settings viz IP address,
717f60cbcfbSSteven Sombar    ...  Network Mask, default gatway and serial console IP and port
718f60cbcfbSSteven Sombar    ...  information which should be provided in command line.
719f60cbcfbSSteven Sombar
720f60cbcfbSSteven Sombar    [Arguments]  ${host}=${OPENBMC_HOST}  ${mask}=${NET_MASK}
721f60cbcfbSSteven Sombar    ...          ${gw_ip}=${GW_IP}
722f60cbcfbSSteven Sombar
723f60cbcfbSSteven Sombar    # Description of arguments:
724f60cbcfbSSteven Sombar    # host  IP address of the OS Host.
725f60cbcfbSSteven Sombar    # mask  Network mask.
726f60cbcfbSSteven Sombar    # gu_ip  Gateway IP address or hostname.
727f60cbcfbSSteven Sombar
728f60cbcfbSSteven Sombar    # Open telnet connection and ignore the error, in case telnet session is
729f60cbcfbSSteven Sombar    # already opened by the program calling this keyword.
730f60cbcfbSSteven Sombar    Run Keyword And Ignore Error  Open Telnet Connection to BMC Serial Console
731f60cbcfbSSteven Sombar    Telnet.write  ifconfig eth0 ${host} netmask ${mask}
732f60cbcfbSSteven Sombar    Telnet.write  route add default gw ${gw_ip}
733f60cbcfbSSteven Sombar
734f60cbcfbSSteven Sombar
735f60cbcfbSSteven SombarInstall Debug Tarball On BMC
736f60cbcfbSSteven Sombar    [Documentation]  Copy the debug tar file to BMC and install.
737f60cbcfbSSteven Sombar    [Arguments]  ${tarball_file_path}=${default_tarball}
738f60cbcfbSSteven Sombar    ...  ${targ_tarball_dir_path}=/tmp/tarball/
739f60cbcfbSSteven Sombar
740f60cbcfbSSteven Sombar    # Description of arguments:
741f60cbcfbSSteven Sombar    # tarball_file_path      Path of the debug tarball file.
742f60cbcfbSSteven Sombar    #                        The tar file is downloaded from the build page
743f60cbcfbSSteven Sombar    #                        https://openpower.xyz/job/openbmc-build/
744f60cbcfbSSteven Sombar    #                        obmc-phosphor-debug-tarball-witherspoon.tar.xz
745f60cbcfbSSteven Sombar    #
746f60cbcfbSSteven Sombar    # targ_tarball_dir_path  The directory path where the tarball is to be
747f60cbcfbSSteven Sombar    #                        installed.
748f60cbcfbSSteven Sombar
749f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${tarball_file_path}
750f60cbcfbSSteven Sombar    ...  msg=${tarball_file_path} doesn't exist.
751f60cbcfbSSteven Sombar
752f60cbcfbSSteven Sombar    # Upload the file to BMC.
753f60cbcfbSSteven Sombar    Import Library  SCPLibrary  WITH NAME  scp
754f60cbcfbSSteven Sombar    Open Connection for SCP
755f60cbcfbSSteven Sombar    scp.Put File  ${tarball_file_path}  /tmp/debug-tarball.tar.xz
756f60cbcfbSSteven Sombar
757f60cbcfbSSteven Sombar    # Create tarball directory and install.
758f60cbcfbSSteven Sombar    BMC Execute Command  mkdir -p ${targ_tarball_dir_path}
759f60cbcfbSSteven Sombar    BMC Execute Command
760f60cbcfbSSteven Sombar    ...  tar -xf /tmp/debug-tarball.tar.xz -C ${targ_tarball_dir_path}
761f60cbcfbSSteven Sombar
762f60cbcfbSSteven Sombar    # Remove the tarball file from BMC.
763f60cbcfbSSteven Sombar    BMC Execute Command  rm -f /tmp/debug-tarball.tar.xz
764f60cbcfbSSteven Sombar
765f60cbcfbSSteven Sombar
766f60cbcfbSSteven SombarGet BMC Boot Count
767f60cbcfbSSteven Sombar    [Documentation]  Returns BMC boot count based on boot time.
768f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
769f60cbcfbSSteven Sombar
770f60cbcfbSSteven Sombar    # Set global variable BOOT_TIME to current boot time if current boot time
771f60cbcfbSSteven Sombar    # is changed. Also increase value of global variable BOOT_COUNT by 1.
772f60cbcfbSSteven Sombar    Run Keyword If  ${cur_btime} > ${BOOT_TIME}
773f60cbcfbSSteven Sombar    ...  Run Keywords  Set Global Variable  ${BOOT_TIME}  ${cur_btime}
774f60cbcfbSSteven Sombar    ...  AND
775f60cbcfbSSteven Sombar    ...  Set Global Variable  ${BOOT_COUNT}  ${BOOT_COUNT + 1}
776f60cbcfbSSteven Sombar
777f60cbcfbSSteven Sombar    [Return]  ${BOOT_COUNT}
778f60cbcfbSSteven Sombar
779f60cbcfbSSteven Sombar
780f60cbcfbSSteven SombarSet BMC Boot Count
781f60cbcfbSSteven Sombar    [Documentation]  Set BMC boot count to given value.
782f60cbcfbSSteven Sombar    [Arguments]  ${count}
783f60cbcfbSSteven Sombar
784f60cbcfbSSteven Sombar    # Description of arguments:
785f60cbcfbSSteven Sombar    # count  boot count value.
786f60cbcfbSSteven Sombar    ${cur_btime}=  Get BMC Boot Time
787f60cbcfbSSteven Sombar
788f60cbcfbSSteven Sombar    # Set global variable BOOT_COUNT to given value.
789f60cbcfbSSteven Sombar    Set Global Variable  ${BOOT_COUNT}  ${count}
790f60cbcfbSSteven Sombar
791f60cbcfbSSteven Sombar    # Set BOOT_TIME variable to current boot time.
792f60cbcfbSSteven Sombar    Set Global Variable  ${BOOT_COUNT}  ${count}
793f60cbcfbSSteven Sombar
794f60cbcfbSSteven Sombar
795f60cbcfbSSteven SombarDelete Error Log Entry
796f60cbcfbSSteven Sombar    [Documentation]  Delete error log entry.
797f60cbcfbSSteven Sombar    [Arguments]  ${entry_path}
798f60cbcfbSSteven Sombar
799f60cbcfbSSteven Sombar    # Description of argument(s):
800f60cbcfbSSteven Sombar    # entry_path  Delete an error log entry.
801f60cbcfbSSteven Sombar    #             Ex. /xyz/openbmc_project/logging/entry/1
802f60cbcfbSSteven Sombar
803f60cbcfbSSteven Sombar    # Skip delete if entry URI is a callout.
804f60cbcfbSSteven Sombar    # Examples:
805f60cbcfbSSteven Sombar    # /xyz/openbmc_project/logging/entry/1/callout
806f60cbcfbSSteven Sombar    # /xyz/openbmc_project/logging/entry/1/callouts/0
807f60cbcfbSSteven Sombar    ${callout_entry}=  Run Keyword And Return Status
808f60cbcfbSSteven Sombar    ...  Should Match Regexp  ${entry_path}  /callout[s]?(/|$)
809f60cbcfbSSteven Sombar    Return From Keyword If  ${callout_entry}
810f60cbcfbSSteven Sombar
811f60cbcfbSSteven Sombar    ${data}=  Create Dictionary  data=@{EMPTY}
812f60cbcfbSSteven Sombar    ${resp}=  Openbmc Delete Request  ${entry_path}  data=${data}
813f60cbcfbSSteven Sombar    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
814f60cbcfbSSteven Sombar
815f60cbcfbSSteven Sombar
816f60cbcfbSSteven SombarGet BMC Version
817f60cbcfbSSteven Sombar    [Documentation]  Returns BMC version from /etc/os-release.
818f60cbcfbSSteven Sombar    ...              e.g. "v1.99.6-141-ge662190"
819f60cbcfbSSteven Sombar
820f60cbcfbSSteven Sombar    ${cmd}=  Set Variable  grep ^VERSION_ID= /etc/os-release | cut -f 2 -d '='
821f60cbcfbSSteven Sombar    ${output}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
822f60cbcfbSSteven Sombar    [Return]  ${output}
823f60cbcfbSSteven Sombar
824f60cbcfbSSteven Sombar
825f60cbcfbSSteven SombarGet PNOR Version
826f60cbcfbSSteven Sombar    [Documentation]  Returns the PNOR version from the BMC.
827f60cbcfbSSteven Sombar
828f60cbcfbSSteven Sombar    ${pnor_attrs}=  Get PNOR Attributes
829f60cbcfbSSteven Sombar    [Return]  ${pnor_attrs['version']}
830f60cbcfbSSteven Sombar
831f60cbcfbSSteven Sombar
832f60cbcfbSSteven SombarGet PNOR Attributes
833f60cbcfbSSteven Sombar    [Documentation]  Return PNOR software attributes as a dictionary.
834f60cbcfbSSteven Sombar
835f60cbcfbSSteven Sombar    # This keyword parses /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
836f60cbcfbSSteven Sombar    # into key/value pairs.
837f60cbcfbSSteven Sombar
838f60cbcfbSSteven Sombar    ${outbuf}  ${stderr}  ${rc}=  BMC Execute Command
839f60cbcfbSSteven Sombar    ...  cat /var/lib/phosphor-software-manager/pnor/ro/pnor.toc
840f60cbcfbSSteven Sombar    ${pnor_attrs}=  Key Value Outbuf To Dict  ${outbuf}  delim==
841f60cbcfbSSteven Sombar
842f60cbcfbSSteven Sombar    [Return]  ${pnor_attrs}
843f60cbcfbSSteven Sombar
844f60cbcfbSSteven Sombar
84517dae1aeSSivas SRRGET BMC PNOR Version
84617dae1aeSSivas SRR    [Documentation]  Return BMC & PNOR version from openbmc shell.
84717dae1aeSSivas SRR
84817dae1aeSSivas SRR    ${bmc_version}=  GET BMC Version
84917dae1aeSSivas SRR    ${pnor_version}=  GET PNOR Version
85017dae1aeSSivas SRR    Log  ${bmc_version}
85117dae1aeSSivas SRR    Rprint Vars  bmc_version
85217dae1aeSSivas SRR    Log  ${pnor_version}
85317dae1aeSSivas SRR    Rprint Vars  pnor_version
85417dae1aeSSivas SRR
85517dae1aeSSivas SRR    [Return]  ${bmc_version}  ${pnor_version}
85617dae1aeSSivas SRR
85717dae1aeSSivas SRR
8585ea86d02SSushil SinghRedfish Get BMC Version
8595ea86d02SSushil Singh    [Documentation]  Get BMC version via Redfish.
8605ea86d02SSushil Singh
8615ea86d02SSushil Singh    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/bmc  FirmwareVersion
8625ea86d02SSushil Singh    [Return]  ${output}
8635ea86d02SSushil Singh
8645ea86d02SSushil SinghRedfish Get Host Version
8655ea86d02SSushil Singh    [Documentation]  Get host version via Redfish.
8665ea86d02SSushil Singh
8675ea86d02SSushil Singh    ${output}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Systems/system  BiosVersion
8685ea86d02SSushil Singh    [Return]  ${output}
8695ea86d02SSushil Singh
8705ea86d02SSushil Singh
871f60cbcfbSSteven SombarCopy Address Translation Utils To HOST OS
872f60cbcfbSSteven Sombar    [Documentation]  Copy address translation utils to host OS.
873f60cbcfbSSteven Sombar
874f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${probe_cpu_tool_path}
875f60cbcfbSSteven Sombar    ...  msg=${probe_cpu_tool_path} doesn't exist.
876f60cbcfbSSteven Sombar    OperatingSystem.File Should Exist  ${probe_cpu_tool_path}
877f60cbcfbSSteven Sombar    ...  msg=${probe_cpu_tool_path} doesn't exist.
878f60cbcfbSSteven Sombar
879f60cbcfbSSteven Sombar    scp.Open connection  ${OS_HOST}  username=${OS_USERNAME}
880f60cbcfbSSteven Sombar    ...  password=${OS_PASSWORD}
881f60cbcfbSSteven Sombar    scp.Put File  ${probe_cpu_tool_path}  ${target_file_path}
882f60cbcfbSSteven Sombar    scp.Put File  ${scom_addrs_tool_path}  ${target_file_path}
883f60cbcfbSSteven Sombar
884f60cbcfbSSteven Sombar
885f60cbcfbSSteven SombarVerify BMC RTC And UTC Time Drift
886f60cbcfbSSteven Sombar    [Documentation]  Verify that the RTC and UTC time difference is less than
887f60cbcfbSSteven Sombar    ...              the given time_drift_max.
888f60cbcfbSSteven Sombar    [Arguments]  ${time_diff_max}=${10}
889f60cbcfbSSteven Sombar
890f60cbcfbSSteven Sombar    # Description of argument(s):
891f60cbcfbSSteven Sombar    # time_diff_max   The max allowable RTC and UTC time difference in seconds.
892f60cbcfbSSteven Sombar
893f60cbcfbSSteven Sombar    # Example:
894f60cbcfbSSteven Sombar    # time_dict:
895f60cbcfbSSteven Sombar    #   [local_time]:               Fri 2017-11-03 152756 UTC
896f60cbcfbSSteven Sombar    #   [local_time_seconds]:       1509740876
897f60cbcfbSSteven Sombar    #   [universal_time]:           Fri 2017-11-03 152756 UTC
898f60cbcfbSSteven Sombar    #   [universal_time_seconds]:   1509740876
899f60cbcfbSSteven Sombar    #   [rtc_time]:                 Fri 2016-05-20 163403
900f60cbcfbSSteven Sombar    #   [rtc_time_seconds]:         1463780043
901f60cbcfbSSteven Sombar    #   [time_zone]:                n/a (UTC, +0000)
902f60cbcfbSSteven Sombar    #   [network_time_on]:          yes
903f60cbcfbSSteven Sombar    #   [ntp_synchronized]:         no
904f60cbcfbSSteven Sombar    #   [rtc_in_local_tz]:          no
905f60cbcfbSSteven Sombar
906f60cbcfbSSteven Sombar    ${time}=  Get BMC Date Time
907f60cbcfbSSteven Sombar    ${time_diff}=  Evaluate
908f60cbcfbSSteven Sombar    ...  ${time['universal_time_seconds']} - ${time['rtc_time_seconds']}
909f60cbcfbSSteven Sombar    Should Be True  ${time_diff} < ${time_diff_max}
910f60cbcfbSSteven Sombar
911f60cbcfbSSteven Sombar
912f60cbcfbSSteven SombarValidate IP On BMC
913f60cbcfbSSteven Sombar    [Documentation]  Validate IP address is present in set of IP addresses.
914f60cbcfbSSteven Sombar    [Arguments]  ${ip_address}  ${ip_data}
915f60cbcfbSSteven Sombar
916f60cbcfbSSteven Sombar    # Description of argument(s):
917f60cbcfbSSteven Sombar    # ip_address  IP address to check (e.g. xx.xx.xx.xx).
918f60cbcfbSSteven Sombar    # ip_data     Set of the IP addresses present.
919f60cbcfbSSteven Sombar
920f60cbcfbSSteven Sombar    Should Contain Match  ${ip_data}  ${ip_address}/*
921f60cbcfbSSteven Sombar    ...  msg=${ip_address} not found in the list provided.
922f60cbcfbSSteven Sombar
923f60cbcfbSSteven Sombar
924f60cbcfbSSteven SombarRemove Journald Logs
925f60cbcfbSSteven Sombar    [Documentation]  Remove all journald logs and restart service.
926f60cbcfbSSteven Sombar
927f60cbcfbSSteven Sombar    ${cmd}=  Catenate  systemctl stop systemd-journald.service &&
928f60cbcfbSSteven Sombar    ...  rm -rf /var/log/journal && systemctl start systemd-journald.service
929f60cbcfbSSteven Sombar
930f60cbcfbSSteven Sombar    BMC Execute Command  ${cmd}
931f60cbcfbSSteven Sombar
932f60cbcfbSSteven Sombar
933f60cbcfbSSteven SombarCheck For Regex In Journald
934f60cbcfbSSteven Sombar    [Documentation]  Parse the journal log and check for regex string.
935f60cbcfbSSteven Sombar    [Arguments]  ${regex}=${ERROR_REGEX}  ${error_check}=${0}  ${boot}=${EMPTY}
936f60cbcfbSSteven Sombar
937f60cbcfbSSteven Sombar    # Description of argument(s):
938f60cbcfbSSteven Sombar    # regex            Strings to be filter.
939f60cbcfbSSteven Sombar    # error_check      Check for errors.
940f60cbcfbSSteven Sombar    # boot             Argument to check current or persistent full boot log
941f60cbcfbSSteven Sombar    #                  (e.g. "-b").
942f60cbcfbSSteven Sombar
943f60cbcfbSSteven Sombar    ${journal_log}  ${stderr}  ${rc}=  BMC Execute Command
944f60cbcfbSSteven Sombar    ...  journalctl --no-pager ${boot} | egrep '${regex}'  ignore_err=1
945f60cbcfbSSteven Sombar
946f60cbcfbSSteven Sombar    Run Keyword If  ${error_check} == ${0}
947f60cbcfbSSteven Sombar    ...    Should Be Empty  ${journal_log}
948f60cbcfbSSteven Sombar    ...  ELSE
949f60cbcfbSSteven Sombar    ...    Should Not Be Empty  ${journal_log}
950f60cbcfbSSteven Sombar
951f60cbcfbSSteven Sombar
952f60cbcfbSSteven SombarGet Service Attribute
953f60cbcfbSSteven Sombar    [Documentation]  Get service attribute policy output.
954f60cbcfbSSteven Sombar    [Arguments]  ${option}  ${servicename}
955f60cbcfbSSteven Sombar
956f60cbcfbSSteven Sombar    # Description of argument(s):
957f60cbcfbSSteven Sombar    # option       systemctl supported options
958f60cbcfbSSteven Sombar    # servicename  Qualified service name
959f60cbcfbSSteven Sombar    ${cmd}=  Set Variable
960f60cbcfbSSteven Sombar    ...  systemctl -p ${option} show ${servicename} | cut -d = -f2
961f60cbcfbSSteven Sombar    ${attr}  ${stderr}  ${rc}=  BMC Execute Command  ${cmd}
962f60cbcfbSSteven Sombar    [Return]  ${attr}
963eda09492SAnusha Dathatri
964eda09492SAnusha Dathatri
965eda09492SAnusha DathatriVerify Watchdog Enabled
966eda09492SAnusha Dathatri    [Documentation]  Check that watchdog settings are enabled.
967eda09492SAnusha Dathatri
968eda09492SAnusha Dathatri    ${properties}=  Read Properties  /xyz/openbmc_project/watchdog/host0
969eda09492SAnusha Dathatri    Should Be Equal As Strings  ${properties["Enabled"]}  ${True}
970eda09492SAnusha Dathatri    Should Not Be Equal As Strings  ${properties["TimeRemaining"]}  0
971