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