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