Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Test BMC manager protocol enable/disable functionality. |
| 3 | |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 4 | Resource ../../lib/bmc_redfish_resource.robot |
| 5 | Resource ../../lib/openbmc_ffdc.robot |
Prashanth Katti | f59a73e | 2021-09-22 03:03:58 -0500 | [diff] [blame] | 6 | Resource ../../lib/protocol_setting_utils.robot |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 7 | |
Brian Ma | 274b724 | 2021-12-09 09:00:45 +0800 | [diff] [blame] | 8 | Suite Setup Suite Setup Execution |
| 9 | Suite Teardown Run Keywords Enable IPMI Protocol ${initial_ipmi_state} AND Redfish.Logout |
Prashanth Katti | 2e41345 | 2021-07-13 02:26:45 -0500 | [diff] [blame] | 10 | Test Teardown FFDC On Test Case Fail |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 11 | |
| 12 | |
Prashanth Katti | 7062017 | 2021-07-28 07:17:39 -0500 | [diff] [blame] | 13 | *** Variables *** |
| 14 | |
meghagn | 6f1d9d8 | 2021-11-11 21:56:21 -0600 | [diff] [blame] | 15 | ${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD} |
Prashanth Katti | 7062017 | 2021-07-28 07:17:39 -0500 | [diff] [blame] | 16 | |
| 17 | |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 18 | *** Test Cases *** |
| 19 | |
Prashanth Katti | 2e41345 | 2021-07-13 02:26:45 -0500 | [diff] [blame] | 20 | Verify SSH Is Enabled By Default |
| 21 | [Documentation] Verify SSH is enabled by default. |
| 22 | [Tags] Verify_SSH_Is_Enabled_By_Default |
| 23 | |
| 24 | # Check if SSH is enabled by default. |
| 25 | Verify SSH Protocol State ${True} |
| 26 | |
| 27 | |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 28 | Enable SSH Protocol And Verify |
| 29 | [Documentation] Enable SSH protocol and verify. |
| 30 | [Tags] Enable_SSH_Protocol_And_Verify |
| 31 | |
| 32 | Enable SSH Protocol ${True} |
| 33 | |
| 34 | # Check if SSH is really enabled via Redfish. |
| 35 | Verify SSH Protocol State ${True} |
| 36 | |
| 37 | # Check if SSH login and commands on SSH session work. |
| 38 | Verify SSH Login And Commands Work |
| 39 | |
| 40 | |
| 41 | Disable SSH Protocol And Verify |
| 42 | [Documentation] Disable SSH protocol and verify. |
| 43 | [Teardown] Enable SSH Protocol ${True} |
| 44 | |
| 45 | # Disable SSH interface. |
| 46 | Enable SSH Protocol ${False} |
| 47 | |
| 48 | # Check if SSH is really disabled via Redfish. |
| 49 | Verify SSH Protocol State ${False} |
| 50 | |
| 51 | # Check if SSH login and commands fail. |
| 52 | ${status}= Run Keyword And Return Status |
| 53 | ... Verify SSH Login And Commands Work |
| 54 | |
| 55 | Should Be Equal As Strings ${status} False |
| 56 | ... msg=SSH Login and commands are working after disabling SSH. |
| 57 | |
| 58 | |
| 59 | Enable SSH Protocol And Check Persistency On BMC Reboot |
| 60 | [Documentation] Enable SSH protocol and verify persistency. |
| 61 | |
| 62 | Enable SSH Protocol ${True} |
| 63 | |
| 64 | # Reboot BMC and verify persistency. |
| 65 | OBMC Reboot (off) |
| 66 | |
| 67 | # Check if SSH is really enabled via Redfish. |
| 68 | Verify SSH Protocol State ${True} |
| 69 | |
| 70 | # Check if SSH login and commands on SSH session work. |
| 71 | Verify SSH Login And Commands Work |
| 72 | |
| 73 | |
| 74 | Disable SSH Protocol And Check Persistency On BMC Reboot |
| 75 | [Documentation] Disable SSH protocol and verify persistency. |
| 76 | [Teardown] Enable SSH Protocol ${True} |
| 77 | |
| 78 | # Disable SSH interface. |
| 79 | Enable SSH Protocol ${False} |
| 80 | |
| 81 | # Reboot BMC and verify persistency. |
Brian Ma | 4ddcb4d | 2021-12-03 09:31:05 +0800 | [diff] [blame] | 82 | Redfish BMC Reboot |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 83 | |
| 84 | # Check if SSH is really disabled via Redfish. |
| 85 | Verify SSH Protocol State ${False} |
| 86 | |
| 87 | # Check if SSH login and commands fail. |
| 88 | ${status}= Run Keyword And Return Status |
| 89 | ... Verify SSH Login And Commands Work |
| 90 | |
| 91 | Should Be Equal As Strings ${status} False |
| 92 | ... msg=SSH Login and commands are working after disabling SSH. |
| 93 | |
| 94 | |
Prashanth Katti | 2e41345 | 2021-07-13 02:26:45 -0500 | [diff] [blame] | 95 | Verify Disabling SSH Port Does Not Disable Serial Console Port |
| 96 | [Documentation] Verify disabling SSH does not disable serial console port. |
| 97 | [Tags] Verify_Disabling_SSH_Port_Does_Not_Disable_Serial_Console_Port |
| 98 | [Teardown] Enable SSH Protocol ${True} |
| 99 | |
| 100 | # Disable SSH interface. |
| 101 | Enable SSH Protocol ${False} |
| 102 | |
| 103 | # Check able to establish connection with serial port console. |
| 104 | Open Connection And Log In host=${OPENBMC_HOST} port=2200 |
| 105 | Close All Connections |
| 106 | |
| 107 | |
| 108 | Verify Existing SSH Session Gets Closed On Disabling SSH |
| 109 | [Documentation] Verify existing SSH session gets closed on disabling ssh. |
| 110 | [Tags] Verify_Existing_SSH_Session_Gets_Closed_On_Disabling_SSH |
| 111 | [Teardown] Enable SSH Protocol ${True} |
| 112 | |
| 113 | # Open SSH connection. |
| 114 | Open Connection And Login |
| 115 | |
| 116 | # Disable SSH interface. |
| 117 | Enable SSH Protocol ${False} |
| 118 | |
| 119 | # Check if SSH is really disabled via Redfish. |
| 120 | Verify SSH Protocol State ${False} |
| 121 | |
| 122 | # Try to execute CLI command on SSH connection. |
| 123 | # It should fail as disable SSH will close pre existing sessions. |
| 124 | ${status}= Run Keyword And Return Status |
| 125 | ... BMC Execute Command /sbin/ip addr |
| 126 | |
| 127 | Should Be Equal As Strings ${status} False |
| 128 | ... msg=Disabling SSH has not closed existing SSH sessions. |
| 129 | |
| 130 | |
Prashanth Katti | 7062017 | 2021-07-28 07:17:39 -0500 | [diff] [blame] | 131 | Enable IPMI Protocol And Verify |
| 132 | [Documentation] Enable IPMI protocol and verify. |
| 133 | [Tags] Enable_IPMI_Protocol_And_Verify |
Prashanth Katti | 7062017 | 2021-07-28 07:17:39 -0500 | [diff] [blame] | 134 | |
| 135 | Enable IPMI Protocol ${True} |
| 136 | |
| 137 | # Check if IPMI is really enabled via Redfish. |
| 138 | Verify IPMI Protocol State ${True} |
| 139 | |
| 140 | # Check if IPMI commands starts working. |
| 141 | Verify IPMI Works lan print |
| 142 | |
| 143 | |
| 144 | Disable IPMI Protocol And Verify |
| 145 | [Documentation] Disable IPMI protocol and verify. |
| 146 | [Tags] Disable_IPMI_Protocol_And_Verify |
| 147 | |
| 148 | # Disable IPMI interface. |
| 149 | Enable IPMI Protocol ${False} |
| 150 | |
| 151 | # Check if IPMI is really disabled via Redfish. |
| 152 | Verify IPMI Protocol State ${False} |
| 153 | |
| 154 | # Check if IPMI commands fail. |
| 155 | ${status}= Run Keyword And Return Status |
| 156 | ... Verify IPMI Works lan print |
| 157 | |
| 158 | Should Be Equal As Strings ${status} False |
| 159 | ... msg=IPMI commands are working after disabling IPMI. |
| 160 | |
| 161 | |
meghagn | ef433de | 2022-02-08 00:57:52 -0600 | [diff] [blame] | 162 | Enable IPMI Protocol And Check Persistency On BMC Reboot |
George Keishing | 33be359 | 2022-03-08 08:52:25 -0600 | [diff] [blame] | 163 | [Documentation] Set the IPMI protocol attribute to True, reset BMC, and verify |
| 164 | ... that the setting persists. |
meghagn | ef433de | 2022-02-08 00:57:52 -0600 | [diff] [blame] | 165 | [Tags] Enable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot |
| 166 | |
| 167 | Enable IPMI Protocol ${True} |
| 168 | |
| 169 | Redfish OBMC Reboot (off) stack_mode=skip |
| 170 | |
| 171 | # Check if the IPMI enabled is set. |
| 172 | Verify IPMI Protocol State ${True} |
| 173 | |
| 174 | # Confirm that IPMI commands to access BMC work. |
| 175 | Verify IPMI Works lan print |
| 176 | |
| 177 | |
| 178 | Disable IPMI Protocol And Check Persistency On BMC Reboot |
George Keishing | 33be359 | 2022-03-08 08:52:25 -0600 | [diff] [blame] | 179 | [Documentation] Set the IPMI protocol attribute to False, reset BMC, and verify |
| 180 | ... that the setting persists. |
meghagn | ef433de | 2022-02-08 00:57:52 -0600 | [diff] [blame] | 181 | [Tags] Disable_IPMI_Protocol_And_Check_Persistency_On_BMC_Reboot |
| 182 | |
| 183 | # Disable IPMI interface. |
| 184 | Enable IPMI Protocol ${False} |
| 185 | |
| 186 | Redfish OBMC Reboot (off) stack_mode=skip |
| 187 | |
| 188 | # Check if the IPMI disabled is set. |
| 189 | Verify IPMI Protocol State ${False} |
| 190 | |
| 191 | # Confirm that IPMI connection request fails. |
| 192 | ${status}= Run Keyword And Return Status |
| 193 | ... Verify IPMI Works lan print |
| 194 | |
| 195 | Should Be Equal As Strings ${status} False |
| 196 | ... msg=IPMI commands are working after disabling IPMI. |
| 197 | |
| 198 | |
meghagn | 6f1d9d8 | 2021-11-11 21:56:21 -0600 | [diff] [blame] | 199 | Enable SSH And IPMI Protocol And Verify |
| 200 | [Documentation] Set the SSH and IPMI protocol attributes to True, and verify |
| 201 | ... that the setting attribute value is boolean True. |
| 202 | [Tags] Enable_SSH_And_IPMI_Protocol_And_Verify |
| 203 | |
| 204 | Set SSH And IPMI Protocol ${True} ${True} |
| 205 | |
| 206 | # Check if SSH and IPMI enabled is set. |
| 207 | Verify SSH Protocol State ${True} |
| 208 | Verify IPMI Protocol State ${True} |
| 209 | |
| 210 | # Check if SSH login and IPMI commands work. |
| 211 | Verify SSH Login And Commands Work |
| 212 | Verify IPMI Works lan print |
| 213 | |
| 214 | |
| 215 | Disable SSH And IPMI Protocol And Verify |
| 216 | [Documentation] Set the SSH and IPMI protocol attributes to False, and verify |
| 217 | ... that both SSH login and IPMI commands does not work. |
| 218 | [Tags] Disable_SSH_And_IPMI_Protocol_And_Verify |
| 219 | [Teardown] Enable SSH Protocol ${True} |
| 220 | |
| 221 | Set SSH And IPMI Protocol ${False} ${False} |
| 222 | |
| 223 | # Check if SSH login and commands fail. |
| 224 | ${status}= Run Keyword And Return Status |
| 225 | ... Verify SSH Login And Commands Work |
| 226 | |
| 227 | Should Be Equal As Strings ${status} False |
| 228 | ... msg=SSH Login and commands are working after disabling SSH. |
| 229 | |
| 230 | # Check if IPMI commands fail. |
| 231 | ${status}= Run Keyword And Return Status |
| 232 | ... Verify IPMI Works lan print |
| 233 | |
| 234 | Should Be Equal As Strings ${status} False |
| 235 | ... msg=IPMI commands are working after disabling IPMI. |
| 236 | |
| 237 | |
| 238 | Enable SSH And Disable IPMI And Verify |
| 239 | [Documentation] Set the SSH protocol attribute to True and IPMI protocol attribute to False, and verify |
| 240 | ... that SSH login works and IPMI command does not work. |
| 241 | [Tags] Enable_SSH_And_Disable_IPMI_And_Verify |
| 242 | |
| 243 | Set SSH And IPMI Protocol ${True} ${False} |
| 244 | |
| 245 | Verify SSH Login And Commands Work |
| 246 | |
| 247 | # Check if IPMI commands fail. |
| 248 | ${status}= Run Keyword And Return Status |
| 249 | ... Verify IPMI Works lan print |
| 250 | |
| 251 | Should Be Equal As Strings ${status} False |
| 252 | ... msg=IPMI commands are working after disabling IPMI. |
| 253 | |
| 254 | |
Prashanth Katti | abbce3d | 2021-06-29 04:56:37 -0500 | [diff] [blame] | 255 | *** Keywords *** |
| 256 | |
Brian Ma | 274b724 | 2021-12-09 09:00:45 +0800 | [diff] [blame] | 257 | Suite Setup Execution |
| 258 | [Documentation] Do suite setup tasks. |
| 259 | |
| 260 | Redfish.Login |
| 261 | |
| 262 | ${state}= Run Keyword And Return Status Verify IPMI Protocol State |
| 263 | Set Suite Variable ${initial_ipmi_state} ${state} |
| 264 | |
| 265 | |
Brian Ma | 4ddcb4d | 2021-12-03 09:31:05 +0800 | [diff] [blame] | 266 | Is BMC LastResetTime Changed |
| 267 | [Documentation] return fail if BMC last reset time is not changed |
| 268 | [Arguments] ${reset_time} |
| 269 | |
| 270 | ${last_reset_time}= Redfish.Get Attribute /redfish/v1/Managers/bmc LastResetTime |
| 271 | Should Not Be Equal ${last_reset_time} ${reset_time} |
| 272 | |
| 273 | |
| 274 | Redfish BMC Reboot |
| 275 | [Documentation] Use Redfish API reboot BMC and wait for BMC ready |
| 276 | |
| 277 | # Get BMC last reset time for compare |
| 278 | ${last_reset_time}= Redfish.Get Attribute /redfish/v1/Managers/bmc LastResetTime |
| 279 | |
| 280 | # Reboot BMC by Redfish API |
| 281 | Redfish BMC Reset Operation |
| 282 | |
| 283 | # Wait for BMC real reboot and Redfish API ready |
| 284 | Wait Until Keyword Succeeds 3 min 10 sec Is BMC LastResetTime Changed ${last_reset_time} |
| 285 | |
meghagn | 6f1d9d8 | 2021-11-11 21:56:21 -0600 | [diff] [blame] | 286 | |
| 287 | Set SSH And IPMI Protocol |
| 288 | [Documentation] Set SSH and IPMI protocol state. |
| 289 | [Arguments] ${ssh_state} ${ipmi_state} |
| 290 | |
| 291 | # Description of argument(s): |
| 292 | # ssh_state state of SSH to be set(e.g. True, False). |
| 293 | # ipmi_state state of IPMI to be set(e.g. True, False). |
| 294 | |
| 295 | ${ssh_protocol_state}= Create Dictionary ProtocolEnabled=${ssh_state} |
| 296 | ${ipmi_protocol_state}= Create Dictionary ProtocolEnabled=${ipmi_state} |
| 297 | ${data}= Create Dictionary SSH=${ssh_protocol_state} IPMI=${ipmi_protocol_state} |
| 298 | |
| 299 | Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} |
| 300 | ... valid_status_codes=[${HTTP_NO_CONTENT}] |
| 301 | |
| 302 | # Wait for timeout for new values to take effect. |
| 303 | Sleep ${NETWORK_TIMEOUT}s |