1*** Settings *** 2Documentation Test BMC multiple network interface functionalities. 3... Run on setup with both eth0 and eth1 in static mode. 4 5Resource ../../lib/resource.robot 6Resource ../../lib/common_utils.robot 7Resource ../../lib/connection_client.robot 8Resource ../../lib/bmc_network_utils.robot 9Resource ../../lib/openbmc_ffdc.robot 10Resource ../../lib/bmc_ldap_utils.robot 11Resource ../../lib/snmp/resource.robot 12Resource ../../lib/snmp/redfish_snmp_utils.robot 13Resource ../../lib/certificate_utils.robot 14Resource ../../lib/protocol_setting_utils.robot 15Library ../../lib/jobs_processing.py 16Library OperatingSystem 17 18# User input BMC IP for the eth1. 19# Use can input as -v OPENBMC_HOST_ETH1:xx.xxx.xx from command line. 20Library ../../lib/bmc_redfish.py https://${OPENBMC_HOST_ETH1}:${HTTPS_PORT} 21... ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} AS Redfish1 22 23Suite Setup Suite Setup Execution 24Test Setup Run Keywords Redfish.Login AND Redfish1.Login 25Test Teardown Run Keywords FFDC On Test Case Fail AND Redfish.Logout AND Redfish1.Logout 26Suite Teardown Run Keywords Redfish1.Logout AND Redfish.Logout 27 28*** Variables *** 29 30${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${IPMI_USERNAME} -P ${IPMI_PASSWORD} 31${test_ipv4_addr} 10.7.7.7 32${test_ipv4_addr2} 10.7.7.8 33${test_subnet_mask} 255.255.255.0 34 35*** Test Cases *** 36 37Verify Both Interfaces BMC IP Addresses Accessible Via SSH 38 [Documentation] Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH. 39 [Tags] Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH 40 41 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST} 42 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST_ETH1} 43 Close All Connections 44 45 46Verify Redfish Works On Both Interfaces 47 [Documentation] Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish. 48 [Tags] Verify_Redfish_Works_On_Both_Interfaces 49 [Teardown] Run Keywords 50 ... Configure Hostname ${hostname} AND Validate Hostname On BMC ${hostname} 51 52 ${hostname}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName 53 ${data}= Create Dictionary HostName=openbmc 54 Redfish1.patch ${REDFISH_NW_ETH_IFACE}eth1 body=&{data} 55 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 56 57 Validate Hostname On BMC openbmc 58 59 ${resp1}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0 60 ${resp2}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1 61 Should Be Equal ${resp1.dict['HostName']} ${resp2.dict['HostName']} 62 63 64Verify LDAP Login Works When Eth1 IP Is Not Configured 65 [Documentation] Verify LDAP login works when eth1 IP is erased. 66 [Tags] Verify_LDAP_Login_Works_When_Eth1_IP_Is_Not_Configured 67 [Setup] Run Keywords Set Test Variable ${CHANNEL_NUMBER} ${SECONDARY_CHANNEL_NUMBER} 68 ... AND Redfish.Login AND Delete IP Address ${OPENBMC_HOST_ETH1} 69 [Teardown] Run Keywords Redfish.Logout AND Redfish.Login AND 70 ... Add IP Address ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway} 71 72 Create LDAP Configuration 73 Redfish.Logout 74 Sleep 30 75 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} 76 77 78Verify LDAP Login Works When Both Interfaces Are Configured 79 [Documentation] Verify LDAP login works when both interfaces are configured. 80 [Tags] Verify_LDAP_Login_Works_When_Both_Interfaces_Are_Configured 81 82 Create LDAP Configuration 83 Redfish.Logout 84 Sleep 30 85 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} 86 87 88Verify Secure LDAP Login Works When Both Interfaces Are Configured 89 [Documentation] Verify Secure LDAP login works when both the interfaces are configured. 90 [Tags] Verify_Secure_LDAP_Login_Works_When_Both_Interfaces_Are_Configured 91 92 Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI_1} ${LDAP_BIND_DN} 93 ... ${LDAP_BIND_DN_PASSWORD} ${LDAP_BASE_DN} 94 Redfish.Logout 95 Sleep 30 96 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} 97 98 99Verify SNMP Works When Eth1 IP Is Not Configured 100 [Documentation] Verify SNMP works when eth1 IP is not configured. 101 [Tags] Verify_SNMP_Works_When_Eth1_IP_Is_Not_Configured 102 [Setup] Run Keywords Redfish.Login AND 103 ... Set Test Variable ${CHANNEL_NUMBER} ${SECONDARY_CHANNEL_NUMBER} 104 ... AND Delete IP Address ${OPENBMC_HOST_ETH1} 105 [Teardown] Add IP Address ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway} 106 107 Create Error On BMC And Verify Trap 108 109 110Disable And Enable Eth0 Interface 111 [Documentation] Disable and Enable eth0 ethernet interface via redfish. 112 [Tags] Disable_And_Enable_Eth0_Interface 113 [Template] Set BMC Ethernet Interfaces State 114 115 # interface_ip interface enabled 116 ${OPENBMC_HOST} eth0 ${False} 117 ${OPENBMC_HOST} eth0 ${True} 118 119 120Verify Both Interfaces Access Concurrently Via Redfish 121 [Documentation] Verify both interfaces access conurrently via redfish. 122 [Tags] Verify_Both_Interfaces_Access_Concurrently_Via_Redfish 123 124 ${dict}= Execute Process Multi Keyword ${2} 125 ... Redfish.patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}} 126 ... Redfish1.patch ${REDFISH_NW_ETH_IFACE}eth1 body={'DHCPv4':{'UseDNSServers':${True}}} 127 128 Dictionary Should Not Contain Value ${dict} False 129 ... msg=One or more operations has failed. 130 131 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0 132 ${resp1}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1 133 134 Should Be Equal ${resp.dict["DHCPv4"]['UseDNSServers']} ${True} 135 Should Be Equal ${resp1.dict["DHCPv4"]['UseDNSServers']} ${True} 136 137Able To Access Serial Console Via Both Network Interfaces 138 [Documentation] Able to access serial console via both network interfaces. 139 [Tags] Able_To_Access_Serial_Console_Via_Both_Network_Interfaces 140 141 Open Connection And Log In host=${OPENBMC_HOST} port=2200 142 Open Connection And Log In host=${OPENBMC_HOST_ETH1} port=2200 143 Close All Connections 144 145Verify IPMI Works On Both Network Interfaces 146 [Documentation] Verify IPMI works on both network interfaces. 147 [Tags] Verify_IPMI_Works_On_Both_Network_Interfaces 148 149 Run IPMI ${OPENBMC_HOST_ETH1} power on 150 ${status1}= Run IPMI ${OPENBMC_HOST} power status 151 ${status2}= Run IPMI ${OPENBMC_HOST_ETH1} power status 152 Should Be Equal ${status1} ${status2} 153 154Verify Modifying IP Address Multiple Times On Interface 155 [Documentation] Verify modifying IP address multiple times on interface. 156 [Tags] Verify_Modifying_IP_Address_Multiple_Times_On_Interface 157 [Teardown] Run Keywords 158 ... Delete IP Address ${test_ipv4_addr} AND Redfish.Logout 159 160 ${test_gateway}= Get BMC Default Gateway 161 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway} 162 Update IP Address ${test_ipv4_addr} ${test_ipv4_addr2} ${test_subnet_mask} ${test_gateway} 163 Update IP Address ${test_ipv4_addr2} ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway} 164 Run Keyword Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 165 Run Keyword Wait For Host To Ping ${OPENBMC_HOST_ETH1} ${NETWORK_TIMEOUT} 166 167Verify Able To Load Certificates Via Eth1 IP Address 168 [Documentation] Verify able to load certificates via eth1 IP address. 169 [Tags] Verify_Able_To_Load_Certificates_Via_Eth1_IP_Address 170 [Template] Install Certificate Via Redfish And Verify 171 172 # cert_type cert_format expected_status 173 CA Valid Certificate ok 174 Client Valid Certificate Valid Privatekey ok 175 176Enable SSH Protocol Via Eth1 And Verify On Both Interfaces 177 [Documentation] Enable SSH protocol via eth1 and verify on both interfaces. 178 [Tags] Enable_SSH_Protocol_Via_Eth1_And_Verify_On_Both_Interfaces 179 180 Set SSH Value Via Eth1 ${True} 181 # Check if SSH is really enabled via Redfish via eth1. 182 Verify SSH Protocol State Via Eth1 ${True} 183 # Check if SSH login and commands on SSH session work on both interfaces. 184 Verify SSH Login And Commands Work 185 Verify SSH Login And Commands Work ${OPENBMC_HOST_ETH1} 186 187Disable SSH Protocol Via Eth1 And Verify On Both Interfaces 188 [Documentation] Disable SSH protocol via eth1 and verify on both interfaces. 189 [Tags] Disable_SSH_Protocol_Via_Eth1_And_Verify_On_Both_Interfaces 190 [Teardown] Set SSH Value Via Eth1 ${True} 191 192 Set SSH Value Via Eth1 ${False} 193 # Check if SSH is really disabled via Redfish via eth1. 194 Verify SSH Protocol State Via Eth1 ${False} 195 # Check if SSH login and commands fail on eth1. 196 ${status}= Run Keyword And Return Status 197 ... Verify SSH Login And Commands Work ${OPENBMC_HOST_ETH1} 198 199 Should Be Equal As Strings ${status} False 200 ... msg=SSH Login and commands are working after disabling SSH via eth1. 201 202 # Check if SSH login and commands fail. 203 ${status}= Run Keyword And Return Status 204 ... Verify SSH Login And Commands Work 205 206 Should Be Equal As Strings ${status} False 207 ... msg=SSH Login and commands are working after disabling SSH. 208 209*** Keywords *** 210 211Get Network Configuration Using Channel Number 212 [Documentation] Get ethernet interface. 213 [Arguments] ${channel_number} 214 215 # Description of argument(s): 216 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1"). 217 218 ${active_channel_config}= Get Active Channel Config 219 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']} 220 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 221 222 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses 223 RETURN @{network_configurations} 224 225 226Suite Setup Execution 227 [Documentation] Do suite setup task. 228 229 Valid Value OPENBMC_HOST_ETH1 230 231 # Check both interfaces are configured and reachable. 232 Ping Host ${OPENBMC_HOST} 233 Ping Host ${OPENBMC_HOST_ETH1} 234 235 ${network_configurations}= Get Network Configuration Using Channel Number ${SECONDARY_CHANNEL_NUMBER} 236 FOR ${network_configuration} IN @{network_configurations} 237 238 IF '${network_configuration['Address']}' == '${OPENBMC_HOST_ETH1}' 239 Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} 240 Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} 241 BREAK 242 END 243 244 END 245 246 247Set BMC Ethernet Interfaces State 248 [Documentation] Set BMC ethernet interface state. 249 [Arguments] ${interface_ip} ${interface} ${enabled} 250 [Teardown] Redfish1.Logout 251 252 # Description of argument(s): 253 # interface_ip IP address of ethernet interface. 254 # interface The ethernet interface name (eg. eth0 or eth1). 255 # enabled Indicates interface should be enabled (eg. True or False). 256 257 Redfish1.Login 258 259 ${data}= Create Dictionary InterfaceEnabled=${enabled} 260 261 Redfish1.patch ${REDFISH_NW_ETH_IFACE}${interface} body=&{data} 262 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 263 264 Sleep ${NETWORK_TIMEOUT}s 265 ${interface_status}= Redfish1.Get Attribute ${REDFISH_NW_ETH_IFACE}${interface} InterfaceEnabled 266 Should Be Equal ${interface_status} ${enabled} 267 268 ${status}= Run Keyword And Return Status Ping Host ${interface_ip} 269 270 IF ${enabled} == ${True} 271 Should Be Equal ${status} ${True} 272 ELSE 273 Should Be Equal ${status} ${False} 274 END 275 276 277Run IPMI 278 [Documentation] Run IPMI command. 279 [Arguments] ${host} ${sub_cmd} 280 281 # Description of argument(s): 282 # host BMC host name or IP address. 283 # sub_cmd The IPMI command string to be executed. 284 285 ${rc} ${output}= Run And Return Rc And Output ${cmd_prefix} -H ${host} ${sub_cmd} 286 Should Be Equal As Strings ${rc} 0 287 RETURN ${output} 288 289 290Install Certificate Via Redfish And Verify 291 [Documentation] Install and verify certificate using Redfish. 292 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True} 293 [Teardown] Remove Directory certificate_dir recursive=True 294 295 # Description of argument(s): 296 # cert_type Certificate type (e.g. "Client" or "CA"). 297 # cert_format Certificate file format 298 # (e.g. "Valid_Certificate_Valid_Privatekey"). 299 # expected_status Expected status of certificate replace Redfish 300 # request (i.e. "ok" or "error"). 301 # delete_cert Certificate will be deleted before installing if this True. 302 303 Create Directory certificate_dir 304 # AUTH_URI is a global variable defined in lib/resource.robot 305 Set Test Variable ${AUTH_URI} https://${OPENBMC_HOST_ETH1} 306 IF '${cert_type}' == 'CA' and '${delete_cert}' == '${True}' 307 Delete All CA Certificate Via Redfish 308 ELSE IF '${cert_type}' == 'Client' and '${delete_cert}' == '${True}' 309 Delete Certificate Via BMC CLI ${cert_type} 310 END 311 312 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format} 313 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path} 314 ${file_data}= Decode Bytes To String ${bytes} UTF-8 315 316 ${certificate_uri}= Set Variable If 317 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI} 318 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI} 319 320 ${cert_id}= Install Certificate File On BMC ${certificate_uri} ${expected_status} data=${file_data} 321 Logging Installed certificate id: ${cert_id} 322 323 Sleep 30s 324 325 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} 326 327 ${content}= redfish_utils.Get Attribute 328 ... ${certificate_uri}/${cert_id} CertificateString 329 330 ${bmc_cert_content}= Set Variable If '${expected_status}' == 'ok' 331 ... ${content} 332 333 IF '${expected_status}' == 'ok' 334 Should Contain ${cert_file_content} ${bmc_cert_content} 335 END 336 RETURN ${cert_id} 337 338Set SSH Value Via Eth1 339 [Documentation] Enable or disable SSH protocol via Eth1. 340 [Arguments] ${enable_value}=${True} 341 342 # Description of argument(s}: 343 # enable_value Enable or disable SSH, e.g. (true, false). 344 345 ${ssh_state}= Create Dictionary ProtocolEnabled=${enable_value} 346 ${data}= Create Dictionary SSH=${ssh_state} 347 348 Redfish1.Login 349 Redfish1.patch ${REDFISH_NW_PROTOCOL_URI} body=&{data} 350 ... valid_status_codes=[${HTTP_NO_CONTENT}] 351 352 # Wait for timeout for new values to take effect. 353 Sleep ${NETWORK_TIMEOUT}s 354 355Verify SSH Protocol State Via Eth1 356 [Documentation] Verify SSH protocol state via eth1. 357 [Arguments] ${state}=${True} 358 359 # Description of argument(s}: 360 # state Enable or disable SSH, e.g. (true, false) 361 362 ${resp}= Redfish1.Get ${REDFISH_NW_PROTOCOL_URI} 363 Should Be Equal As Strings ${resp.dict['SSH']['ProtocolEnabled']} ${state} 364 ... msg=Protocol states are not matching. 365