本文整理汇总了Java中org.opendaylight.controller.networkconfig.neutron.NeutronSubnet.getCidr方法的典型用法代码示例。如果您正苦于以下问题:Java NeutronSubnet.getCidr方法的具体用法?Java NeutronSubnet.getCidr怎么用?Java NeutronSubnet.getCidr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.networkconfig.neutron.NeutronSubnet
的用法示例。
在下文中一共展示了NeutronSubnet.getCidr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validGatewayIP
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入方法依赖的package包/类
boolean validGatewayIP(NeutronSubnet subnet, String ipAddress) {
try {
SubnetUtils util = new SubnetUtils(subnet.getCidr());
SubnetInfo info = util.getInfo();
boolean inRange = info.isInRange(ipAddress);
if (!inRange) {
return false;
} else {
// ip available in allocation pool
Iterator<NeutronSubnet_IPAllocationPool> i = subnet.getAllocationPools().iterator();
while (i.hasNext()) {
NeutronSubnet_IPAllocationPool pool = i.next();
if (pool.contains(ipAddress)) {
return true;
}
}
return true;
}
} catch (Exception e) {
LOGGER.error("Exception : " + e);
return false;
}
}
示例2: subnetExists
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入方法依赖的package包/类
private int subnetExists(List<ObjectReference<VnSubnetsType>> ipamRefs, NeutronSubnet subnet) {
for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
VnSubnetsType vnSubnetsType = ref.getAttr();
if (vnSubnetsType != null) {
List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
if (subnets != null) {
if (subnet.getCidr() == null) {
LOGGER.error("CIDR can't be null");
return HttpURLConnection.HTTP_BAD_REQUEST;
}
for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
String[] ipPrefix = getIpPrefix(subnet);
Boolean doesSubnetExist = subnetValue.getSubnet().getIpPrefix().matches(ipPrefix[0]);
if (doesSubnetExist) {
LOGGER.error("The subnet already exists..");
return HttpURLConnection.HTTP_FORBIDDEN;
}
}
}
}
}
return 0;
}
示例3: getIpPrefix
import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入方法依赖的package包/类
/**
* Invoked to get the IP Prefix from the Neutron Subnet object.
*
* @param subnet
* An instance of new Neutron Subnet object.
*
* @return IP Prefix
* @throws Exception
*/
String[] getIpPrefix(NeutronSubnet subnet) {
String[] ipPrefix = null;
String cidr = subnet.getCidr();
if (cidr.contains("/")) {
ipPrefix = cidr.split("/");
} else {
throw new IllegalArgumentException("String " + cidr + " not in correct format..");
}
return ipPrefix;
}