@Test(expected = IllegalArgumentException.class) public void testIsIpv4ExpectException2() { NetUtils.isIpv4("2001:db8:300::/64"); }
@Test(expected = IllegalArgumentException.class) public void testIsIpv4ExpectException() { NetUtils.isIpv4("test"); }
@Override public void create() throws ResourceAllocationException { NicSecondaryIp result; IpAddresses requestedIpPair = new IpAddresses(ipAddr, null); if (!NetUtils.isIpv4(ipAddr)) { requestedIpPair = new IpAddresses(null, ipAddr); } try { result = _networkService.allocateSecondaryGuestIP(getNicId(), requestedIpPair); if (result != null) { setEntityId(result.getId()); setEntityUuid(result.getUuid()); } } catch (InsufficientAddressCapacityException e) { throw new InvalidParameterValueException("Allocating guest ip for nic failed : " + e.getMessage()); } if (result == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to assign secondary ip to nic"); } } }
if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && org.apache.commons.lang3.StringUtils.isBlank(ipv6Address))) { ipaddr = _ipAddrMgr.allocateGuestIP(network, ipv4Address);