1*** Settings *** 2Documentation Test BMC manager protocol enable/disable functionality. 3 4Resource ../../lib/bmc_redfish_resource.robot 5Resource ../../lib/openbmc_ffdc.robot 6Resource ../../lib/protocol_setting_utils.robot 7 8Suite Setup Suite Setup Execution 9Suite Teardown Run Keywords Enable IPMI Protocol ${initial_ipmi_state} AND Redfish.Logout 10Test Teardown FFDC On Test Case Fail 11 12 13*** Variables *** 14 15${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD} 16 17 18*** Test Cases *** 19 20Verify 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 28Enable 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 41Disable SSH Protocol And Verify 42 [Documentation] Disable SSH protocol and verify. 43 [Tags] Disable_SSH_Protocol_And_Verify 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 60Enable SSH Protocol And Check Persistency On BMC Reboot 61 [Documentation] Enable SSH protocol and verify persistency. 62 [Tags] Enable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot 63 64 Enable SSH Protocol ${True} 65 66 # Reboot BMC and verify persistency. 67 OBMC Reboot (off) 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 76Disable SSH Protocol And Check Persistency On BMC Reboot 77 [Documentation] Disable SSH protocol and verify persistency. 78 [Tags] Disable_SSH_Protocol_And_Check_Persistency_On_BMC_Reboot 79 [Teardown] Enable SSH Protocol ${True} 80 81 # Disable SSH interface. 82 Enable SSH Protocol ${False} 83 84 # Reboot BMC and verify persistency. 85 Redfish BMC Reboot 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 98Verify 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 111Verify 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 134Enable IPMI Protocol And Verify 135 [Documentation] Enable IPMI protocol and verify. 136 [Tags] Enable_IPMI_Protocol_And_Verify 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 147Disable 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 165Enable IPMI Protocol And Check Persistency On BMC Reboot 166 [Documentation] Set the IPMI protocol attribute to True, reset BMC, and verify 167 ... that the setting persists. 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 181Disable IPMI Protocol And Check Persistency On BMC Reboot 182 [Documentation] Set the IPMI protocol attribute to False, reset BMC, and verify 183 ... that the setting persists. 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 202Enable SSH And IPMI Protocol And Verify 203 [Documentation] Set the SSH and IPMI protocol attributes to True, and verify 204 ... that the setting attribute value is boolean True. 205 [Tags] Enable_SSH_And_IPMI_Protocol_And_Verify 206 207 Set SSH And IPMI Protocol ${True} ${True} 208 209 # Check if SSH and IPMI enabled is set. 210 Verify SSH Protocol State ${True} 211 Verify IPMI Protocol State ${True} 212 213 # Check if SSH login and IPMI commands work. 214 Verify SSH Login And Commands Work 215 Verify IPMI Works lan print 216 217 218Disable SSH And IPMI Protocol And Verify 219 [Documentation] Set the SSH and IPMI protocol attributes to False, and verify 220 ... that both SSH login and IPMI commands does not work. 221 [Tags] Disable_SSH_And_IPMI_Protocol_And_Verify 222 [Teardown] Enable SSH Protocol ${True} 223 224 Set SSH And IPMI Protocol ${False} ${False} 225 226 # Check if SSH login and commands fail. 227 ${status}= Run Keyword And Return Status 228 ... Verify SSH Login And Commands Work 229 230 Should Be Equal As Strings ${status} False 231 ... msg=SSH Login and commands are working after disabling SSH. 232 233 # Check if IPMI commands fail. 234 ${status}= Run Keyword And Return Status 235 ... Verify IPMI Works lan print 236 237 Should Be Equal As Strings ${status} False 238 ... msg=IPMI commands are working after disabling IPMI. 239 240 241Enable SSH And Disable IPMI And Verify 242 [Documentation] Set the SSH protocol attribute to True and IPMI protocol attribute to False, and verify 243 ... that SSH login works and IPMI command does not work. 244 [Tags] Enable_SSH_And_Disable_IPMI_And_Verify 245 246 Set SSH And IPMI Protocol ${True} ${False} 247 248 Verify SSH Login And Commands Work 249 250 # Check if IPMI commands fail. 251 ${status}= Run Keyword And Return Status 252 ... Verify IPMI Works lan print 253 254 Should Be Equal As Strings ${status} False 255 ... msg=IPMI commands are working after disabling IPMI. 256 257 258*** Keywords *** 259 260Suite Setup Execution 261 [Documentation] Do suite setup tasks. 262 263 Redfish.Login 264 265 ${state}= Run Keyword And Return Status Verify IPMI Protocol State 266 Set Suite Variable ${initial_ipmi_state} ${state} 267 268 269Is BMC LastResetTime Changed 270 [Documentation] return fail if BMC last reset time is not changed 271 [Arguments] ${reset_time} 272 273 ${last_reset_time}= Redfish.Get Attribute /redfish/v1/Managers/bmc LastResetTime 274 Should Not Be Equal ${last_reset_time} ${reset_time} 275 276 277Redfish BMC Reboot 278 [Documentation] Use Redfish API reboot BMC and wait for BMC ready 279 280 # Get BMC last reset time for compare 281 ${last_reset_time}= Redfish.Get Attribute /redfish/v1/Managers/bmc LastResetTime 282 283 # Reboot BMC by Redfish API 284 Redfish BMC Reset Operation 285 286 # Wait for BMC real reboot and Redfish API ready 287 Wait Until Keyword Succeeds 3 min 10 sec Is BMC LastResetTime Changed ${last_reset_time} 288 289 290Set SSH And IPMI Protocol 291 [Documentation] Set SSH and IPMI protocol state. 292 [Arguments] ${ssh_state} ${ipmi_state} 293 294 # Description of argument(s): 295 # ssh_state state of SSH to be set(e.g. True, False). 296 # ipmi_state state of IPMI to be set(e.g. True, False). 297 298 ${ssh_protocol_state}= Create Dictionary ProtocolEnabled=${ssh_state} 299 ${ipmi_protocol_state}= Create Dictionary ProtocolEnabled=${ipmi_state} 300 ${data}= Create Dictionary SSH=${ssh_protocol_state} IPMI=${ipmi_protocol_state} 301 302 Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} 303 ... valid_status_codes=[${HTTP_NO_CONTENT}] 304 305 # Wait for timeout for new values to take effect. 306 Sleep ${NETWORK_TIMEOUT}s 307