use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.
the class VrfEntryListener method deleteFibEntries.
private void deleteFibEntries(final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry) {
final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
final String rd = vrfTableKey.getRouteDistinguisher();
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
if (vpnInstance == null) {
LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
return;
}
final Map<VpnToDpnListKey, VpnToDpnList> keyVpnToDpnListMap;
if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
// This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
keyVpnToDpnListMap = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
LOG.info("deleteFibEntries: Processing deletion of PNF FIB entry with rd {} prefix {}", vrfEntry.getParentVpnRd(), vrfEntry.getDestPrefix());
} else {
keyVpnToDpnListMap = vpnInstance.getVpnToDpnList();
}
SubnetRoute subnetRoute = vrfEntry.augmentation(SubnetRoute.class);
final java.util.Optional<Uint32> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
if (subnetRoute != null) {
long elanTag = subnetRoute.getElantag().toJava();
LOG.trace("SUBNETROUTE: deleteFibEntries: SubnetRoute augmented vrfentry found for rd {} prefix {}" + " with elantag {}", rd, vrfEntry.getDestPrefix(), elanTag);
if (keyVpnToDpnListMap != null) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
for (final VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
baseVrfEntryHandler.makeConnectedRoute(curDpn.getDpnId(), vpnInstance.getVpnId(), vrfEntry, vrfTableKey.getRouteDistinguisher(), null, NwConstants.DEL_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
optionalLabel.ifPresent(label -> makeLFibTableEntry(curDpn.getDpnId(), label, null, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.DEL_FLOW, tx));
}
installSubnetBroadcastAddrDropRule(curDpn.getDpnId(), rd, vpnInstance.getVpnId(), vrfEntry, NwConstants.DEL_FLOW, tx);
}
})));
}
return;
}
final List<Uint64> localDpnIdList = deleteLocalFibEntry(vpnInstance.getVpnId(), vrfTableKey.getRouteDistinguisher(), vrfEntry);
if (keyVpnToDpnListMap != null) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
String jobKey;
Optional<Routes> extraRouteOptional;
// Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
if (usedRds != null && !usedRds.isEmpty()) {
if (usedRds.size() > 1) {
LOG.error("The extra route prefix is still present in some DPNs");
return;
} else {
// The first rd is retrieved from usedrds as Only 1 rd would be present as extra route prefix
// is not present in any other DPN
extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRds.get(0), vrfEntry.getDestPrefix());
}
} else {
extraRouteOptional = Optional.empty();
}
jobCoordinator.enqueueJob(FibUtil.getJobKeyForRdPrefix(rd, vrfEntry.getDestPrefix()), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
if (localDpnIdList.size() <= 0) {
for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
baseVrfEntryHandler.deleteRemoteRoute(Uint64.ZERO, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
} else {
for (Uint64 localDpnId : localDpnIdList) {
for (VpnToDpnList curDpn : keyVpnToDpnListMap.values()) {
if (!Objects.equals(curDpn.getDpnId(), localDpnId)) {
baseVrfEntryHandler.deleteRemoteRoute(localDpnId, curDpn.getDpnId(), vpnInstance.getVpnId(), vrfTableKey, vrfEntry, extraRouteOptional, TransactionAdapter.toWriteTransaction(tx));
}
}
}
}
if (extraRouteOptional.isPresent()) {
// Remove select groups only for extra-routes
nextHopManager.removeNextHopPointer(nextHopManager.getRemoteSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
nextHopManager.removeNextHopPointer(nextHopManager.getLocalSelectGroupKey(vpnInstance.getVpnId(), vrfEntry.getDestPrefix()));
}
})), MAX_RETRIES);
}
// The flow/group entry has been deleted from config DS; need to clean up associated operational
// DS entries in VPN Op DS, VpnInstanceOpData and PrefixToInterface to complete deletion
cleanUpOpDataForFib(vpnInstance.getVpnId(), vrfTableKey.getRouteDistinguisher(), vrfEntry);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.
the class VpnUtil method getVpnsImportingMyRoute.
@SuppressWarnings("checkstyle:IllegalCatch")
public List<VpnInstanceOpDataEntry> getVpnsImportingMyRoute(final String vpnName) {
List<VpnInstanceOpDataEntry> vpnsToImportRoute = new ArrayList<>();
final VpnInstanceOpDataEntry vpnInstanceOpDataEntry;
final String vpnRd = getVpnRd(vpnName);
if (vpnRd == null) {
LOG.error("getVpnsImportingMyRoute: vpn {} not present in config DS.", vpnName);
return vpnsToImportRoute;
}
if (vpnRd.equals(vpnName)) {
LOG.error("getVpnsImportingMyRoute: Internal vpn {} do not export/import routes", vpnName);
return vpnsToImportRoute;
}
try {
final VpnInstanceOpDataEntry opDataEntry = getVpnInstanceOpData(vpnRd);
if (opDataEntry == null) {
LOG.error("getVpnsImportingMyRoute: Could not retrieve vpn instance op data for vpn {} rd {}" + " to check for vpns importing the routes", vpnName, vpnRd);
return vpnsToImportRoute;
}
vpnInstanceOpDataEntry = opDataEntry;
} catch (Exception e) {
LOG.error("getVpnsImportingMyRoute: DSException when retrieving vpn instance op data for vpn {} rd {}" + " to check for vpns importing the routes", vpnName, vpnRd);
return vpnsToImportRoute;
}
Predicate<VpnInstanceOpDataEntry> excludeVpn = input -> {
if (input.getVpnInstanceName() == null) {
LOG.error("getVpnsImportingMyRoute.excludeVpn: Received vpn instance with rd {} without a name.", input.getVrfId());
return false;
}
return !input.getVpnInstanceName().equals(vpnName);
};
Predicate<VpnInstanceOpDataEntry> matchRTs = input -> {
Iterable<String> commonRTs = intersection(getRts(vpnInstanceOpDataEntry, VpnTarget.VrfRTType.ExportExtcommunity), getRts(input, VpnTarget.VrfRTType.ImportExtcommunity));
return Iterators.size(commonRTs.iterator()) > 0;
};
vpnsToImportRoute = getAllVpnInstanceOpData().stream().filter(excludeVpn).filter(matchRTs).collect(Collectors.toList());
return vpnsToImportRoute;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.
the class ShowVpn method doExecute.
@Override
@Nullable
protected Object doExecute() {
Map<String, Integer> vpnNameToConfigInterfaceMap = new HashMap<>();
Map<String, Integer> vpnNameToOperInterfaceMap = new HashMap<>();
if (detail == null) {
showVpn();
Set<String> vpnInstances = new HashSet<>();
for (VpnInterface vpnInterface : vpnInterfaceConfigList) {
if (vpnInterface.getVpnInstanceNames() != null) {
for (VpnInstanceNames vpnInterfaceVpnInstance : vpnInterface.getVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
if (vpnName != null) {
vpnInstances.add(vpnName);
}
}
}
}
for (String routerId : vpnInstances) {
ifPresent = vpnNameToConfigInterfaceMap.get(routerId);
if (ifPresent == null) {
vpnNameToConfigInterfaceMap.put(routerId, 1);
} else {
vpnNameToConfigInterfaceMap.put(routerId, vpnNameToConfigInterfaceMap.get(routerId) + 1);
}
}
for (VpnInterfaceOpDataEntry vpnInterfaceOp : vpnInterfaceOpList) {
ifPresent = vpnNameToOperInterfaceMap.get(vpnInterfaceOp.getVpnInstanceName());
if (ifPresent == null) {
vpnNameToOperInterfaceMap.put(vpnInterfaceOp.getVpnInstanceName(), 1);
} else {
vpnNameToOperInterfaceMap.put(vpnInterfaceOp.getVpnInstanceName(), vpnNameToOperInterfaceMap.get(vpnInterfaceOp.getVpnInstanceName()) + 1);
}
}
session.getConsole().println("-----------------------------------------------------------------------");
session.getConsole().println(String.format(" %s %14s %5s %5s", "VpnInstanceName", "RD", "Config Count", "Oper Count"));
session.getConsole().println("\n-----------------------------------------------------------------------");
for (VpnInstance vpnInstance : vpnInstanceList) {
configCount = 0;
operCount = 0;
Integer count = vpnNameToConfigInterfaceMap.get(vpnInstance.getVpnInstanceName());
if (count != null) {
configCount = vpnNameToConfigInterfaceMap.get(vpnInstance.getVpnInstanceName());
totalConfigCount = totalConfigCount + configCount;
}
count = vpnNameToOperInterfaceMap.get(vpnInstance.getVpnInstanceName());
if (count != null) {
operCount = vpnNameToOperInterfaceMap.get(vpnInstance.getVpnInstanceName());
totalOperCount = totalOperCount + operCount;
}
session.getConsole().println(String.format("%-32s %-10s %-10s %-10s", vpnInstance.getVpnInstanceName(), vpnInstance.getRouteDistinguisher(), configCount, operCount));
}
session.getConsole().println("-----------------------------------------------------------------------");
session.getConsole().println(String.format("Total Count: %19s %8s", totalConfigCount, totalOperCount));
session.getConsole().println(getshowVpnCLIHelp());
} else {
showVpn();
session.getConsole().println("Present Config VpnInterfaces are:");
for (VpnInterface vpnInterface : vpnInterfaceConfigList) {
if (vpnInterface.getVpnInstanceNames() != null && VpnHelper.doesVpnInterfaceBelongToVpnInstance(detail, new ArrayList<VpnInstanceNames>(vpnInterface.getVpnInstanceNames().values()))) {
session.getConsole().println(vpnInterface.getName());
}
}
session.getConsole().println("Present Oper VpnInterfaces are:");
for (VpnInterfaceOpDataEntry vpnInterfaceOp : vpnInterfaceOpList) {
if (Objects.equals(vpnInterfaceOp.getVpnInstanceName(), detail)) {
session.getConsole().println(vpnInterfaceOp.getName());
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.
the class HwvtepTerminationPointListener method handlePortAdded.
private List<ListenableFuture<?>> handlePortAdded(TerminationPoint portAdded, NodeId psNodeId) {
Node psNode = null;
try {
psNode = HwvtepUtils.getHwVtepNode(broker, LogicalDatastoreType.OPERATIONAL, psNodeId);
} catch (ExecutionException | InterruptedException e) {
LOG.error("Exception while retriving HwVtepNode {}", psNodeId.getValue(), e);
}
if (psNode != null) {
String psName = psNode.augmentation(PhysicalSwitchAugmentation.class).getHwvtepNodeName().getValue();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(psName);
if (l2GwDevice != null) {
if (isL2GatewayConfigured(l2GwDevice)) {
List<L2gatewayConnection> l2GwConns = L2GatewayConnectionUtils.getAssociatedL2GwConnections(broker, l2GwDevice.getL2GatewayIds());
String newPortId = portAdded.getTpId().getValue();
NodeId hwvtepNodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
List<VlanBindings> vlanBindings = getVlanBindings(l2GwConns, hwvtepNodeId, psName, newPortId);
return Collections.singletonList(elanL2GatewayUtils.updateVlanBindingsInL2GatewayDevice(hwvtepNodeId, psName, newPortId, vlanBindings));
}
} else {
LOG.error("{} details are not present in L2Gateway Cache", psName);
}
} else {
LOG.error("{} entry not in config datastore", psNodeId);
}
return emptyList();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.Config in project netvirt by opendaylight.
the class LocalUcastMacListener method deleteElanMacEntry.
private void deleteElanMacEntry(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs macRemoved) {
String hwvtepNodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue();
String macAddress = macRemoved.getMacEntryKey().getValue().toLowerCase(Locale.getDefault());
String elanName = getElanName(macRemoved);
PhysAddress phyAddress = new PhysAddress(macRemoved.getMacEntryKey().getValue());
InstanceIdentifier<MacEntry> elanMacEntryIid = ElanUtils.getMacEntryOperationalDataPath(elanName, phyAddress);
localMacEntryCache.remove(elanMacEntryIid);
elanClusterUtils.runOnlyInOwnerNode(hwvtepNodeId + ":" + macAddress + HwvtepHAUtil.L2GW_JOB_KEY, "remove elan mac entry from config", () -> {
return Lists.newArrayList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(elanMacEntryIid)));
});
}
Aggregations