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


Java NeutronSubnet类代码示例

本文整理汇总了Java中org.opendaylight.controller.networkconfig.neutron.NeutronSubnet的典型用法代码示例。如果您正苦于以下问题:Java NeutronSubnet类的具体用法?Java NeutronSubnet怎么用?Java NeutronSubnet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NeutronSubnet类属于org.opendaylight.controller.networkconfig.neutron包,在下文中一共展示了NeutronSubnet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: subnetExists

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
private boolean subnetExists(List<ObjectReference<VnSubnetsType>> ipamRefs, NeutronSubnet subnet) {
    if (ipamRefs != null) {
        for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
            VnSubnetsType vnSubnetsType = ref.getAttr();
            if (vnSubnetsType != null) {
                List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
                if (subnets != null) {
                    for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
                        String[] ipPrefix = getIpPrefix(subnet);
                        Boolean doesSubnetExist = subnetValue.getSubnet().getIpPrefix().matches(ipPrefix[0]);
                        if (doesSubnetExist) {
                            return doesSubnetExist;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:21,代码来源:SubnetHandler.java

示例2: neutronSubnetCreated

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
/**
 * Invoked to create the subnet
 *
 * @param subnet
 *            An instance of new Subnet Type object.
 */
@Override
public void neutronSubnetCreated(NeutronSubnet subnet) {
    String networkUUID = subnet.getNetworkUUID();
    String subnetUUID = subnet.getSubnetUUID();
    try {
        if (!(networkUUID.contains("-"))) {
            networkUUID = Utils.uuidFormater(networkUUID);
        }
        networkUUID = UUID.fromString(networkUUID).toString();
        if (!(subnetUUID.contains("-"))) {
            subnetUUID = Utils.uuidFormater(subnetUUID);
        }
        subnetUUID = UUID.fromString(subnetUUID).toString();
        createSubnet(subnet);
        VirtualNetwork virtualNetwork = (VirtualNetwork) apiConnector.findById(VirtualNetwork.class, networkUUID);
        boolean ifSubnetExists = subnetExists(virtualNetwork.getNetworkIpam(), subnet);
        if (ifSubnetExists) {
            LOGGER.info("Subnet creation verified...");
        }
    } catch (IOException ie) {
        LOGGER.error("IOException :   " + ie);
    } catch (Exception ex) {
        LOGGER.error("Exception :   ", ex);
    }
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:32,代码来源:SubnetHandler.java

示例3: 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

示例4: subnetExists

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
/**
 * Invoked to check if subnet exists from the Neutron Subnet object.
 *
 * @param ipamRefs
 *            An list of new ObjectReference<VnSubnetsType> objects.
 *
 * @param subnet
 *            An instance of new Neutron Subnet object.
 *
 * @return boolean
 */
private boolean subnetExists(List<ObjectReference<VnSubnetsType>> ipamRefs, NeutronSubnet subnet) {
    if (ipamRefs != null) {
        for (ObjectReference<VnSubnetsType> ref : ipamRefs) {
            VnSubnetsType vnSubnetsType = ref.getAttr();
            if (vnSubnetsType != null) {
                List<VnSubnetsType.IpamSubnetType> subnets = vnSubnetsType.getIpamSubnets();
                if (subnets != null) {
                    for (VnSubnetsType.IpamSubnetType subnetValue : subnets) {
                        String[] ipPrefix = getIpPrefix(subnet);
                        Boolean doesSubnetExist = subnetValue.getSubnet().getIpPrefix().matches(ipPrefix[0]);
                        if (doesSubnetExist) {
                            return doesSubnetExist;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:32,代码来源:LoadBalancerHandler.java

示例5: testCanCreateSubnetExists

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testCanCreateSubnetExists() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
    VnSubnetsType vnSubnetType = new VnSubnetsType();
    ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
    List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
    List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
    VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
    SubnetType type = new SubnetType();
    List<String> temp = new ArrayList<String>();
    for (int i = 0; i < 1; i++) {
        subnetType.setSubnet(type);
        subnetType.getSubnet().setIpPrefix("10.0.0.0");
        subnetType.getSubnet().setIpPrefixLen(24);
        subnets.add(subnetType);
        vnSubnetType.addIpamSubnets(subnetType);
        ref.setReference(temp, vnSubnetType, "", "");
        ipamRefs.add(ref);
    }
    when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
    assertEquals(HttpURLConnection.HTTP_FORBIDDEN, subnetHandler.canCreateSubnet(neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:25,代码来源:SubnetHandlerTest.java

示例6: testcanUpdateSubnetNotFound

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testcanUpdateSubnetNotFound() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    NeutronSubnet deltaSubnet = defaultDeltaSubnet();
    when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
    VnSubnetsType vnSubnetType = new VnSubnetsType();
    ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
    List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
    List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
    VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
    SubnetType type = new SubnetType();
    List<String> temp = new ArrayList<String>();
    for (int i = 0; i < 1; i++) {
        subnetType.setSubnet(type);
        subnetType.setSubnetUuid("9b9570f2-17b1-4fc3-99ec-1b7f7778a29b");
        subnetType.getSubnet().setIpPrefix("10.0.0.0");
        subnetType.getSubnet().setIpPrefixLen(24);
        subnets.add(subnetType);
        vnSubnetType.addIpamSubnets(subnetType);
        ref.setReference(temp, vnSubnetType, "", "");
        ipamRefs.add(ref);
    }
    when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:27,代码来源:SubnetHandlerTest.java

示例7: testcanUpdateSubnetOK

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testcanUpdateSubnetOK() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    NeutronSubnet deltaSubnet = defaultDeltaSubnet();
    when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
    VnSubnetsType vnSubnetType = new VnSubnetsType();
    ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
    List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
    List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
    VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
    SubnetType type = new SubnetType();
    List<String> temp = new ArrayList<String>();
    for (int i = 0; i < 1; i++) {
        subnetType.setSubnet(type);
        subnetType.setSubnetUuid("7b9570f2-17b1-4fc3-99ec-1b7f7778a29b");
        subnetType.getSubnet().setIpPrefix("10.0.0.0");
        subnetType.getSubnet().setIpPrefixLen(24);
        subnets.add(subnetType);
        vnSubnetType.addIpamSubnets(subnetType);
        ref.setReference(temp, vnSubnetType, "", "");
        ipamRefs.add(ref);
    }
    when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
    assertEquals(HttpURLConnection.HTTP_OK, subnetHandler.canUpdateSubnet(deltaSubnet, neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:27,代码来源:SubnetHandlerTest.java

示例8: testCanDeleteSubnetOK

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testCanDeleteSubnetOK() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
    VnSubnetsType vnSubnetType = new VnSubnetsType();
    ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
    List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
    List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
    VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
    SubnetType type = new SubnetType();
    List<String> temp = new ArrayList<String>();
    for (int i = 0; i < 1; i++) {
        subnetType.setSubnet(type);
        subnetType.setSubnetUuid("7b9570f2-17b1-4fc3-99ec-1b7f7778a29b");
        subnetType.getSubnet().setIpPrefix("10.0.0.0");
        subnetType.getSubnet().setIpPrefixLen(24);
        subnets.add(subnetType);
        vnSubnetType.addIpamSubnets(subnetType);
        ref.setReference(temp, vnSubnetType, "", "");
        ipamRefs.add(ref);
    }
    when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
    when(mockedVirtualNetwork.getFloatingIpPools()).thenReturn(null);
    assertEquals(HttpURLConnection.HTTP_OK, subnetHandler.canDeleteSubnet(neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:27,代码来源:SubnetHandlerTest.java

示例9: 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

示例10: testCanCreateSubnetExists

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testCanCreateSubnetExists() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    when(mockedApiConnector.findById(VirtualNetwork.class, neutronSubnet.getNetworkUUID())).thenReturn(mockedVirtualNetwork);
    VnSubnetsType vnSubnetType = new VnSubnetsType();
    ObjectReference<VnSubnetsType> ref = new ObjectReference<>();
    List<ObjectReference<VnSubnetsType>> ipamRefs = new ArrayList<ObjectReference<VnSubnetsType>>();
    List<VnSubnetsType.IpamSubnetType> subnets = new ArrayList<VnSubnetsType.IpamSubnetType>();
    VnSubnetsType.IpamSubnetType subnetType = new VnSubnetsType.IpamSubnetType();
    SubnetType type = new SubnetType();
    List<String> temp = new ArrayList<String>();
    for (int i = 0; i < 1; i++) {
        subnetType.setSubnet(type);
        subnetType.getSubnet().setIpPrefix("10.0.0.1");
        subnetType.getSubnet().setIpPrefixLen(24);
        subnets.add(subnetType);
        vnSubnetType.addIpamSubnets(subnetType);
        ref.setReference(temp, vnSubnetType, "", "");
        ipamRefs.add(ref);
    }
    when(mockedVirtualNetwork.getNetworkIpam()).thenReturn(ipamRefs);
    assertTrue(subnetType.getSubnet().getIpPrefix().matches("10.0.0.1"));
    assertEquals(HttpURLConnection.HTTP_FORBIDDEN, subnetHandler.canCreateSubnet(neutronSubnet));
}
 
开发者ID:Juniper,项目名称:odl-opencontrail-plugin,代码行数:26,代码来源:SubnetHandlerTest.java

示例11: 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

示例12: defaultSubnetObject

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
public NeutronSubnet defaultSubnetObject() {
    NeutronSubnet subnet = new NeutronSubnet();
    List<NeutronSubnet_IPAllocationPool> allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();
    NeutronSubnet_IPAllocationPool neutronSubnet_IPAllocationPool = new NeutronSubnet_IPAllocationPool();
    subnet.setNetworkUUID("6b9570f2-17b1-4fc3-99ec-1b7f7778a29b");
    subnet.setSubnetUUID("7b9570f2-17b1-4fc3-99ec-1b7f7778a29b");
    subnet.setCidr("10.0.0.0/24");
    subnet.setGatewayIP("10.0.0.254");
    neutronSubnet_IPAllocationPool.setPoolStart("10.0.0.1");
    neutronSubnet_IPAllocationPool.setPoolEnd("10.0.0.254");
    allocationPools.add(neutronSubnet_IPAllocationPool);
    subnet.setAllocationPools(allocationPools);
    subnet.setEnableDHCP(true);
    return subnet;
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:16,代码来源:SubnetHandlerTest.java

示例13: defaultDeltaSubnet

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
public NeutronSubnet defaultDeltaSubnet() {
    NeutronSubnet subnet = new NeutronSubnet();
    subnet.setNetworkUUID("6b9570f2-17b1-4fc399ec-1b7f7778a29b");
    subnet.setSubnetUUID("7b9570f2-17b1-4fc399ec-1b7f7778a29b");
    subnet.setCidr("10.0.0.0/24");
    subnet.setGatewayIP("10.0.0.254");
    return subnet;
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:9,代码来源:SubnetHandlerTest.java

示例14: testCanCreateSubnetCidrNull

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testCanCreateSubnetCidrNull() {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    neutronSubnet.setCidr(null);
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canCreateSubnet(neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:8,代码来源:SubnetHandlerTest.java

示例15: testCanCreateSubnetInvalidGatewayIp

import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; //导入依赖的package包/类
@Test
public void testCanCreateSubnetInvalidGatewayIp() throws IOException {
    Activator.apiConnector = mockedApiConnector;
    NeutronSubnet neutronSubnet = defaultSubnetObject();
    neutronSubnet.setGatewayIP("20.0.0.250");
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, subnetHandler.canCreateSubnet(neutronSubnet));
}
 
开发者ID:opendaylight,项目名称:archived-plugin2oc,代码行数:8,代码来源:SubnetHandlerTest.java


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