Tony Lee | 6c998f7 | 2020-03-09 18:28:35 +0800 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation This suite tests IPMI Payload in OpenBMC. |
| 3 | |
| 4 | Resource ../lib/ipmi_client.robot |
| 5 | Resource ../lib/openbmc_ffdc.robot |
nagarjunb22 | a2255de | 2022-05-25 19:15:10 +0530 | [diff] [blame^] | 6 | Resource ../lib/bmc_network_utils.robot |
Tony Lee | 6c998f7 | 2020-03-09 18:28:35 +0800 | [diff] [blame] | 7 | Variables ../data/ipmi_raw_cmd_table.py |
nagarjunb22 | a2255de | 2022-05-25 19:15:10 +0530 | [diff] [blame^] | 8 | Library ../lib/ipmi_utils.py |
| 9 | |
| 10 | |
| 11 | Test Teardown FFDC On Test Case Fail |
| 12 | |
| 13 | |
| 14 | *** Variables *** |
| 15 | ${user_priv} 2 |
| 16 | ${operator_priv} 3 |
| 17 | ${admin_level_priv} 4 |
| 18 | ${no_access_priv} 15 |
| 19 | ${new_user_passwd} 0penBmc1 |
Tony Lee | 6c998f7 | 2020-03-09 18:28:35 +0800 | [diff] [blame] | 20 | |
| 21 | |
| 22 | *** Test Cases *** |
| 23 | |
| 24 | Test Get Payload Activation Status |
| 25 | [Documentation] Test get payload activation status. |
| 26 | [Tags] Test_Get_Payload_Activation_Status |
| 27 | |
| 28 | # SOL is the payload currently supported for payload status. |
| 29 | # Currently supports only one SOL session. |
| 30 | # Response Data |
| 31 | # 01 instance 1 is activated. |
| 32 | # 00 instance 1 is deactivated. |
| 33 | ${payload_status}= Get Payload Activation Status |
| 34 | Should Contain Any ${payload_status} 01 00 |
| 35 | |
| 36 | |
| 37 | Test Activate Payload |
| 38 | [Documentation] Test activate payload via IPMI raw command. |
| 39 | [Tags] Test_Activate_Payload |
| 40 | |
| 41 | ${payload_status}= Get Payload Activation Status |
| 42 | Run Keyword If '${payload_status}' == '01' Deactivate Payload |
| 43 | |
| 44 | Activate Payload |
| 45 | |
| 46 | ${payload_status}= Get Payload Activation Status |
| 47 | Should Contain ${payload_status} 01 |
| 48 | |
| 49 | |
| 50 | Test Deactivate Payload |
| 51 | [Documentation] Test deactivate payload via IPMI raw command. |
| 52 | [Tags] Test_Deactivate_Payload |
| 53 | |
| 54 | ${payload_status}= Get Payload Activation Status |
| 55 | Run Keyword If '${payload_status}' == '00' Activate Payload |
| 56 | |
| 57 | Deactivate Payload |
| 58 | |
| 59 | ${payload_status}= Get Payload Activation Status |
| 60 | Should Contain ${payload_status} 00 |
| 61 | |
| 62 | |
| 63 | Test Get Payload Instance Info |
| 64 | [Documentation] Test Get Payload Instance via IPMI raw command. |
| 65 | [Tags] Test_Get_Payload_Instance_Info |
| 66 | |
| 67 | ${payload_status}= Get Payload Activation Status |
| 68 | Run keyword If '${payload_status}' == '01' |
| 69 | ... Deactivate Payload |
| 70 | |
| 71 | # First four bytes should be 00 if given instance is not activated. |
| 72 | ${resp}= Run IPMI Command |
| 73 | ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]} |
| 74 | Should Contain ${resp} ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]} |
| 75 | Activate Payload |
| 76 | |
| 77 | # First four bytes should be session ID when payload is activated. |
| 78 | ${resp}= Run IPMI Command |
| 79 | ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][0]} |
| 80 | Should Not Contain ${resp} ${IPMI_RAW_CMD['Payload']['Get_Payload_Instance_Info'][1]} |
| 81 | |
| 82 | |
nagarjunb22 | a2255de | 2022-05-25 19:15:10 +0530 | [diff] [blame^] | 83 | Verify Set User Access Payload For Standard Payload SOL |
| 84 | [Documentation] Disable standard payload for SOL and verify IPMI sol activate command does not work. |
| 85 | [Tags] Verify_Set_User_Access_Payload_For_Standard_Payload_SOL |
| 86 | [Teardown] Run Keywords Set User Access Payload For Given User ${user_id_in_hex} |
| 87 | ... AND Delete Created User ${userid} |
| 88 | ... AND FFDC On Test Case Fail |
| 89 | |
| 90 | ${userid} ${username}= Create And Verify IPMI User |
| 91 | ${user_id_in_hex}= Convert To Hex ${userid} |
| 92 | ${userid_in_hex_format}= Convert To Hex ${userid} prefix=0x length=2 |
| 93 | |
| 94 | # Get default user access payload values. |
| 95 | ${default_user_access_payload}= Get User Access Payload For Given Channel ${userid_in_hex_format} |
| 96 | |
| 97 | # Disable Standard payload 1 via set user access payload command. |
| 98 | Set User Access Payload For Given User ${user_id_in_hex} Disable |
| 99 | |
| 100 | Verify Standard Payload ${userid_in_hex_format} ${username} Disabled |
| 101 | |
| 102 | |
| 103 | Verify Set User Access Payload For Operator Privileged User |
| 104 | [Documentation] Try to set user access payload using operator privileged user and expect error. |
| 105 | [Tags] Verify_Set_User_Access_Payload_For_Operator_Privileged_User |
| 106 | [Teardown] Run Keywords Delete Created User ${userid} AND FFDC On Test Case Fail |
| 107 | |
| 108 | ${userid} ${username}= Create And Verify IPMI User ${operator_priv} Operator |
| 109 | |
| 110 | ${payload_raw_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]} |
| 111 | ... ${CHANNEL_NUMBER} 0x${user_id} 0x02 0x00 0x00 0x00 |
| 112 | |
| 113 | Run Keyword and Expect Error *Unable to establish IPMI* |
| 114 | ... Run External IPMI Raw Command ${payload_raw_cmd} U=${userid} P=${new_user_passwd} L=Operator |
| 115 | |
| 116 | |
Tony Lee | 6c998f7 | 2020-03-09 18:28:35 +0800 | [diff] [blame] | 117 | *** Keywords *** |
| 118 | |
| 119 | Get Payload Activation Status |
| 120 | [Documentation] Get payload activation status. |
| 121 | |
| 122 | ${resp}= Run IPMI Command |
| 123 | ... ${IPMI_RAW_CMD['Payload']['Get_Payload_Activation_Status'][0]} |
| 124 | |
| 125 | @{resp}= Split String ${resp} |
| 126 | |
| 127 | ${payload_status}= Set Variable ${resp[1]} |
| 128 | |
| 129 | [return] ${payload_status} |
| 130 | |
| 131 | |
| 132 | Activate Payload |
| 133 | [Documentation] Activate Payload. |
| 134 | |
| 135 | ${resp}= Run IPMI Command |
| 136 | ... ${IPMI_RAW_CMD['Payload']['Activate_Payload'][0]} |
| 137 | Should Contain ${resp} ${IPMI_RAW_CMD['Payload']['Activate_Payload'][1]} |
| 138 | |
| 139 | |
| 140 | Deactivate Payload |
| 141 | [Documentation] Deactivate Payload. |
| 142 | |
| 143 | ${resp}= Run IPMI Command |
| 144 | ... ${IPMI_RAW_CMD['Payload']['Deactivate_Payload'][0]} |
| 145 | Should Be Empty ${resp} |
nagarjunb22 | a2255de | 2022-05-25 19:15:10 +0530 | [diff] [blame^] | 146 | |
| 147 | |
| 148 | Get User Access Payload For Given Channel |
| 149 | [Documentation] Execute get user access payload IPMI command for given channel |
| 150 | ... and return response. |
| 151 | [Arguments] ${user_id} ${channel_number}=${CHANNEL_NUMBER} |
| 152 | |
| 153 | # Description of argument(s): |
| 154 | # user_id The user ID (e.g. "1", "2", etc.). |
| 155 | # channel_number Input channel number(e.g. "1", "2"). |
| 156 | |
| 157 | ${raw_command}= Catenate ${IPMI_RAW_CMD['Payload']['Get_User_Access_Payload'][0]} |
| 158 | ... ${channel_number} ${user_id} |
| 159 | ${resp}= Run External IPMI Raw Command ${raw_command} |
| 160 | [Return] ${resp} |
| 161 | |
| 162 | |
| 163 | Create And Verify IPMI User |
| 164 | [Documentation] Create IPMI User, set password, set privilege and enable the user. |
| 165 | [Arguments] ${user_privilege_level}=${admin_level_priv} ${privilege}=Administrator |
| 166 | |
| 167 | # Description of argument(s): |
| 168 | # user_privilege_level User Privilege level in integer. |
| 169 | # (e.g. 4-Administrator, 3-Operator, 2-Readonly). |
| 170 | # privilege User Privilege in Wordings. |
| 171 | # (e.g. "Administrator", "Operator", "ReadOnly"). |
| 172 | |
| 173 | ${random_user_id} ${random_user_name}= Create Random IPMI User |
| 174 | Set User Password ${random_user_id} ${new_user_passwd} 16 |
| 175 | Set And Verify User Access Privilege ${random_user_id} ${user_privilege_level} |
| 176 | Verify Username And Password ${random_user_name} ${new_user_passwd} L=${privilege} |
| 177 | |
| 178 | [Return] ${random_user_id} ${random_user_name} |
| 179 | |
| 180 | |
| 181 | Set User Password |
| 182 | [Documentation] Set user password for given user ID. |
| 183 | [Arguments] ${user_id} ${password} ${password_option} |
| 184 | |
| 185 | # Description of argument(s): |
| 186 | # user_id The user ID (e.g. "1", "2", etc.). |
| 187 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 188 | # password_option Password length option to be given in IPMI command (e.g. "16", "20"). |
| 189 | |
| 190 | Run IPMI Standard Command user set password ${user_id} ${password} ${password_option} |
| 191 | |
| 192 | Set And Verify User Access Privilege |
| 193 | [Documentation] Set User Access Privilege, enable and verify user for given user ID. |
| 194 | [Arguments] ${user_id} ${privilege_level} |
| 195 | |
| 196 | # Description of argument(s): |
| 197 | # user_id The user ID (e.g. "1", "2", etc.). |
| 198 | # privilege_level User Privilege level in hex value. |
| 199 | # (e.g. 0x04-Administrator, 0x03-Operator, 0x02-Readonly). |
| 200 | |
| 201 | Set Channel Access ${_user_id} ipmi=on privilege=${privilege_level} |
| 202 | |
| 203 | # Delay added for user privilege to get set. |
| 204 | Sleep 5s |
| 205 | |
| 206 | Enable IPMI User And Verify ${user_id} |
| 207 | |
| 208 | |
| 209 | Verify Username And Password |
| 210 | [Documentation] Verify that newly created user is able to run IPMI command |
| 211 | ... with given username and password. |
| 212 | [Arguments] ${username} ${password} &{options} |
| 213 | |
| 214 | # Description of argument(s): |
| 215 | # username The user name (e.g. "root", "robert", etc.). |
| 216 | # password The user password (e.g. "0penBmc", "0penBmc1", etc.). |
| 217 | # options Additional ipmitool command options (e.g "-L=Operator","-C=3"). |
| 218 | |
| 219 | Wait Until Keyword Succeeds 15 sec 5 sec Run External IPMI Raw Command |
| 220 | ... ${IPMI_RAW_CMD['Device GUID']['Get'][0]} U=${username} P=${password} &{options} |
| 221 | |
| 222 | |
| 223 | Verify Standard Payload |
| 224 | [Documentation] Verify standard payload is disabled or enabled. |
| 225 | [Arguments] ${user_id} ${user_name} ${standard_payload}=Enabled |
| 226 | |
| 227 | # Description of argument(s): |
| 228 | # user_id The user ID (e.g. "1", "2", etc.). |
| 229 | # username The user name (e.g. "root", "robert", etc.). |
| 230 | # standard_payload Enabled or Disabled. |
| 231 | |
| 232 | # Verify the standard payload 1 (sol) is disabled. |
| 233 | ${get_user_access_payload}= Get User Access Payload For Given Channel ${user_id} |
| 234 | @{get_user_access_cmd_resp_list}= Split String ${get_user_access_payload} |
| 235 | |
| 236 | Run Keyword If '${standard_payload}' == 'Disabled' |
| 237 | ... Should Be Equal ${get_user_access_cmd_resp_list}[0] 00 |
| 238 | ... ELSE |
| 239 | ... Should Be Equal ${get_user_access_cmd_resp_list}[0] 02 |
| 240 | |
| 241 | Run Keyword If '${standard_payload}' == 'Disabled' |
| 242 | ... Verify Sol Activate Disabled ${user_name} |
| 243 | |
| 244 | |
| 245 | Verify Sol Activate Disabled |
| 246 | [Documentation] Verify SOL activate IPMI command is not working. |
| 247 | [Arguments] ${user_name} |
| 248 | |
| 249 | # Description of argument(s): |
| 250 | # username The user name (e.g. "root", "robert", etc.). |
| 251 | |
| 252 | ${resp}= Run External IPMI Standard Command |
| 253 | ... sol activate expected_rc=${1} U=${username} P=${new_user_passwd} |
| 254 | |
| 255 | Should Contain ${resp} SOL payload disabled |
| 256 | |
| 257 | |
| 258 | Set User Access Payload For Given User |
| 259 | [Documentation] Set the user access payload on given user, channel and return response. |
| 260 | [Arguments] ${user_id} ${operation_mode}=Enable ${oempayload_value}=0x00 ${standard_payload_value}=0x02 |
| 261 | |
| 262 | # Description of argument(s): |
| 263 | # user_id The user ID (e.g. "1", "2", etc.). |
| 264 | # operation_mode Enable or Disable payload type. |
| 265 | # oempayload_value Oempayload in hex (e.g. "0x00", "0x01", "0x02", "0x04" etc). |
| 266 | # standard_payload_value Standard payload type IPMI or SOL. |
| 267 | # (e.g. 0x01 - IPMI, 0x02- SOL). |
| 268 | |
| 269 | # If operation mode is disable 2nd byte of raw command is 4${user_id}. |
| 270 | # (e.g) 2n byte will be 0x4a (if user_id is a). |
| 271 | # If operation mode is enable 2nd byte of raw command is 0${user_id}. |
| 272 | # (e.g.) 3rd byte will be 0x0a (if user_id is a). |
| 273 | # 0x02- standard payload for SOL, 0x01 standard payload for IPMI. |
| 274 | # 3rd byte represent standard payload enables 1 (SOL). |
| 275 | # 4th to 6th byte represent standard payload enables 2 and OEM payload 1 & 2 respectively. |
| 276 | |
| 277 | ${operation_mode_value}= Set Variable If '${operation_mode}' == 'Enable' |
| 278 | ... 0 4 |
| 279 | ${set_cmd}= Catenate ${IPMI_RAW_CMD['Payload']['Set_User_Access_Payload'][0]} |
| 280 | ... ${CHANNEL_NUMBER} 0x${operation_mode_value}${user_id} ${standard_payload_value} 0x00 ${oempayload_value} 0x00 |
| 281 | |
| 282 | ${resp}= Run IPMI Command ${set_cmd} |
| 283 | |
| 284 | [Return] ${resp} |