summaryrefslogtreecommitdiffstats
path: root/infra/northbound/bgp
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-07-21 15:26:10 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-08-03 07:53:43 +0200
commitfd692c20d9dc48529aa7d545397f1b009d3bd479 (patch)
tree9df2be315acf1600212424c7ef2f6db62151a303 /infra/northbound/bgp
parent8768252309014a2a1cfc71b9e78cfd3de3dae1f9 (diff)
HONEYCOMB-362: bump ODL dependencies to Carbon
Change-Id: I63fa239e34178ab03c4eecd421bf19d80303d30e Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/northbound/bgp')
-rw-r--r--infra/northbound/bgp/pom.xml11
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java5
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java39
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java54
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java3
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java14
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java2
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java6
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java6
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java27
-rw-r--r--infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java27
11 files changed, 144 insertions, 50 deletions
diff --git a/infra/northbound/bgp/pom.xml b/infra/northbound/bgp/pom.xml
index 2831924d4..ac5a46c33 100644
--- a/infra/northbound/bgp/pom.xml
+++ b/infra/northbound/bgp/pom.xml
@@ -77,17 +77,6 @@
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>bgp-rib-impl</artifactId>
- <!-- TODO remove exclusion after bumping to Boron-SR4 -->
- <exclusions>
- <exclusion>
- <groupId>org.powermock</groupId>
- <artifactId>powermock</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.bgpcep</groupId>
- <artifactId>bgp-openconfig-impl</artifactId>
</dependency>
<!-- ODL BGP extensions -->
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java
index 92b743660..c737f7493 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java
@@ -22,15 +22,18 @@ import io.netty.channel.EventLoopGroup;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
+import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
final class BGPDispatcherImplProvider extends ProviderTrait<BGPDispatcher> {
@Inject
private BGPExtensionConsumerContext consumerContext;
@Inject
private EventLoopGroup threadGroup;
+ @Inject
+ private BGPPeerRegistry peerRegistry;
@Override
protected BGPDispatcher create() {
- return new BGPDispatcherImpl(consumerContext.getMessageRegistry(), threadGroup, threadGroup);
+ return new BGPDispatcherImpl(consumerContext.getMessageRegistry(), threadGroup, threadGroup, peerRegistry);
}
}
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java
new file mode 100644
index 000000000..06ef5ea7a
--- /dev/null
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPTableTypeRegistryConsumerProvider.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.infra.bgp;
+
+import com.google.inject.Inject;
+import io.fd.honeycomb.binding.init.ProviderTrait;
+import java.util.Set;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
+import org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider;
+
+final class BGPTableTypeRegistryConsumerProvider extends ProviderTrait<BGPTableTypeRegistryConsumer> {
+ @Inject
+ private Set<BGPTableType> tableTypes;
+
+ @Override
+ protected BGPTableTypeRegistryConsumer create() {
+ final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
+ tableTypes.stream().forEach(tableType -> tableType.register(registry));
+ return registry;
+ }
+
+ interface BGPTableType {
+ void register(SimpleBGPTableTypeRegistryProvider registry);
+ }
+}
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
index b096e3dbd..4f9ab7a61 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
@@ -19,12 +19,30 @@ package io.fd.honeycomb.infra.bgp;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4LABELLEDUNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6LABELLEDUNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L2VPNEVPN;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV4UNICAST;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.L3VPNIPV6UNICAST;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.EvpnSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.L2vpnAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev150525.LabeledUnicastSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.LINKSTATE;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
/**
* Registers BGP extensions provided by ODL implementation.
@@ -41,6 +59,7 @@ final class BgpExtensionsModule extends AbstractModule {
// https://github.com/google/guice/issues/906
configureRIBExtensions();
configureBGPExtensions();
+ configureTableTypes();
}
private void configureRIBExtensions() {
@@ -69,4 +88,39 @@ final class BgpExtensionsModule extends AbstractModule {
bind(BGPExtensionConsumerContext.class).toProvider(BGPExtensionConsumerContextProvider.class)
.in(Singleton.class);
}
+
+ private void configureTableTypes() {
+ final Multibinder<BGPTableTypeRegistryConsumerProvider.BGPTableType> tableTypeBinder =
+ Multibinder.newSetBinder(binder(),
+ BGPTableTypeRegistryConsumerProvider.BGPTableType.class);
+
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, L2VPNEVPN.class));
+
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV4UNICAST.class));
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class, IPV6UNICAST.class));
+
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class,
+ L3VPNIPV4UNICAST.class));
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class,
+ L3VPNIPV6UNICAST.class));
+
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv4AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class,
+ IPV4LABELLEDUNICAST.class));
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(Ipv6AddressFamily.class, LabeledUnicastSubsequentAddressFamily.class,
+ IPV6LABELLEDUNICAST.class));
+
+ tableTypeBinder.addBinding().toInstance(provider -> provider
+ .registerBGPTableType(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class,
+ LINKSTATE.class));
+
+ bind(BGPTableTypeRegistryConsumer.class).toProvider(BGPTableTypeRegistryConsumerProvider.class)
+ .in(Singleton.class);
+ }
}
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
index 3cab508b4..943a57e1a 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
@@ -57,9 +57,8 @@ public final class BgpModule extends PrivateModule {
bind(RibWriter.class).toProvider(LocRibWriterProvider.class).asEagerSingleton();
expose(RibWriter.class);
- // install other BGP modules (hidden from HC user):
+ // install configuration module (hidden from HC user):
install(new BgpConfigurationModule());
- install(new BgpExtensionsModule());
}
private void configureRIB() {
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java
index 7fcddfc5c..a25808850 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java
@@ -16,6 +16,8 @@
package io.fd.honeycomb.infra.bgp;
+import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes;
+
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
@@ -30,8 +32,9 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.RIBImpl;
+import org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
@@ -64,7 +67,7 @@ final class BgpRIBProvider extends ProviderTrait<RIB> {
@Inject
private DOMDataBroker domBroker;
@Inject
- private BGPOpenConfigMappingService mappingService;
+ private BGPTableTypeRegistryConsumer tableTypeRegistry;
@Inject
private SchemaService schemaService;
@@ -87,14 +90,15 @@ final class BgpRIBProvider extends ProviderTrait<RIB> {
.setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build())
.build()
);
- final Map<TablesKey, PathSelectionMode> pathSelectionModes = mappingService.toPathSelectionMode(afiSafi)
+ final Map<TablesKey, PathSelectionMode> pathSelectionModes =
+ OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry)
.entrySet().stream().collect(Collectors.toMap(entry ->
new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
- // based on RIBImpl.createRib
+ // based on org.opendaylight.protocol.bgp.rib.impl.config.RibImpl.createRib
final RIBImpl rib =
new RIBImpl(new NoopClusterSingletonServiceProvider(), new RibId(cfg.bgpProtocolInstanceName.get()),
asNumber, new BgpId(routerId), clusterId, extensions, dispatcher, codec,
- new PingPongDataBroker(domBroker), mappingService.toTableTypes(afiSafi), pathSelectionModes,
+ new PingPongDataBroker(domBroker), toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes,
extensions.getClassLoadingStrategy(), null);
// required for proper RIB's CodecRegistry initialization (based on RIBImpl.start)
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java
index ba95d32a0..876a39f14 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java
@@ -57,7 +57,7 @@ public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.Bg
}
final InetSocketAddress address = new InetSocketAddress(bindingAddress, cfg.bgpPort.get());
LOG.debug("Creating BgpServer for {}", address);
- final ChannelFuture localServer = dispatcher.createServer(peerRegistry, address);
+ final ChannelFuture localServer = dispatcher.createServer(address);
localServer.addListener(future -> {
Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", address, future.cause());
final Channel channel = localServer.channel();
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
index 589eeac7b..c58afc067 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
@@ -21,8 +21,6 @@ import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import io.fd.honeycomb.infra.bgp.neighbors.BgpPeerWriterFactory;
import io.fd.honeycomb.translate.write.WriterFactory;
-import org.opendaylight.protocol.bgp.openconfig.impl.BGPOpenConfigMappingServiceImpl;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.slf4j.Logger;
@@ -42,9 +40,11 @@ public final class BgpWritersModule extends AbstractModule {
// https://github.com/google/guice/issues/906
// Configure peer registry
- bind(BGPOpenConfigMappingService.class).toInstance(new BGPOpenConfigMappingServiceImpl());
bind(BGPPeerRegistry.class).toInstance(StrictBGPPeerRegistry.instance());
+ // install extensions module (hidden from HC user until HONEYCOMB-363 is fixed):
+ install(new BgpExtensionsModule());
+
final Multibinder<WriterFactory> binder = Multibinder.newSetBinder(binder(), WriterFactory.class);
binder.addBinding().to(ApplicationRibWriterFactory.class).in(Singleton.class);
binder.addBinding().to(BgpPeerWriterFactory.class).in(Singleton.class);
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java
index 064c70b57..8b7510eb8 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/BgpPeerWriterFactory.java
@@ -23,7 +23,7 @@ import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
@@ -63,7 +63,7 @@ public final class BgpPeerWriterFactory implements WriterFactory {
@Inject
private RIB globalRib;
@Inject
- private BGPOpenConfigMappingService mappingService;
+ private BGPTableTypeRegistryConsumer tableTypeRegistry;
@Inject
private BGPPeerRegistry peerRegistry;
@@ -104,7 +104,7 @@ public final class BgpPeerWriterFactory implements WriterFactory {
),
new GenericListWriter<>(
NEIGHBOR_ID,
- new NeighborCustomizer(globalRib, peerRegistry, mappingService)));
+ new NeighborCustomizer(globalRib, peerRegistry, tableTypeRegistry)));
}
}
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java
index 50ae45b40..baccb9a1c 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizer.java
@@ -18,7 +18,7 @@ package io.fd.honeycomb.infra.bgp.neighbors;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
-import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.APPLICATION_PEER_GROUP_NAME;
+import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.isApplicationPeer;
import com.google.common.annotations.VisibleForTesting;
import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
@@ -29,16 +29,14 @@ import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.config.AppPeer;
import org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer;
import org.opendaylight.protocol.bgp.rib.impl.config.PeerBean;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighborPeerGroupConfig;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,16 +50,17 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo
private static final Logger LOG = LoggerFactory.getLogger(NeighborCustomizer.class);
private final RIB globalRib;
private final BGPPeerRegistry peerRegistry;
- private final BGPOpenConfigMappingService mappingService;
+ private BGPTableTypeRegistryConsumer tableTypeRegistry;
+
@GuardedBy("this")
private final Map<InstanceIdentifier<Neighbor>, PeerBean> peers = new HashMap<>();
public NeighborCustomizer(@Nonnull final RIB globalRib, @Nonnull final BGPPeerRegistry peerRegistry,
- @Nonnull final BGPOpenConfigMappingService mappingService) {
+ @Nonnull final BGPTableTypeRegistryConsumer tableTypeRegistry) {
this.globalRib = checkNotNull(globalRib, "globalRib should not be null");
this.peerRegistry = checkNotNull(peerRegistry, "globalRib should not be null");
- this.mappingService = checkNotNull(mappingService, "globalRib should not be null");
+ this.tableTypeRegistry = checkNotNull(tableTypeRegistry, "tableTypeRegistry should not be null");
}
@VisibleForTesting
@@ -86,10 +85,10 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo
peer = new AppPeer();
} else {
LOG.debug("Starting BgpPeer bean for {}: {}", id, neighbor);
- peer = new BgpPeer(null, peerRegistry);
+ peer = new BgpPeer(null);
}
LOG.debug("Starting bgp peer for {}", id);
- peer.start(globalRib, neighbor, mappingService, null);
+ peer.start(globalRib, neighbor, tableTypeRegistry, null);
addPeer(id, peer);
}
@@ -103,7 +102,7 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo
final PeerBean peer = peers.get(id);
checkState(peer != null, "Could not find peer bean while updating neighbor {}", id);
closePeerBean(peer);
- peer.start(globalRib, dataAfter, mappingService, null);
+ peer.start(globalRib, dataAfter, tableTypeRegistry, null);
LOG.debug("Peer instance updated {}", peer);
}
@@ -120,14 +119,6 @@ final class NeighborCustomizer implements ListWriterCustomizer<Neighbor, Neighbo
}
}
- private static boolean isApplicationPeer(@Nonnull final Neighbor neighbor) {
- return java.util.Optional.of(neighbor.getConfig())
- .map(config -> config.getAugmentation(Config2.class))
- .map(BgpNeighborPeerGroupConfig::getPeerGroup)
- .map(APPLICATION_PEER_GROUP_NAME::equals)
- .orElse(false);
- }
-
private static void closePeerBean(final PeerBean peer) {
try {
peer.closeServiceInstance().get();
diff --git a/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java b/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java
index 4f348510a..ba71cc90e 100644
--- a/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java
+++ b/infra/northbound/bgp/src/test/java/io/fd/honeycomb/infra/bgp/neighbors/NeighborCustomizerTest.java
@@ -22,42 +22,52 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
-import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.APPLICATION_PEER_GROUP_NAME;
import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
-import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
+import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.protocol.bgp.rib.impl.config.PeerBean;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborKey;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.PeerType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev160614.Config2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
public class NeighborCustomizerTest {
private static final IpAddress IP = new IpAddress(new Ipv4Address("10.25.1.9"));
private static final InstanceIdentifier<Neighbor> ID =
InstanceIdentifier.create(Neighbors.class).child(Neighbor.class, new NeighborKey(IP));
+ private static final KeyedInstanceIdentifier<Rib, RibKey> RIB_IID =
+ InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(new RibId("test-rib-id")));
@Mock
private RIB globalRib;
@Mock
private BGPPeerRegistry peerRegistry;
@Mock
- private BGPOpenConfigMappingService mappingService;
+ private BGPTableTypeRegistryConsumer tableTypeRegistry;
@Mock
private WriteContext ctx;
@@ -68,7 +78,8 @@ public class NeighborCustomizerTest {
initMocks(this);
when(globalRib.getYangRibId()).thenReturn(YangInstanceIdentifier.EMPTY);
when(globalRib.getRibIServiceGroupIdentifier()).thenReturn(ServiceGroupIdentifier.create("sgid"));
- customizer = new NeighborCustomizer(globalRib, peerRegistry, mappingService);
+ when(globalRib.getInstanceIdentifier()).thenReturn(RIB_IID);
+ customizer = new NeighborCustomizer(globalRib, peerRegistry, tableTypeRegistry);
}
@Test
@@ -79,7 +90,7 @@ public class NeighborCustomizerTest {
new ConfigBuilder()
.addAugmentation(
Config2.class,
- new Config2Builder().setPeerGroup(APPLICATION_PEER_GROUP_NAME).build()
+ new Config2Builder().setPeerGroup("application-peers").build()
).build())
.build();
customizer.writeCurrentAttributes(ID, neighbor, ctx);
@@ -90,6 +101,10 @@ public class NeighborCustomizerTest {
public void testAddInternalPeer() throws WriteFailedException {
final Neighbor neighbor = new NeighborBuilder()
.setNeighborAddress(IP)
+ .setAfiSafis(new AfiSafisBuilder()
+ .setAfiSafi(Collections.singletonList(
+ new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build()
+ )).build())
.setConfig(
new ConfigBuilder()
.setPeerType(PeerType.INTERNAL)
@@ -108,7 +123,7 @@ public class NeighborCustomizerTest {
customizer.updateCurrentAttributes(ID, before, after, ctx);
verify(peer).closeServiceInstance();
verify(peer).close();
- verify(peer).start(globalRib, after, mappingService, null);
+ verify(peer).start(globalRib, after, tableTypeRegistry, null);
}
@Test