Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 1 | *** Settings *** |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 2 | Documentation This module is for IPMI client for copying ipmitool to |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 3 | ... openbmc box and execute ipmitool IPMI standard |
| 4 | ... command. IPMI raw command will use dbus-send command |
Sandhya Somashekar | 839a0c2 | 2019-01-31 05:05:43 -0600 | [diff] [blame] | 5 | Resource ../lib/resource.robot |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 6 | Resource ../lib/connection_client.robot |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 7 | Resource ../lib/utils.robot |
| 8 | Resource ../lib/state_manager.robot |
| 9 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 10 | Library String |
Michael Walsh | 34c79af | 2019-12-09 11:46:48 -0600 | [diff] [blame] | 11 | Library var_funcs.py |
Michael Walsh | 19621ba | 2018-12-03 17:16:02 -0600 | [diff] [blame] | 12 | Library ipmi_client.py |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 13 | Library ../lib/bmc_ssh_utils.py |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 14 | |
| 15 | *** Variables *** |
George Keishing | d7f11f7 | 2017-01-04 10:58:19 -0600 | [diff] [blame] | 16 | ${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1 |
| 17 | ${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 18 | ${netfnByte}= ${EMPTY} |
George Keishing | d7f11f7 | 2017-01-04 10:58:19 -0600 | [diff] [blame] | 19 | ${cmdByte}= ${EMPTY} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 20 | ${arrayByte}= array:byte: |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 21 | ${IPMI_USER_OPTIONS} ${EMPTY} |
George Keishing | 75f55dc | 2021-03-29 10:48:09 -0500 | [diff] [blame] | 22 | ${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} -N ${IPMI_TIMEOUT} -p ${IPMI_PORT} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 23 | ${HOST}= -H |
| 24 | ${RAW}= raw |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 25 | ${IPMITOOL_PATH} /tmp/ipmitool |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 26 | |
| 27 | *** Keywords *** |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 28 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 29 | Run IPMI Command |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 30 | [Documentation] Run the raw IPMI command. |
| 31 | [Arguments] ${command} ${fail_on_err}=${1} &{options} |
| 32 | |
| 33 | # Description of argument(s): |
| 34 | # command The IPMI command string to be executed |
| 35 | # (e.g. "power status"). |
| 36 | # fail_on_err Fail if the IPMI command execution fails. |
| 37 | # options Additional ipmitool command options (e.g. |
| 38 | # -C=3, -I=lanplus, etc.). Currently, only |
| 39 | # used for external IPMI commands. |
| 40 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 41 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 42 | ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 43 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 44 | ... Run Inband IPMI Raw Command ${command} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 45 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 46 | ... Run Dbus IPMI RAW Command ${command} |
| 47 | ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 48 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 49 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 50 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 51 | Run IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 52 | [Documentation] Run the standard IPMI command. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 53 | [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 54 | |
| 55 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 56 | # command The IPMI command string to be executed |
| 57 | # (e.g. "0x06 0x36"). |
| 58 | # fail_on_err Fail if the IPMI command execution fails. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 59 | # expected_rc The expected return code from the ipmi |
| 60 | # command (e.g. ${0}, ${1}, etc.). |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 61 | # options Additional ipmitool command options (e.g. |
| 62 | # -C=3, -I=lanplus, etc.). Currently, only |
| 63 | # used for external IPMI commands. |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 64 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 65 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 66 | ... Run External IPMI Standard Command ${command} ${fail_on_err} ${expected_rc} &{options} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 67 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 68 | ... Run Inband IPMI Standard Command ${command} ${fail_on_err} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 69 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 70 | ... Run Dbus IPMI Standard Command ${command} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 71 | ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 72 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 73 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 74 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 75 | Run Dbus IPMI RAW Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 76 | [Documentation] Run the raw IPMI command through dbus. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 77 | [Arguments] ${command} |
| 78 | ${valueinBytes}= Byte Conversion ${command} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 79 | ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} |
| 80 | ${cmd}= Catenate ${cmd} ${valueinBytes} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 81 | ${output} ${stderr}= Execute Command ${cmd} return_stderr=True |
| 82 | Should Be Empty ${stderr} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 83 | set test variable ${OUTPUT} "${output}" |
| 84 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 85 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 86 | Run Dbus IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 87 | [Documentation] Run the standard IPMI command through dbus. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 88 | [Arguments] ${command} |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 89 | Copy ipmitool |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 90 | ${stdout} ${stderr} ${output}= Execute Command |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 91 | ... ${IPMITOOL_PATH} -I dbus ${command} return_stdout=True |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 92 | ... return_stderr= True return_rc=True |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 93 | Should Be Equal ${output} ${0} msg=${stderr} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 94 | [Return] ${stdout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 95 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 96 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 97 | Run Inband IPMI Raw Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 98 | [Documentation] Run the raw IPMI command in-band. |
chithrag | 4ad123a | 2022-04-12 19:26:05 +0000 | [diff] [blame] | 99 | [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 100 | ... ${os_password}=${OS_PASSWORD} |
| 101 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 102 | # Description of argument(s): |
| 103 | # command The IPMI command string to be executed |
| 104 | # (e.g. "0x06 0x36"). |
| 105 | # os_host The host name or IP address of the OS Host. |
| 106 | # os_username The OS host user name. |
| 107 | # os_password The OS host passwrd. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 108 | |
| 109 | Login To OS Host ${os_host} ${os_username} ${os_password} |
| 110 | Check If IPMI Tool Exist |
| 111 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 112 | ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${command} |
| 113 | Qprint Issuing ${ipmi_cmd} |
| 114 | ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True |
chithrag | 4ad123a | 2022-04-12 19:26:05 +0000 | [diff] [blame] | 115 | Return From Keyword If ${fail_on_err} == ${0} ${stderr} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 116 | Should Be Empty ${stderr} msg=${stdout} |
| 117 | [Return] ${stdout} |
| 118 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 119 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 120 | Run Inband IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 121 | [Documentation] Run the standard IPMI command in-band. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 122 | [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST} |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 123 | ... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 124 | ... ${login_host}=${1} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 125 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 126 | # Description of argument(s): |
| 127 | # command The IPMI command string to be executed |
| 128 | # (e.g. "power status"). |
| 129 | # os_host The host name or IP address of the OS Host. |
| 130 | # os_username The OS host user name. |
| 131 | # os_password The OS host passwrd. |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 132 | # login_host Indicates that this keyword should login to host OS. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 133 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 134 | Run Keyword If ${login_host} == ${1} |
| 135 | ... Login To OS Host ${os_host} ${os_username} ${os_password} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 136 | Check If IPMI Tool Exist |
| 137 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 138 | ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command} |
| 139 | Qprint Issuing ${ipmi_cmd} |
| 140 | ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 141 | Return From Keyword If ${fail_on_err} == ${0} ${stderr} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 142 | Should Be Empty ${stderr} msg=${stdout} |
| 143 | [Return] ${stdout} |
| 144 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 145 | |
| 146 | Run External IPMI Standard Command |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 147 | [Documentation] Run the external IPMI standard command. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 148 | [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 149 | |
| 150 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 151 | # command The IPMI command string to be executed |
| 152 | # (e.g. "power status"). Note that if |
| 153 | # ${IPMI_USER_OPTIONS} has a value (e.g. |
| 154 | # "-vvv"), it will be pre-pended to this |
| 155 | # command string. |
| 156 | # fail_on_err Fail if the IPMI command execution fails. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 157 | # expected_rc The expected return code from the ipmi |
| 158 | # command (e.g. ${0}, ${1}, etc.). |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 159 | # options Additional ipmitool command options (e.g. |
| 160 | # -C=3, -I=lanplus, etc.). |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 161 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 162 | ${command_string}= Process IPMI User Options ${command} |
| 163 | ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options} |
| 164 | Qprint Issuing ${ipmi_cmd} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 165 | ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd} |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 166 | Return From Keyword If ${fail_on_err} == ${0} ${output} |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 167 | Should Be Equal ${rc} ${expected_rc} msg=${output} |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 168 | [Return] ${output} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 169 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 170 | |
| 171 | Run External IPMI Raw Command |
| 172 | [Documentation] Run the external IPMI raw command. |
| 173 | [Arguments] ${command} ${fail_on_err}=${1} &{options} |
| 174 | |
| 175 | # This keyword is a wrapper for 'Run External IPMI Standard Command'. See |
| 176 | # that keyword's prolog for argument details. This keyword will pre-pend |
| 177 | # the word "raw" plus a space to command prior to calling 'Run External |
| 178 | # IPMI Standard Command'. |
| 179 | |
| 180 | ${output}= Run External IPMI Standard Command |
| 181 | ... raw ${command} ${fail_on_err} &{options} |
| 182 | [Return] ${output} |
| 183 | |
| 184 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 185 | Check If IPMI Tool Exist |
| 186 | [Documentation] Check if IPMI Tool installed or not. |
| 187 | ${output}= Execute Command which ipmitool |
| 188 | Should Not Be Empty ${output} msg=ipmitool not installed. |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 189 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 190 | |
| 191 | Activate SOL Via IPMI |
| 192 | [Documentation] Start SOL using IPMI and route output to a file. |
George Keishing | 2620672 | 2021-11-17 01:29:53 -0600 | [diff] [blame] | 193 | [Arguments] ${file_path}=${IPMI_SOL_LOG_FILE} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 194 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 195 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 196 | # file_path The file path on the local machine (vs. |
| 197 | # OBMC) to collect SOL output. By default |
| 198 | # SOL output is collected at |
George Keishing | 2620672 | 2021-11-17 01:29:53 -0600 | [diff] [blame] | 199 | # logs/sol_<BMC_IP> else user input location. |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 200 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 201 | ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive |
| 202 | Qprint Issuing ${ipmi_cmd} |
George Keishing | 2102f6b | 2017-06-06 08:30:10 -0500 | [diff] [blame] | 203 | Start Process ${ipmi_cmd} shell=True stdout=${file_path} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 204 | ... alias=sol_proc |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 205 | |
| 206 | |
| 207 | Deactivate SOL Via IPMI |
| 208 | [Documentation] Stop SOL using IPMI and return SOL output. |
George Keishing | 2620672 | 2021-11-17 01:29:53 -0600 | [diff] [blame] | 209 | [Arguments] ${file_path}=${IPMI_SOL_LOG_FILE} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 210 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 211 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 212 | # file_path The file path on the local machine to copy |
| 213 | # SOL output collected by above "Activate |
| 214 | # SOL Via IPMI" keyword. By default it |
George Keishing | 2620672 | 2021-11-17 01:29:53 -0600 | [diff] [blame] | 215 | # copies log from logs/sol_<BMC_IP>. |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 216 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 217 | ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate |
| 218 | Qprint Issuing ${ipmi_cmd} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 219 | ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 220 | Run Keyword If ${rc} > 0 Run Keywords |
Rahul Maheshwari | 7f48a2c | 2017-06-16 04:00:26 -0500 | [diff] [blame] | 221 | ... Run Keyword And Ignore Error Terminate Process sol_proc |
| 222 | ... AND Return From Keyword ${output} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 223 | |
George Keishing | aec8b87 | 2019-07-08 23:44:08 -0500 | [diff] [blame] | 224 | ${output}= OperatingSystem.Get File ${file_path} encoding_errors=ignore |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 225 | |
| 226 | # Logging SOL output for debug purpose. |
| 227 | Log ${output} |
| 228 | |
| 229 | [Return] ${output} |
| 230 | |
| 231 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 232 | Byte Conversion |
| 233 | [Documentation] Byte Conversion method receives IPMI RAW commands as |
| 234 | ... argument in string format. |
| 235 | ... Sample argument is as follows |
| 236 | ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 |
| 237 | ... 0x00" |
| 238 | ... IPMI RAW command format is as follows |
| 239 | ... <netfn Byte> <cmd Byte> <Data Bytes..> |
| 240 | ... This method converts IPMI command format into |
| 241 | ... dbus command format as follows |
| 242 | ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> |
| 243 | ... <array:byte:data> |
| 244 | ... Sample dbus Host IPMI Received Message argument |
| 245 | ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 |
| 246 | ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 247 | [Arguments] ${args} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 248 | ${argLength}= Get Length ${args} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 249 | Set Global Variable ${arrayByte} array:byte: |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 250 | @{listargs}= Split String ${args} |
| 251 | ${index}= Set Variable ${0} |
Marissa Garza | 20ccfc7 | 2020-06-19 12:51:10 -0500 | [diff] [blame] | 252 | FOR ${word} IN @{listargs} |
| 253 | Run Keyword if ${index} == 0 Set NetFn Byte ${word} |
| 254 | Run Keyword if ${index} == 1 Set Cmd Byte ${word} |
| 255 | Run Keyword if ${index} > 1 Set Array Byte ${word} |
| 256 | ${index}= Set Variable ${index + 1} |
| 257 | END |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 258 | ${length}= Get Length ${arrayByte} |
| 259 | ${length}= Evaluate ${length} - 1 |
| 260 | ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 261 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 262 | ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 263 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} |
| 264 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} |
| 265 | ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 266 | ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 267 | # To Check scenario for smaller IPMI raw commands with only 2 arguments |
| 268 | # instead of usual 12 arguments. |
| 269 | # Sample small IPMI raw command: Run IPMI command 0x06 0x36 |
| 270 | # If IPMI raw argument length is only 9 then return value in bytes without |
| 271 | # array population. |
| 272 | # Equivalent dbus-send argument for smaller IPMI raw command: |
| 273 | # byte:0x00 byte:0x06 byte:0x00 byte:0x36 |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 274 | Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 275 | [Return] ${valueinBytesWithArray} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 276 | |
| 277 | |
| 278 | Set NetFn Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 279 | [Documentation] Set the network function byte. |
| 280 | [Arguments] ${word} |
| 281 | ${netfnByteLocal}= Catenate byte:${word} |
| 282 | Set Global Variable ${netfnByte} ${netfnByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 283 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 284 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 285 | Set Cmd Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 286 | [Documentation] Set the command byte. |
| 287 | [Arguments] ${word} |
| 288 | ${cmdByteLocal}= Catenate byte:${word} |
| 289 | Set Global Variable ${cmdByte} ${cmdByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 290 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 291 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 292 | Set Array Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 293 | [Documentation] Set the array byte. |
| 294 | [Arguments] ${word} |
| 295 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} |
| 296 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , |
| 297 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 298 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 299 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 300 | Copy ipmitool |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 301 | [Documentation] Copy the ipmitool to the BMC. |
| 302 | ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory. |
| 303 | ... It is not part of the automation code by default. You must manually copy or link the correct openbmc |
| 304 | ... version of the tool in to the tools directory in order to run this test suite. |
| 305 | |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 306 | ${response} ${stderr} ${rc}= BMC Execute Command |
| 307 | ... which ipmitool ignore_err=${1} |
| 308 | ${installed}= Get Regexp Matches ${response} ipmitool |
| 309 | Run Keyword If ${installed} == ['ipmitool'] |
| 310 | ... Run Keywords Set Suite Variable ${IPMITOOL_PATH} ${response} |
| 311 | ... AND SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 312 | ... AND SSHLibrary.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 313 | ... AND Return From Keyword |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 314 | |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 315 | OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 316 | Import Library SCPLibrary WITH NAME scp |
| 317 | scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} |
| 318 | scp.Put File tools/ipmitool /tmp |
| 319 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
George Keishing | f94de71 | 2021-11-10 13:59:44 -0600 | [diff] [blame] | 320 | SSHLibrary.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
leet | b9a29a6 | 2022-05-17 19:30:25 +0000 | [diff] [blame] | 321 | Execute Command chmod +x ${IPMITOOL_PATH} |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 322 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 323 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 324 | Initiate Host Boot Via External IPMI |
| 325 | [Documentation] Initiate host power on using external IPMI. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 326 | [Arguments] ${wait}=${1} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 327 | |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 328 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 329 | # wait Indicates that this keyword should wait |
| 330 | # for host running state. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 331 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 332 | ${output}= Run External IPMI Standard Command chassis power on |
| 333 | Should Not Contain ${output} Error |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 334 | |
| 335 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 336 | Wait Until Keyword Succeeds 10 min 10 sec Is Host Running |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 337 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 338 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 339 | Initiate Host PowerOff Via External IPMI |
| 340 | [Documentation] Initiate host power off using external IPMI. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 341 | [Arguments] ${wait}=${1} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 342 | |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 343 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 344 | # wait Indicates that this keyword should wait |
| 345 | # for host off state. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 346 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 347 | ${output}= Run External IPMI Standard Command chassis power off |
| 348 | Should Not Contain ${output} Error |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 349 | |
| 350 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 351 | Wait Until Keyword Succeeds 3 min 10 sec Is Host Off |
| 352 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 353 | |
Rahul Maheshwari | 460778d | 2020-02-23 22:37:22 -0600 | [diff] [blame] | 354 | Is Host Off Via IPMI |
| 355 | [Documentation] Verify if the Host is off using IPMI command. |
| 356 | |
| 357 | ${status}= Run External IPMI Standard Command chassis power status |
| 358 | Should Contain ${status} off |
| 359 | |
| 360 | |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 361 | Get Host State Via External IPMI |
| 362 | [Documentation] Returns host state using external IPMI. |
| 363 | |
| 364 | ${output}= Run External IPMI Standard Command chassis power status |
| 365 | Should Not Contain ${output} Error |
| 366 | ${output}= Fetch From Right ${output} ${SPACE} |
| 367 | |
| 368 | [Return] ${output} |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 369 | |
| 370 | |
| 371 | Set BMC Network From Host |
| 372 | [Documentation] Set BMC network from host. |
| 373 | [Arguments] ${nw_info} |
| 374 | |
| 375 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 376 | # nw_info A dictionary containing the network |
| 377 | # information to apply. |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 378 | |
| 379 | Run Inband IPMI Standard Command |
| 380 | ... lan set 1 ipaddr ${nw_info['IP Address']} |
| 381 | |
| 382 | Run Inband IPMI Standard Command |
| 383 | ... lan set 1 netmask ${nw_info['Subnet Mask']} |
| 384 | |
| 385 | Run Inband IPMI Standard Command |
| 386 | ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']} |
Rahul Maheshwari | c3d1e96 | 2019-03-06 23:53:21 -0600 | [diff] [blame] | 387 | |
| 388 | |
| 389 | Verify IPMI Username And Password |
| 390 | [Documentation] Verify that user is able to run IPMI command |
| 391 | ... with given username and password. |
| 392 | [Arguments] ${username} ${password} |
| 393 | |
| 394 | # Description of argument(s): |
| 395 | # username The user name (e.g. "root", "robert", etc.). |
| 396 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 397 | |
Tony Lee | f9379e8 | 2020-01-08 18:20:38 +0800 | [diff] [blame] | 398 | ${output}= Wait Until Keyword Succeeds 15 sec 5 sec Run External IPMI Standard Command |
Rahul Maheshwari | c3d1e96 | 2019-03-06 23:53:21 -0600 | [diff] [blame] | 399 | ... sel info U=${username} P=${password} |
| 400 | Should Contain ${output} SEL Information msg=SEL information not present |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 401 | |
| 402 | |
| 403 | IPMI Create User |
| 404 | [Documentation] Create IPMI user with given userid and username. |
| 405 | [Arguments] ${userid} ${username} |
| 406 | |
| 407 | # Description of argument(s): |
| 408 | # userid The user ID (e.g. "1", "2", etc.). |
| 409 | # username The user name (e.g. "root", "robert", etc.). |
| 410 | |
| 411 | ${ipmi_cmd}= Catenate user set name ${userid} ${username} |
| 412 | ${resp}= Run IPMI Standard Command ${ipmi_cmd} |
| 413 | ${user_info}= Get User Info ${userid} |
| 414 | Should Be Equal ${user_info['user_name']} ${username} |
| 415 | |
| 416 | |
nagarjunb22 | a2255de | 2022-05-25 19:15:10 +0530 | [diff] [blame] | 417 | Enable IPMI User And Verify |
| 418 | [Documentation] Enable the userid and verify that it has been enabled. |
| 419 | [Arguments] ${userid} |
| 420 | |
| 421 | # Description of argument(s): |
| 422 | # userid A numeric userid (e.g. "4"). |
| 423 | |
| 424 | Run IPMI Standard Command user enable ${userid} |
| 425 | ${user_info}= Get User Info ${userid} |
| 426 | Valid Value user_info['enable_status'] ['enabled'] |
| 427 | |
| 428 | |
| 429 | Create Random IPMI User |
| 430 | [Documentation] Create IPMI user with random username and userid and return those fields. |
| 431 | |
| 432 | ${random_username}= Generate Random String 8 [LETTERS] |
| 433 | ${random_userid}= Evaluate random.randint(2, 15) modules=random |
| 434 | IPMI Create User ${random_userid} ${random_username} |
| 435 | [Return] ${random_userid} ${random_username} |
| 436 | |
| 437 | |
| 438 | Delete Created User |
| 439 | [Documentation] Delete created IPMI user. |
| 440 | [Arguments] ${userid} |
| 441 | # Description of argument(s): |
| 442 | # userid The user ID (e.g. "1", "2", etc.). |
| 443 | |
| 444 | Run IPMI Standard Command user set name ${userid} "" |
| 445 | Sleep 5s |
| 446 | |
| 447 | |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 448 | Set Channel Access |
| 449 | [Documentation] Verify that user is able to run IPMI command |
| 450 | ... with given username and password. |
Tony Lee | 7c5f4b2 | 2019-12-06 17:21:31 +0800 | [diff] [blame] | 451 | [Arguments] ${userid} ${options} ${channel_number}=${CHANNEL_NUMBER} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 452 | |
| 453 | # Description of argument(s): |
| 454 | # userid The user ID (e.g. "1", "2", etc.). |
| 455 | # options Set channel command options (e.g. |
| 456 | # "link=on", "ipmi=on", etc.). |
| 457 | # channel_number The user's channel number (e.g. "1"). |
| 458 | |
| 459 | ${ipmi_cmd}= Catenate SEPARATOR= |
Tony Lee | 7c5f4b2 | 2019-12-06 17:21:31 +0800 | [diff] [blame] | 460 | ... channel setaccess${SPACE}${channel_number}${SPACE}${userid} |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 461 | ... ${SPACE}${options} |
| 462 | Run IPMI Standard Command ${ipmi_cmd} |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 463 | |
| 464 | |
| 465 | Delete All Non Root IPMI User |
| 466 | [Documentation] Delete all non-root IPMI user. |
| 467 | |
Michael Walsh | 34c79af | 2019-12-09 11:46:48 -0600 | [diff] [blame] | 468 | # Get complete list of user info records. |
| 469 | ${user_info}= Get User Info ${EMPTY} |
| 470 | # Remove header record. |
| 471 | ${user_info}= Filter Struct ${user_info} [('user_name', None)] invert=1 |
| 472 | ${non_empty_user_info}= Filter Struct ${user_info} [('user_name', '')] invert=1 |
| 473 | ${non_root_user_info}= Filter Struct ${non_empty_user_info} [('user_name', 'root')] invert=1 |
| 474 | |
| 475 | FOR ${user_record} IN @{non_root_user_info} |
| 476 | Run IPMI Standard Command user set name ${user_record['user_id']} "" |
| 477 | Sleep 5s |
Rahul Maheshwari | 460778d | 2020-02-23 22:37:22 -0600 | [diff] [blame] | 478 | END |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 479 | |
| 480 | |
| 481 | Create SEL |
| 482 | [Documentation] Create a SEL. |
| 483 | [Arguments] ${sensor_type} ${sensor_number} |
| 484 | |
| 485 | # Create a SEL. |
| 486 | # Example: |
| 487 | # a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 | | Asserted |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 488 | # Description of argument(s): |
| 489 | # ${sensor_type} Type of the sensor used in hexadecimal (can be fan, temp etc.,), |
| 490 | # obtained from Sensor Type field in - ipmitool sdr get "sensor_name". |
| 491 | # Example: Sensor Type (Threshold) : Fan (0x04), here 0xHH is sensor type. |
| 492 | |
| 493 | # ${sensor_number} Sensor number of the sensor in hexadecimal. |
| 494 | # obtained from Sensor ID field in - ipmitool sdr get "sensor_name". |
| 495 | # Example: Sensor ID : SENSOR_1 (0xHH), here 0xHH is sensor number. |
| 496 | |
| 497 | ${resp}= Run IPMI Command |
| 498 | ... ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][0]} 0x${sensor_type} 0x${sensor_number} ${IPMI_RAW_CMD['SEL_entry']['Create_SEL'][1]} |
| 499 | |
chithrag | d7e009b | 2022-03-01 12:20:57 +0000 | [diff] [blame] | 500 | Should Not Contain ${resp} 00 00 msg=SEL not created. |
| 501 | |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 502 | [Return] ${resp} |
| 503 | |
| 504 | |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 505 | Fetch One Threshold Sensor From Sensor List |
| 506 | [Documentation] Fetch one threshold sensor randomly from Sensor list. |
ganesanb | d282b56 | 2022-05-11 20:30:52 +0530 | [diff] [blame] | 507 | |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 508 | @{sensor_name_list}= Create List |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 509 | |
| 510 | ${resp}= Run IPMI Standard Command sensor |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 511 | @{sensor_list}= Split To Lines ${resp} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 512 | |
ganesanb | d282b56 | 2022-05-11 20:30:52 +0530 | [diff] [blame] | 513 | # Omit the discrete sensor and create an threshold sensor name list |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 514 | FOR ${sensor} IN @{sensor_list} |
ganesanb | d282b56 | 2022-05-11 20:30:52 +0530 | [diff] [blame] | 515 | ${discrete_sensor_status}= Run Keyword And Return Status Should Contain ${sensor} discrete |
| 516 | Continue For Loop If '${discrete_sensor_status}' == 'True' |
| 517 | ${sensor_details}= Split String ${sensor} | |
| 518 | ${get_sensor_name}= Get From List ${sensor_details} 0 |
| 519 | ${sensor_name}= Set Variable ${get_sensor_name.strip()} |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 520 | Append To List ${sensor_name_list} ${sensor_name} |
ganesanb | d282b56 | 2022-05-11 20:30:52 +0530 | [diff] [blame] | 521 | END |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 522 | |
ganesanb | ebea55f | 2022-08-29 10:54:38 +0000 | [diff] [blame] | 523 | ${random_sensor_name}= Evaluate random.choice(${sensor_name_list}) random |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 524 | |
ganesanb | d282b56 | 2022-05-11 20:30:52 +0530 | [diff] [blame] | 525 | [Return] ${random_sensor_name} |
chithrag | 0a8c878 | 2022-03-01 12:35:00 +0000 | [diff] [blame] | 526 | |
| 527 | Fetch Sensor Details From SDR |
| 528 | [Documentation] Identify the sensors from sdr get and fetch sensor details required. |
| 529 | [Arguments] ${sensor_name} ${setting} |
| 530 | |
| 531 | # Description of argument(s): |
| 532 | # ${sensor_number} Sensor number of the sensor in hexadecimal. |
| 533 | # obtained sensor name from - 'ipmitool sensor' command. |
| 534 | # Example: a | 02/14/2020 | 01:16:58 | Sensor_type #0x17 | | Asserted |
| 535 | # here, a is the sensor name. |
| 536 | |
| 537 | # ${setting} Field to fetch data. Example : Sensor ID, Sensor Type (Threshold), etc,. |
| 538 | |
| 539 | ${resp}= Run IPMI Standard Command sdr get "${sensor_name}" |
| 540 | |
| 541 | ${setting_line}= Get Lines Containing String ${resp} ${setting} |
| 542 | ... case-insensitive |
| 543 | ${setting_status}= Fetch From Right ${setting_line} :${SPACE} |
| 544 | |
| 545 | [Return] ${setting_status} |
| 546 | |
| 547 | |
| 548 | Get Data And Byte From SDR Sensor |
| 549 | [Documentation] Fetch the Field Data and hexadecimal values from given details. |
| 550 | [Arguments] ${sensor_detail} |
| 551 | |
| 552 | # Description of argument(s): |
| 553 | # ${sensor_detail} Requested field and the value from the sdr get ipmi command. |
| 554 | # Example : if Sensor ID is the requesting setting, then, |
| 555 | # ${sensor_detail} will be "Sensor ID : SENSOR_1 (0xHH)" |
| 556 | |
| 557 | ${sensor_detail}= Split String ${sensor_detail} (0x |
| 558 | ${field_data}= Set Variable ${sensor_detail[0]} |
| 559 | ${field_data}= Remove Whitespace ${field_data} |
| 560 | ${sensor_hex}= Replace String ${sensor_detail[1]} ) ${EMPTY} |
| 561 | ${sensor_hex}= Zfill Data ${sensor_hex} 2 |
| 562 | |
| 563 | [Return] ${field_data} ${sensor_hex} |
| 564 | |
| 565 | |
| 566 | Get Current Date from BMC |
| 567 | [Documentation] Runs the date command from BMC and returns current date and time |
| 568 | |
| 569 | # Get Current Date from BMC |
| 570 | ${date} ${stderr} ${rc}= BMC Execute Command date |
| 571 | |
| 572 | # Split the string and remove first and 2nd last value from the list and join to form %d %b %H:%M:%S %Y date format |
| 573 | ${date}= Split String ${date} |
| 574 | Remove From List ${date} 0 |
| 575 | Remove From List ${date} -2 |
| 576 | ${date}= Evaluate " ".join(${date}) |
| 577 | |
| 578 | # Convert the date format to %m/%d/%Y %H:%M:%S |
| 579 | ${date}= Convert Date ${date} date_format=%b %d %H:%M:%S %Y result_format=%m/%d/%Y %H:%M:%S exclude_millis=True |
| 580 | |
| 581 | [Return] ${date} |
chithrag | d7e009b | 2022-03-01 12:20:57 +0000 | [diff] [blame] | 582 | |
| 583 | |
| 584 | Get SEL Info Via IPMI |
| 585 | [Documentation] Get the SEL Info via IPMI raw command |
| 586 | |
| 587 | # Get SEL Info response consist of 14 bytes of hexadecimal data. |
| 588 | |
| 589 | # Byte 1 - SEL Version, |
| 590 | # Byte 2 & 3 - Entry bytes - LSB MSB, |
| 591 | # Byte 4 & 5 - Free Space in bytes, LS Byte first. |
| 592 | # Byte 6 - 9 - Most recent addition timestamp, |
| 593 | # Byte 10-13 - Most recent erase timestamp, |
| 594 | # Byte 14 - Operation Support |
| 595 | |
| 596 | # Example: ${resp} will be "51 XX XX XX XX ff ff ff ff ff ff ff ff XX" |
| 597 | |
| 598 | ${resp}= Run IPMI Standard Command |
| 599 | ... raw ${IPMI_RAW_CMD['SEL_entry']['SEL_info'][0]} |
| 600 | ${resp}= Split String ${resp} |
| 601 | |
| 602 | [Return] ${resp} |
nagarjunb22 | 7fabf79 | 2022-04-19 11:09:29 +0530 | [diff] [blame] | 603 | |
| 604 | |
| 605 | Verify Invalid IPMI Command |
| 606 | [Documentation] Execute invalid IPMI command and verify with given response code. |
| 607 | [Arguments] ${ipmi_cmd} ${error_code}=0xc9 |
| 608 | |
| 609 | # Description Of Arguments. |
| 610 | # ${ipmi_cmd} - IPMI raw cmd with invalid data length. |
| 611 | # ${error_code} - Expected error code e.g 0xc7, 0xcc. |
| 612 | |
| 613 | ${resp}= Run External IPMI Raw Command ${ipmi_cmd} fail_on_err=0 |
| 614 | |
ganesanb | c288aff | 2022-05-19 19:55:47 +0530 | [diff] [blame] | 615 | Should Contain ${resp} rsp=${error_code} |
| 616 | |
| 617 | |
| 618 | Identify Request Data |
| 619 | [Documentation] Convert text from variable declared to request data. |
| 620 | [Arguments] ${string} |
| 621 | |
| 622 | # Convert string to hexadecimal data for each character. |
| 623 | # Return the hex data with prefix of 0x as string and list of hex data. |
| 624 | # Description of argument(s): |
| 625 | # string Any string to be converted to hex. |
| 626 | |
| 627 | # Given a string, convert to hexadecimal and prefix with 0x |
| 628 | ${hex1}= Create List |
| 629 | ${hex2}= Create List |
| 630 | ${resp_data}= Split String With Index ${string} 1 |
| 631 | FOR ${data} IN @{resp_data} |
| 632 | # prefixes 0x by default |
| 633 | ${hex_value}= Evaluate hex(ord("${data}")) |
| 634 | # prefixes string with bytes prefixed 0x by default |
| 635 | Append To List ${hex1} ${hex_value} |
| 636 | # provides only hexadecimal bytes |
| 637 | ${hex}= Evaluate hex(ord("${data}"))[2:] |
| 638 | # provides string with only hexadecimal bytes |
| 639 | Append To List ${hex2} ${hex} |
| 640 | END |
| 641 | ${hex1}= Evaluate " ".join(${hex1}) |
| 642 | |
| 643 | # ${hex1} will contains the data to write for fru in list. |
| 644 | # ${hex2} will contains the data to verify fru after write operation completed. |
| 645 | |
| 646 | [Return] ${hex1} ${hex2} |