use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class ShowFibCommand method printVrfTable.
private void printVrfTable(VrfTables vrfTable, PrintStream console, boolean isIpv4, boolean isIpv6, boolean isL2vpn, String inputPrefixOrSubnet) {
List<VrfEntry> vrfEntries = vrfTable.getVrfEntry();
if (vrfEntries == null) {
LOG.warn("Null vrfEntries found for VPN with rd={}", vrfTable.getRouteDistinguisher());
return;
}
for (VrfEntry vrfEntry : vrfEntries) {
boolean showIt = false;
if (isIpv4 && isIpv6 && isL2vpn) {
showIt = true;
}
if (!showIt && isIpv4) {
LOG.debug("is ipv4 address family=> vrfEntry.getDestPrefix() = {}", vrfEntry.getDestPrefix());
showIt = FibHelper.isIpv4Prefix(vrfEntry.getDestPrefix());
}
if (!showIt && isIpv6) {
LOG.debug("is ipv6 address family=> vrfEntry.getDestPrefix() = {}", vrfEntry.getDestPrefix());
showIt = FibHelper.isIpv6Prefix(vrfEntry.getDestPrefix());
}
if (!showIt && isL2vpn) {
if (vrfEntry.getEncapType() != null && !EncapType.Mplsgre.equals(vrfEntry.getEncapType())) {
LOG.debug("is l2vpn address family=> vrfEntry.getEncapType() = {}", vrfEntry.getEncapType());
showIt = true;
}
}
if (!showIt && inputPrefixOrSubnet != null) {
showIt = FibHelper.isBelongingPrefix(vrfEntry.getDestPrefix(), inputPrefixOrSubnet);
}
if (!showIt) {
continue;
}
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
if (routePaths == null || routePaths.isEmpty()) {
console.println(String.format(TABULAR_FORMAT, vrfTable.getRouteDistinguisher(), vrfEntry.getDestPrefix(), "local", routePaths == null ? "<not set>" : "<empty>", vrfEntry.getOrigin()));
continue;
}
for (RoutePaths routePath : routePaths) {
console.println(String.format(TABULAR_FORMAT, vrfTable.getRouteDistinguisher(), vrfEntry.getDestPrefix(), routePath.getNexthopAddress(), routePath.getLabel(), vrfEntry.getOrigin()));
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentrybase.RoutePaths in project netvirt by opendaylight.
the class BaseVrfEntryHandler method resolveAdjacency.
@Nonnull
protected List<AdjacencyResult> resolveAdjacency(final BigInteger remoteDpnId, final long vpnId, final VrfEntry vrfEntry, String rd) {
List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
FibHelper.sortIpAddress(routePaths);
List<AdjacencyResult> adjacencyList = new ArrayList<>();
List<String> prefixIpList;
LOG.trace("resolveAdjacency called with remotedDpnId {}, vpnId{}, VrfEntry {}", remoteDpnId, vpnId, vrfEntry);
try {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker, fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
if (vpnExtraRoutes.isEmpty()) {
Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
// We don't want to provide an adjacencyList for an extra-route-prefix.
if (prefixInfo == null) {
LOG.debug("The extra route {} in rd {} for vpn {} has been removed from all the next hops", vrfEntry.getDestPrefix(), rd, vpnId);
return adjacencyList;
}
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
} else {
List<String> prefixIpListLocal = new ArrayList<>();
vpnExtraRoutes.stream().forEach(route -> {
route.getNexthopIpList().stream().forEach(extraRouteIp -> {
String ipPrefix;
if (isIpv4Address(extraRouteIp)) {
ipPrefix = extraRouteIp + NwConstants.IPV4PREFIX;
} else {
ipPrefix = extraRouteIp + NwConstants.IPV6PREFIX;
}
prefixIpListLocal.add(ipPrefix);
});
});
prefixIpList = prefixIpListLocal;
}
} else {
prefixIpList = Collections.singletonList(vrfEntry.getDestPrefix());
}
for (String prefixIp : prefixIpList) {
if (routePaths == null || routePaths.isEmpty()) {
LOG.trace("Processing Destination IP {} without NextHop IP", prefixIp);
AdjacencyResult adjacencyResult = nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, null);
addAdjacencyResultToList(adjacencyList, adjacencyResult);
continue;
}
adjacencyList.addAll(routePaths.stream().map(routePath -> {
LOG.debug("NextHop IP for destination {} is {}", prefixIp, routePath.getNexthopAddress());
return nextHopManager.getRemoteNextHopPointer(remoteDpnId, vpnId, prefixIp, routePath.getNexthopAddress());
}).filter(adjacencyResult -> adjacencyResult != null && !adjacencyList.contains(adjacencyResult)).distinct().collect(toList()));
}
} catch (NullPointerException e) {
LOG.trace("", e);
}
return adjacencyList;
}
Aggregations