Search in sources :

Example 11 with GroupEntity

use of org.opendaylight.genius.mdsalutil.GroupEntity in project netvirt by opendaylight.

the class ArpResponderUtil method installGroup.

/**
 * Install Group flow on the DPN.
 *
 * @param mdSalManager
 *            Reference of MDSAL API RPC that provides API for installing
 *            group flow
 * @param dpnId
 *            DPN on which group flow to be installed
 * @param groupdId
 *            Uniquely identifiable Group Id for the group flow
 * @param groupName
 *            Name of the group flow
 * @param buckets
 *            List of the bucket actions for the group flow
 */
public static void installGroup(IMdsalApiManager mdSalManager, BigInteger dpnId, long groupdId, String groupName, List<BucketInfo> buckets) {
    LOG.trace("Installing group flow on dpn {}", dpnId);
    GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupdId, groupName, GroupTypes.GroupAll, buckets);
    mdSalManager.syncInstallGroup(groupEntity);
    try {
        Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
    } catch (InterruptedException e1) {
        LOG.warn("Error while waiting for ARP Responder Group Entry to be installed on DPN {} ", dpnId);
    }
}
Also used : GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity)

Example 12 with GroupEntity

use of org.opendaylight.genius.mdsalutil.GroupEntity in project genius by opendaylight.

the class MdSalUtilTest method testRemoveGroup.

@Test
public void testRemoveGroup() throws Exception {
    String inport = "2";
    int vlanid = 100;
    GroupEntity grpEntity = createGroupEntity(NODE_ID, inport, vlanid);
    // To test RemoveGroup add and then delete Group
    mdSalMgr.installGroupInternal(grpEntity).get();
    grpFwder.awaitDataChangeCount(1);
    mdSalMgr.removeGroupInternal(grpEntity.getDpnId(), grpEntity.getGroupId()).get();
    grpFwder.awaitDataChangeCount(0);
}
Also used : GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) AbstractConcurrentDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest) Test(org.junit.Test)

Example 13 with GroupEntity

use of org.opendaylight.genius.mdsalutil.GroupEntity in project netvirt by opendaylight.

the class ExternalNetworkGroupInstaller method removeExtNetGroupEntries.

public void removeExtNetGroupEntries(Subnetmap subnetMap) {
    if (subnetMap == null) {
        return;
    }
    String subnetName = subnetMap.getId().getValue();
    Uuid networkId = subnetMap.getNetworkId();
    if (networkId == null) {
        LOG.error("removeExtNetGroupEntries : No external network associated subnet id {}", subnetName);
        return;
    }
    Collection<String> extInterfaces = elanService.getExternalElanInterfaces(networkId.getValue());
    if (extInterfaces == null || extInterfaces.isEmpty()) {
        LOG.debug("removeExtNetGroupEntries : No external ELAN interfaces attached to network {} subnet {}", networkId, subnetName);
        return;
    }
    long groupId = NatUtil.createGroupId(NatUtil.getGroupIdKey(subnetName), idManager);
    for (String extInterface : extInterfaces) {
        GroupEntity groupEntity = buildEmptyExtNetGroupEntity(subnetName, groupId, extInterface);
        if (groupEntity != null) {
            LOG.info("removeExtNetGroupEntries : Remove ext-net Group: id {}, subnet id {}", groupId, subnetName);
            NatServiceCounters.remove_external_network_group.inc();
            mdsalManager.syncRemoveGroup(groupEntity);
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity)

Example 14 with GroupEntity

use of org.opendaylight.genius.mdsalutil.GroupEntity in project netvirt by opendaylight.

the class ExternalRoutersListener method removeFlowsFromNonActiveSwitches.

public void removeFlowsFromNonActiveSwitches(long routerId, String routerName, BigInteger naptSwitchDpnId, WriteTransaction removeFlowInvTx) {
    LOG.debug("removeFlowsFromNonActiveSwitches : Remove NAPT related flows from non active switches");
    // Remove the flows from the other switches which points to the primary and secondary switches
    // for the flows related the router ID.
    List<BigInteger> allSwitchList = naptSwitchSelector.getDpnsForVpn(routerName);
    if (allSwitchList.isEmpty()) {
        LOG.error("removeFlowsFromNonActiveSwitches : Unable to get the swithces for the router {}", routerName);
        return;
    }
    for (BigInteger dpnId : allSwitchList) {
        if (!naptSwitchDpnId.equals(dpnId)) {
            LOG.info("removeFlowsFromNonActiveSwitches : Handle Ordinary switch");
            // Remove the PSNAT entry which forwards the packet to Terminating Service table
            String preSnatFlowRef = getFlowRefSnat(dpnId, NwConstants.PSNAT_TABLE, String.valueOf(routerName));
            FlowEntity preSnatFlowEntity = NatUtil.buildFlowEntity(dpnId, NwConstants.PSNAT_TABLE, preSnatFlowRef);
            LOG.info("removeFlowsFromNonActiveSwitches : Remove the flow in the {} for the non active switch " + "with the DPN ID {} and router ID {}", NwConstants.PSNAT_TABLE, dpnId, routerId);
            mdsalManager.removeFlowToTx(preSnatFlowEntity, removeFlowInvTx);
            // Remove the group entry which forwards the traffic to the out port (VXLAN tunnel).
            long groupId = createGroupId(getGroupIdKey(routerName));
            List<BucketInfo> listBucketInfo = new ArrayList<>();
            GroupEntity preSnatGroupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, routerName, GroupTypes.GroupAll, listBucketInfo);
            LOG.info("removeFlowsFromNonActiveSwitches : Remove the group {} for the non active switch with " + "the DPN ID {} and router ID {}", groupId, dpnId, routerId);
            mdsalManager.removeGroup(preSnatGroupEntity);
        }
    }
}
Also used : GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) BucketInfo(org.opendaylight.genius.mdsalutil.BucketInfo) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 15 with GroupEntity

use of org.opendaylight.genius.mdsalutil.GroupEntity in project netvirt by opendaylight.

the class NexthopManager method setupLoadBalancingNextHop.

protected long setupLoadBalancingNextHop(Long parentVpnId, BigInteger dpnId, String destPrefix, List<BucketInfo> listBucketInfo, boolean addOrRemove) {
    long groupId = createNextHopPointer(getNextHopKey(parentVpnId, destPrefix));
    if (groupId == FibConstants.INVALID_GROUP_ID) {
        LOG.error("Unable to allocate/retrieve groupId for vpnId {} , prefix {}", parentVpnId, destPrefix);
        return groupId;
    }
    GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpnId, groupId, destPrefix, GroupTypes.GroupSelect, listBucketInfo);
    if (addOrRemove) {
        mdsalApiManager.syncInstallGroup(groupEntity);
        try {
            Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
        } catch (InterruptedException e1) {
            LOG.warn("Thread got interrupted while programming LB group {}", groupEntity);
            Thread.currentThread().interrupt();
        }
    } else {
        mdsalApiManager.removeGroup(groupEntity);
    }
    return groupId;
}
Also used : GroupEntity(org.opendaylight.genius.mdsalutil.GroupEntity)

Aggregations

GroupEntity (org.opendaylight.genius.mdsalutil.GroupEntity)17 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)5 BigInteger (java.math.BigInteger)4 ArrayList (java.util.ArrayList)4 BucketInfo (org.opendaylight.genius.mdsalutil.BucketInfo)4 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)3 ExecutionException (java.util.concurrent.ExecutionException)2 Test (org.junit.Test)2 AbstractConcurrentDataBrokerTest (org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest)2 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)2 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)2 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)2 ActionSetFieldTunnelId (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)2 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)2 MatchEthernetType (org.opendaylight.genius.mdsalutil.matches.MatchEthernetType)2 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)2 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)2 VpnNexthop (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthop)2 VpnNexthopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopBuilder)2 VpnNexthopKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3nexthop.rev150409.l3nexthop.vpnnexthops.VpnNexthopKey)2