Search in sources :

Example 16 with AdjacencyBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder in project netvirt by opendaylight.

the class NeutronvpnManager method getAdjacencyforExtraRoute.

@NonNull
protected List<Adjacency> getAdjacencyforExtraRoute(List<Routes> routeList, String fixedIp) {
    List<Adjacency> adjList = new ArrayList<>();
    Map<String, List<String>> adjMap = new HashMap<>();
    for (Routes route : routeList) {
        if (route == null || route.getNexthop() == null || route.getDestination() == null) {
            LOG.error("Incorrect input received for extra route. {}", route);
        } else {
            String nextHop = route.getNexthop().stringValue();
            String destination = route.getDestination().stringValue();
            if (!nextHop.equals(fixedIp)) {
                LOG.trace("FixedIP {} is not extra route nexthop for destination {}", fixedIp, destination);
                continue;
            }
            LOG.trace("Adding extra route for destination {} with nexthop {} ", destination, nextHop);
            List<String> hops = adjMap.computeIfAbsent(destination, k -> new ArrayList<>());
            if (!hops.contains(nextHop)) {
                hops.add(nextHop);
            }
        }
    }
    for (Entry<String, List<String>> entry : adjMap.entrySet()) {
        final String destination = entry.getKey();
        final List<String> ipList = entry.getValue();
        Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setAdjacencyType(AdjacencyType.ExtraRoute).setNextHopIpList(ipList).withKey(new AdjacencyKey(destination)).build();
        adjList.add(erAdj);
    }
    return adjList;
}
Also used : AdjacencyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) AdjacencyKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey) ArrayList(java.util.ArrayList) Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes) Adjacency(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

ArrayList (java.util.ArrayList)11 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.Adjacency)10 AdjacencyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyBuilder)10 ExecutionException (java.util.concurrent.ExecutionException)8 VrfEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry)7 AdjacenciesOp (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.AdjacenciesOp)7 VpnInterfaceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntry)7 VpnInstanceOpDataEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry)7 AdjacencyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.l3vpn.rev200204.adjacency.list.AdjacencyKey)7 Adjacency (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.Adjacency)6 AdjacencyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder)6 Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes)5 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)4 VpnInterfaceOpDataEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryBuilder)4 VpnInterfaceOpDataEntryKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn._interface.op.data.VpnInterfaceOpDataEntryKey)4 BigInteger (java.math.BigInteger)3 TransactionCommitFailedException (org.opendaylight.mdsal.common.api.TransactionCommitFailedException)3 RouteOrigin (org.opendaylight.netvirt.fibmanager.api.RouteOrigin)3 AdjacencyKey (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey)3