provide way to extract routes from routesContainer 87/78487/11
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 23:29:44 +0000 (00:29 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Mon, 10 Dec 2018 11:28:43 +0000 (11:28 +0000)
EffectiveRibInWriter operates with binding databroker and while
we have tools to construct InstanceIdentifier for routesContainer
we are missing tool to extract routes from it. This patch should
provide just that.

JIRA:BGPCEP-495
Change-Id: I1aea06ec4f082d11643566aed761fcc4092b6fcc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Matej Perina <matej.perina@pantheon.tech>
17 files changed:
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/EvpnRibSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv4RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FlowspecIpv6RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv4/FlowspecL3vpnIpv4RIBSupport.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/l3vpn/ipv6/FlowspecL3vpnIpv6RIBSupport.java
bgp/extensions/inet/src/main/java/org/opendaylight/protocol/bgp/inet/IPv4RIBSupport.java
bgp/extensions/inet/src/main/java/org/opendaylight/protocol/bgp/inet/IPv6RIBSupport.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/mcast/AbstractL3vpnMcastIpRIBSupport.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/AbstractVpnRIBSupport.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv4/VpnIpv4RIBSupport.java
bgp/extensions/l3vpn/src/main/java/org/opendaylight/protocol/bgp/l3vpn/unicast/ipv6/VpnIpv6RIBSupport.java
bgp/extensions/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/AbstractLabeledUnicastRIBSupport.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/LinkstateRIBSupport.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/AbstractMvpnRIBSupport.java
bgp/extensions/route-target/src/main/java/org/opendaylight/protocol/bgp/route/targetcontrain/impl/RouteTargetConstrainRIBSupport.java
bgp/rib-spi/src/main/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupport.java
bgp/rib-spi/src/test/java/org/opendaylight/protocol/bgp/rib/spi/RIBSupportTestImp.java

index be3c3a7c5ccc0b55a5221a3905d3f7c823950086..eb6ce80b77ab6f6e2d4be157f80527608111490b 100644 (file)
@@ -160,4 +160,9 @@ final class EvpnRibSupport extends AbstractRIBSupport<EvpnRoutesCase, EvpnRoutes
     public EvpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new EvpnRouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<EvpnRoute> routesFromContainer(final EvpnRoutes container) {
+        return container.getEvpnRoute();
+    }
 }
index 0a077ad9a3643d4864feb494672886b3dafabace..d5a8014cbdab31fa4f0d990a87643d7378367db5 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.flowspec;
 
 import java.util.Collections;
+import java.util.List;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecRoutesCase;
@@ -85,4 +86,9 @@ public final class FlowspecIpv4RIBSupport
     public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new FlowspecRouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<FlowspecRoute> routesFromContainer(final FlowspecRoutes container) {
+        return container.getFlowspecRoute();
+    }
 }
index 7729d8942ee6fbd9d69ae9578705c5d755d8a70d..9fd1c5011391c00200c643282131aa892d855f1c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.flowspec;
 
 import java.util.Collections;
+import java.util.List;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.FlowspecSubsequentAddressFamily;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecIpv6RoutesCase;
@@ -85,4 +86,9 @@ public final class FlowspecIpv6RIBSupport
     public FlowspecRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new FlowspecRouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<FlowspecRoute> routesFromContainer(final FlowspecIpv6Routes container) {
+        return container.getFlowspecRoute();
+    }
 }
index 3e5b762b0ca74e9c3495f5748ec8ed35b59b4471..561a050cd09c6c9d884e71f8131bc13e93a55e3a 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4;
 
 import java.util.Collections;
+import java.util.List;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
@@ -61,7 +62,7 @@ public final class FlowspecL3vpnIpv4RIBSupport
     }
 
     @Override
-    public final FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
+    public FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
     }
 
@@ -87,4 +88,9 @@ public final class FlowspecL3vpnIpv4RIBSupport
     public FlowspecL3vpnIpv4Routes emptyRoutesContainer() {
         return EMPTY_CONTAINER;
     }
+
+    @Override
+    public List<FlowspecL3vpnRoute> routesFromContainer(final FlowspecL3vpnIpv4Routes container) {
+        return container.getFlowspecL3vpnRoute();
+    }
 }
index 8232685f08855c367714ba1573d60ad00e2a73d5..1114a7cd5ad563f3a86a38c9c35ed822b570f47b 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6;
 
 import java.util.Collections;
+import java.util.List;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
@@ -61,7 +62,7 @@ public final class FlowspecL3vpnIpv6RIBSupport
     }
 
     @Override
-    public final FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
+    public FlowspecL3vpnRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new FlowspecL3vpnRouteKey(new PathId(pathId), routeKey);
     }
 
@@ -87,4 +88,9 @@ public final class FlowspecL3vpnIpv6RIBSupport
     public FlowspecL3vpnIpv6Routes emptyRoutesContainer() {
         return EMPTY_CONTAINER;
     }
+
+    @Override
+    public List<FlowspecL3vpnRoute> routesFromContainer(final FlowspecL3vpnIpv6Routes container) {
+        return container.getFlowspecL3vpnRoute();
+    }
 }
index 7db4eec453acda8c03145abdd782aa1364d4983d..00426892fb8bd0872c65e996803bfeee314a585a 100644 (file)
@@ -115,4 +115,9 @@ final class IPv4RIBSupport extends AbstractIPRibSupport<Ipv4RoutesCase, Ipv4Rout
     public Ipv4RouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new Ipv4RouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<Ipv4Route> routesFromContainer(final Ipv4Routes container) {
+        return container.getIpv4Route();
+    }
 }
index 94a45427c885eb4288f036515b0b11776dcf0361..acc8d56a9a4c7faf9df178a2a790a985ae424d69 100644 (file)
@@ -111,4 +111,9 @@ final class IPv6RIBSupport extends AbstractIPRibSupport<Ipv6RoutesCase, Ipv6Rout
     public Ipv6RouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new Ipv6RouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<Ipv6Route> routesFromContainer(final Ipv6Routes container) {
+        return container.getIpv6Route();
+    }
 }
index 8c5badf5fa6dffd5a22e6b3f0b5d37db8613e6da..50587d24d912b06d3050683ebd7157b86200835a 100644 (file)
@@ -162,5 +162,11 @@ abstract class AbstractL3vpnMcastIpRIBSupport<
                 .build();
     }
 
+
+    @Override
+    public final List<L3vpnMcastRoute> routesFromContainer(final S container) {
+        return container.getL3vpnMcastRoute();
+    }
+
     abstract NodeIdentifierWithPredicates createRouteKey(UnkeyedListEntryNode l3vpn);
 }
index 5d8edc7bc5435f648b44c22b4b735fe92575014a..1ffa2395a856da09f7b12a59bb6f39fdc0739fbd 100644 (file)
@@ -184,7 +184,12 @@ public abstract class AbstractVpnRIBSupport<C extends Routes & DataObject, S ext
     }
 
     @Override
-    public VpnRouteKey createRouteListKey(final long pathId, final String vpnRouteKey) {
+    public final VpnRouteKey createRouteListKey(final long pathId, final String vpnRouteKey) {
         return new VpnRouteKey(new PathId(pathId), vpnRouteKey);
     }
+
+    @Override
+    public final List<VpnRoute> routesFromContainer(final S container) {
+        return container.getVpnRoute();
+    }
 }
index e70995246d5e5649f94e9100465fe1e97e16cc46..25ff6525d3c502ef154503c830f765d1c95a811a 100644 (file)
@@ -57,14 +57,14 @@ public final class VpnIpv4RIBSupport extends AbstractVpnRIBSupport<VpnIpv4Routes
     }
 
     @Override
-    protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
+    protected DestinationType getAdvertisedDestinationType(final List<VpnDestination> dests) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
                 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
                 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
     }
 
     @Override
-    protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
+    protected DestinationType getWithdrawnDestinationType(final List<VpnDestination> dests) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
                 .setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(dests).build()).build();
index 639a49e48bba4f6c75bd2cc4044e6d4e50e5accd..fe88aefe67d66e82d1ccb665c40b4e8be1be8d46 100644 (file)
@@ -57,14 +57,14 @@ public final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport<VpnIpv6Routes
     }
 
     @Override
-    protected DestinationType getAdvertisedDestinationType(List<VpnDestination> dests) {
+    protected DestinationType getAdvertisedDestinationType(final List<VpnDestination> dests) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
                 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
                 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
     }
 
     @Override
-    protected DestinationType getWithdrawnDestinationType(List<VpnDestination> dests) {
+    protected DestinationType getWithdrawnDestinationType(final List<VpnDestination> dests) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
                 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
index b2a5f37f96d81ad4c9be2af40622a97e301d812e..04b90f36bdbed61c7fc0473074b5e5f1660901dd 100644 (file)
@@ -187,4 +187,9 @@ abstract class AbstractLabeledUnicastRIBSupport<
         return builder.withKey(new LabeledUnicastRouteKey(new PathId(pathId), routeKey))
                 .setAttributes(attributes).build();
     }
+
+    @Override
+    public final List<LabeledUnicastRoute> routesFromContainer(final S container) {
+        return container.getLabeledUnicastRoute();
+    }
 }
index 47229e29dfc0fa0ddd7ea9cc0b1e99c43e3058a9..4d0e30b5ddf0267976e43310cd242b0678ff81a4 100644 (file)
@@ -172,4 +172,9 @@ public final class LinkstateRIBSupport
     public LinkstateRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new LinkstateRouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<LinkstateRoute> routesFromContainer(final LinkstateRoutes container) {
+        return container.getLinkstateRoute();
+    }
 }
index 1f438254607961cd7e9b37fbc1b99eb48b71d46a..042564c24a648fa14dab11ddf8ede8fca8b399a1 100644 (file)
@@ -104,6 +104,11 @@ abstract class AbstractMvpnRIBSupport<C extends Routes & DataObject & ChoiceIn<T
         return new MvpnRouteKey(new PathId(pathId), routeKey);
     }
 
+    @Override
+    public final List<MvpnRoute> routesFromContainer(final S container) {
+        return container.getMvpnRoute();
+    }
+
     final MvpnChoice extractMvpnChoice(final DataContainerNode<? extends PathArgument> route) {
         final DataObject nn = this.mappingService.fromNormalizedNode(this.routeDefaultYii, route).getValue();
         return ((MvpnRoute) nn).getMvpnChoice();
index d2a719b3716d34027a68c7b74b57bacdbfee36ca..4f76384db46cffadab7a0b1ba9c375fbecc70928 100644 (file)
@@ -223,4 +223,9 @@ public final class RouteTargetConstrainRIBSupport
     public RouteTargetConstrainRouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new RouteTargetConstrainRouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<RouteTargetConstrainRoute> routesFromContainer(final RouteTargetConstrainRoutes container) {
+        return container.getRouteTargetConstrainRoute();
+    }
 }
index f55b149a88a39d228ce5b184be6077a80d3f6786..9b5c981036dc79085692ccc432c93eb3e397bd7f 100644 (file)
@@ -12,6 +12,7 @@ import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VA
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
+import java.util.List;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
@@ -92,6 +93,8 @@ public interface RIBSupport<
     @Nonnull
     Class<R> routesListClass();
 
+    @Nullable List<R> routesFromContainer(@Nonnull S container);
+
     @Nonnull
     default ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects() {
         return ImmutableSet.of();
index 79918a3b3155cd079f01cc8f4f8c9e6b397f15d5..49c60c08d9961802739f6e4f2027017e7b6f233e 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.protocol.bgp.rib.spi;
 import com.google.common.collect.ImmutableMap;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
@@ -83,4 +84,9 @@ public final class RIBSupportTestImp extends AbstractRIBSupport<Ipv4RoutesCase,
     public Ipv4RouteKey createRouteListKey(final long pathId, final String routeKey) {
         return new Ipv4RouteKey(new PathId(pathId), routeKey);
     }
+
+    @Override
+    public List<Ipv4Route> routesFromContainer(final Ipv4Routes container) {
+        return container.getIpv4Route();
+    }
 }
\ No newline at end of file