Search in sources :

Example 1 with RoutesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.RoutesKey in project netvirt by opendaylight.

the class IVpnLinkServiceImpl method handleStaticRoutes.

@Override
public void handleStaticRoutes(InterVpnLinkDataComposite ivpnLink) {
    /*
         * Checks if there are any static routes pointing to any of both
         * InterVpnLink's endpoints. Goes through all routers checking if they have
         * a route whose nexthop is an InterVpnLink endpoint
         */
    // Map that corresponds a routerId with the L3VPN that it's been assigned to.
    Map<String, String> routerXL3VpnMap = buildRouterXL3VPNMap();
    // Retrieving all Routers
    InstanceIdentifier<Routers> routersIid = InstanceIdentifier.builder(Neutron.class).child(Routers.class).build();
    Optional<Routers> routerOpData = Optional.empty();
    try {
        routerOpData = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIid);
    } catch (ExecutionException | InterruptedException e) {
        LOG.error("handleStaticRoutes: Exception while reading routers DS", e);
    }
    if (!routerOpData.isPresent()) {
        return;
    }
    Map<RouterKey, Router> keyRouterMap = routerOpData.get().nonnullRouter();
    for (Router router : keyRouterMap.values()) {
        String vpnId = routerXL3VpnMap.get(router.getUuid().getValue());
        if (vpnId == null) {
            LOG.warn("Could not find suitable VPN for router {}", router.getUuid());
            // with next router
            continue;
        }
        Map<RoutesKey, Routes> routesKeyRoutesMap = router.nonnullRoutes();
        if (routesKeyRoutesMap != null) {
            for (Routes route : routesKeyRoutesMap.values()) {
                handleStaticRoute(vpnId, route, ivpnLink);
            }
        }
    }
}
Also used : Routers(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers) RoutesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.RoutesKey) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) RouterKey(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterKey) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)1 RoutesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.RoutesKey)1 Routers (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers)1 Router (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router)1 RouterKey (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterKey)1