Search in sources :

Example 6 with ElanInstanceKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.

the class DhcpExternalTunnelManager method configureDhcpArpRequestResponseFlow.

public void configureDhcpArpRequestResponseFlow(BigInteger dpnId, String elanInstanceName, boolean addFlow, IpAddress tunnelIp, String dhcpIpAddress, String dhcpMacAddress) {
    L2GatewayDevice device = getDeviceFromTunnelIp(tunnelIp);
    if (device == null) {
        LOG.error("Unable to get L2Device for tunnelIp {} and elanInstanceName {}", tunnelIp, elanInstanceName);
    }
    jobCoordinator.enqueueJob(getJobKey(elanInstanceName), () -> {
        if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
            String tunnelInterfaceName = getExternalTunnelInterfaceName(String.valueOf(dpnId), device.getHwvtepNodeId());
            int lportTag = interfaceManager.getInterfaceInfo(tunnelInterfaceName).getInterfaceTag();
            InstanceIdentifier<ElanInstance> elanIdentifier = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).build();
            Optional<ElanInstance> optElan = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, elanIdentifier);
            if (optElan.isPresent()) {
                LOG.trace("Configuring the SR-IOV Arp request/response flows for LPort {} ElanTag {}.", lportTag, optElan.get().getElanTag());
                Uuid nwUuid = new Uuid(elanInstanceName);
                String strVni = DhcpServiceUtils.getSegmentationId(nwUuid, broker);
                BigInteger vni = strVni != null ? new BigInteger(strVni) : BigInteger.ZERO;
                if (!vni.equals(BigInteger.ZERO)) {
                    if (addFlow) {
                        LOG.trace("Installing the SR-IOV DHCP Arp flow for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
                        installDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag, optElan.get().getElanTag());
                        installDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, elanInstanceName, dhcpIpAddress, dhcpMacAddress);
                    } else {
                        LOG.trace("Uninstalling the SR-IOV DHCP Arp flows for DPN {} Port Ip {}, Lport {}.", dpnId, dhcpIpAddress, lportTag);
                        uninstallDhcpArpRequestFlows(dpnId, vni, dhcpIpAddress, lportTag);
                        uninstallDhcpArpResponderFlows(dpnId, tunnelInterfaceName, lportTag, dhcpIpAddress);
                    }
                }
            }
        }
        return null;
    });
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) BigInteger(java.math.BigInteger) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) TerminationPoint(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)

Example 7 with ElanInstanceKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.

the class ElanServiceChainUtils method updateElanToLportTagMap.

/**
 * Stores the relation between ElanLport and scfTag.
 *
 * @param broker dataBroker service reference
 * @param elanInstanceName Name of the ELAN. Typically its UUID
 * @param lportTag Dataplane identifier of the ElanPseudoPort
 * @param scfTag Dataplane identifier of the SCF
 * @param addOrRemove States if flows must be added or removed
 */
public static void updateElanToLportTagMap(final DataBroker broker, final String elanInstanceName, final int lportTag, final long scfTag, final int addOrRemove) {
    Long portTag = Long.valueOf(lportTag);
    ElanToPseudoPortDataKey key = new ElanToPseudoPortDataKey(portTag, scfTag);
    InstanceIdentifier<ElanToPseudoPortData> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).child(ElanToPseudoPortData.class, key).build();
    if (addOrRemove == NwConstants.ADD_FLOW) {
        ElanToPseudoPortData newValue = new ElanToPseudoPortDataBuilder().setKey(key).setElanLportTag(portTag).setScfTag(scfTag).build();
        MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, path, newValue);
    } else {
        MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, path);
    }
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanToPseudoPortDataKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortDataKey) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanToPseudoPortDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortDataBuilder) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData)

Example 8 with ElanInstanceKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.

the class CoeUtils method buildElanInstance.

static ElanInstance buildElanInstance(String elanInstanceName, Class<? extends SegmentTypeBase> segmentType, String segmentationId, Boolean isExternal) {
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder().setElanInstanceName(elanInstanceName);
    if (segmentType != null) {
        elanInstanceBuilder.setSegmentType(segmentType);
        if (segmentationId != null) {
            elanInstanceBuilder.setSegmentationId(Long.valueOf(segmentationId));
        }
    }
    elanInstanceBuilder.setExternal(isExternal);
    elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
    return elanInstanceBuilder.build();
}
Also used : ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)

Example 9 with ElanInstanceKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey in project netvirt by opendaylight.

the class ElanServiceChainHandler method removeElanPseudoPortFlows.

public void removeElanPseudoPortFlows(String elanName, int elanLportTag) {
    Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
    if (!elanServiceChainState.isPresent()) {
        LOG.warn("Could not find ServiceChain state data for Elan {}, elanPseudoLportTag={}", elanName, elanLportTag);
        return;
    }
    Optional<ElanInstance> elanInstance = ElanServiceChainUtils.getElanInstanceByName(broker, elanName);
    if (!elanInstance.isPresent()) {
        LOG.warn("Could not find ElanInstance for name {}", elanName);
        return;
    }
    Long vni = elanInstance.get().getSegmentationId();
    if (vni == null) {
        LOG.warn("Elan {} is not related to a VNI. VNI is mandatory for ServiceChaining. Returning", elanName);
        return;
    }
    List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
    if (elanToPseudoPortDataList == null || elanToPseudoPortDataList.isEmpty()) {
        LOG.info("Could not find elan {} with elanPseudoPort {} participating in any ServiceChain", elanName, elanLportTag);
        return;
    }
    if (elanInstance.get().getElanTag() == null) {
        LOG.info("Could not find elanTag for elan {} ", elanName);
        return;
    }
    int elanTag = elanInstance.get().getElanTag().intValue();
    List<BigInteger> operativeDPNs = NWUtil.getOperativeDPNs(broker);
    for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
        Long scfTag = elanToPseudoPortData.getScfTag();
        for (BigInteger dpnId : operativeDPNs) {
            ElanServiceChainUtils.programLPortDispatcherToScf(mdsalManager, dpnId, elanTag, elanLportTag, NwConstants.SCF_DOWN_SUB_FILTER_TCP_BASED_TABLE, scfTag, NwConstants.DEL_FLOW);
            ElanServiceChainUtils.programLPortDispatcherFromScf(mdsalManager, dpnId, elanLportTag, elanTag, NwConstants.DEL_FLOW);
            ElanServiceChainUtils.programExternalTunnelTable(mdsalManager, dpnId, elanLportTag, vni, elanTag, NwConstants.DEL_FLOW);
        }
    }
    // Lastly, remove the serviceChain-state for the Elan
    InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanName)).augmentation(ElanServiceChainState.class).build();
    MDSALUtil.syncDelete(broker, LogicalDatastoreType.OPERATIONAL, path);
}
Also used : ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanInstances(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState) ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) BigInteger(java.math.BigInteger) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData)

Example 10 with ElanInstanceKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey 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

ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)13 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)10 ElanInstanceBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder)4 Test (org.junit.Test)3 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)3 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)3 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)3 BigInteger (java.math.BigInteger)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 ElanServiceChainState (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)2 ElanToPseudoPortData (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData)2 ElanInstances (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)2 Before (org.junit.Before)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 TunnelInterfaceDetails (org.opendaylight.genius.testutils.interfacemanager.TunnelInterfaceDetails)1 CacheManagersRegistryImpl (org.opendaylight.infrautils.caches.baseimpl.internal.CacheManagersRegistryImpl)1 GuavaCacheProvider (org.opendaylight.infrautils.caches.guava.internal.GuavaCacheProvider)1 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)1 ElanToPseudoPortDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortDataBuilder)1 ElanToPseudoPortDataKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortDataKey)1