Search in sources :

Example 1 with ElanToPseudoPortData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData in project netvirt by opendaylight.

the class ElanServiceChainUtils method getElanServiceChainState.

/**
 * Read from ElanToLportTagMap the PsuedoLogicalPort related with a given elan.
 *
 * @param broker dataBroker service reference
 * @param elanInstanceName the name of the Elan
 * @return the ElanToPseudoPortData object or Optional.absent() if it
 *     cannot be found
 */
public static Optional<ElanServiceChainState> getElanServiceChainState(final DataBroker broker, final String elanInstanceName) {
    InstanceIdentifier<ElanServiceChainState> path = InstanceIdentifier.builder(ElanInstances.class).child(ElanInstance.class, new ElanInstanceKey(elanInstanceName)).augmentation(ElanServiceChainState.class).build();
    Optional<ElanServiceChainState> elanServiceChainStateOpc = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, path);
    return elanServiceChainStateOpc;
}
Also used : ElanInstanceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey) 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)

Example 2 with ElanToPseudoPortData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData in project netvirt by opendaylight.

the class ElanDpnInterfacesListener method add.

@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
    final String elanName = getElanName(identifier);
    BigInteger addDpnId = dpnInterfaces.getDpId();
    LOG.debug("ELAN interfaces {} added on DPN {} for Elan {}", dpnInterfaces.getInterfaces(), addDpnId, elanName);
    Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
    if (elanServiceChainState.isPresent()) {
        List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
        for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
            Long scfTag = elanToPseudoPortData.getScfTag();
            Long elanLportTag = elanToPseudoPortData.getElanLportTag();
            if (elanLportTag != null && scfTag != null) {
                short tableId = NwConstants.SCF_DOWN_SUB_FILTER_TCP_BASED_TABLE;
                handleUpdate(addDpnId, elanName, tableId, elanLportTag.intValue(), /*21 bit*/
                scfTag, NwConstants.ADD_FLOW);
            } else {
                LOG.debug("Could not find lportTag for ELAN={}", elanName);
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)

Example 3 with ElanToPseudoPortData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData 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 4 with ElanToPseudoPortData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData 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 5 with ElanToPseudoPortData

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData in project netvirt by opendaylight.

the class ElanDpnInterfacesListener method remove.

@Override
protected void remove(InstanceIdentifier<DpnInterfaces> identifier, final DpnInterfaces dpnInterfaces) {
    final String elanName = getElanName(identifier);
    BigInteger removeDpnId = dpnInterfaces.getDpId();
    LOG.debug("ELAN interfaces {} removed from on DPN {} for ELAN {}", dpnInterfaces.getInterfaces(), removeDpnId, elanName);
    Optional<ElanServiceChainState> elanServiceChainState = ElanServiceChainUtils.getElanServiceChainState(broker, elanName);
    if (elanServiceChainState.isPresent()) {
        List<ElanToPseudoPortData> elanToPseudoPortDataList = elanServiceChainState.get().getElanToPseudoPortData();
        for (ElanToPseudoPortData elanToPseudoPortData : elanToPseudoPortDataList) {
            Long scfTag = elanToPseudoPortData.getScfTag();
            Long elanLportTag = elanToPseudoPortData.getElanLportTag();
            if (scfTag != null && elanLportTag != null) {
                handleUpdate(removeDpnId, elanName, (short) 0, /* tableId, ignored in removals */
                elanLportTag.intValue(), /*21 bit*/
                0, /* scfTag, ignored in removals */
                NwConstants.DEL_FLOW);
            } else {
                LOG.debug("One of scfTag or lPortTag is null for ELAN={}:  scfTag={}  lportTag={}", elanName, scfTag, elanLportTag);
            }
        }
    }
}
Also used : BigInteger(java.math.BigInteger) ElanToPseudoPortData(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData) ElanServiceChainState(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)

Aggregations

ElanServiceChainState (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.ElanServiceChainState)4 ElanToPseudoPortData (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.cloud.servicechain.state.rev160711.elan.to.pseudo.port.data.list.ElanToPseudoPortData)4 BigInteger (java.math.BigInteger)3 ElanInstanceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceKey)3 ElanInstances (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanInstances)2 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)2 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