use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route 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.Route 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.Route in project bgpcep by opendaylight.
the class VpnIpv6RIBSupportTest method testPutRoutes.
@Test
public void testPutRoutes() {
RIB_SUPPORT.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
final VpnRoute route = (VpnRoute) this.insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method extractCLabeledUnicastDestination.
/**
* Conversion from DataContainer to LabeledUnicastDestination Object
*
* @param route DataContainer
* @return LabeledUnicastDestination Object
*/
private CLabeledUnicastDestination extractCLabeledUnicastDestination(final DataContainerNode<? extends PathArgument> route) {
final CLabeledUnicastDestinationBuilder builder = new CLabeledUnicastDestinationBuilder();
builder.setPrefix(extractPrefix(route, PREFIX_TYPE_NID));
builder.setLabelStack(extractLabel(route, LABEL_STACK_NID, LV_NID));
builder.setPathId(PathIdUtil.buildPathId(route, routePathIdNid()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method extractLabel.
public static List<LabelStack> extractLabel(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
final List<LabelStack> labels = new ArrayList<>();
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStacks = route.getChild(labelStackNid);
if (labelStacks.isPresent()) {
for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks.get()).getValue()) {
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStack = label.getChild(labelValueNid);
if (labelStack.isPresent()) {
final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
labels.add(labelStackbuilder.build());
}
}
}
return labels;
}
Aggregations