private static IpV6Address createIpV6Address(ResultSet rs, String v6BootProtocol) throws SQLException { final IpV6Address ipV6Address = new IpV6Address(); ipV6Address.setBootProtocol(Ipv6BootProtocol.valueOf(v6BootProtocol)); ipV6Address.setAddress(rs.getString("ipv6_address")); if (rs.getObject("ipv6_prefix") != null) { ipV6Address.setPrefix(rs. getInt("ipv6_prefix")); } ipV6Address.setGateway(rs.getString("ipv6_gateway")); return ipV6Address; }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("address", getAddress()) .append("prefix", getPrefix()) .append("gateway", getGateway()) .append("bootProtocol", getBootProtocol()) .build(); } }
public static IpV6Address createDefaultIpv6Address() { IpV6Address ipv6Address = new IpV6Address(); ipv6Address.setBootProtocol(Ipv6BootProtocol.NONE); return ipv6Address; }
private void initIpv6ConfigurationStaticBootProtocol(Ipv6BootProtocol networkBootProtocol) { initIpv6Configuration(); ipv6Address.setBootProtocol(networkBootProtocol); iface.setIpv6BootProtocol(networkBootProtocol); }
@Override public Integer getIpv6Prefix() { return iPv6Address.getPrefix(); }
@Override public String getIpv6Gateway() { return iPv6Address.getGateway(); }
private void initIpv6ConfigurationBootProtocolGateway(Ipv6BootProtocol networkBootProtocol, boolean syncGateway) { initIpv6ConfigurationStaticBootProtocol(networkBootProtocol); ipv6Address.setGateway(IPV6_GATEWAY); iface.setIpv6Gateway(syncGateway ? IPV6_GATEWAY : null); }
private void initIpv6ConfigurationBootProtocolAddress(Ipv6BootProtocol networkBootProtocol, boolean syncAddress) { initIpv6ConfigurationStaticBootProtocol(networkBootProtocol); ipv6Address.setAddress(IPV6_ADDRESS); iface.setIpv6Address(syncAddress ? IPV6_ADDRESS : null); }
private void initIpv6ConfigurationBootProtocolPrefix(Ipv6BootProtocol networkBootProtocol, boolean syncPrefix) { initIpv6ConfigurationStaticBootProtocol(networkBootProtocol); ipv6Address.setPrefix(IPV6_PREFIX); iface.setIpv6Prefix(syncPrefix ? IPV6_PREFIX : null); }
@Override public Ipv6BootProtocol getIpv6BootProtocol() { return iPv6Address.getBootProtocol(); }
@Override public String getIpv6Address() { return iPv6Address.getAddress(); }
public IpV6Address createPrimaryIpv6Address() { IpV6Address ipv6Address = new IpV6Address(); ipv6Address.setBootProtocol(Ipv6BootProtocol.DHCP); return ipv6Address; }
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); }
private boolean isIpv6PrefixInSync() { return Objects.equals(iface.getIpv6Prefix(), getIpv6PrimaryAddress().getPrefix()); }
private boolean isIpv6GatewayInSync() { String gatewayDesiredValue = getIpv6PrimaryAddress().getGateway(); String gatewayActualValue = iface.getIpv6Gateway(); return Objects.equals(gatewayDesiredValue, gatewayActualValue); }
@Test public void testIsNetworkInSyncWhenIpv6GatewayBothNull() { initIpv6ConfigurationStaticBootProtocol(Ipv6BootProtocol.STATIC_IP); ipv6Address.setGateway(null); iface.setIpv6Gateway(null); assertThat(createTestedInstance().isNetworkInSync(), is(true)); }
public Ipv6BootProtocol getIpv6BootProtocol() { if (primaryIpv6AddressNotSet()) { return null; } return getIpConfiguration().getIpv6PrimaryAddress().getBootProtocol(); }
public String getIpv6Address() { if (primaryIpv6AddressNotSet()) { return null; } return getIpConfiguration().getIpv6PrimaryAddress().getAddress(); }
public static void populateIpv6Details(InterfacePropertiesAccessor interfacePropertiesAccessor, IpV6Address ipv6Address) { final Ipv6BootProtocol ipv6BootProtocol = interfacePropertiesAccessor.getIpv6BootProtocol(); ipv6Address.setBootProtocol(ipv6BootProtocol); final boolean staticBootProtocol = Ipv6BootProtocol.STATIC_IP == ipv6BootProtocol; ipv6Address.setAddress(staticBootProtocol ? interfacePropertiesAccessor.getIpv6Address() : null); ipv6Address.setPrefix(staticBootProtocol ? interfacePropertiesAccessor.getIpv6Prefix() : null); ipv6Address.setGateway(staticBootProtocol ? interfacePropertiesAccessor.getIpv6Gateway() : null); } }
static IpAddressAssignment mapIpv6AddressAssignment(IpV6Address ipV6Address) { IpAddressAssignment ipAddressAssignment = new IpAddressAssignment(); Ip ip = new Ip(); ip.setVersion(IpVersion.V6); if (ipV6Address.getAddress() != null) { ip.setAddress(ipV6Address.getAddress()); } if (ipV6Address.getGateway() != null) { ip.setGateway(ipV6Address.getGateway()); } if (ipV6Address.getPrefix() != null) { ip.setNetmask(ipV6Address.getPrefix().toString()); } ipAddressAssignment.setIp(ip); BootProtocol assignmentMethod = Ipv6BootProtocolMapper.map(ipV6Address.getBootProtocol()); ipAddressAssignment.setAssignmentMethod(assignmentMethod); return ipAddressAssignment; }