Search in sources :

Example 26 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.

the class ElanInterfaceStateChangeListener method remove.

@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface delIf) {
    if (!L2vlan.class.equals(delIf.getType())) {
        return;
    }
    LOG.trace("Received interface {} Down event", delIf);
    String interfaceName = delIf.getName();
    Optional<ElanInterface> elanInterface = elanInterfaceCache.get(interfaceName);
    if (!elanInterface.isPresent()) {
        LOG.debug("No Elan Interface is created for the interface:{} ", interfaceName);
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(delIf.getLowerLayerIf().get(0));
    BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    InterfaceInfo interfaceInfo = new InterfaceInfo(dpId, nodeConnectorId.getValue());
    interfaceInfo.setInterfaceName(interfaceName);
    interfaceInfo.setInterfaceType(InterfaceInfo.InterfaceType.VLAN_INTERFACE);
    interfaceInfo.setInterfaceTag(delIf.getIfIndex());
    String elanInstanceName = elanInterface.get().getElanInstanceName();
    ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
    if (elanInstance == null) {
        LOG.debug("No Elan instance is available for the interface:{} ", interfaceName);
        return;
    }
    InterfaceRemoveWorkerOnElan removeWorker = new InterfaceRemoveWorkerOnElan(elanInstanceName, elanInstance, interfaceName, interfaceInfo, elanInterfaceManager);
    jobCoordinator.enqueueJob(elanInstanceName, removeWorker, ElanConstants.JOB_MAX_RETRIES);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 27 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.

the class ElanPacketInHandler method tryAndRemoveInvalidMacEntry.

/*
     * Though this method is a little costlier because it uses try-catch
     * construct, it is used only in rare scenarios like MAC movement or invalid
     * Static MAC having been added on a wrong ELAN.
     */
private void tryAndRemoveInvalidMacEntry(String elanName, MacEntry macEntry) {
    ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
    if (elanInfo == null) {
        LOG.warn("MAC {} is been added (either statically or dynamically) for an invalid Elan {}. " + "Manual cleanup may be necessary", macEntry.getMacAddress(), elanName);
        return;
    }
    InterfaceInfo oldInterfaceLport = interfaceManager.getInterfaceInfo(macEntry.getInterface());
    if (oldInterfaceLport == null) {
        LOG.warn("MAC {} is been added (either statically or dynamically) on an invalid Logical Port {}. " + "Manual cleanup may be necessary", macEntry.getMacAddress(), macEntry.getInterface());
        return;
    }
    ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> elanUtils.deleteMacFlows(elanInfo, oldInterfaceLport, macEntry, tx)), LOG, "Error deleting invalid MAC entry");
    elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo, Collections.singletonList(macEntry.getMacAddress()));
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) NWUtil(org.opendaylight.genius.mdsalutil.NWUtil) PacketProcessingListener(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) MacEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry) MacEntryKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey) NetUtils(org.opendaylight.openflowplugin.libraries.liblldp.NetUtils) PacketInReason(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason) Inject(javax.inject.Inject) MacEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder) ElanUtils(org.opendaylight.netvirt.elan.utils.ElanUtils) Optional(com.google.common.base.Optional) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) IInterfaceManager(org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) NoMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.NoMatch) Logger(org.slf4j.Logger) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) ElanInstanceCache(org.opendaylight.netvirt.elan.cache.ElanInstanceCache) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) JobCoordinator(org.opendaylight.infrautils.jobcoordinator.JobCoordinator) IfIndexInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406._if.indexes._interface.map.IfIndexInterface) Ethernet(org.opendaylight.genius.mdsalutil.packet.Ethernet) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) EvpnUtils(org.opendaylight.netvirt.elan.evpn.utils.EvpnUtils) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) ElanL2GatewayUtils(org.opendaylight.netvirt.elan.l2gw.utils.ElanL2GatewayUtils) ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ElanInterfaceMac(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac) PacketException(org.opendaylight.openflowplugin.libraries.liblldp.PacketException) Collections(java.util.Collections) MetaDataUtil(org.opendaylight.genius.mdsalutil.MetaDataUtil) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Example 28 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.

the class EtreeInterfaceGet method displayInterfaces.

private void displayInterfaces(ElanInstance elanInstance, List<String> interfaceList) {
    if (!interfaceList.isEmpty()) {
        for (String elanInterface : interfaceList) {
            InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(elanInterface);
            EtreeInterface etreeInterface = elanProvider.getEtreeInterfaceByElanInterfaceName(elanInterface);
            if (interfaceInfo != null) {
                session.getConsole().println(String.format(ElanCLIUtils.ETREE_INTERFACE_CLI_FORMAT, elanInstance.getElanInstanceName() + "/" + elanInstance.getElanTag(), elanInterface + "/" + interfaceInfo.getInterfaceTag(), interfaceInfo.getOpState(), interfaceInfo.getAdminState(), etreeInterface.getEtreeInterfaceType().getName()));
            }
        }
    }
}
Also used : InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) EtreeInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface)

Example 29 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.

the class StatisticsImpl method createElementCountersResult.

private CounterResultDataStructure createElementCountersResult(CounterRequests counterRequest) {
    ElementCountersRequest ecr = createElementCounterRequest(counterRequest.getPortId(), counterRequest.getLportTag(), counterRequest.getDpn(), ElementCountersDirection.valueOf(counterRequest.getTrafficDirection()), counterRequest.getFilters()).iterator().next();
    BigInteger dpId = getDpn(ecr.getPortId());
    InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ecr.getPortId());
    if (interfaceInfo == null) {
        return null;
    }
    int lportTag = interfaceInfo.getInterfaceTag();
    List<MatchInfoBase> matches = CountersServiceUtils.getCounterFlowMatch(ecr, lportTag, ElementCountersDirection.valueOf(counterRequest.getTrafficDirection()));
    Match match = MDSALUtil.buildMatches(matches);
    return counterRetriever.getSwitchFlowCountersDirect(dpId, match);
}
Also used : BigInteger(java.math.BigInteger) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match)

Example 30 with InterfaceInfo

use of org.opendaylight.genius.interfacemanager.globals.InterfaceInfo in project netvirt by opendaylight.

the class ElanServiceTest method checkDmacSameDPN.

@Test
public void checkDmacSameDPN() throws Exception {
    // Create Elan instance
    createElanInstance(ExpectedObjects.ELAN1, ExpectedObjects.ELAN1_SEGMENT_ID);
    awaitForElanTag(ExpectedObjects.ELAN1);
    // Add Elan interface in DPN1
    InterfaceInfo interfaceInfo = ELAN_INTERFACES.get(ELAN1 + ":" + DPN1MAC1).getLeft();
    addElanInterface(ExpectedObjects.ELAN1, interfaceInfo, DPN1IP1);
    // Read Elan instance
    InstanceIdentifier<ElanInstance> elanInstanceIid = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(ExpectedObjects.ELAN1)).build();
    ElanInstance actualElanInstances = singleTxdataBroker.syncRead(CONFIGURATION, elanInstanceIid);
    // Read DMAC Flow in DPN1
    String flowId = new StringBuffer().append(NwConstants.ELAN_DMAC_TABLE).append(actualElanInstances.getElanTag()).append(DPN1_ID).append(interfaceInfo.getInterfaceTag()).append(interfaceInfo.getMacAddress()).toString();
    InstanceIdentifier<Flow> flowInstanceIidDst = getFlowIid(NwConstants.ELAN_DMAC_TABLE, new FlowId(flowId), DPN1_ID);
    awaitForData(LogicalDatastoreType.CONFIGURATION, flowInstanceIidDst);
    Flow flowDst = singleTxdataBroker.syncRead(CONFIGURATION, flowInstanceIidDst);
    flowDst = getFlowWithoutCookie(flowDst);
    Flow expected = ExpectedObjects.checkDmacOfSameDpn(flowId, interfaceInfo, actualElanInstances);
    AssertDataObjects.assertEqualBeans(getSortedActions(expected), getSortedActions(flowDst));
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Test(org.junit.Test)

Aggregations

InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)40 BigInteger (java.math.BigInteger)16 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)12 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)8 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)8 ArrayList (java.util.ArrayList)7 Collections (java.util.Collections)7 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)6 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)5 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)5 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)5 MacEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryBuilder)5 MacEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntryKey)5 Optional (com.google.common.base.Optional)4 Inject (javax.inject.Inject)4 Singleton (javax.inject.Singleton)4 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)4 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)4