Search in sources :

Example 81 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class ElanUtils method updateOperationalDataStore.

/**
 * Updates the Elan information in the Operational DS. It also updates the
 * ElanInstance in the Config DS by setting the adquired elanTag.
 *
 * @param idManager
 *            the id manager
 * @param elanInstanceAdded
 *            the elan instance added
 * @param elanInterfaces
 *            the elan interfaces
 * @param operTx
 *            transaction
 *
 * @return the updated ELAN instance.
 */
public static ElanInstance updateOperationalDataStore(IdManagerService idManager, ElanInstance elanInstanceAdded, List<String> elanInterfaces, TypedWriteTransaction<Configuration> confTx, TypedWriteTransaction<Operational> operTx) {
    String elanInstanceName = elanInstanceAdded.getElanInstanceName();
    Uint32 elanTag = elanInstanceAdded.getElanTag();
    if (elanTag == null || elanTag.longValue() == 0L) {
        elanTag = retrieveNewElanTag(idManager, elanInstanceName);
    }
    if (elanTag.longValue() == 0L) {
        LOG.error("ELAN tag creation failed for elan instance {}. Not updating the ELAN DS. " + "Recreate network for recovery", elanInstanceName);
        return null;
    }
    Elan elanInfo = new ElanBuilder().setName(elanInstanceName).setElanInterfaces(elanInterfaces).withKey(new ElanKey(elanInstanceName)).build();
    // Add the ElanState in the elan-state operational data-store
    operTx.mergeParentStructurePut(getElanInstanceOperationalDataPath(elanInstanceName), elanInfo);
    // Add the ElanMacTable in the elan-mac-table operational data-store
    MacTable elanMacTable = new MacTableBuilder().withKey(new MacTableKey(elanInstanceName)).build();
    operTx.mergeParentStructurePut(getElanMacTableOperationalDataPath(elanInstanceName), elanMacTable);
    ElanTagNameBuilder elanTagNameBuilder = new ElanTagNameBuilder().setElanTag(elanTag).withKey(new ElanTagNameKey(elanTag)).setName(elanInstanceName);
    Uint32 etreeLeafTag = Uint32.valueOf(0L);
    if (isEtreeInstance(elanInstanceAdded)) {
        etreeLeafTag = retrieveNewElanTag(idManager, elanInstanceName + ElanConstants.LEAVES_POSTFIX);
        EtreeLeafTagName etreeLeafTagName = new EtreeLeafTagNameBuilder().setEtreeLeafTag(new EtreeLeafTag(etreeLeafTag)).build();
        elanTagNameBuilder.addAugmentation(etreeLeafTagName);
        addTheLeafTagAsElanTag(elanInstanceName, etreeLeafTag, operTx);
    }
    ElanTagName elanTagName = elanTagNameBuilder.build();
    // Add the ElanTag to ElanName in the elan-tag-name Operational
    // data-store
    operTx.put(getElanInfoEntriesOperationalDataPath(elanTag), elanTagName);
    // Updates the ElanInstance Config DS by setting the just acquired
    // elanTag
    ElanInstanceBuilder elanInstanceBuilder = new ElanInstanceBuilder(elanInstanceAdded).setElanInstanceName(elanInstanceName).setDescription(elanInstanceAdded.getDescription()).setMacTimeout(elanInstanceAdded.getMacTimeout() == null ? Uint32.valueOf(ElanConstants.DEFAULT_MAC_TIME_OUT) : elanInstanceAdded.getMacTimeout()).withKey(elanInstanceAdded.key()).setElanTag(elanTag);
    if (isEtreeInstance(elanInstanceAdded)) {
        EtreeInstance etreeInstance = new EtreeInstanceBuilder().setEtreeLeafTagVal(new EtreeLeafTag(etreeLeafTag)).build();
        elanInstanceBuilder.addAugmentation(etreeInstance);
    }
    ElanInstance elanInstanceWithTag = elanInstanceBuilder.build();
    LOG.trace("Updated elan Operational DS for elan: {} with elanTag: {} and interfaces: {}", elanInstanceName, elanTag, elanInterfaces);
    confTx.mergeParentStructureMerge(ElanHelper.getElanInstanceConfigurationDataPath(elanInstanceName), elanInstanceWithTag);
    return elanInstanceWithTag;
}
Also used : ElanTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName) ElanInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance) ElanKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanKey) MacTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableBuilder) ElanInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstanceBuilder) EtreeInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstance) MacTable(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTable) EtreeLeafTagName(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName) ElanBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.ElanBuilder) ElanTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameBuilder) MacTableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.forwarding.tables.MacTableKey) ElanTagNameKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagNameKey) Elan(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.state.Elan) EtreeInstanceBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInstanceBuilder) Uint32(org.opendaylight.yangtools.yang.common.Uint32) EtreeLeafTagNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagNameBuilder) EtreeLeafTag(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTag)

Example 82 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class ElanUtils method deleteMacFlows.

public void deleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
    String elanInstanceName = elanInfo.getElanInstanceName();
    List<DpnInterfaces> remoteFEs = getInvolvedDpnsInElan(elanInstanceName);
    Uint64 srcdpId = interfaceInfo.getDpId();
    boolean isFlowsRemovedInSrcDpn = false;
    for (DpnInterfaces dpnInterface : remoteFEs) {
        Uint32 elanTag = elanInfo.getElanTag();
        Uint64 dstDpId = dpnInterface.getDpId();
        if (executeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId, elanTag, dstDpId, flowTx)) {
            isFlowsRemovedInSrcDpn = true;
        }
        executeEtreeDeleteMacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, elanInstanceName, srcdpId, elanTag, dstDpId, flowTx);
    }
    if (!isFlowsRemovedInSrcDpn) {
        deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, flowTx);
    }
}
Also used : 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) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 83 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class ElanUtils method deleteSmacAndDmacFlows.

private void deleteSmacAndDmacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, boolean deleteSmac, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
    String elanInstanceName = elanInfo.getElanInstanceName();
    Uint64 srcdpId = interfaceInfo.getDpId();
    Uint32 elanTag = elanInfo.getElanTag();
    if (deleteSmac) {
        LOG.debug("Deleting SMAC flow with id {}", getKnownDynamicmacFlowRef(elanTag, macAddress));
        mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
    }
    mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
    LOG.debug("All the required flows deleted for elan:{}, logical Interface port:{} and MAC address:{} on dpn:{}", elanInstanceName, interfaceInfo.getPortName(), macAddress, srcdpId);
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 84 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class ElanUtils method deleteSmacFlowOnly.

public void deleteSmacFlowOnly(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress, TypedReadWriteTransaction<Configuration> flowTx) throws ExecutionException, InterruptedException {
    Uint64 srcdpId = interfaceInfo.getDpId();
    Uint32 elanTag = elanInfo.getElanTag();
    LOG.debug("Deleting SMAC flow with id {}", getKnownDynamicmacFlowRef(elanTag, macAddress));
    mdsalManager.removeFlow(flowTx, srcdpId, MDSALUtil.buildFlow(NwConstants.ELAN_SMAC_TABLE, getKnownDynamicmacFlowRef(elanTag, macAddress)));
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 85 with Uint32

use of org.opendaylight.yangtools.yang.common.Uint32 in project netvirt by opendaylight.

the class BgpManagerTest method testConnectedRoutNullNextHop.

@Test
public void testConnectedRoutNullNextHop() {
    String rd = "101";
    String prefix = "10.10.10.10/32";
    Uint32 label = Uint32.valueOf(1234);
    try {
        bgpFibWriter.addFibEntryToDS(rd, /*macAddress*/
        prefix, null, VrfEntry.EncapType.Mplsgre, label, Uint32.ZERO, /*l3vni*/
        null, /*gatewayMacAddress*/
        RouteOrigin.CONNECTED);
        // The code is not launching NullPointerException
        assertEquals(1, 0);
    } catch (NullPointerException e) {
        // The code must launch NullPointerException
        assertEquals(1, 1);
    }
}
Also used : Uint32(org.opendaylight.yangtools.yang.common.Uint32) Test(org.junit.Test) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)

Aggregations

Uint32 (org.opendaylight.yangtools.yang.common.Uint32)394 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)111 ArrayList (java.util.ArrayList)105 ExecutionException (java.util.concurrent.ExecutionException)79 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)68 List (java.util.List)60 Optional (java.util.Optional)52 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)51 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)51 Logger (org.slf4j.Logger)51 LoggerFactory (org.slf4j.LoggerFactory)51 ManagedNewTransactionRunner (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunner)49 Inject (javax.inject.Inject)48 Singleton (javax.inject.Singleton)48 Test (org.junit.Test)48 ManagedNewTransactionRunnerImpl (org.opendaylight.mdsal.binding.util.ManagedNewTransactionRunnerImpl)48 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)46 Collections (java.util.Collections)44 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)43 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)38