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 |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 5 | Resource ../lib/resource.txt |
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 | 19621ba | 2018-12-03 17:16:02 -0600 | [diff] [blame] | 19 | ${IPMI_EXT_CMD} ${EMPTY} |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 20 | ${IPMI_USER_OPTIONS} ${EMPTY} |
George Keishing | 39967eb | 2018-04-30 11:36:23 -0500 | [diff] [blame] | 21 | ${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 22 | ${HOST}= -H |
| 23 | ${RAW}= raw |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 24 | |
| 25 | *** Keywords *** |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 26 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 27 | Run IPMI Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 28 | [Documentation] Run the given IPMI command. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 29 | [Arguments] ${args} |
| 30 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 31 | ... Run External IPMI Raw Command ${args} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 32 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 33 | ... Run Inband IPMI Raw Command ${args} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 34 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
| 35 | ... Run Dbus IPMI RAW Command ${args} |
| 36 | ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} |
| 37 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 38 | |
| 39 | Run IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 40 | [Documentation] Run the standard IPMI command. |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 41 | [Arguments] ${args} ${fail_on_err}=${1} |
| 42 | |
| 43 | # Description of argument(s): |
| 44 | # args IPMI command to be executed. |
| 45 | # fail_on_err Fail if keyword the IPMI command fails |
| 46 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 47 | ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External' |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 48 | ... Run External IPMI Standard Command ${args} ${fail_on_err} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 49 | ... ELSE IF '${IPMI_COMMAND}' == 'Inband' |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 50 | ... Run Inband IPMI Standard Command ${args} ${fail_on_err} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 51 | ... ELSE IF '${IPMI_COMMAND}' == 'Dbus' |
| 52 | ... Run Dbus IPMI Standard Command ${args} |
| 53 | ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 54 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 55 | [Return] ${resp} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 56 | |
| 57 | Run Dbus IPMI RAW Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 58 | [Documentation] Run the raw IPMI command through dbus. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 59 | [Arguments] ${args} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 60 | ${valueinBytes}= Byte Conversion ${args} |
| 61 | ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg} |
| 62 | ${cmd}= Catenate ${cmd} ${valueinBytes} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 63 | ${output} ${stderr}= Execute Command ${cmd} return_stderr=True |
| 64 | Should Be Empty ${stderr} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 65 | set test variable ${OUTPUT} "${output}" |
| 66 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 67 | Run Dbus IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 68 | [Documentation] Run the standard IPMI command through dbus. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 69 | [Arguments] ${args} |
George Keishing | 4d6c1da | 2016-07-15 05:51:22 -0500 | [diff] [blame] | 70 | Copy ipmitool |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 71 | ${stdout} ${stderr} ${output}= Execute Command |
| 72 | ... /tmp/ipmitool -I dbus ${args} return_stdout=True |
| 73 | ... return_stderr= True return_rc=True |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 74 | Should Be Equal ${output} ${0} msg=${stderr} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 75 | [Return] ${stdout} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 76 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 77 | Run Inband IPMI Raw Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 78 | [Documentation] Run the raw IPMI command in-band. |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 79 | [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME} |
| 80 | ... ${os_password}=${OS_PASSWORD} |
| 81 | |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 82 | # Description of arguments: |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 83 | # ${args} parameters to IPMI command. |
| 84 | # ${os_host} IP address of the OS Host. |
| 85 | # ${os_username} OS Host Login user name. |
| 86 | # ${os_password} OS Host Login passwrd. |
| 87 | |
| 88 | Login To OS Host ${os_host} ${os_username} ${os_password} |
| 89 | Check If IPMI Tool Exist |
| 90 | |
| 91 | ${inband_raw_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${args} |
| 92 | ${stdout} ${stderr}= Execute Command ${inband_raw_cmd} return_stderr=True |
| 93 | Should Be Empty ${stderr} msg=${stdout} |
| 94 | [Return] ${stdout} |
| 95 | |
| 96 | Run Inband IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 97 | [Documentation] Run the standard IPMI command in-band. |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 98 | [Arguments] ${args} ${fail_on_err}=${1} ${os_host}=${OS_HOST} |
| 99 | ... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 100 | |
Gunnar Mills | 28e403b | 2017-10-25 16:16:38 -0500 | [diff] [blame] | 101 | # Description of arguments: |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 102 | # ${args} parameters to IPMI command. |
| 103 | # ${os_host} IP address of the OS Host. |
| 104 | # ${os_username} OS Host Login user name. |
| 105 | # ${os_password} OS Host Login passwrd. |
| 106 | |
| 107 | Login To OS Host ${os_host} ${os_username} ${os_password} |
| 108 | Check If IPMI Tool Exist |
| 109 | |
| 110 | ${inband_std_cmd}= Catenate ${IPMI_INBAND_CMD} ${args} |
| 111 | ${stdout} ${stderr}= Execute Command ${inband_std_cmd} return_stderr=True |
Rahul Maheshwari | 20f3bf7 | 2018-12-18 04:24:20 -0600 | [diff] [blame] | 112 | Return From Keyword If ${fail_on_err} == ${0} ${stderr} |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 113 | Should Be Empty ${stderr} msg=${stdout} |
| 114 | [Return] ${stdout} |
| 115 | |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 116 | Run External IPMI Raw Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 117 | [Documentation] Run the raw IPMI command externally. |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 118 | [Arguments] ${args} |
Michael Walsh | 19621ba | 2018-12-03 17:16:02 -0600 | [diff] [blame] | 119 | |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 120 | ${ipmi_raw_cmd}= Catenate SEPARATOR= |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 121 | ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 122 | ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args} |
| 123 | ${rc} ${output}= Run and Return RC and Output ${ipmi_raw_cmd} |
| 124 | Should Be Equal ${rc} ${0} msg=${output} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 125 | [Return] ${output} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 126 | |
| 127 | Run External IPMI Standard Command |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 128 | [Documentation] Run the standard IPMI command in-band. |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 129 | [Arguments] ${args} ${fail_on_err}=${1} |
| 130 | |
| 131 | # Description of argument(s): |
| 132 | # args IPMI command to be executed. |
| 133 | # fail_on_err Fail if keyword the IPMI command fails |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 134 | |
| 135 | ${ipmi_cmd}= Catenate SEPARATOR= |
| 136 | ... ${IPMI_EXT_CMD} ${IPMI_USER_OPTIONS} -P${SPACE}${IPMI_PASSWORD} |
| 137 | ... ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 138 | ${rc} ${output}= Run And Return RC and Output ${ipmi_cmd} |
George Keishing | 02651f0 | 2018-04-11 02:07:16 -0500 | [diff] [blame] | 139 | Return From Keyword If ${fail_on_err} == ${0} ${output} |
Michael Walsh | a791389 | 2017-04-20 16:29:01 -0500 | [diff] [blame] | 140 | Should Be Equal ${rc} ${0} msg=${output} |
| 141 | [Return] ${output} |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 142 | |
Prashanth Katti | ae7c228 | 2017-03-15 07:43:46 -0500 | [diff] [blame] | 143 | Check If IPMI Tool Exist |
| 144 | [Documentation] Check if IPMI Tool installed or not. |
| 145 | ${output}= Execute Command which ipmitool |
| 146 | Should Not Be Empty ${output} msg=ipmitool not installed. |
Rahul Maheshwari | 7a212a0 | 2016-09-05 21:17:30 -0500 | [diff] [blame] | 147 | |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 148 | |
| 149 | Activate SOL Via IPMI |
| 150 | [Documentation] Start SOL using IPMI and route output to a file. |
| 151 | [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST} |
| 152 | # Description of argument(s): |
| 153 | # file_path The file path on the local machine (vs OBMC) to collect SOL |
| 154 | # output. By default SOL output is collected at |
| 155 | # /tmp/sol_<BMC_IP> else user input location. |
| 156 | |
| 157 | ${ipmi_cmd}= Catenate SEPARATOR= |
Rahul Maheshwari | c847088 | 2017-08-30 05:41:16 -0500 | [diff] [blame] | 158 | ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}${HOST} |
| 159 | ... ${SPACE}${OPENBMC_HOST}${SPACE}sol activate usesolkeepalive |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 160 | |
George Keishing | 2102f6b | 2017-06-06 08:30:10 -0500 | [diff] [blame] | 161 | Start Process ${ipmi_cmd} shell=True stdout=${file_path} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 162 | ... alias=sol_proc |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 163 | |
| 164 | |
| 165 | Deactivate SOL Via IPMI |
| 166 | [Documentation] Stop SOL using IPMI and return SOL output. |
| 167 | [Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST} |
| 168 | # Description of argument(s): |
| 169 | # file_path The file path on the local machine to copy SOL output |
| 170 | # collected by above "Activate SOL Via IPMI" keyword. |
| 171 | # By default it copies log from /tmp/sol_<BMC_IP>. |
| 172 | |
| 173 | ${ipmi_cmd}= Catenate SEPARATOR= |
| 174 | ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE} |
| 175 | ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}sol deactivate |
| 176 | |
| 177 | ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd} |
Rahul Maheshwari | 4f36084 | 2017-06-06 15:05:01 -0500 | [diff] [blame] | 178 | Run Keyword If ${rc} > 0 Run Keywords |
Rahul Maheshwari | 7f48a2c | 2017-06-16 04:00:26 -0500 | [diff] [blame] | 179 | ... Run Keyword And Ignore Error Terminate Process sol_proc |
| 180 | ... AND Return From Keyword ${output} |
Rahul Maheshwari | 04a2204 | 2017-05-02 01:54:31 -0500 | [diff] [blame] | 181 | |
| 182 | ${rc} ${output}= Run and Return RC and Output cat ${file_path} |
| 183 | Should Be Equal ${rc} ${0} msg=${output} |
| 184 | |
| 185 | # Logging SOL output for debug purpose. |
| 186 | Log ${output} |
| 187 | |
| 188 | [Return] ${output} |
| 189 | |
| 190 | |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 191 | Byte Conversion |
| 192 | [Documentation] Byte Conversion method receives IPMI RAW commands as |
| 193 | ... argument in string format. |
| 194 | ... Sample argument is as follows |
| 195 | ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00 |
| 196 | ... 0x00" |
| 197 | ... IPMI RAW command format is as follows |
| 198 | ... <netfn Byte> <cmd Byte> <Data Bytes..> |
| 199 | ... This method converts IPMI command format into |
| 200 | ... dbus command format as follows |
| 201 | ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd> |
| 202 | ... <array:byte:data> |
| 203 | ... Sample dbus Host IPMI Received Message argument |
| 204 | ... byte:0x00 byte:0x04 byte:0x00 byte:0x30 |
| 205 | ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00 |
Gunnar Mills | 3803280 | 2016-12-12 13:43:40 -0600 | [diff] [blame] | 206 | [Arguments] ${args} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 207 | ${argLength}= Get Length ${args} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 208 | Set Global Variable ${arrayByte} array:byte: |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 209 | @{listargs}= Split String ${args} |
| 210 | ${index}= Set Variable ${0} |
George Keishing | 9a08944 | 2018-12-10 09:38:50 -0600 | [diff] [blame] | 211 | :FOR ${word} IN @{listargs} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 212 | \ Run Keyword if ${index} == 0 Set NetFn Byte ${word} |
| 213 | \ Run Keyword if ${index} == 1 Set Cmd Byte ${word} |
| 214 | \ Run Keyword if ${index} > 1 Set Array Byte ${word} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 215 | \ ${index}= Set Variable ${index + 1} |
| 216 | ${length}= Get Length ${arrayByte} |
| 217 | ${length}= Evaluate ${length} - 1 |
| 218 | ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 219 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Gunnar Mills | 59204d2 | 2016-12-06 11:05:19 -0600 | [diff] [blame] | 220 | ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 221 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte} |
| 222 | ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte} |
| 223 | ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00 |
| 224 | ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 225 | # To Check scenario for smaller IPMI raw commands with only 2 arguments |
| 226 | # instead of usual 12 arguments. |
| 227 | # Sample small IPMI raw command: Run IPMI command 0x06 0x36 |
| 228 | # If IPMI raw argument length is only 9 then return value in bytes without |
| 229 | # array population. |
| 230 | # Equivalent dbus-send argument for smaller IPMI raw command: |
| 231 | # byte:0x00 byte:0x06 byte:0x00 byte:0x36 |
| 232 | Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray} |
Gunnar Mills | c9ea936 | 2016-12-13 16:21:13 -0600 | [diff] [blame] | 233 | [Return] ${valueinBytesWithArray} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 234 | |
| 235 | |
| 236 | Set NetFn Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 237 | [Documentation] Set the network function byte. |
| 238 | [Arguments] ${word} |
| 239 | ${netfnByteLocal}= Catenate byte:${word} |
| 240 | Set Global Variable ${netfnByte} ${netfnByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 241 | |
| 242 | Set Cmd Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 243 | [Documentation] Set the command byte. |
| 244 | [Arguments] ${word} |
| 245 | ${cmdByteLocal}= Catenate byte:${word} |
| 246 | Set Global Variable ${cmdByte} ${cmdByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 247 | |
| 248 | Set Array Byte |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 249 | [Documentation] Set the array byte. |
| 250 | [Arguments] ${word} |
| 251 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word} |
| 252 | ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} , |
| 253 | Set Global Variable ${arrayByte} ${arrayByteLocal} |
Sivas SRR | a2dab3c | 2016-07-25 05:08:18 -0500 | [diff] [blame] | 254 | |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 255 | Copy ipmitool |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 256 | [Documentation] Copy the ipmitool to the BMC. |
| 257 | ${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory. |
| 258 | ... It is not part of the automation code by default. You must manually copy or link the correct openbmc |
| 259 | ... version of the tool in to the tools directory in order to run this test suite. |
| 260 | |
| 261 | OperatingSystem.File Should Exist tools/ipmitool msg=${ipmitool_error} |
Chris Austen | b29d2e8 | 2016-06-07 12:25:35 -0500 | [diff] [blame] | 262 | |
| 263 | Import Library SCPLibrary WITH NAME scp |
| 264 | scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD} |
| 265 | scp.Put File tools/ipmitool /tmp |
| 266 | SSHLibrary.Open Connection ${OPENBMC_HOST} |
| 267 | Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} |
| 268 | Execute Command chmod +x /tmp/ipmitool |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 269 | |
| 270 | Initiate Host Boot Via External IPMI |
| 271 | [Documentation] Initiate host power on using external IPMI. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 272 | [Arguments] ${wait}=${1} |
| 273 | # Description of argument(s): |
| 274 | # wait Indicates that this keyword should wait for host running state. |
| 275 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 276 | ${output}= Run External IPMI Standard Command chassis power on |
| 277 | Should Not Contain ${output} Error |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 278 | |
| 279 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 280 | Wait Until Keyword Succeeds 10 min 10 sec Is Host Running |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 281 | |
| 282 | Initiate Host PowerOff Via External IPMI |
| 283 | [Documentation] Initiate host power off using external IPMI. |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 284 | [Arguments] ${wait}=${1} |
| 285 | # Description of argument(s): |
| 286 | # wait Indicates that this keyword should wait for host off state. |
| 287 | |
Sridevi Ramesh | 0c34f69 | 2017-04-25 02:40:32 -0500 | [diff] [blame] | 288 | ${output}= Run External IPMI Standard Command chassis power off |
| 289 | Should Not Contain ${output} Error |
Rahul Maheshwari | 982fee4 | 2017-05-03 00:33:15 -0500 | [diff] [blame] | 290 | |
| 291 | Run Keyword If '${wait}' == '${0}' Return From Keyword |
| 292 | Wait Until Keyword Succeeds 3 min 10 sec Is Host Off |
| 293 | |
| 294 | Get Host State Via External IPMI |
| 295 | [Documentation] Returns host state using external IPMI. |
| 296 | |
| 297 | ${output}= Run External IPMI Standard Command chassis power status |
| 298 | Should Not Contain ${output} Error |
| 299 | ${output}= Fetch From Right ${output} ${SPACE} |
| 300 | |
| 301 | [Return] ${output} |
George Keishing | b4d4a4a | 2018-08-27 13:35:39 -0500 | [diff] [blame] | 302 | |
| 303 | |
| 304 | Set BMC Network From Host |
| 305 | [Documentation] Set BMC network from host. |
| 306 | [Arguments] ${nw_info} |
| 307 | |
| 308 | # Description of argument(s): |
| 309 | # nw_info A dictionary containing the network information to apply. |
| 310 | |
| 311 | Run Inband IPMI Standard Command |
| 312 | ... lan set 1 ipaddr ${nw_info['IP Address']} |
| 313 | |
| 314 | Run Inband IPMI Standard Command |
| 315 | ... lan set 1 netmask ${nw_info['Subnet Mask']} |
| 316 | |
| 317 | Run Inband IPMI Standard Command |
| 318 | ... lan set 1 defgw ipaddr ${nw_info['Default Gateway IP']} |