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