1*** Settings *** 2Documentation Test BMC DHCP multiple network interface functionalities. 3 ... Run on setup eth0 in static and eth1 in DHCP. 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 10 11Suite Setup Suite Setup Execution 12Test Teardown FFDC On Test Case Fail 13Suite Teardown Redfish.Logout 14 15Test Tags Multiple_Interfaces_DHCP 16 17*** Variables *** 18 19${ethernet_interface} eth1 20 21&{dns_enable_dict} UseDNSServers=${True} 22&{dns_disable_dict} UseDNSServers=${False} 23&{ntp_enable_dict} UseNTPServers=${True} 24&{ntp_disable_dict} UseNTPServers=${False} 25&{domain_name_enable_dict} UseDomainName=${True} 26&{domain_name_disable_dict} UseDomainName=${False} 27&{enable_multiple_properties} UseDomainName=${True} 28... UseNTPServers=${True} 29... UseDNSServers=${True} 30&{disable_multiple_properties} UseDomainName=${False} 31... UseNTPServers=${False} 32... UseDNSServers=${False} 33 34*** Test Cases *** 35 36Disable DHCP On Eth1 And Verify System Is Accessible By Eth0 37 [Documentation] Disable DHCP on eth1 using Redfish and verify 38 ... if system is accessible by eth0. 39 [Tags] Disable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0 40 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1 41 42 Set DHCPEnabled To Enable Or Disable False eth1 43 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} 44 Should Be Equal ${DHCPEnabled} ${False} 45 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 46 47Enable DHCP On Eth1 And Verify System Is Accessible By Eth0 48 [Documentation] Enable DHCP on eth1 using Redfish and verify if system 49 ... is accessible by eth0. 50 [Tags] Enable_DHCP_On_Eth1_And_Verify_System_Is_Accessible_By_Eth0 51 [Setup] Set DHCPEnabled To Enable Or Disable False eth1 52 53 Set DHCPEnabled To Enable Or Disable True eth1 54 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} 55 Should Be Equal ${DHCPEnabled} ${True} 56 Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT} 57 58Set Network Property via Redfish And Verify 59 [Documentation] Set network property via Redfish and verify. 60 [Tags] Set_Network_Property_via_Redfish_And_Verify 61 [Template] Apply DHCP Config 62 63 # property 64 ${dns_enable_dict} 65 ${dns_disable_dict} 66 ${domain_name_enable_dict} 67 ${domain_name_disable_dict} 68 ${ntp_enable_dict} 69 ${ntp_disable_dict} 70 ${enable_multiple_properties} 71 ${disable_multiple_properties} 72 73Set Network Property For DHCPv6 via Redfish And Verify 74 [Documentation] Set network property for DHCPv6 via Redfish and verify. 75 [Tags] Set_Network_Property_For_DHCPv6_via_Redfish_And_Verify 76 [Template] Apply DHCPv6 Config And Verify 77 78 # property 79 ${dns_enable_dict} 80 ${dns_disable_dict} 81 ${domain_name_enable_dict} 82 ${domain_name_disable_dict} 83 ${ntp_enable_dict} 84 ${ntp_disable_dict} 85 ${enable_multiple_properties} 86 ${disable_multiple_properties} 87 88Enable DHCP On Eth1 And Check No Impact On Eth0 89 [Documentation] Enable DHCP On Eth1 And Check No Impact On Eth0. 90 [Tags] Enable_DHCP_On_Eth1_And_Check_No_Impact_On_Eth0 91 [Setup] Set DHCPEnabled To Enable Or Disable False eth1 92 93 # Getting the eth0 details before enabling DHCP. 94 ${ip_data_before}= Get BMC IP Info 95 96 # Enable DHCP on eth1. 97 Set DHCPEnabled To Enable Or Disable True eth1 98 99 # Check the value of DHCPEnabled on eth0 is not impacted. 100 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${1} 101 Should Be Equal ${DHCPEnabled} ${False} 102 103 # Getting eth0 details after enabling DHCP. 104 ${ip_data_after}= Get BMC IP Info 105 106 # Before and after IP details must match. 107 Should Be Equal ${ip_data_before} ${ip_data_after} 108 109Enable DHCP On Eth1 And Check Persistency On Reboot 110 [Documentation] Enable DHCP on Eth1 and check persistency 111 ... on reboot and should not switch to static. 112 [Tags] Enable_DHCP_On_Eth1_And_Check_Persistency_On_Reboot 113 [Setup] Set DHCPEnabled To Enable Or Disable False eth1 114 115 Set DHCPEnabled To Enable Or Disable True eth1 116 Redfish OBMC Reboot (off) stack_mode=skip 117 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} 118 Should Be Equal ${DHCPEnabled} ${True} 119 120Switch Between DHCP And Static 121 [Documentation] Switch between DHCP and static. 122 [Tags] Switch_Between_DHCP_And_Static 123 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1 124 125 # Fetch the IP details before. 126 ${ip_addr_before} ${gateway_before} ${subnetmask_before} Get DHCP IP Info 127 128 # Switch Between Static and DHCP. 129 FOR ${i} IN RANGE ${10} 130 Set DHCPEnabled To Enable Or Disable False eth1 131 Set DHCPEnabled To Enable Or Disable True eth1 132 END 133 Sleep 5s 134 135 # Fetch the IP details after. 136 ${ip_addr_after} ${gateway_after} ${subnetmask_after} Get DHCP IP Info 137 138 # DHCP Details must be the same before and after. 139 Should Be Equal ${ip_addr_before} ${ip_addr_after} 140 Should Be Equal ${gateway_before} ${gateway_after} 141 Should Be Equal ${subnetmask_before} ${subnetmask_after} 142 143Disable DHCP On Eth1 And Verify DHCP IP Erased 144 [Documentation] Disable DHCP on Eth1 and verify DHCP IP erased. 145 [Tags] Disable_DHCP_On_Eth1_And_Verify_DHCP_IP_Erased 146 [Teardown] Set DHCPEnabled To Enable Or Disable True eth1 147 148 Set DHCPEnabled To Enable Or Disable False eth1 149 ${DHCPEnabled}= Get IPv4 DHCP Enabled Status ${2} 150 Should Be Equal ${DHCPEnabled} ${False} 151 152 ${dhcp_ip_list}= Get Network Configuration Using Channel Number ${2} 153 154 Should Be Empty ${dhcp_ip_list} 155 ... msg=From switching from DHCP to Static DHCP IP is not erased. 156 157*** Keywords *** 158 159Apply DHCP Config 160 [Documentation] Apply DHCP Config 161 [Arguments] ${property} 162 163 # Description of Argument(s): 164 # property DHCP property values. 165 166 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 167 ... body={"DHCPv4":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 168 169 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 170 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv4"]} 171 172Apply DHCPv6 Config And Verify 173 [Documentation] Apply DHCPv6 config and verify. 174 [Arguments] ${property} 175 176 # Description of Argument(s): 177 # property DHCPv6 property values. 178 179 Redfish.Patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 180 ... body={"DHCPv6":${property}} valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] 181 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 182 183 Verify Ethernet Config Property ${property} ${resp.dict["DHCPv6"]} 184 185Verify Ethernet Config Property 186 [Documentation] verify ethernet config properties. 187 [Arguments] ${property} ${response_data} 188 189 # Description of argument(s): 190 # property DHCP Properties in dictionary. 191 # Example: 192 # property value 193 # DHCPEnabled :False 194 # UseDomainName :True 195 # UseNTPServers :True 196 # UseDNSServers :True 197 # response_data DHCP Response data in dictionary. 198 # Example: 199 # property value 200 # DHCPEnabled :False 201 # UseDomainName :True 202 # UseNTPServers :True 203 # UseDNSServers :True 204 205 ${key_map}= Get Dictionary Items ${property} 206 FOR ${key} ${value} IN @{key_map} 207 Should Be Equal As Strings ${response_data['${key}']} ${value} 208 END 209 210Restore Configuration 211 [Documentation] Restore the configuration to Both Static Network 212 213 IF '${CHANNEL_NUMBER}' == '${1}' 214 Add IP Address ${OPENBMC_HOST} ${eth0_subnet_mask} ${eth0_gateway} 215 ELSE IF '${CHANNEL_NUMBER}' == '{2}' 216 Add IP Address ${OPENBMC_HOST_ETH1} ${eth1_subnet_mask} ${eth1_gateway} 217 END 218 219Get Network Configuration Using Channel Number 220 [Documentation] Get ethernet interface. 221 [Arguments] ${channel_number} 222 223 # Description of argument(s): 224 # channel_number Ethernet channel number, 1 is for eth0 and 2 is for eth1 (e.g. "1"). 225 226 ${resp}= Redfish.Get ${REDFISH_NW_ETH_IFACE}${ethernet_interface} 227 228 @{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses 229 RETURN @{network_configurations} 230 231Suite Setup Execution 232 [Documentation] Do suite setup task. 233 234 Ping Host ${OPENBMC_HOST} 235 Redfish.Login 236 237 ${active_channel_config}= Get Active Channel Config 238 ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']} 239 240 # Get the configuration of eth1 241 ${network_configurations}= Get Network Configuration Using Channel Number ${2} 242 FOR ${network_configuration} IN @{network_configurations} 243 IF '${network_configuration['Address']}' == '${OPENBMC_HOST_ETH1}' 244 Set Suite Variable ${eth1_subnet_mask} ${network_configuration['SubnetMask']} 245 Set Suite Variable ${eth1_gateway} ${network_configuration['Gateway']} 246 BREAK 247 END 248 END 249 250 # Get the configuration of eth0 251 ${network_configurations}= Get Network Configuration Using Channel Number ${1} 252 FOR ${network_configuration} IN @{network_configurations} 253 IF '${network_configuration['Address']}' == '${OPENBMC_HOST}' 254 Set Suite Variable ${eth0_subnet_mask} ${network_configuration['SubnetMask']} 255 Set Suite Variable ${eth0_gateway} ${network_configuration['Gateway']} 256 BREAK 257 END 258 END 259