Search in sources :

Example 11 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface 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 12 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface 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 13 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ElanServiceProvider method createExternalElanNetwork.

protected void createExternalElanNetwork(ElanInstance elanInstance, BigInteger dpId) {
    String providerIntfName = bridgeMgr.getProviderInterfaceName(dpId, elanInstance.getPhysicalNetworkName());
    String intfName = providerIntfName + IfmConstants.OF_URI_SEPARATOR + elanInstance.getSegmentationId();
    Interface memberIntf = interfaceManager.getInterfaceInfoFromConfigDataStore(intfName);
    if (memberIntf == null) {
        LOG.debug("creating vlan prv intf in elan {}, dpn {}", elanInstance.getElanInstanceName(), dpId);
        createExternalElanNetwork(elanInstance, providerIntfName);
    }
}
Also used : Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 14 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ElanServiceProvider method deleteIetfInterface.

private void deleteIetfInterface(String interfaceName) {
    InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
    InstanceIdentifier<Interface> interfaceInstanceIdentifier = InstanceIdentifier.builder(Interfaces.class).child(Interface.class, interfaceKey).build();
    MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
    LOG.debug("Deleting IETF interface {}", interfaceName);
}
Also used : ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 15 with Interface

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface in project netvirt by opendaylight.

the class ElanServiceProvider method addElanInterface.

@Override
public void addElanInterface(String elanInstanceName, String interfaceName, List<String> staticMacAddresses, String description) {
    Optional<ElanInstance> existingElanInstance = elanInstanceCache.get(elanInstanceName);
    if (existingElanInstance.isPresent()) {
        ElanInterfaceBuilder elanInterfaceBuilder = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName).setDescription(description).setName(interfaceName).setKey(new ElanInterfaceKey(interfaceName));
        if (staticMacAddresses != null) {
            List<StaticMacEntries> staticMacEntries = ElanUtils.getStaticMacEntries(staticMacAddresses);
            elanInterfaceBuilder.setStaticMacEntries(staticMacEntries);
        }
        ElanInterface elanInterface = elanInterfaceBuilder.build();
        MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName), elanInterface);
        LOG.debug("Created the new ELan Interface {}", elanInterface);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) ElanInterfaceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceBuilder) StaticMacEntries(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries) ElanInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterfaceKey)

Aggregations

BigInteger (java.math.BigInteger)131 ArrayList (java.util.ArrayList)117 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)69 ExecutionException (java.util.concurrent.ExecutionException)64 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)56 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)52 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)47 List (java.util.List)45 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)44 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)40 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)39 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)39 Logger (org.slf4j.Logger)39 LoggerFactory (org.slf4j.LoggerFactory)39 Collections (java.util.Collections)38 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)34 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface)33 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)33 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)32