use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method checkAlarmExtraRoutes.
/**
* This method setup or down an alarm about extra route fault.
* When extra routes are configured, through a router, if the number of nexthops is greater than the number of
* available RDs, then an alarm and an error is generated.<br>
* <b>Be careful</b> the routeList could be changed.
*
* @param vpnId the vpnId of vpn to control.
* @param routeList the list of router to check, it could be modified.
*/
private void checkAlarmExtraRoutes(Uuid vpnId, List<Routes> routeList) {
if (!neutronvpnAlarm.isAlarmEnabled()) {
LOG.debug("checkAlarmExtraRoutes is not enable for vpnId {} routeList {}", vpnId, routeList);
return;
}
VpnInstance vpnInstance = neutronvpnUtils.getVpnInstance(vpnId);
if (vpnInstance == null || routeList == null || routeList.isEmpty() || !neutronvpnAlarm.isAlarmEnabled()) {
LOG.debug("checkAlarmExtraRoutes have args null as following : vpnId {} routeList {}", vpnId, routeList);
return;
}
String primaryRd = neutronvpnUtils.getVpnRd(vpnId.getValue());
if (primaryRd == null || primaryRd.equals(vpnId.getValue())) {
LOG.debug("checkAlarmExtraRoutes. vpn {} is not a BGPVPN. cancel checkExtraRoute", vpnId);
return;
}
for (Routes route : routeList) {
// count the number of nexthops for each same route.getDestingation().getValue()
String destination = route.getDestination().stringValue();
String nextHop = route.getNexthop().stringValue();
List<String> nextHopList = new ArrayList<>();
nextHopList.add(nextHop);
int nbNextHops = 1;
for (Routes routeTmp : routeList) {
String routeDest = routeTmp.getDestination().stringValue();
if (!destination.equals(routeDest)) {
continue;
}
String routeNextH = routeTmp.getNexthop().stringValue();
if (nextHop.equals(routeNextH)) {
continue;
}
nbNextHops++;
nextHopList.add(routeTmp.getNexthop().stringValue());
}
final List<String> rdList = new ArrayList<>();
if (vpnInstance != null && vpnInstance.getRouteDistinguisher() != null) {
vpnInstance.getRouteDistinguisher().forEach(rd -> {
if (rd != null) {
rdList.add(rd);
}
});
}
// 1. VPN Instance Name
String typeAlarm = "for vpnId: " + vpnId + " have exceeded next hops for prefixe";
// 2. Router ID
List<Uuid> routerUuidList = neutronvpnUtils.getRouterIdListforVpn(vpnId);
Uuid routerUuid = routerUuidList.get(0);
StringBuilder detailsAlarm = new StringBuilder("routerUuid: ");
detailsAlarm.append(routerUuid == null ? vpnId.toString() : routerUuid.getValue());
// 3. List of RDs associated with the VPN
detailsAlarm.append(" List of RDs associated with the VPN: ");
for (String s : rdList) {
detailsAlarm.append(s);
detailsAlarm.append(", ");
}
// 4. Prefix in question
detailsAlarm.append(" for prefix: ");
detailsAlarm.append(route.getDestination().stringValue());
// 5. List of NHs for the prefix
detailsAlarm.append(" for nextHops: ");
for (String s : nextHopList) {
detailsAlarm.append(s);
detailsAlarm.append(", ");
}
if (rdList.size() < nbNextHops) {
neutronvpnAlarm.raiseNeutronvpnAlarm(typeAlarm, detailsAlarm.toString());
} else {
neutronvpnAlarm.clearNeutronvpnAlarm(typeAlarm, detailsAlarm.toString());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project netvirt by opendaylight.
the class NeutronvpnManager method removeInterVpnRoutes.
/**
* Removes the corresponding static routes from the specified VPN. These static routes point to an
* InterVpnLink endpoint and the specified VPN must be the other end of the InterVpnLink.
*
* @param vpnName the VPN identifier
* @param interVpnLinkRoutes The list of static routes
* @param nexthopsXinterVpnLinks A Map with the correspondence nextHop-InterVpnLink
*/
public void removeInterVpnRoutes(Uuid vpnName, List<Routes> interVpnLinkRoutes, HashMap<String, InterVpnLink> nexthopsXinterVpnLinks) {
for (Routes route : interVpnLinkRoutes) {
String nexthop = route.getNexthop().stringValue();
String destination = route.getDestination().stringValue();
InterVpnLink interVpnLink = nexthopsXinterVpnLinks.get(nexthop);
if (isNexthopTheOtherVpnLinkEndpoint(nexthop, vpnName.getValue(), interVpnLink)) {
RemoveStaticRouteInput rpcInput = new RemoveStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop).setVpnInstanceName(vpnName.getValue()).build();
LoggingFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(vpnRpcService.removeStaticRoute(rpcInput)), LOG, "Remove VPN routes");
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink", route.getDestination().stringValue(), nexthop);
continue;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class LabeledUnicastIpv4RIBSupportTest method testEmptyRoute.
@Test
public void testEmptyRoute() throws Exception {
final Routes empty = new LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(new LabeledUnicastRoutesBuilder().setLabeledUnicastRoute(Collections.emptyList()).build()).build();
final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class LabeledUnicastIpv6RIBSupportTest method testEmptyRoute.
@Test
public void testEmptyRoute() {
final Routes empty = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(new LabeledUnicastIpv6RoutesBuilder().setLabeledUnicastRoute(Collections.emptyList()).build()).build();
final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes in project bgpcep by opendaylight.
the class VpnIpv6RIBSupportTest method testBuildMpReachNlriUpdate.
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
Aggregations