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