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