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