1*** Settings *** 2Documentation Test BMC multiple network interface functionalities. 3 4# User input BMC IP for the eth1. 5# Use can input as -v OPENBMC_HOST_1:xx.xxx.xx from command line. 6Library ../../lib/bmc_redfish.py https://${OPENBMC_HOST_1}:${HTTPS_PORT} 7... ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} WITH NAME Redfish1 8 9Resource ../../lib/resource.robot 10Resource ../../lib/common_utils.robot 11Resource ../../lib/connection_client.robot 12Resource ../../lib/bmc_network_utils.robot 13Resource ../../lib/openbmc_ffdc.robot 14Resource ../../lib/bmc_ldap_utils.robot 15Resource ../../lib/snmp/resource.robot 16Resource ../../lib/snmp/redfish_snmp_utils.robot 17Resource ../../lib/certificate_utils.robot 18Library ../../lib/jobs_processing.py 19Library OperatingSystem 20 21Suite Setup Suite Setup Execution 22Test Teardown FFDC On Test Case Fail 23Suite Teardown Run Keywords Redfish1.Logout AND Redfish.Logout 24 25*** Variables *** 26 27${cmd_prefix} ipmitool -I lanplus -C 17 -p 623 -U ${OPENBMC_USERNAME} -P ${OPENBMC_PASSWORD} 28${test_ipv4_addr} 10.7.7.7 29${test_ipv4_addr2} 10.7.7.8 30${test_subnet_mask} 255.255.255.0 31 32*** Test Cases *** 33 34Verify Both Interfaces BMC IP Addresses Accessible Via SSH 35 [Documentation] Verify both interfaces (eth0, eth1) BMC IP addresses accessible via SSH. 36 [Tags] Verify_Both_Interfaces_BMC_IP_Addresses_Accessible_Via_SSH 37 38 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST} 39 Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} host=${OPENBMC_HOST_1} 40 Close All Connections 41 42 43Verify Redfish Works On Both Interfaces 44 [Documentation] Verify access BMC with both interfaces (eth0, eth1) IP addresses via Redfish. 45 [Tags] Verify_Redfish_Works_On_Both_Interfaces 46 [Teardown] Run Keywords 47 ... Configure Hostname ${hostname} AND Validate Hostname On BMC ${hostname} 48 49 Redfish1.Login 50 Redfish.Login 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} ${2} 68 ... AND Delete IP Address ${OPENBMC_HOST_1} 69 [Teardown] Run Keywords Redfish.Login AND 70 ... Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway} 71 72 Create LDAP Configuration 73 Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD} 74 Redfish.Logout 75 76 77Verify SNMP Works When Eth1 IP Is Not Configured 78 [Documentation] Verify SNMP works when eth1 IP is not configured. 79 [Tags] Verify_SNMP_Works_When_Eth1_IP_Is_Not_Configured 80 [Setup] Run Keywords Set Test Variable ${CHANNEL_NUMBER} ${2} 81 ... AND Delete IP Address ${OPENBMC_HOST_1} 82 [Teardown] Run Keywords Redfish.Login AND 83 ... Add IP Address ${OPENBMC_HOST_1} ${eth1_subnet_mask} ${eth1_gateway} 84 85 Create Error On BMC And Verify Trap 86 87 88Disable And Enable Eth0 Interface 89 [Documentation] Disable and Enable eth0 ethernet interface via redfish. 90 [Tags] Disable_And_Enable_Eth0_Interface 91 [Template] Set BMC Ethernet Interfaces State 92 93 # interface_ip interface enabled 94 ${OPENBMC_HOST} eth0 ${False} 95 ${OPENBMC_HOST} eth0 ${True} 96 97 98Verify Both Interfaces Access Concurrently Via Redfish 99 [Documentation] Verify both interfaces access conurrently via redfish. 100 [Tags] Verify_Both_Interfaces_Access_Concurrently_Via_Redfish 101 102 Redfish.Login 103 Redfish1.Login 104 105 ${dict}= Execute Process Multi Keyword ${2} 106 ... Redfish.Patch ${REDFISH_NW_ETH_IFACE}eth0 body={'DHCPv4':{'UseDNSServers':${True}}} 107 ... Redfish1.Patch ${REDFISH_NW_ETH_IFACE}eth1 body={'DHCPv4':{'UseDNSServers':${True}}} 108 109 Dictionary Should Not Contain Value ${dict} False 110 ... msg=One or more operations has failed. 111 112 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}eth0 113 ${resp1}= Redfish1.Get ${REDFISH_NW_ETH_IFACE}eth1 114 115 Should Be Equal ${resp.dict["DHCPv4"]['UseDNSServers']} ${True} 116 Should Be Equal ${resp1.dict["DHCPv4"]['UseDNSServers']} ${True} 117 118 119Able To Access Serial Console Via Both Network Interfaces 120 [Documentation] Able to access serial console via both network interfaces. 121 [Tags] Able_To_Access_Serial_Console_Via_Both_Network_Interfaces 122 123 Open Connection And Log In host=${OPENBMC_HOST} port=2200 124 Open Connection And Log In host=${OPENBMC_HOST_1} port=2200 125 Close All Connections 126 127 128Verify IPMI Works On Both Network Interfaces 129 [Documentation] Verify IPMI works on both network interfaces. 130 [Tags] Verify_IPMI_Works_On_Both_Network_Interfaces 131 132 Run IPMI ${OPENBMC_HOST_1} power on 133 ${status1}= Run IPMI ${OPENBMC_HOST} power status 134 ${status2}= Run IPMI ${OPENBMC_HOST_1} power status 135 Should Be Equal ${status1} ${status2} 136 137Verify Modifying IP Address Multiple Times On Interface 138 [Documentation] Verify modifying IP address multiple times on interface. 139 [Tags] Verify_Modifying_IP_Address_Multiple_Times_On_Interface 140 [Teardown] Run Keywords 141 ... Delete IP Address ${test_ipv4_addr} AND Test Teardown 142 143 ${test_gateway}= Get BMC Default Gateway 144 Add IP Address ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway} 145 Update IP Address ${test_ipv4_addr} ${test_ipv4_addr2} ${test_subnet_mask} ${test_gateway} 146 Update IP Address ${test_ipv4_addr2} ${test_ipv4_addr} ${test_subnet_mask} ${test_gateway} 147 Run Keyword Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 148 Run Keyword Wait For Host To Ping ${OPENBMC_HOST_1} ${NETWORK_TIMEOUT} 149 150Verify Able To Load Certificates Via Eth1 IP Address 151 [Documentation] Verify able to load certificates via eth1 IP address. 152 [Setup] Create Directory certificate_dir 153 [Tags] Verify_Able_To_Load_Certificates_Via_Eth1_IP_Address 154 [Teardown] Run Keywords Remove Directory certificate_dir recursive=True 155 ... AND FFDC On Test Case Fail 156 [Template] Install Certificate Via Redfish And Verify 157 158 # cert_type cert_format expected_status 159 CA Valid Certificate ok 160 Client Valid Certificate Valid Privatekey ok 161 162*** Keywords *** 163 164Get Network Configuration Using Channel Number 165 [Documentation] Get ethernet interface. 166 [Arguments] ${channel_number} 167 168 # Description of argument(s): 169 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1"). 170 171 ${active_channel_config}= Get Active Channel Config 172 ${ethernet_interface}= Set Variable ${active_channel_config['${channel_number}']['name']} 173 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 174 175 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses 176 [Return] @{network_configurations} 177 178 179Suite Setup Execution 180 [Documentation] Do suite setup task. 181 182 Valid Value OPENBMC_HOST_1 183 184 # Check both interfaces are configured and reachable. 185 Ping Host ${OPENBMC_HOST} 186 Ping Host ${OPENBMC_HOST_1} 187 188 ${network_configurations}= Get Network Configuration Using Channel Number ${2} 189 FOR ${network_configuration} IN @{network_configurations} 190 191 Run Keyword If '${network_configuration['Address']}' == '${OPENBMC_HOST_1}' 192 ... Run Keywords Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} 193 ... AND Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} 194 ... AND Exit For Loop 195 196 END 197 198 199Set BMC Ethernet Interfaces State 200 [Documentation] Set BMC ethernet interface state. 201 [Arguments] ${interface_ip} ${interface} ${enabled} 202 [Teardown] Redfish1.Logout 203 204 # Description of argument(s): 205 # interface_ip IP address of ethernet interface. 206 # interface The ethernet interface name (eg. eth0 or eth1). 207 # enabled Indicates interface should be enabled (eg. True or False). 208 209 Redfish1.Login 210 211 ${data}= Create Dictionary InterfaceEnabled=${enabled} 212 213 Redfish1.patch ${REDFISH_NW_ETH_IFACE}${interface} body=&{data} 214 ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 215 216 Sleep ${NETWORK_TIMEOUT}s 217 ${interface_status}= Redfish1.Get Attribute ${REDFISH_NW_ETH_IFACE}${interface} InterfaceEnabled 218 Should Be Equal ${interface_status} ${enabled} 219 220 ${status}= Run Keyword And Return Status Ping Host ${interface_ip} 221 222 Run Keyword If ${enabled} == ${True} Should Be Equal ${status} ${True} 223 ... ELSE Should Be Equal ${status} ${False} 224 225 226Run IPMI 227 [Documentation] Run IPMI command. 228 [Arguments] ${host} ${sub_cmd} 229 230 # Description of argument(s): 231 # host BMC host name or IP address. 232 # sub_cmd The IPMI command string to be executed. 233 234 ${rc} ${output}= Run And Return Rc And Output ${cmd_prefix} -H ${host} ${sub_cmd} 235 Should Be Equal As Strings ${rc} 0 236 [Return] ${output} 237 238 239Install Certificate Via Redfish And Verify 240 [Documentation] Install and verify certificate using Redfish. 241 [Arguments] ${cert_type} ${cert_format} ${expected_status} ${delete_cert}=${True} 242 243 # Description of argument(s): 244 # cert_type Certificate type (e.g. "Client" or "CA"). 245 # cert_format Certificate file format 246 # (e.g. "Valid_Certificate_Valid_Privatekey"). 247 # expected_status Expected status of certificate replace Redfish 248 # request (i.e. "ok" or "error"). 249 # delete_cert Certificate will be deleted before installing if this True. 250 251 # AUTH_URI is a global variable defined in lib/resource.robot 252 Set Test Variable ${AUTH_URI} https://${OPENBMC_HOST_1} 253 Run Keyword If '${cert_type}' == 'CA' and '${delete_cert}' == '${True}' 254 ... Delete All CA Certificate Via Redfish 255 ... ELSE IF '${cert_type}' == 'Client' and '${delete_cert}' == '${True}' 256 ... Delete Certificate Via BMC CLI ${cert_type} 257 258 ${cert_file_path}= Generate Certificate File Via Openssl ${cert_format} 259 ${bytes}= OperatingSystem.Get Binary File ${cert_file_path} 260 ${file_data}= Decode Bytes To String ${bytes} UTF-8 261 262 ${certificate_uri}= Set Variable If 263 ... '${cert_type}' == 'Client' ${REDFISH_LDAP_CERTIFICATE_URI} 264 ... '${cert_type}' == 'CA' ${REDFISH_CA_CERTIFICATE_URI} 265 266 ${cert_id}= Install Certificate File On BMC ${certificate_uri} ${expected_status} data=${file_data} 267 Logging Installed certificate id: ${cert_id} 268 269 Sleep 30s 270 ${cert_file_content}= OperatingSystem.Get File ${cert_file_path} 271 ${bmc_cert_content}= Run Keyword If '${expected_status}' == 'ok' redfish_utils.Get Attribute 272 ... ${certificate_uri}/${cert_id} CertificateString 273 Run Keyword If '${expected_status}' == 'ok' Should Contain ${cert_file_content} ${bmc_cert_content} 274 [Return] ${cert_id} 275