Search in sources :

Example 56 with Routes

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());
        }
    }
}
Also used : Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInstance(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.vpn.instances.VpnInstance) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)

Example 57 with Routes

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;
        }
    }
}
Also used : InterVpnLink(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.inter.vpn.link.rev160311.inter.vpn.links.InterVpnLink) RemoveStaticRouteInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.RemoveStaticRouteInputBuilder) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) RemoveStaticRouteInput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.vpn.rpc.rev160201.RemoveStaticRouteInput)

Example 58 with Routes

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);
}
Also used : LabeledUnicastRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.routes.LabeledUnicastRoutesBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Routes) LabeledUnicastRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.routes.LabeledUnicastRoutes) LabeledUnicastRoutesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastRoutesCaseBuilder) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Example 59 with Routes

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);
}
Also used : LabeledUnicastIpv6RoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.ipv6.routes.LabeledUnicastIpv6RoutesBuilder) LabeledUnicastIpv6RoutesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.bgp.rib.rib.loc.rib.tables.routes.LabeledUnicastIpv6RoutesCaseBuilder) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Routes) LabeledUnicastIpv6Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.ipv6.routes.LabeledUnicastIpv6Routes) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Example 60 with Routes

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));
}
Also used : Attributes2(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)86 ArrayList (java.util.ArrayList)69 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)61 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)45 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)43 ExecutionException (java.util.concurrent.ExecutionException)41 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)40 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.to.extraroutes.vpn.extra.routes.Routes)33 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)31 List (java.util.List)30 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)30 BigInteger (java.math.BigInteger)29 InstructionGotoTable (org.opendaylight.genius.mdsalutil.instructions.InstructionGotoTable)27 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)27 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)27 Logger (org.slf4j.Logger)27 LoggerFactory (org.slf4j.LoggerFactory)27 Collections (java.util.Collections)26 Prefixes (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes)26 AttributesReach (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.AttributesReach)26