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);
}
}
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);
}
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);
}
}
}
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);
}
}
}
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;
}
Aggregations