Search in sources :

Example 21 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project lispflowmapping by opendaylight.

the class MapReplySerializationTest method deserialize__MultipleRecordsWithoutRLOCs.

@Test
public void deserialize__MultipleRecordsWithoutRLOCs() throws Exception {
    MapReply mr = MapReplySerializer.getInstance().deserialize(hexToByteBuffer("20 00 00 02 00 00 " + "00 00 00 00 00 00 00 00 00 01 00 20 00 00 00 00 " + "00 01 01 02 03 04 00 00 00 00 00 10 30 00 00 02 00 01 04 03 00 00"));
    assertArrayEquals(new byte[] { 1, 2, 3, 4 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    // XXX Why here normalized and other cases not normalized?
    assertArrayEquals(new byte[] { 4, 3, 0, 0 }, ((Ipv4PrefixBinary) mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()).getIpv4AddressBinary().getValue());
    assertEquals(false, mr.getMappingRecordItem().get(0).getMappingRecord().isAuthoritative());
    assertEquals(true, mr.getMappingRecordItem().get(1).getMappingRecord().isAuthoritative());
    assertEquals(Action.NoAction, mr.getMappingRecordItem().get(0).getMappingRecord().getAction());
    assertEquals(Action.NativelyForward, mr.getMappingRecordItem().get(1).getMappingRecord().getAction());
    assertEquals(0, mr.getMappingRecordItem().get(0).getMappingRecord().getMapVersion().shortValue());
    assertEquals(2, mr.getMappingRecordItem().get(1).getMappingRecord().getMapVersion().shortValue());
    assertEquals(32, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress()));
    assertEquals(16, MaskUtil.getMaskForAddress(mr.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress()));
    assertEquals(1, mr.getMappingRecordItem().get(0).getMappingRecord().getRecordTtl().byteValue());
    assertEquals(0, mr.getMappingRecordItem().get(1).getMappingRecord().getRecordTtl().byteValue());
}
Also used : Ipv4PrefixBinary(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.augmented.lisp.address.address.Ipv4PrefixBinary) MapReply(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply) Test(org.junit.Test)

Example 22 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project genius by opendaylight.

the class LockManagerTest method test3sOptimisticLockFailedExceptionOnLock.

@Test
public void test3sOptimisticLockFailedExceptionOnLock() throws InterruptedException, ExecutionException, TimeoutException {
    dbFailureSimulator.failSubmits(new OptimisticLockFailedException("bada boum bam!"));
    LockInput lockInput = new LockInputBuilder().setLockName("testLock").build();
    // see other tests above
    runUnfailSubmitsTimerTask(3000);
    assertVoidRpcSuccess(lockManager.lock(lockInput));
}
Also used : TryLockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput) LockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInput) OptimisticLockFailedException(org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException) TryLockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder) LockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.LockInputBuilder) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 23 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class ElanL2GatewayUtils method unInstallL2GwUcastMacFromElanDpns.

/**
 * Uninstall l2gw macs from other DPNs in the elan instance provided.
 * @param elan - Elan Instance for which other DPNs will be scanned.
 * @param l2GwDevice - l2gwDevice whose macs are required to be cleared from other devices.
 * @param macAddresses - Mac address to be cleared.
 */
public void unInstallL2GwUcastMacFromElanDpns(final ElanInstance elan, final L2GatewayDevice l2GwDevice, final Collection<MacAddress> macAddresses) {
    if (macAddresses == null || macAddresses.isEmpty()) {
        return;
    }
    if (elan == null || elan.getElanInstanceName() == null) {
        LOG.error("Could not delete l2gw ucast macs, Failed to find the elan for device {}", l2GwDevice.getHwvtepNodeId());
        return;
    }
    final Collection<DpnInterfaces> elanDpns = getElanDpns(elan.getElanInstanceName());
    // Retrieve all participating DPNs in this Elan. Populate this MAC in
    // DMAC table. Looping through all DPNs in order to add/remove mac flows
    // in their DMAC table
    List<ListenableFuture<Void>> result = new ArrayList<>();
    for (final MacAddress mac : macAddresses) {
        elanClusterUtils.runOnlyInOwnerNode(elan.getElanInstanceName() + ":" + mac.getValue(), "delete remote ucast macs in elan DPNs", () -> {
            for (DpnInterfaces elanDpn : elanDpns) {
                BigInteger dpnId = elanDpn.getDpId();
                result.addAll(elanDmacUtils.deleteDmacFlowsToExternalMac(elan.getElanTag(), dpnId, l2GwDevice.getHwvtepNodeId(), mac.getValue().toLowerCase(Locale.getDefault())));
            }
            return result;
        });
    }
}
Also used : DpnInterfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BigInteger(java.math.BigInteger) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)

Example 24 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class L2GatewayConnectionUtils method disAssociateHwvtepsFromElan.

private void disAssociateHwvtepsFromElan(String elanName, L2gatewayConnection input) {
    Integer defaultVlan = input.getSegmentId();
    List<L2GatewayDevice> l2Devices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
    List<Devices> l2gwDevicesToBeDeleted = new ArrayList<>();
    for (L2GatewayDevice elanL2gwDevice : l2Devices) {
        if (elanL2gwDevice.getL2GatewayIds().contains(input.getKey().getUuid())) {
            l2gwDevicesToBeDeleted.addAll(elanL2gwDevice.getDevicesForL2gwConnectionId(input.getKey().getUuid()));
        }
    }
    if (l2gwDevicesToBeDeleted.isEmpty()) {
        // delete logical switch
        Uuid l2GatewayId = input.getL2gatewayId();
        L2gateway l2Gateway = L2GatewayConnectionUtils.getNeutronL2gateway(broker, l2GatewayId);
        if (l2Gateway == null) {
            LOG.error("Failed to find the l2gateway for the connection {}", input.getUuid());
            return;
        } else {
            l2gwDevicesToBeDeleted.addAll(l2Gateway.getDevices());
        }
    }
    for (Devices l2Device : l2gwDevicesToBeDeleted) {
        String l2DeviceName = l2Device.getDeviceName();
        L2GatewayDevice l2GatewayDevice = l2GatewayCache.get(l2DeviceName);
        String hwvtepNodeId = l2GatewayDevice.getHwvtepNodeId();
        boolean isLastL2GwConnDeleted = false;
        L2GatewayDevice elanL2GwDevice = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
        if (elanL2GwDevice != null && isLastL2GwConnBeingDeleted(elanL2GwDevice)) {
            // Delete L2 Gateway device from 'ElanL2GwDevice' cache
            LOG.debug("Elan L2Gw Conn cache removed for id {}", hwvtepNodeId);
            ElanL2GwCacheUtils.removeL2GatewayDeviceFromCache(elanName, hwvtepNodeId);
            isLastL2GwConnDeleted = true;
        } else {
            Uuid l2GwConnId = input.getKey().getUuid();
            LOG.debug("Elan L2Gw Conn cache with id {} is being referred by other L2Gw Conns; so only " + "L2 Gw Conn {} reference is removed", hwvtepNodeId, l2GwConnId);
            if (elanL2GwDevice != null) {
                elanL2GwDevice.removeL2GatewayId(l2GwConnId);
            } else {
                isLastL2GwConnDeleted = true;
            }
        }
        DisAssociateHwvtepFromElanJob disAssociateHwvtepToElanJob = new DisAssociateHwvtepFromElanJob(elanL2GatewayUtils, elanL2GatewayMulticastUtils, elanL2GwDevice, elanName, () -> elanInstanceCache.get(elanName).orNull(), l2Device, defaultVlan, hwvtepNodeId, isLastL2GwConnDeleted);
        elanClusterUtils.runOnlyInOwnerNode(disAssociateHwvtepToElanJob.getJobKey(), "remove l2gw connection job", disAssociateHwvtepToElanJob);
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) L2gateway(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway) Devices(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateway.attributes.Devices) L2GatewayDevice(org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice) DisAssociateHwvtepFromElanJob(org.opendaylight.netvirt.elan.l2gw.jobs.DisAssociateHwvtepFromElanJob)

Example 25 with Other

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other in project netvirt by opendaylight.

the class ElanUtils method buildRemoteDmacFlowEntry.

/**
 * Builds a Flow to be programmed in a remote DPN's DMAC table. This flow
 * consists in: Match: + elanTag in packet's metadata + packet going to a
 * MAC known to be located in another DPN Actions: + set_tunnel_id
 * + output ITM internal tunnel interface with the other DPN
 *
 * @param srcDpId
 *            the src Dpn Id
 * @param destDpId
 *            dest Dp Id
 * @param lportTagOrVni
 *            lportTag or network VNI
 * @param elanTag
 *            elan Tag
 * @param macAddress
 *            macAddress
 * @param displayName
 *            display Name
 * @param elanInstance
 *            elanInstance
 * @return the flow remote Dmac
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public Flow buildRemoteDmacFlowEntry(BigInteger srcDpId, BigInteger destDpId, long lportTagOrVni, long elanTag, String macAddress, String displayName, ElanInstance elanInstance) {
    List<MatchInfo> mkMatches = new ArrayList<>();
    mkMatches.add(new MatchMetadata(ElanHelper.getElanMetadataLabel(elanTag), MetaDataUtil.METADATA_MASK_SERVICE));
    mkMatches.add(new MatchEthernetDestination(new MacAddress(macAddress)));
    List<Instruction> mkInstructions = new ArrayList<>();
    // List of Action for the provided Source and Destination DPIDs
    try {
        List<Action> actions = null;
        if (isVlan(elanInstance) || isFlat(elanInstance)) {
            String interfaceName = getExternalElanInterface(elanInstance.getElanInstanceName(), srcDpId);
            if (null == interfaceName) {
                LOG.info("buildRemoteDmacFlowEntry: Could not find interfaceName for {} {}", srcDpId, elanInstance);
            }
            actions = getEgressActionsForInterface(interfaceName, null);
        } else if (isVxlanNetworkOrVxlanSegment(elanInstance)) {
            actions = elanItmUtils.getInternalTunnelItmEgressAction(srcDpId, destDpId, lportTagOrVni);
        }
        mkInstructions.add(MDSALUtil.buildApplyActionsInstruction(actions));
    } catch (Exception e) {
        LOG.error("Could not get egress actions to add to flow for srcDpId {}, destDpId {}, lportTag/VNI {}", srcDpId, destDpId, lportTagOrVni, e);
    }
    Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, srcDpId, destDpId, macAddress, elanTag), 20, /* prio */
    displayName, 0, /* idleTimeout */
    0, /* hardTimeout */
    ElanConstants.COOKIE_ELAN_KNOWN_DMAC.add(BigInteger.valueOf(elanTag)), mkMatches, mkInstructions);
    return flow;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) MatchInfo(org.opendaylight.genius.mdsalutil.MatchInfo)

Aggregations

ArrayList (java.util.ArrayList)26 BigInteger (java.math.BigInteger)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)13 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)8 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)7 ExecutionException (java.util.concurrent.ExecutionException)6 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Test (org.junit.Test)4 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)4 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 VrfTablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTablesKey)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 HashSet (java.util.HashSet)3 List (java.util.List)3 L2GatewayDevice (org.opendaylight.netvirt.neutronvpn.api.l2gw.L2GatewayDevice)3