private void initIpv4ConfigurationBootProtocol(boolean sameBootProtocol) { initIpv4Configuration(); ipv4Address.setBootProtocol(IPV4_BOOT_PROTOCOL); Ipv4BootProtocol ifaceBootProtocol = sameBootProtocol ? IPV4_BOOT_PROTOCOL : Ipv4BootProtocol.forValue((IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length); iface.setIpv4BootProtocol(ifaceBootProtocol); }
@Override public String fetchBootProtocol() { return getVmInitNetwork().getBootProtocol().getDisplayName(); } }
private void initIpv6ConfigurationBootProtocol(boolean sameBootProtocol) { initIpv6Configuration(); ipv6Address.setBootProtocol(IPV6_BOOT_PROTOCOL); Ipv6BootProtocol ifaceBootProtocol = sameBootProtocol ? IPV6_BOOT_PROTOCOL : Ipv6BootProtocol.forValue((IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length); iface.setIpv6BootProtocol(ifaceBootProtocol); }
@Test public void testUnmappedEntityValue() { for (Ipv4BootProtocol value : Ipv4BootProtocol.values()) { assertThat(String.format("%s.%s is not mapped", Ipv6BootProtocol.class.getName(), value), Ipv4BootProtocolMapper.map(value), Matchers.notNullValue()); } }
@Test public void testReportConfigurationsOnHostWhenIpv4BootProtocolNotStatic() { initIpv4ConfigurationBootProtocolAddress(Ipv4BootProtocol.NONE, false); initIpv4ConfigurationBootProtocolNetmask(Ipv4BootProtocol.NONE, false); initIpv4ConfigurationBootProtocolGateway(Ipv4BootProtocol.NONE, false); NetworkInSyncWithVdsNetworkInterface testedInstanceWithSameNonQosValues = createTestedInstanceWithSameNonQosValues(); List<ReportedConfiguration> reportedConfigurationList = testedInstanceWithSameNonQosValues.reportConfigurationsOnHost().getReportedConfigurationList(); IPv4Address primaryAddress = this.testedNetworkAttachment.getIpConfiguration().getIpv4PrimaryAddress(); List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations( createBasicAndQosReportedConfigurations(), defaultRouteReportedConfiguration(false), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), primaryAddress.getBootProtocol().name(), true) ); assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true)); assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size())); }
entity.setVdsName(rs.getString("vds_name")); entity.setId(getGuidDefaultEmpty(rs, "id")); entity.setIpv4BootProtocol(Ipv4BootProtocol.forValue(rs.getInt("boot_protocol"))); entity.setIpv6BootProtocol(Ipv6BootProtocol.forValue(rs.getInt("ipv6_boot_protocol"))); entity.setReportedSwitchType(SwitchType.parse(rs.getString("reported_switch_type")));
Ipv4BootProtocol(int intValue, String displayName) { init(intValue, displayName); }
private static IPv4Address createIpv4Address(ResultSet rs, String bootProtocol) throws SQLException { final IPv4Address iPv4Address = new IPv4Address(); iPv4Address.setBootProtocol(Ipv4BootProtocol.valueOf(bootProtocol)); iPv4Address.setAddress(rs.getString("address")); iPv4Address.setNetmask(rs.getString("netmask")); iPv4Address.setGateway(rs.getString("gateway")); return iPv4Address; }
getIpv4BootProtocolList().setItems(Arrays.asList(Ipv4BootProtocol.values())); getIpv4BootProtocolList().setSelectedItem(Ipv4BootProtocol.NONE);
@Test public void testReportConfigurationsOnHostWhenDefaultRouteDiffers() { //cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique. iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP); IPv4Address address = new IPv4Address(); address.setBootProtocol(Ipv4BootProtocol.DHCP); testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address)); //network has default route role NetworkInSyncWithVdsNetworkInterface testedInstance = createTestedInstanceWithSameNonQosValues(true); ReportedConfigurations reportedConfigurations = testedInstance.reportConfigurationsOnHost(); assertThat(reportedConfigurations.isNetworkInSync(), is(false)); List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList(); List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations( combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), "192.168.1.1,2001:0db8:85a3:0000:0000:8a2e:0370:7334", true), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, false, true, false) ); assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true)); assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size())); }
@Test public void testIsNetworkInSyncWhenIpv4StaticBootProtocolAddressDifferent() { initIpv4ConfigurationBootProtocolAddress(IPV4_BOOT_PROTOCOL, false); iface.setIpv4BootProtocol(Ipv4BootProtocol.forValue( (IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length)); assertThat(createTestedInstance().isNetworkInSync(), is(false)); }
@Test public void testReportConfigurationsOnHostWhenDnsConfigurationResolverOutOfSync() { iface.setIpv4DefaultRoute(true); //cannot use initIpv4ConfigurationBootProtocol because of 'randomized tests' technique. iface.setIpv4BootProtocol(Ipv4BootProtocol.DHCP); IPv4Address address = new IPv4Address(); address.setBootProtocol(Ipv4BootProtocol.DHCP); testedNetworkAttachment.getIpConfiguration().setIPv4Addresses(Collections.singletonList(address)); network.setDnsResolverConfiguration(sampleDnsResolverConfiguration2); ReportedConfigurations reportedConfigurations = createTestedInstanceWithSameNonQosValues(true).reportConfigurationsOnHost(); assertThat(reportedConfigurations.isNetworkInSync(), is(false)); List<ReportedConfiguration> reportedConfigurationList = reportedConfigurations.getReportedConfigurationList(); List<ReportedConfiguration> expectedReportedConfigurations = addReportedConfigurations( combineReportedConfigurations(createBasicReportedConfigurations(), reportQos(true)), new ReportedConfiguration(ReportedConfigurationType.IPV4_BOOT_PROTOCOL, iface.getIpv4BootProtocol().name(), /*ipv4Address*/address.getBootProtocol().name(), true), new ReportedConfiguration(ReportedConfigurationType.DNS_CONFIGURATION, addressesAsString(sampleDnsResolverConfiguration.getNameServers()), addressesAsString(network.getDnsResolverConfiguration().getNameServers()), false), new ReportedConfiguration(ReportedConfigurationType.DEFAULT_ROUTE, true, true, true) ); assertThat(reportedConfigurationList.containsAll(expectedReportedConfigurations), is(true)); assertThat(reportedConfigurationList.size(), is(expectedReportedConfigurations.size())); }
@Test public void testIsNetworkInSyncWhenIpv4BootProtocolDifferent() { initIpv4ConfigurationBootProtocol(false); iface.setIpv4BootProtocol(Ipv4BootProtocol.forValue( (IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length)); assertThat(createTestedInstance().isNetworkInSync(), is(false)); }
@Test public void testIsNetworkInSyncWhenIpv4StaticBootProtocolNetmaskDifferent() { initIpv4ConfigurationBootProtocolNetmask(IPV4_BOOT_PROTOCOL, false); iface.setIpv4BootProtocol(Ipv4BootProtocol.forValue( (IPV4_BOOT_PROTOCOL.getValue() + 1) % Ipv4BootProtocol.values().length)); assertThat(createTestedInstance().isNetworkInSync(), is(false)); }