Search in sources :

Example 1 with DpnInterfacesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.

the class ElanInterfaceManager method createElanInterfacesList.

private DpnInterfaces createElanInterfacesList(String elanInstanceName, String interfaceName, BigInteger dpId, WriteTransaction tx) {
    List<String> interfaceNames = new ArrayList<>();
    interfaceNames.add(interfaceName);
    DpnInterfaces dpnInterface = new DpnInterfacesBuilder().setDpId(dpId).setInterfaces(interfaceNames).setKey(new DpnInterfacesKey(dpId)).build();
    tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId), dpnInterface, WriteTransaction.CREATE_MISSING_PARENTS);
    return dpnInterface;
}
Also used : ArrayList(java.util.ArrayList) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)

Example 2 with DpnInterfacesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.

the class ElanInterfaceManager method updateElanDpnInterfacesList.

private DpnInterfaces updateElanDpnInterfacesList(String elanInstanceName, BigInteger dpId, List<String> interfaceNames, WriteTransaction tx) {
    DpnInterfaces dpnInterface = new DpnInterfacesBuilder().setDpId(dpId).setInterfaces(interfaceNames).setKey(new DpnInterfacesKey(dpId)).build();
    tx.put(LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId), dpnInterface, WriteTransaction.CREATE_MISSING_PARENTS);
    return dpnInterface;
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)

Example 3 with DpnInterfacesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.

the class VpnUtil method addRouterPortToElanDpn.

public static void addRouterPortToElanDpn(String elanInstanceName, String routerInterfacePortId, String vpnName, BigInteger dpnId, DataBroker dataBroker) {
    InstanceIdentifier<DpnInterfaces> elanDpnInterfaceId = getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpnId);
    Optional<DpnInterfaces> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
    List<String> elanInterfaceList;
    DpnInterfaces dpnInterface;
    if (!dpnInElanInterfaces.isPresent()) {
        elanInterfaceList = new ArrayList<>();
    } else {
        dpnInterface = dpnInElanInterfaces.get();
        elanInterfaceList = dpnInterface.getInterfaces();
    }
    if (!elanInterfaceList.contains(routerInterfacePortId)) {
        elanInterfaceList.add(routerInterfacePortId);
        dpnInterface = new DpnInterfacesBuilder().setDpId(dpnId).setInterfaces(elanInterfaceList).setKey(new DpnInterfacesKey(dpnId)).build();
        VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId, dpnInterface);
    }
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)

Example 4 with DpnInterfacesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey in project netvirt by opendaylight.

the class VpnUtil method removeRouterPortFromElanDpn.

public static void removeRouterPortFromElanDpn(String elanInstanceName, String routerInterfacePortId, String vpnName, BigInteger dpnId, DataBroker dataBroker) {
    InstanceIdentifier<DpnInterfaces> elanDpnInterfaceId = getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpnId);
    Optional<DpnInterfaces> dpnInElanInterfaces = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId);
    List<String> elanInterfaceList;
    DpnInterfaces dpnInterface;
    if (!dpnInElanInterfaces.isPresent()) {
        LOG.info("No interface in any dpn for {}", vpnName);
        return;
    } else {
        dpnInterface = dpnInElanInterfaces.get();
        elanInterfaceList = dpnInterface.getInterfaces();
    }
    if (!elanInterfaceList.contains(routerInterfacePortId)) {
        LOG.info("Router port not present in DPN {} for VPN {}", dpnId, vpnName);
        return;
    }
    elanInterfaceList.remove(routerInterfacePortId);
    dpnInterface = new DpnInterfacesBuilder().setDpId(dpnId).setInterfaces(elanInterfaceList).setKey(new DpnInterfacesKey(dpnId)).build();
    VpnUtil.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, elanDpnInterfaceId, dpnInterface);
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) DpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey) DpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)

Aggregations

ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)4 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)4 DpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesBuilder)4 DpnInterfacesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfacesKey)4 ArrayList (java.util.ArrayList)1