Search in sources :

Example 16 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class LocalUcastMacListener method added.

public void added(final InstanceIdentifier<LocalUcastMacs> identifier, final LocalUcastMacs macAdded) {
    ResourceBatchingManager.getInstance().put(ResourceBatchingManager.ShardResource.CONFIG_TOPOLOGY, identifier, macAdded);
    String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
    String macAddress = macAdded.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
    String elanName = getElanName(macAdded);
    LOG.trace("LocalUcastMacs {} added to {}", macAddress, hwvtepNodeId);
    ElanInstance elan = elanInstanceCache.get(elanName).orNull();
    if (elan == null) {
        LOG.warn("Could not find ELAN for mac {} being added", macAddress);
        return;
    }
    jobCoordinator.enqueueJob(elanName + HwvtepHAUtil.L2GW_JOB_KEY, () -> {
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice == null) {
            LOG.warn("Could not find L2GatewayDevice for ELAN: {}, nodeID:{} from cache", elanName, hwvtepNodeId);
            return null;
        }
        elanL2GwDevice.addUcastLocalMac(macAdded);
        elanL2GatewayUtils.installL2GwUcastMacInElan(elan, elanL2GwDevice, macAddress.toLowerCase(), macAdded, null);
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)

Example 17 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanDpnToTransportZoneListener method add.

@Override
protected void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
    LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
    BigInteger dpId = dataObjectModification.getDpId();
    String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
    if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orNull())) {
        return;
    }
    transportZoneNotificationUtil.updateTransportZone(elanInstanceName, dpId);
}
Also used : ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) BigInteger(java.math.BigInteger)

Example 18 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInstanceManager method remove.

@Override
protected void remove(InstanceIdentifier<ElanInstance> identifier, ElanInstance deletedElan) {
    LOG.trace("Remove ElanInstance - Key: {}, value: {}", identifier, deletedElan);
    String elanName = deletedElan.getElanInstanceName();
    // check the elan Instance present in the Operational DataStore
    Elan existingElan = ElanUtils.getElanByName(broker, elanName);
    long elanTag = deletedElan.getElanTag();
    // Cleaning up the existing Elan Instance
    if (existingElan != null) {
        List<String> elanInterfaces = existingElan.getElanInterfaces();
        if (elanInterfaces != null && !elanInterfaces.isEmpty()) {
            for (String elanInterfaceName : elanInterfaces) {
                InstanceIdentifier<ElanInterface> elanInterfaceId = ElanUtils.getElanInterfaceConfigurationDataPathId(elanInterfaceName);
                InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(elanInterfaceName);
                elanInterfaceManager.removeElanInterface(deletedElan, elanInterfaceName, interfaceInfo);
                ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION, elanInterfaceId);
            }
        }
        ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInstanceOperationalDataPath(elanName));
        Optional<ElanDpnInterfacesList> elanDpnInterfaceList = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanDpnOperationDataPath(elanName));
        if (elanDpnInterfaceList.isPresent()) {
            ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, getElanDpnOperationDataPath(elanName));
        }
        ElanUtils.delete(broker, LogicalDatastoreType.OPERATIONAL, ElanUtils.getElanInfoEntriesOperationalDataPath(elanTag));
    }
    elanInterfaceCache.getInterfaceNames(elanName).forEach(elanInterfaceName -> jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(elanInterfaceName), () -> Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> {
        LOG.info("Deleting the elanInterface present under ConfigDS:{}", elanInterfaceName);
        ElanUtils.delete(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(elanInterfaceName));
        elanInterfaceManager.unbindService(elanInterfaceName, tx);
        LOG.info("unbind the Interface:{} service bounded to Elan:{}", elanInterfaceName, elanName);
    })), ElanConstants.JOB_MAX_RETRIES));
    // Release tag
    ElanUtils.releaseId(idManager, ElanConstants.ELAN_ID_POOL_NAME, elanName);
    if (deletedElan.getAugmentation(EtreeInstance.class) != null) {
        removeEtreeInstance(deletedElan);
    }
}
Also used : EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) ElanConstants(org.opendaylight.netvirt.elan.utils.ElanConstants) LoggerFactory(org.slf4j.LoggerFactory) ElanInterfaceCache(org.opendaylight.netvirt.elan.cache.ElanInterfaceCache) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) 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) ElanDpnInterfacesListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Logger(org.slf4j.Logger) Collections.emptyList(java.util.Collections.emptyList) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) AsyncDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase) IdManagerService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) List(java.util.List) ElanException(org.opendaylight.netvirt.elan.ElanException) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) Collections(java.util.Collections) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ElanDpnInterfacesList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 19 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInterfaceManager method setBCGrouponOtherDpns.

@SuppressWarnings("checkstyle:IllegalCatch")
private void setBCGrouponOtherDpns(ElanInstance elanInfo, BigInteger dpId, int elanTag, long groupId) {
    int bucketId = 0;
    ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
    if (elanDpns != null) {
        List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
        for (DpnInterfaces dpnInterface : dpnInterfaces) {
            List<Bucket> remoteListBucketInfo = new ArrayList<>();
            if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId) && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
                List<Action> listAction = new ArrayList<>();
                int actionKey = 0;
                listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
                remoteListBucketInfo.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                bucketId++;
                for (DpnInterfaces otherFes : dpnInterfaces) {
                    if (elanUtils.isDpnPresent(otherFes.getDpId()) && !Objects.equals(otherFes.getDpId(), dpnInterface.getDpId()) && otherFes.getInterfaces() != null && !otherFes.getInterfaces().isEmpty()) {
                        try {
                            List<Action> remoteListActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnInterface.getDpId(), otherFes.getDpId(), elanUtils.isOpenstackVniSemanticsEnforced() ? elanUtils.getVxlanSegmentationId(elanInfo) : elanTag);
                            if (!remoteListActionInfo.isEmpty()) {
                                remoteListBucketInfo.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
                                bucketId++;
                            }
                        } catch (Exception ex) {
                            LOG.error("setElanBCGrouponOtherDpns failed due to Exception caught; " + "Logical Group Interface not found between source Dpn - {}, " + "destination Dpn - {} ", dpnInterface.getDpId(), otherFes.getDpId(), ex);
                            return;
                        }
                    }
                }
                List<Bucket> elanL2GwDevicesBuckets = elanL2GatewayMulticastUtils.getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnInterface.getDpId(), bucketId);
                remoteListBucketInfo.addAll(elanL2GwDevicesBuckets);
                if (remoteListBucketInfo.isEmpty()) {
                    LOG.debug("No ITM is present on Dpn - {} ", dpnInterface.getDpId());
                    continue;
                }
                Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(remoteListBucketInfo));
                LOG.trace("Installing remote bc group {} on dpnId {}", group, dpnInterface.getDpId());
                mdsalManager.syncInstallGroup(dpnInterface.getDpId(), group);
            }
        }
        try {
            Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
        } catch (InterruptedException e1) {
            LOG.warn("Error while waiting for remote BC group on other DPNs for ELAN {} to install", elanInfo);
        }
    }
}
Also used : ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) 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) ArrayList(java.util.ArrayList) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) ActionGroup(org.opendaylight.genius.mdsalutil.actions.ActionGroup)

Example 20 with Elan

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan in project netvirt by opendaylight.

the class ElanInterfaceManager method removeElanInterface.

public List<ListenableFuture<Void>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
    String elanName = elanInfo.getElanInstanceName();
    boolean isLastElanInterface = false;
    boolean isLastInterfaceOnDpn = false;
    BigInteger dpId = null;
    long elanTag = elanInfo.getElanTag();
    // We use two transaction so we don't suffer on multiple shards (interfaces and flows)
    WriteTransaction interfaceTx = broker.newWriteOnlyTransaction();
    Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
    if (elanState == null) {
        interfaceTx.cancel();
        return Collections.emptyList();
    }
    WriteTransaction flowTx = broker.newWriteOnlyTransaction();
    List<String> elanInterfaces = elanState.getElanInterfaces();
    if (elanInterfaces.isEmpty()) {
        isLastElanInterface = true;
    }
    if (interfaceInfo != null) {
        dpId = interfaceInfo.getDpId();
        DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, dpId, interfaceName, elanTag, interfaceTx);
        /*
             * If there are not elan ports, remove the unknown dmac, terminating
             * service table flows, remote/local bc group
             */
        if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
            // No more Elan Interfaces in this DPN
            LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), dpId);
            if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
                removeDefaultTermFlow(dpId, elanInfo.getElanTag());
            }
            removeUnknownDmacFlow(dpId, elanInfo, flowTx, elanInfo.getElanTag());
            removeEtreeUnknownDmacFlow(dpId, elanInfo, flowTx);
            removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
            removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
            if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
                if (elanUtils.isOpenstackVniSemanticsEnforced()) {
                    elanUtils.removeTerminatingServiceAction(dpId, elanUtils.getVxlanSegmentationId(elanInfo).intValue());
                }
                unsetExternalTunnelTable(dpId, elanInfo);
            }
            isLastInterfaceOnDpn = true;
        } else {
            setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo);
        }
    }
    List<ListenableFuture<Void>> futures = new ArrayList<>();
    futures.add(ElanUtils.waitForTransactionToComplete(interfaceTx));
    futures.add(ElanUtils.waitForTransactionToComplete(flowTx));
    if (isLastInterfaceOnDpn && dpId != null && isVxlanNetworkOrVxlanSegment(elanInfo)) {
        setElanAndEtreeBCGrouponOtherDpns(elanInfo, dpId);
    }
    InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, isLastElanInterface);
    jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, ElanConstants.JOB_MAX_RETRIES);
    return futures;
}
Also used : ReadWriteTransaction(org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) 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) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Aggregations

ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)52 BigInteger (java.math.BigInteger)36 ArrayList (java.util.ArrayList)31 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)18 DpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)14 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)14 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)14 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)13 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)13 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)13 ElanDpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces)12 ElanDpnInterfacesList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)9 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)9 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)9 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)9 Elan (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan)9 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8