本文整理了Java中com.cloud.utils.net.NetUtils.isIpv4()
方法的一些代码示例,展示了NetUtils.isIpv4()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NetUtils.isIpv4()
方法的具体详情如下:
包路径:com.cloud.utils.net.NetUtils
类名称:NetUtils
方法名:isIpv4
[英]Returns true if the given IP address is IPv4 or false if it is an IPv6. If it is an invalid IP address it throws an exception.
[中]如果给定的IP地址是IPv4,则返回true;如果是IPv6,则返回false。如果是无效的IP地址,则会引发异常。
代码示例来源:origin: apache/cloudstack
@Test(expected = IllegalArgumentException.class)
public void testIsIpv4ExpectException2() {
NetUtils.isIpv4("2001:db8:300::/64");
}
代码示例来源:origin: apache/cloudstack
@Test(expected = IllegalArgumentException.class)
public void testIsIpv4ExpectException() {
NetUtils.isIpv4("test");
}
代码示例来源:origin: apache/cloudstack
@Test
public void testIsIpv4() {
assertTrue(NetUtils.isIpv4("192.168.1.1"));
assertFalse(NetUtils.isIpv4("2a01:4f8:130:2192::2"));
}
代码示例来源:origin: apache/cloudstack
@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");
}
}
}
代码示例来源:origin: apache/cloudstack
if ((ipv4Address != null || NetUtils.isIpv4(network.getGateway()) && org.apache.commons.lang3.StringUtils.isBlank(ipv6Address))) {
ipaddr = _ipAddrMgr.allocateGuestIP(network, ipv4Address);
内容来源于网络,如有侵权,请联系作者删除!