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 | 19621ba | 2018-12-03 17:16:02 -0600 | [diff] [blame] | 11 | Library ipmi_client.py |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 12 | |
| 13 | *** Variables *** |
George Keishing | d7f11f7 | 2017-01-04 10:58:19 -0600 | [diff] [blame] | 14 | ${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1 |
| 15 | ${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 16 | ${netfnByte}= ${EMPTY} |
George Keishing | d7f11f7 | 2017-01-04 10:58:19 -0600 | [diff] [blame] | 17 | ${cmdByte}= ${EMPTY} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 18 | ${arrayByte}= array:byte: |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 19 | ${IPMI_USER_OPTIONS} ${EMPTY} |
George Keishing | 39967eb | 2018-04-30 11:36:23 -0500 | [diff] [blame] | 20 | ${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 21 | ${HOST}= -H |
| 22 | ${RAW}= raw |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 23 | |
| 24 | *** Keywords *** |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 25 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 26 | Run IPMI Command |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 27 | [Documentation] Run the raw IPMI command. |
| 28 | [Arguments] ${command} ${fail_on_err}=${1} &{options} |
| 29 | |
| 30 | # Description of argument(s): |
| 31 | # command The IPMI command string to be executed |
| 32 | # (e.g. "power status"). |
| 33 | # fail_on_err Fail if the IPMI command execution fails. |
| 34 | # options Additional ipmitool command options (e.g. |
| 35 | # -C=3, -I=lanplus, etc.). Currently, only |
| 36 | # used for external IPMI commands. |
| 37 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 38 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 39 | ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 40 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 41 | ... Run Inband IPMI Raw Command ${command} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 42 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 43 | ... Run Dbus IPMI RAW Command ${command} |
| 44 | ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 45 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 46 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 47 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 48 | Run IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 49 | [Documentation] Run the standard IPMI command. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 50 | [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 51 | |
| 52 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 53 | # command The IPMI command string to be executed |
| 54 | # (e.g. "0x06 0x36"). |
| 55 | # fail_on_err Fail if the IPMI command execution fails. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 56 | # expected_rc The expected return code from the ipmi |
| 57 | # command (e.g. ${0}, ${1}, etc.). |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 58 | # options Additional ipmitool command options (e.g. |
| 59 | # -C=3, -I=lanplus, etc.). Currently, only |
| 60 | # used for external IPMI commands. |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 61 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 62 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 63 | ... Run External IPMI Standard Command ${command} ${fail_on_err} ${expected_rc} &{options} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 64 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 65 | ... Run Inband IPMI Standard Command ${command} ${fail_on_err} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 66 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 67 | ... Run Dbus IPMI Standard Command ${command} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 68 | ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 69 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 70 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 71 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 72 | Run Dbus IPMI RAW Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 73 | [Documentation] Run the raw IPMI command through dbus. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 74 | [Arguments] ${command} |
| 75 | ${valueinBytes}= Byte Conversion ${command} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 76 | ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} |
| 77 | ${cmd}= Catenate ${cmd} ${valueinBytes} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 78 | ${output} ${stderr}= Execute Command ${cmd} return_stderr=True |
| 79 | Should Be Empty ${stderr} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 80 | set test variable ${OUTPUT} "${output}" |
| 81 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 82 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 83 | Run Dbus IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 84 | [Documentation] Run the standard IPMI command through dbus. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 85 | [Arguments] ${command} |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 86 | Copy ipmitool |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 87 | ${stdout} ${stderr} ${output}= Execute Command |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 88 | ... /tmp/ipmitool -I dbus ${command} return_stdout=True |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 89 | ... return_stderr= True return_rc=True |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 90 | Should Be Equal ${output} ${0} msg=${stderr} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 91 | [Return] ${stdout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 92 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 93 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 94 | Run Inband IPMI Raw Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 95 | [Documentation] Run the raw IPMI command in-band. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 96 | [Arguments] ${command} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 97 | ... ${os_password}=${OS_PASSWORD} |
| 98 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 99 | # Description of argument(s): |
| 100 | # command The IPMI command string to be executed |
| 101 | # (e.g. "0x06 0x36"). |
| 102 | # os_host The host name or IP address of the OS Host. |
| 103 | # os_username The OS host user name. |
| 104 | # os_password The OS host passwrd. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 105 | |
| 106 | Login To OS Host ${os_host} ${os_username} ${os_password} |
| 107 | Check If IPMI Tool Exist |
| 108 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 109 | ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${command} |
| 110 | Qprint Issuing ${ipmi_cmd} |
| 111 | ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 112 | Should Be Empty ${stderr} msg=${stdout} |
| 113 | [Return] ${stdout} |
| 114 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 115 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 116 | Run Inband IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 117 | [Documentation] Run the standard IPMI command in-band. |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 118 | [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST} |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 119 | ... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD} |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 120 | ... ${login_host}=${1} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 121 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 122 | # Description of argument(s): |
| 123 | # command The IPMI command string to be executed |
| 124 | # (e.g. "power status"). |
| 125 | # os_host The host name or IP address of the OS Host. |
| 126 | # os_username The OS host user name. |
| 127 | # os_password The OS host passwrd. |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 128 | # login_host Indicates that this keyword should login to host OS. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 129 | |
Naman Navin Hegde | 9e8c0d8 | 2019-08-11 15:22:44 -0500 | [diff] [blame] | 130 | Run Keyword If ${login_host} == ${1} |
| 131 | ... Login To OS Host ${os_host} ${os_username} ${os_password} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 132 | Check If IPMI Tool Exist |
| 133 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 134 | ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command} |
| 135 | Qprint Issuing ${ipmi_cmd} |
| 136 | ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 137 | Return From Keyword If ${fail_on_err} == ${0} ${stderr} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 138 | Should Be Empty ${stderr} msg=${stdout} |
| 139 | [Return] ${stdout} |
| 140 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 141 | |
| 142 | Run External IPMI Standard Command |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 143 | [Documentation] Run the external IPMI standard command. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 144 | [Arguments] ${command} ${fail_on_err}=${1} ${expected_rc}=${0} &{options} |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 145 | |
| 146 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 147 | # command The IPMI command string to be executed |
| 148 | # (e.g. "power status"). Note that if |
| 149 | # ${IPMI_USER_OPTIONS} has a value (e.g. |
| 150 | # "-vvv"), it will be pre-pended to this |
| 151 | # command string. |
| 152 | # fail_on_err Fail if the IPMI command execution fails. |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 153 | # expected_rc The expected return code from the ipmi |
| 154 | # command (e.g. ${0}, ${1}, etc.). |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 155 | # options Additional ipmitool command options (e.g. |
| 156 | # -C=3, -I=lanplus, etc.). |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 157 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 158 | ${command_string}= Process IPMI User Options ${command} |
| 159 | ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options} |
| 160 | Qprint Issuing ${ipmi_cmd} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 161 | ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd} |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 162 | Return From Keyword If ${fail_on_err} == ${0} ${output} |
Michael Walsh | d0e58e7 | 2019-05-14 11:07:14 -0500 | [diff] [blame] | 163 | Should Be Equal ${rc} ${expected_rc} msg=${output} |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 164 | [Return] ${output} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 165 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 166 | |
| 167 | Run External IPMI Raw Command |
| 168 | [Documentation] Run the external IPMI raw command. |
| 169 | [Arguments] ${command} ${fail_on_err}=${1} &{options} |
| 170 | |
| 171 | # This keyword is a wrapper for 'Run External IPMI Standard Command'. See |
| 172 | # that keyword's prolog for argument details. This keyword will pre-pend |
| 173 | # the word "raw" plus a space to command prior to calling 'Run External |
| 174 | # IPMI Standard Command'. |
| 175 | |
| 176 | ${output}= Run External IPMI Standard Command |
| 177 | ... raw ${command} ${fail_on_err} &{options} |
| 178 | [Return] ${output} |
| 179 | |
| 180 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 181 | Check If IPMI Tool Exist |
| 182 | [Documentation] Check if IPMI Tool installed or not. |
| 183 | ${output}= Execute Command which ipmitool |
| 184 | Should Not Be Empty ${output} msg=ipmitool not installed. |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 185 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 186 | |
| 187 | Activate SOL Via IPMI |
| 188 | [Documentation] Start SOL using IPMI and route output to a file. |
| 189 | [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 190 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 191 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 192 | # file_path The file path on the local machine (vs. |
| 193 | # OBMC) to collect SOL output. By default |
| 194 | # SOL output is collected at |
| 195 | # /tmp/sol_<BMC_IP> else user input location. |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 196 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 197 | ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive |
| 198 | Qprint Issuing ${ipmi_cmd} |
George Keishing | 2102f6b | 2017-06-06 08:30:10 -0500 | [diff] [blame] | 199 | Start Process ${ipmi_cmd} shell=True stdout=${file_path} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 200 | ... alias=sol_proc |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 201 | |
| 202 | |
| 203 | Deactivate SOL Via IPMI |
| 204 | [Documentation] Stop SOL using IPMI and return SOL output. |
| 205 | [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 206 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 207 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 208 | # file_path The file path on the local machine to copy |
| 209 | # SOL output collected by above "Activate |
| 210 | # SOL Via IPMI" keyword. By default it |
| 211 | # copies log from /tmp/sol_<BMC_IP>. |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 212 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 213 | ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate |
| 214 | Qprint Issuing ${ipmi_cmd} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 215 | ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 216 | Run Keyword If ${rc} > 0 Run Keywords |
Rahul Maheshwari | 7f48a2c | 2017-06-16 04:00:26 -0500 | [diff] [blame] | 217 | ... Run Keyword And Ignore Error Terminate Process sol_proc |
| 218 | ... AND Return From Keyword ${output} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 219 | |
George Keishing | aec8b87 | 2019-07-08 23:44:08 -0500 | [diff] [blame] | 220 | ${output}= OperatingSystem.Get File ${file_path} encoding_errors=ignore |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 221 | |
| 222 | # Logging SOL output for debug purpose. |
| 223 | Log ${output} |
| 224 | |
| 225 | [Return] ${output} |
| 226 | |
| 227 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 228 | Byte Conversion |
| 229 | [Documentation] Byte Conversion method receives IPMI RAW commands as |
| 230 | ... argument in string format. |
| 231 | ... Sample argument is as follows |
| 232 | ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 |
| 233 | ... 0x00" |
| 234 | ... IPMI RAW command format is as follows |
| 235 | ... <netfn Byte> <cmd Byte> <Data Bytes..> |
| 236 | ... This method converts IPMI command format into |
| 237 | ... dbus command format as follows |
| 238 | ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> |
| 239 | ... <array:byte:data> |
| 240 | ... Sample dbus Host IPMI Received Message argument |
| 241 | ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 |
| 242 | ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 243 | [Arguments] ${args} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 244 | ${argLength}= Get Length ${args} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 245 | Set Global Variable ${arrayByte} array:byte: |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 246 | @{listargs}= Split String ${args} |
| 247 | ${index}= Set Variable ${0} |
George Keishing | 9a08944 | 2018-12-10 09:38:50 -0600 | [diff] [blame] | 248 | :FOR ${word} IN @{listargs} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 249 | \ Run Keyword if ${index} == 0 Set NetFn Byte ${word} |
| 250 | \ Run Keyword if ${index} == 1 Set Cmd Byte ${word} |
| 251 | \ Run Keyword if ${index} > 1 Set Array Byte ${word} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 252 | \ ${index}= Set Variable ${index + 1} |
| 253 | ${length}= Get Length ${arrayByte} |
| 254 | ${length}= Evaluate ${length} - 1 |
| 255 | ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 256 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 257 | ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 258 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} |
| 259 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} |
| 260 | ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 261 | ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 262 | # To Check scenario for smaller IPMI raw commands with only 2 arguments |
| 263 | # instead of usual 12 arguments. |
| 264 | # Sample small IPMI raw command: Run IPMI command 0x06 0x36 |
| 265 | # If IPMI raw argument length is only 9 then return value in bytes without |
| 266 | # array population. |
| 267 | # Equivalent dbus-send argument for smaller IPMI raw command: |
| 268 | # byte:0x00 byte:0x06 byte:0x00 byte:0x36 |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 269 | Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 270 | [Return] ${valueinBytesWithArray} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 271 | |
| 272 | |
| 273 | Set NetFn Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 274 | [Documentation] Set the network function byte. |
| 275 | [Arguments] ${word} |
| 276 | ${netfnByteLocal}= Catenate byte:${word} |
| 277 | Set Global Variable ${netfnByte} ${netfnByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 278 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 279 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 280 | Set Cmd Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 281 | [Documentation] Set the command byte. |
| 282 | [Arguments] ${word} |
| 283 | ${cmdByteLocal}= Catenate byte:${word} |
| 284 | Set Global Variable ${cmdByte} ${cmdByteLocal} |
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 Array Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 288 | [Documentation] Set the array byte. |
| 289 | [Arguments] ${word} |
| 290 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} |
| 291 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , |
| 292 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 293 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 294 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 295 | Copy ipmitool |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 296 | [Documentation] Copy the ipmitool to the BMC. |
| 297 | ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory. |
| 298 | ... It is not part of the automation code by default. You must manually copy or link the correct openbmc |
| 299 | ... version of the tool in to the tools directory in order to run this test suite. |
| 300 | |
| 301 | OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 302 | |
| 303 | Import Library SCPLibrary WITH NAME scp |
| 304 | scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} |
| 305 | scp.Put File tools/ipmitool /tmp |
| 306 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 307 | Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 308 | Execute Command chmod +x /tmp/ipmitool |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 309 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 310 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 311 | Initiate Host Boot Via External IPMI |
| 312 | [Documentation] Initiate host power on using external IPMI. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 313 | [Arguments] ${wait}=${1} |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 314 | |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 315 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 316 | # wait Indicates that this keyword should wait |
| 317 | # for host running state. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 318 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 319 | ${output}= Run External IPMI Standard Command chassis power on |
| 320 | Should Not Contain ${output} Error |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 321 | |
| 322 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 323 | Wait Until Keyword Succeeds 10 min 10 sec Is Host Running |
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 PowerOff Via External IPMI |
| 327 | [Documentation] Initiate host power off 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 off 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 off |
| 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 3 min 10 sec Is Host Off |
| 339 | |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 340 | |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 341 | Get Host State Via External IPMI |
| 342 | [Documentation] Returns host state using external IPMI. |
| 343 | |
| 344 | ${output}= Run External IPMI Standard Command chassis power status |
| 345 | Should Not Contain ${output} Error |
| 346 | ${output}= Fetch From Right ${output} ${SPACE} |
| 347 | |
| 348 | [Return] ${output} |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 349 | |
| 350 | |
| 351 | Set BMC Network From Host |
| 352 | [Documentation] Set BMC network from host. |
| 353 | [Arguments] ${nw_info} |
| 354 | |
| 355 | # Description of argument(s): |
Michael Walsh | 3ef2e92 | 2019-01-23 10:40:16 -0600 | [diff] [blame] | 356 | # nw_info A dictionary containing the network |
| 357 | # information to apply. |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 358 | |
| 359 | Run Inband IPMI Standard Command |
| 360 | ... lan set 1 ipaddr ${nw_info['IP Address']} |
| 361 | |
| 362 | Run Inband IPMI Standard Command |
| 363 | ... lan set 1 netmask ${nw_info['Subnet Mask']} |
| 364 | |
| 365 | Run Inband IPMI Standard Command |
| 366 | ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']} |
Rahul Maheshwari | c3d1e96 | 2019-03-06 23:53:21 -0600 | [diff] [blame] | 367 | |
| 368 | |
| 369 | Verify IPMI Username And Password |
| 370 | [Documentation] Verify that user is able to run IPMI command |
| 371 | ... with given username and password. |
| 372 | [Arguments] ${username} ${password} |
| 373 | |
| 374 | # Description of argument(s): |
| 375 | # username The user name (e.g. "root", "robert", etc.). |
| 376 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 377 | |
| 378 | ${output}= Run External IPMI Standard Command |
| 379 | ... sel info U=${username} P=${password} |
| 380 | Should Contain ${output} SEL Information msg=SEL information not present |
Rahul Maheshwari | 75e91fe | 2019-03-29 05:32:28 -0500 | [diff] [blame] | 381 | |
| 382 | |
| 383 | IPMI Create User |
| 384 | [Documentation] Create IPMI user with given userid and username. |
| 385 | [Arguments] ${userid} ${username} |
| 386 | |
| 387 | # Description of argument(s): |
| 388 | # userid The user ID (e.g. "1", "2", etc.). |
| 389 | # username The user name (e.g. "root", "robert", etc.). |
| 390 | |
| 391 | ${ipmi_cmd}= Catenate user set name ${userid} ${username} |
| 392 | ${resp}= Run IPMI Standard Command ${ipmi_cmd} |
| 393 | ${user_info}= Get User Info ${userid} |
| 394 | Should Be Equal ${user_info['user_name']} ${username} |
| 395 | |
| 396 | |
| 397 | Set Channel Access |
| 398 | [Documentation] Verify that user is able to run IPMI command |
| 399 | ... with given username and password. |
| 400 | [Arguments] ${userid} ${options} ${channel}=1 |
| 401 | |
| 402 | # Description of argument(s): |
| 403 | # userid The user ID (e.g. "1", "2", etc.). |
| 404 | # options Set channel command options (e.g. |
| 405 | # "link=on", "ipmi=on", etc.). |
| 406 | # channel_number The user's channel number (e.g. "1"). |
| 407 | |
| 408 | ${ipmi_cmd}= Catenate SEPARATOR= |
| 409 | ... channel setaccess${SPACE}${channel}${SPACE}${userid} |
| 410 | ... ${SPACE}${options} |
| 411 | Run IPMI Standard Command ${ipmi_cmd} |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 412 | |
| 413 | |
| 414 | Delete All Non Root IPMI User |
| 415 | [Documentation] Delete all non-root IPMI user. |
| 416 | |
| 417 | FOR ${userid} IN RANGE 2 16 |
| 418 | ${user_info}= Get User Info ${userid} |
| 419 | Run Keyword If "${user_info['user_name']}" != "" |
| 420 | ... Run IPMI Standard Command user set name ${userid} "" |
Rahul Maheshwari | bb3d21c | 2019-07-23 01:08:19 -0500 | [diff] [blame] | 421 | Sleep 5s |
Rahul Maheshwari | 3e61ce6 | 2019-06-18 02:09:01 -0500 | [diff] [blame] | 422 | END |