use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanInterfaceManager method handleInternalTunnelStateEvent.
@SuppressWarnings("checkstyle:IllegalCatch")
public void handleInternalTunnelStateEvent(BigInteger srcDpId, BigInteger dstDpId) {
ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
LOG.trace("processing tunnel state event for srcDpId {} dstDpId {}" + " and dpnInterfaceList {}", srcDpId, dstDpId, dpnInterfaceLists);
if (dpnInterfaceLists == null) {
return;
}
List<ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.getElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf) {
int cnt = 0;
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (elanInfo == null) {
LOG.warn("ELAN Info is null for elanName {} that does exist in elanDpnInterfaceList, " + "skipping this ELAN for tunnel handling", elanName);
continue;
}
if (ElanUtils.isFlat(elanInfo) || ElanUtils.isVlan(elanInfo)) {
LOG.debug("Ignoring internal tunnel state event for Flat/Vlan elan {}", elanName);
continue;
}
List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
if (dpnInterfaces == null) {
continue;
}
DpnInterfaces dstDpnIf = null;
for (DpnInterfaces dpnIf : dpnInterfaces) {
BigInteger dpnIfDpId = dpnIf.getDpId();
if (dpnIfDpId.equals(srcDpId)) {
cnt++;
} else if (dpnIfDpId.equals(dstDpId)) {
cnt++;
dstDpnIf = dpnIf;
}
}
if (cnt == 2) {
LOG.info("Elan instance:{} is present b/w srcDpn:{} and dstDpn:{}", elanName, srcDpId, dstDpId);
// var needs to be final so it can be accessed in lambda
final DpnInterfaces finalDstDpnIf = dstDpnIf;
jobCoordinator.enqueueJob(elanName, () -> {
// update Remote BC Group
LOG.trace("procesing elan remote bc group for tunnel event {}", elanInfo);
try {
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, srcDpId);
} catch (RuntimeException e) {
LOG.error("Error while adding remote bc group for {} on dpId {} ", elanName, srcDpId);
}
Set<String> interfaceLists = new HashSet<>();
interfaceLists.addAll(finalDstDpnIf.getInterfaces());
for (String ifName : interfaceLists) {
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(ifName), () -> {
LOG.info("Processing tunnel up event for elan {} and interface {}", elanName, ifName);
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ifName);
if (isOperational(interfaceInfo)) {
return installDMacAddressTables(elanInfo, interfaceInfo, srcDpId);
}
return Collections.emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
return Collections.emptyList();
}, ElanConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanInterfaceManager method removeFilterEqualsTable.
public void removeFilterEqualsTable(ElanInstance elanInfo, InterfaceInfo interfaceInfo, WriteTransaction deleteFlowGroupTx) {
int ifTag = interfaceInfo.getInterfaceTag();
Flow flow = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "group"), 9, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), ElanUtils.getTunnelIdMatchForFilterEqualsLPortTag(ifTag), elanUtils.getInstructionsInPortForOutGroup(interfaceInfo.getInterfaceName()));
mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flow, deleteFlowGroupTx);
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ELAN_FILTER_EQUALS_TABLE, getFlowRef(NwConstants.ELAN_FILTER_EQUALS_TABLE, ifTag, "drop"), 10, elanInfo.getElanInstanceName(), 0, 0, ElanConstants.COOKIE_ELAN_FILTER_EQUALS.add(BigInteger.valueOf(ifTag)), getMatchesForFilterEqualsLPortTag(ifTag), MDSALUtil.buildInstructionsDrop());
mdsalManager.removeFlowToTx(interfaceInfo.getDpId(), flowEntity, deleteFlowGroupTx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanInterfaceManager method setupStandardLocalBroadcastGroups.
public void setupStandardLocalBroadcastGroups(ElanInstance elanInfo, DpnInterfaces newDpnInterface, InterfaceInfo interfaceInfo) {
List<Bucket> listBucket = new ArrayList<>();
int bucketId = 0;
long groupId = ElanUtils.getElanLocalBCGId(elanInfo.getElanTag());
List<String> interfaces = new ArrayList<>();
if (newDpnInterface != null) {
interfaces = newDpnInterface.getInterfaces();
}
for (String ifName : interfaces) {
// In case if there is a InterfacePort in the cache which is not in
// operational state, skip processing it
InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
if (!isOperational(ifInfo)) {
continue;
}
if (!interfaceManager.isExternalInterface(ifName)) {
listBucket.add(MDSALUtil.buildBucket(getInterfacePortActions(ifInfo), MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
bucketId++;
}
}
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
LOG.trace("installing the localBroadCast Group:{}", group);
mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanGroupListener method update.
@Override
protected void update(InstanceIdentifier<Group> identifier, Group original, Group update) {
LOG.trace("received group updated {}", update.getKey().getGroupId());
final BigInteger dpnId = getDpnId(identifier.firstKeyOf(Node.class).getId().getValue());
if (dpnId == null) {
return;
}
List<L2GatewayDevice> allDevices = ElanL2GwCacheUtils.getAllElanDevicesFromCache();
if (allDevices == null || allDevices.isEmpty()) {
LOG.trace("no elan devices present in cache {}", update.getKey().getGroupId());
return;
}
int expectedElanFootprint = 0;
final ElanInstance elanInstance = getElanInstanceFromGroupId(update);
if (elanInstance == null) {
LOG.trace("no elan instance is null {}", update.getKey().getGroupId());
return;
}
ConcurrentMap<String, L2GatewayDevice> devices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstance.getElanInstanceName());
if (devices == null || devices.isEmpty()) {
LOG.trace("no elan devices in elan cache {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
return;
}
boolean updateGroup = false;
List<DpnInterfaces> dpns = elanUtils.getElanDPNByName(elanInstance.getElanInstanceName());
if (dpns.size() > 0) {
expectedElanFootprint += dpns.size();
} else {
updateGroup = true;
}
expectedElanFootprint += devices.size();
if (update.getBuckets() != null && update.getBuckets().getBucket() != null) {
if (update.getBuckets().getBucket().size() != expectedElanFootprint) {
updateGroup = true;
} else {
LOG.trace("no of buckets matched perfectly {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
if (updateGroup) {
List<Bucket> bucketList = elanL2GatewayMulticastUtils.getRemoteBCGroupBuckets(elanInstance, null, dpnId, 0, elanInstance.getElanTag());
// remove local bcgroup bucket
expectedElanFootprint--;
if (bucketList.size() != expectedElanFootprint) {
// no point in retrying if not able to meet expected foot print
return;
}
LOG.trace("no of buckets mismatched {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
elanClusterUtils.runOnlyInOwnerNode(elanInstance.getElanInstanceName(), "updating broadcast group", () -> {
elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInstance, dpnId);
return null;
});
} else {
LOG.trace("no buckets in the update {} {}", elanInstance.getElanInstanceName(), update.getKey().getGroupId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group in project netvirt by opendaylight.
the class ElanInterfaceManager method setBCGrouponOtherDpns.
@SuppressWarnings("checkstyle:IllegalCatch")
private void setBCGrouponOtherDpns(ElanInstance elanInfo, BigInteger dpId, int elanTag, long groupId) {
int bucketId = 0;
ElanDpnInterfacesList elanDpns = elanUtils.getElanDpnInterfacesList(elanInfo.getElanInstanceName());
if (elanDpns != null) {
List<DpnInterfaces> dpnInterfaces = elanDpns.getDpnInterfaces();
for (DpnInterfaces dpnInterface : dpnInterfaces) {
List<Bucket> remoteListBucketInfo = new ArrayList<>();
if (elanUtils.isDpnPresent(dpnInterface.getDpId()) && !Objects.equals(dpnInterface.getDpId(), dpId) && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
List<Action> listAction = new ArrayList<>();
int actionKey = 0;
listAction.add(new ActionGroup(ElanUtils.getElanLocalBCGId(elanTag)).buildAction(++actionKey));
remoteListBucketInfo.add(MDSALUtil.buildBucket(listAction, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
bucketId++;
for (DpnInterfaces otherFes : dpnInterfaces) {
if (elanUtils.isDpnPresent(otherFes.getDpId()) && !Objects.equals(otherFes.getDpId(), dpnInterface.getDpId()) && otherFes.getInterfaces() != null && !otherFes.getInterfaces().isEmpty()) {
try {
List<Action> remoteListActionInfo = elanItmUtils.getInternalTunnelItmEgressAction(dpnInterface.getDpId(), otherFes.getDpId(), elanUtils.isOpenstackVniSemanticsEnforced() ? elanUtils.getVxlanSegmentationId(elanInfo) : elanTag);
if (!remoteListActionInfo.isEmpty()) {
remoteListBucketInfo.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
bucketId++;
}
} catch (Exception ex) {
LOG.error("setElanBCGrouponOtherDpns failed due to Exception caught; " + "Logical Group Interface not found between source Dpn - {}, " + "destination Dpn - {} ", dpnInterface.getDpId(), otherFes.getDpId(), ex);
return;
}
}
}
List<Bucket> elanL2GwDevicesBuckets = elanL2GatewayMulticastUtils.getRemoteBCGroupBucketsOfElanL2GwDevices(elanInfo, dpnInterface.getDpId(), bucketId);
remoteListBucketInfo.addAll(elanL2GwDevicesBuckets);
if (remoteListBucketInfo.isEmpty()) {
LOG.debug("No ITM is present on Dpn - {} ", dpnInterface.getDpId());
continue;
}
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(remoteListBucketInfo));
LOG.trace("Installing remote bc group {} on dpnId {}", group, dpnInterface.getDpId());
mdsalManager.syncInstallGroup(dpnInterface.getDpId(), group);
}
}
try {
Thread.sleep(WAIT_TIME_FOR_SYNC_INSTALL);
} catch (InterruptedException e1) {
LOG.warn("Error while waiting for remote BC group on other DPNs for ELAN {} to install", elanInfo);
}
}
}
Aggregations