Search in sources :

Example 1 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces in project netvirt by opendaylight.

the class SubnetOpDpnManager method addDpnToSubnet.

private SubnetToDpn addDpnToSubnet(Uuid subnetId, BigInteger dpnId) {
    try {
        InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        InstanceIdentifier<SubnetToDpn> dpnOpId = subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
        Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
        if (optionalSubDpn.isPresent()) {
            LOG.error("addDpnToSubnet: Cannot create, SubnetToDpn for subnet {} as DPN {}" + " already seen in datastore", subnetId.getValue(), dpnId);
            return null;
        }
        SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder().setKey(new SubnetToDpnKey(dpnId));
        List<VpnInterfaces> vpnIntfList = new ArrayList<>();
        subDpnBuilder.setVpnInterfaces(vpnIntfList);
        SubnetToDpn subDpn = subDpnBuilder.build();
        SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
        LOG.info("addDpnToSubnet: Created SubnetToDpn entry for subnet {} with DPNId {} ", subnetId.getValue(), dpnId);
        return subDpn;
    } catch (TransactionCommitFailedException ex) {
        LOG.error("addDpnToSubnet: Creation of SubnetToDpn for subnet {} with DpnId {} failed", subnetId.getValue(), dpnId, ex);
        return null;
    }
}
Also used : SubnetToDpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces) ArrayList(java.util.ArrayList) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) SubnetToDpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn)

Example 2 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces in project netvirt by opendaylight.

the class SubnetOpDpnManager method removeInterfaceFromDpn.

public boolean removeInterfaceFromDpn(Uuid subnetId, BigInteger dpnId, String intfName) {
    boolean dpnRemoved = false;
    try {
        InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        InstanceIdentifier<SubnetToDpn> dpnOpId = subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
        Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
        if (!optionalSubDpn.isPresent()) {
            LOG.debug("removeInterfaceFromDpn: Cannot delete, SubnetToDpn for intf {} subnet {} DPN {}" + " not available in datastore", intfName, subnetId.getValue(), dpnId);
            return false;
        }
        SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(optionalSubDpn.get());
        List<VpnInterfaces> vpnIntfList = subDpnBuilder.getVpnInterfaces();
        VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().setKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build();
        vpnIntfList.remove(vpnIntfs);
        if (vpnIntfList.isEmpty()) {
            // Remove the DPN as well
            removeDpnFromSubnet(subnetId, dpnId);
            dpnRemoved = true;
        } else {
            subDpnBuilder.setVpnInterfaces(vpnIntfList);
            SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpnBuilder.build());
        }
        LOG.info("removeInterfaceFromDpn: Removed interface {} from sunbet {} dpn {}", intfName, subnetId.getValue(), dpnId);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("removeInterfaceFromDpn: Deletion of Interface {} for SubnetToDpn on subnet {}" + " with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
        return false;
    }
    return dpnRemoved;
}
Also used : SubnetToDpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesKey) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesBuilder) SubnetToDpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey)

Example 3 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces in project netvirt by opendaylight.

the class SubnetOpDpnManager method addInterfaceToDpn.

public SubnetToDpn addInterfaceToDpn(Uuid subnetId, BigInteger dpnId, String intfName) {
    SubnetToDpn subDpn = null;
    try {
        // Create and add SubnetOpDataEntry object for this subnet to the SubnetOpData container
        InstanceIdentifier<SubnetOpDataEntry> subOpIdentifier = InstanceIdentifier.builder(SubnetOpData.class).child(SubnetOpDataEntry.class, new SubnetOpDataEntryKey(subnetId)).build();
        // Please use a synchronize block here as we donot need a cluster-wide lock
        InstanceIdentifier<SubnetToDpn> dpnOpId = subOpIdentifier.child(SubnetToDpn.class, new SubnetToDpnKey(dpnId));
        Optional<SubnetToDpn> optionalSubDpn = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId);
        if (!optionalSubDpn.isPresent()) {
            // Create a new DPN Entry
            subDpn = addDpnToSubnet(subnetId, dpnId);
        } else {
            subDpn = optionalSubDpn.get();
        }
        SubnetToDpnBuilder subDpnBuilder = new SubnetToDpnBuilder(subDpn);
        List<VpnInterfaces> vpnIntfList = subDpnBuilder.getVpnInterfaces();
        VpnInterfaces vpnIntfs = new VpnInterfacesBuilder().setKey(new VpnInterfacesKey(intfName)).setInterfaceName(intfName).build();
        vpnIntfList.add(vpnIntfs);
        subDpnBuilder.setVpnInterfaces(vpnIntfList);
        subDpn = subDpnBuilder.build();
        SingleTransactionDataBroker.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, dpnOpId, subDpn);
        LOG.info("addInterfaceToDpn: Created SubnetToDpn entry for subnet {} with DPNId {} intfName {}", subnetId.getValue(), dpnId, intfName);
    } catch (TransactionCommitFailedException ex) {
        LOG.error("addInterfaceToDpn: Addition of Interface {} for SubnetToDpn on subnet {} with DPN {} failed", intfName, subnetId.getValue(), dpnId, ex);
        return null;
    }
    return subDpn;
}
Also used : SubnetToDpnBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces) VpnInterfacesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesKey) SubnetOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry) SubnetToDpn(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) SubnetOpDataEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey) VpnInterfacesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfacesBuilder) SubnetToDpnKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey)

Example 4 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces in project netvirt by opendaylight.

the class TunnelEndPointChangeListener method add.

@Override
protected void add(InstanceIdentifier<TunnelEndPoints> key, TunnelEndPoints tep) {
    BigInteger dpnId = key.firstIdentifierOf(DPNTEPsInfo.class).firstKeyOf(DPNTEPsInfo.class).getDPNID();
    if (BigInteger.ZERO.equals(dpnId)) {
        LOG.warn("add: Invalid DPN id for TEP {}", tep.getInterfaceName());
        return;
    }
    List<VpnInstance> vpnInstances = VpnHelper.getAllVpnInstances(broker);
    if (vpnInstances == null || vpnInstances.isEmpty()) {
        LOG.warn("add: dpnId: {}: tep: {}: No VPN instances defined", dpnId, tep.getInterfaceName());
        return;
    }
    for (VpnInstance vpnInstance : vpnInstances) {
        final String vpnName = vpnInstance.getVpnInstanceName();
        final long vpnId = VpnUtil.getVpnId(broker, vpnName);
        LOG.info("add: Handling TEP {} add for VPN instance {}", tep.getInterfaceName(), vpnName);
        final String primaryRd = VpnUtil.getPrimaryRd(broker, vpnName);
        if (!VpnUtil.isVpnPendingDelete(broker, primaryRd)) {
            List<VpnInterfaces> vpnInterfaces = VpnUtil.getDpnVpnInterfaces(broker, vpnInstance, dpnId);
            if (vpnInterfaces != null) {
                for (VpnInterfaces vpnInterface : vpnInterfaces) {
                    String vpnInterfaceName = vpnInterface.getInterfaceName();
                    jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterfaceName, () -> {
                        final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(broker, vpnInterfaceName);
                        if (interfaceState == null) {
                            LOG.debug("add: Cannot retrieve interfaceState for vpnInterfaceName {}, " + "cannot generate lPortTag and process adjacencies", vpnInterfaceName);
                            return Collections.emptyList();
                        }
                        final int lPortTag = interfaceState.getIfIndex();
                        List<ListenableFuture<Void>> futures = new ArrayList<>();
                        futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeOperTxn -> futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeInvTxn -> vpnInterfaceManager.processVpnInterfaceAdjacencies(dpnId, lPortTag, vpnName, primaryRd, vpnInterfaceName, vpnId, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState)))))));
                        LOG.trace("add: Handled TEP {} add for VPN instance {} VPN interface {}", tep.getInterfaceName(), vpnName, vpnInterfaceName);
                        return futures;
                    });
                }
            }
        } else {
            LOG.error("add: Ignoring addition of tunnel interface {} dpn {} for vpnInstance {} with primaryRd {}," + " as the VPN is already marked for deletion", tep.getInterfaceName(), dpnId, vpnName, primaryRd);
        }
    }
}
Also used : Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) LoggerFactory(org.slf4j.LoggerFactory) DpnEndpoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.DpnEndpoints) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Singleton(javax.inject.Singleton) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ArrayList(java.util.ArrayList) VpnHelper(org.opendaylight.netvirt.vpnmanager.api.VpnHelper) Inject(javax.inject.Inject) List(java.util.List) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) InterfaceUtils(org.opendaylight.netvirt.vpnmanager.api.InterfaceUtils) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) PostConstruct(javax.annotation.PostConstruct) BigInteger(java.math.BigInteger) Collections(java.util.Collections) VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) Collections(java.util.Collections) VpnInstance(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 5 with VpnInterfaces

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces in project netvirt by opendaylight.

the class TransportZoneNotificationUtil method shouldCreateVtep.

public boolean shouldCreateVtep(List<VpnInterfaces> vpnInterfaces) {
    if (vpnInterfaces == null || vpnInterfaces.isEmpty()) {
        return false;
    }
    for (VpnInterfaces vpnInterface : vpnInterfaces) {
        String interfaceName = vpnInterface.getInterfaceName();
        ElanInterface elanInt = elanService.getElanInterfaceByElanInterfaceName(interfaceName);
        if (elanInt == null) {
            continue;
        }
        if (ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInt.getElanInstanceName()).orNull())) {
            return true;
        } else {
            LOG.debug("Non-VXLAN elanInstance: {}", elanInt.getElanInstanceName());
        }
    }
    return false;
}
Also used : VpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)

Aggregations

ArrayList (java.util.ArrayList)8 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)8 BigInteger (java.math.BigInteger)6 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)6 ExecutionException (java.util.concurrent.ExecutionException)5 SubnetToDpnBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnBuilder)5 SubnetToDpnKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpnKey)5 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.subnet.to.dpn.VpnInterfaces)5 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)5 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)5 Collections (java.util.Collections)4 List (java.util.List)4 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)4 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 SubnetOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntry)4 SubnetOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.SubnetOpDataEntryKey)4 SubnetToDpn (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.subnet.op.data.subnet.op.data.entry.SubnetToDpn)4