private static void addIpsByVersion(Ips ips, List<String> entityIps, IpVersion ipVersion) { if (entityIps != null) { for (String entityIp : entityIps) { Ip ip = new Ip(); ip.setAddress(entityIp); ip.setVersion(ipVersion); ips.getIps().add(ip); } } }
/** * Checks that when explicitly given IPv6 it ignores the address. */ @Test public void testIgnoreAddressWhenV6ExplicitlyGiven() { Ip ip = new Ip(); ip.setAddress("127.0.0.1"); ip.setVersion(IpVersion.V6); IpVersion version = IpHelper.getVersion(ip); assertEquals(IpVersion.V6, version); }
/** * Checks that when explicitly given IPv4 it ignores the address. */ @Test public void testIgnoreAddressWhenV4ExplicitlyGiven() { Ip ip = new Ip(); ip.setAddress("::1"); ip.setVersion(IpVersion.V4); IpVersion version = IpHelper.getVersion(ip); assertEquals(IpVersion.V4, version); }
@Override protected ReportedDevice postPopulate(ReportedDevice model) { model.setType(ReportedDeviceType.NETWORK); for (Ip ip : model.getIps().getIps()) { ip.setVersion(IpVersion.V4); ip.setGateway(null); ip.setNetmask(null); } return model; }
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; }
private static void mapIpv6ToModel(VdsNetworkInterface entity, HostNic model) { BootProtocol ipv6BootProtocol = Ipv6BootProtocolMapper.map(entity.getIpv6BootProtocol()); if(ipv6BootProtocol!=null){ model.setIpv6BootProtocol(ipv6BootProtocol); } if (entity.getIpv6Address() != null || entity.getIpv6Gateway() != null || entity.getIpv6Prefix() != null) { final Ip ipv6 = new Ip(); ipv6.setVersion(IpVersion.V6); if (entity.getIpv6Address() != null) { ipv6.setAddress(entity.getIpv6Address()); } if (entity.getIpv6Gateway() != null) { ipv6.setGateway(entity.getIpv6Gateway()); } if (entity.getIpv6Prefix() != null) { ipv6.setNetmask(entity.getIpv6Prefix().toString()); } model.setIpv6(ipv6); } }
@Override public Ip adapt(V3IP from) { Ip to = new Ip(); if (from.isSetAddress()) { to.setAddress(from.getAddress()); } if (from.isSetGateway()) { to.setGateway(from.getGateway()); } if (from.isSetNetmask()) { to.setNetmask(from.getNetmask()); } if (from.isSetVersion()) { to.setVersion(IpVersion.fromValue(from.getVersion())); } return to; } }
private static IpAddressAssignment mapIpv4Address(IPv4Address iPv4Address) { IpAddressAssignment ipAddressAssignment = new IpAddressAssignment(); Ip ip = new Ip(); ip.setVersion(IpVersion.V4); if (iPv4Address.getAddress() != null) { ip.setAddress(iPv4Address.getAddress()); } if (iPv4Address.getGateway() != null) { ip.setGateway(iPv4Address.getGateway()); } if (iPv4Address.getNetmask() != null) { ip.setNetmask(iPv4Address.getNetmask()); } ipAddressAssignment.setIp(ip); BootProtocol assignmentMethod = Ipv4BootProtocolMapper.map(iPv4Address.getBootProtocol()); ipAddressAssignment.setAssignmentMethod(assignmentMethod == null ? null : assignmentMethod); return ipAddressAssignment; }
private static void mapIpv4ToModel(VdsNetworkInterface entity, HostNic model) { BootProtocol ipv4BootProtocol = Ipv4BootProtocolMapper.map(entity.getIpv4BootProtocol()); if(ipv4BootProtocol!=null){ model.setBootProtocol(ipv4BootProtocol); } if (entity.getIpv4Address() != null || entity.getIpv4Gateway() != null || entity.getIpv4Subnet() != null) { final Ip ipv4 = new Ip(); ipv4.setVersion(IpVersion.V4); if (entity.getIpv4Address() != null) { ipv4.setAddress(entity.getIpv4Address()); } if (entity.getIpv4Gateway() != null) { ipv4.setGateway(entity.getIpv4Gateway()); } if (entity.getIpv4Subnet() != null) { ipv4.setNetmask(entity.getIpv4Subnet()); } model.setIp(ipv4); } }