Search in sources :

Example 36 with DpnInterfaces

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

the class VpnServiceElanDpnInterfacesListener method update.

@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
    LOG.info("received Dpninterfaces update event for dpn {}", update.getDpId());
    BigInteger dpnId = update.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = VpnUtil.getElanInstanceByName(dataBroker, elanInstanceName);
    String vpnName = VpnUtil.getVpnNameFromElanIntanceName(dataBroker, elanInstanceName);
    if (vpnName == null) {
        return;
    }
    String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
    if (elanInstance != null && !elanInstance.isExternal() && VpnUtil.isVlan(elanInstance)) {
        jobCoordinator.enqueueJob(elanInstance.getElanInstanceName(), () -> {
            return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
                List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(), original.getInterfaces());
                for (String addedInterface : addedInterfaces) {
                    if (interfaceManager.isExternalInterface(addedInterface)) {
                        InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(primaryRd, dpnId);
                        Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
                        if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
                            return;
                        }
                        if (!VpnUtil.shouldPopulateFibForVlan(dataBroker, vpnName, elanInstanceName, dpnId, interfaceManager)) {
                            return;
                        }
                        long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
                        fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
                        break;
                    }
                }
                List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(), update.getInterfaces());
                if (!deletedInterfaces.isEmpty()) {
                    String routerPortUuid = VpnUtil.getRouterPordIdFromElanInstance(dataBroker, elanInstanceName);
                    if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
                        VpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId, dataBroker);
                    }
                }
            }));
        });
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) IFibManager(org.opendaylight.netvirt.fibmanager.api.IFibManager) LoggerFactory(org.slf4j.LoggerFactory) DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ElanDpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) List(java.util.List) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) Collections(java.util.Collections) Optional(com.google.common.base.Optional) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ArrayList(java.util.ArrayList) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) List(java.util.List) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)

Example 37 with DpnInterfaces

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

the class DhcpServiceUtils method getDpnsForElan.

@Nonnull
public static List<BigInteger> getDpnsForElan(String elanInstanceName, DataBroker broker) {
    List<BigInteger> elanDpns = new LinkedList<>();
    InstanceIdentifier<ElanDpnInterfacesList> elanDpnInstanceIdentifier = InstanceIdentifier.builder(ElanDpnInterfaces.class).child(ElanDpnInterfacesList.class, new ElanDpnInterfacesListKey(elanInstanceName)).build();
    Optional<ElanDpnInterfacesList> elanDpnOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, elanDpnInstanceIdentifier);
    if (elanDpnOptional.isPresent()) {
        List<DpnInterfaces> dpns = elanDpnOptional.get().getDpnInterfaces();
        for (DpnInterfaces dpnInterfaces : dpns) {
            elanDpns.add(dpnInterfaces.getDpId());
        }
    }
    return elanDpns;
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) 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) BigInteger(java.math.BigInteger) ElanDpnInterfacesListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey) LinkedList(java.util.LinkedList) Nonnull(javax.annotation.Nonnull)

Example 38 with DpnInterfaces

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

the class ElanDpnInterfacesListener method add.

@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces dpnInterfaces) {
    LOG.debug("received Dpninterfaces add event for dpn {}", dpnInterfaces.getDpId());
    BigInteger dpnId = dpnInterfaces.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    // on br-int patch port for this DPN
    if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
        jobCoordinator.enqueueJob(dpnId.toString(), () -> {
            LOG.debug("creating vlan member intf for elan {}, dpn {}", elanInstance.getPhysicalNetworkName(), dpnId);
            elanService.createExternalElanNetwork(elanInstance, dpnId);
            return Collections.emptyList();
        });
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 39 with DpnInterfaces

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

the class ElanDpnInterfacesListener method update.

@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
    LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
    BigInteger dpnId = update.getDpId();
    String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
        List<String> interfaces = update.getInterfaces();
        // trigger deletion for vlan provider intf on the DPN for the vlan provider network
        if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
            LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
            jobCoordinator.enqueueJob(dpnId.toString(), () -> {
                elanService.deleteExternalElanNetwork(elanInstance, dpnId);
                return Collections.emptyList();
            });
        }
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 40 with DpnInterfaces

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

the class ElanDpnToTransportZoneListener method remove.

@Override
protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
    LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
    BigInteger dpId = dataObjectModification.getDpId();
    String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orNull())) {
        LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
        return;
    }
    LOG.debug("Deleting tz for elanInstance {} dpId {}", elanInstanceName, dpId);
    transportZoneNotificationUtil.deleteTransportZone(elanInstanceName, dpId);
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Aggregations

DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)32 BigInteger (java.math.BigInteger)25 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)20 ArrayList (java.util.ArrayList)19 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)15 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)9 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)8 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)5 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)5 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)5 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)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 Nonnull (javax.annotation.Nonnull)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3 HashSet (java.util.HashSet)2 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)2