<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>concepts</artifactId>
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RdTwoOctetAs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisherBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return null;
}
}
+
+ public static RouteDistinguisher extractRouteDistinguisher(final DataContainerNode<?> route, final NodeIdentifier rdNid) {
+ final NormalizedNode<?, ?> rdNode = NormalizedNodes.findNode(route, rdNid).orNull();
+ if (rdNode != null) {
+ return parseRouteDistinguisher(rdNode.getValue());
+ }
+ return null;
+ }
}
*/
package org.opendaylight.protocol.bgp.flowspec.l3vpn;
-import com.google.common.base.Optional;
+import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher;
+
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.List;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * @author Kevin Wang
- */
public abstract class AbstractFlowspecL3vpnNlriParser extends AbstractFlowspecNlriParser {
private static final Logger LOG = LoggerFactory.getLogger(AbstractFlowspecL3vpnNlriParser.class);
+ public static final NodeIdentifier RD_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(), Flowspec.QNAME.getRevision(), "route-distinguisher"));
- private static final NodeIdentifier RD_NID = new NodeIdentifier(QName.create(Flowspec.QNAME.getNamespace(), Flowspec.QNAME.getRevision(), "route-distinguisher"));
-
- protected AbstractFlowspecL3vpnNlriParser(SimpleFlowspecTypeRegistry flowspecTypeRegistry) {
+ protected AbstractFlowspecL3vpnNlriParser(final SimpleFlowspecTypeRegistry flowspecTypeRegistry) {
super(flowspecTypeRegistry);
}
@Override
public String stringNlri(final DataContainerNode<?> flowspec) {
final StringBuilder buffer = new StringBuilder();
- final RouteDistinguisher rd = extractRouteDistinguisher(flowspec);
+ final RouteDistinguisher rd = extractRouteDistinguisher(flowspec, RD_NID);
if (rd != null) {
buffer.append("[l3vpn with route-distinguisher ").append(rd.getValue()).append("] ");
}
return buffer.toString();
}
- public static final RouteDistinguisher extractRouteDistinguisher(final DataContainerNode<?> route) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> rdNode = route.getChild(RD_NID);
- if (rdNode.isPresent()) {
- return RouteDistinguisherUtil.parseRouteDistinguisher(rdNode.get().getValue());
- }
- return null;
- }
-
/**
* For flowspec-l3vpn, there is a route distinguisher field at the beginning of NLRI (8 bytes)
*
* @param nlri
* @return
*/
- private static final RouteDistinguisher readRouteDistinguisher(final ByteBuf nlri) {
+ private static RouteDistinguisher readRouteDistinguisher(final ByteBuf nlri) {
final RouteDistinguisher rd = RouteDistinguisherUtil.parseRouteDistinguisher(nlri);
LOG.trace("Route Distinguisher read from NLRI: {}", rd);
return rd;
*/
package org.opendaylight.protocol.bgp.flowspec.l3vpn;
+import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher;
+
import com.google.common.collect.Iterables;
import java.util.Collection;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+
import org.opendaylight.protocol.bgp.flowspec.AbstractFlowspecRIBSupport;
import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.FlowspecL3vpnSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-/**
- * @author Kevin Wang
- */
public abstract class AbstractFlowspecL3vpnRIBSupport<T extends AbstractFlowspecL3vpnNlriParser> extends AbstractFlowspecRIBSupport<T> {
private final NodeIdentifier routeDistinguisherNID;
final T flowspecNlriParser
) {
super(cazeClass, containerClass, listClass, afiClass, FlowspecL3vpnSubsequentAddressFamily.class, dstContainerClassQName, flowspecNlriParser);
- final QName routeDistinguisherQName = QName.create(routeQName(), "route-distinguisher").intern();
- routeDistinguisherNID = new NodeIdentifier(routeDistinguisherQName);
- }
-
- @Nullable
- private RouteDistinguisher buildRouteDistinguisher(final DataContainerNode<? extends PathArgument> data) {
- final NormalizedNode<?, ?> rdNode = NormalizedNodes.findNode(data, routeDistinguisherNID).orNull();
- RouteDistinguisher rd = null;
- if (rdNode != null) {
- rd = RouteDistinguisherUtil.parseRouteDistinguisher(rdNode.getValue());
- }
- return rd;
+ this.routeDistinguisherNID = new NodeIdentifier(QName.create(routeQName(), "route-distinguisher").intern());
}
@Nonnull
protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- final RouteDistinguisher rd = buildRouteDistinguisher(routesCont);
+ final RouteDistinguisher rd = extractRouteDistinguisher(routesCont, this.routeDistinguisherNID);
return this.nlriParser.createAdvertizedRoutesDestinationType(
new Object[] {rd, this.nlriParser.extractFlowspec(routesCont)},
pathId
protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
final MapEntryNode routesCont = Iterables.getOnlyElement(routes);
final PathId pathId = PathIdUtil.buildPathId(routesCont, routePathIdNid());
- final RouteDistinguisher rd = buildRouteDistinguisher(routesCont);
+ final RouteDistinguisher rd = extractRouteDistinguisher(routesCont, this.routeDistinguisherNID);
return this.nlriParser.createWithdrawnDestinationType(
new Object[] {rd, nlriParser.extractFlowspec(Iterables.getOnlyElement(routes))},
pathId
import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv4RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv4.route.FlowspecRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv4.routes.FlowspecL3vpnIpv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv4.route.FlowspecL3vpnRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
-/**
- * @author Kevin Wang
- */
public final class FlowspecL3vpnIpv4RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv4NlriParser> {
- public FlowspecL3vpnIpv4RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+ public FlowspecL3vpnIpv4RIBSupport(final SimpleFlowspecExtensionProviderContext context) {
super(
FlowspecL3vpnIpv4RoutesCase.class,
FlowspecL3vpnIpv4Routes.class,
- FlowspecRoute.class,
+ FlowspecL3vpnRoute.class,
DestinationFlowspecL3vpnIpv4.QNAME,
Ipv4AddressFamily.class,
new FlowspecL3vpnIpv4NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV4, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
);
}
- public static final FlowspecL3vpnIpv4RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
+ public static FlowspecL3vpnIpv4RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
return new FlowspecL3vpnIpv4RIBSupport(context);
}
}
import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.ipv6.route.FlowspecRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
-/**
- * @author Kevin Wang
- */
public final class FlowspecL3vpnIpv6RIBSupport extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser> {
-
- public FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
+ private FlowspecL3vpnIpv6RIBSupport(SimpleFlowspecExtensionProviderContext context) {
super(
FlowspecL3vpnIpv6RoutesCase.class,
FlowspecL3vpnIpv6Routes.class,
- FlowspecRoute.class,
+ FlowspecL3vpnRoute.class,
DestinationFlowspecL3vpnIpv6.QNAME,
Ipv6AddressFamily.class,
new FlowspecL3vpnIpv6NlriParser(context.getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6, SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
);
}
- public static final FlowspecL3vpnIpv6RIBSupport getInstance(SimpleFlowspecExtensionProviderContext context) {
+ public static FlowspecL3vpnIpv6RIBSupport getInstance(final SimpleFlowspecExtensionProviderContext context) {
return new FlowspecL3vpnIpv6RIBSupport(context);
}
}
}
}
+ grouping flowspec-ipv4-route-list {
+ leaf route-key {
+ description
+ "The sole function of this leaf
+ to act as the key in the list.
+ Its format does not form the
+ API contract of this model.";
+ type string;
+ }
+ uses flowspec-destination-group-ipv4;
+ uses bgp-rib-route;
+ }
+
grouping flowspec-ipv4-route {
list flowspec-route {
- leaf route-key {
- description
- "The sole function of this leaf
- to act as the key in the list.
- Its format does not form the
- API contract of this model.";
- type string;
- }
key "route-key path-id";
+ uses flowspec-ipv4-route-list;
+ }
+ }
- uses flowspec-destination-group-ipv4;
+ grouping flowspec-l3vpn-ipv4-route {
+ list flowspec-l3vpn-route {
+ key "route-key path-id";
+ uses flowspec-ipv4-route-list;
+ uses flowspec-l3vpn-rd;
+ }
+ }
- uses bgp-rib-route;
+ grouping flowspec-ipv6-route-list {
+ uses flowspec-destination-group-ipv6;
+ uses bgp-rib-route;
+ leaf route-key {
+ description
+ "The sole function of this leaf
+ to act as the key in the list.
+ Its format does not form the
+ API contract of this model.";
+ type string;
}
}
grouping flowspec-ipv6-route {
list flowspec-route {
- leaf route-key {
- description
- "The sole function of this leaf
- to act as the key in the list.
- Its format does not form the
- API contract of this model.";
- type string;
- }
key "route-key path-id";
+ uses flowspec-ipv6-route-list;
+ }
+ }
- uses flowspec-destination-group-ipv6;
-
- uses bgp-rib-route;
+ grouping flowspec-l3vpn-ipv6-route {
+ list flowspec-l3vpn-route {
+ key "route-key path-id";
+ uses flowspec-ipv6-route-list;
+ uses flowspec-l3vpn-rd;
}
}
grouping flowspec-l3vpn-ipv4-routes {
container flowspec-l3vpn-ipv4-routes {
- uses flowspec-ipv4-route {
- augment "flowspec-route" {
- uses flowspec-l3vpn-rd;
- }
- }
+ uses flowspec-l3vpn-ipv4-route;
}
}
grouping flowspec-l3vpn-ipv6-routes {
container flowspec-l3vpn-ipv6-routes {
- uses flowspec-ipv6-route {
- augment "flowspec-route" {
- uses flowspec-l3vpn-rd;
- }
- }
+ uses flowspec-l3vpn-ipv6-route;
}
}
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
);
RouteDistinguisher rd = RouteDistinguisherBuilder.getDefaultInstance(ROUTE_DISTINGUISHER);
- assertEquals(rd, FS_PARSER.extractRouteDistinguisher(entry.build()));
+ assertEquals(rd, extractRouteDistinguisher(entry.build(), FS_PARSER.RD_NID));
}
}
<!-- concepts -->
<bundle>mvn:com.google.guava/guava/{{VERSION}}</bundle>
<feature version='${mdsal.model.version}'>odl-mdsal-models</feature>
+ <feature version='${yangtools.version}'>odl-yangtools-yang-data</feature>
<bundle>mvn:org.opendaylight.bgpcep/concepts/{{VERSION}}</bundle>
<!-- util -->
<feature version='[4.0.30,4.1.0)'>odl-netty</feature>