当前位置: 首页>>代码示例>>Java>>正文


Java NeutronSubnet.getCidr方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:25,代码来源:SubnetHandler.java

示例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;
}
 
开发者ID:Juniper,项目名称:odl-opencontrail-plugin,代码行数:24,代码来源:SubnetHandler.java

示例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;
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:20,代码来源:SubnetHandler.java


注:本文中的org.opendaylight.controller.networkconfig.neutron.NeutronSubnet.getCidr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。