import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
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.BGPDispatcher;
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.BgpNeighbors;
public final class BgpModule extends PrivateModule {
// Configure peer registry
bind(BGPOpenConfigMappingService.class).toInstance(new BGPOpenConfigMappingServiceImpl());
- bind(BGPPeerRegistry.class).toProvider(BGPPeerRegistryProvider.class);
+ bind(BGPPeerRegistry.class).toInstance(StrictBGPPeerRegistry.instance());
+
// Create BGP server instance
bind(BgpServerProvider.BgpServer.class).toProvider(BgpServerProvider.class).in(Singleton.class);
expose(BgpServerProvider.BgpServer.class);
+
+ // Initialize BgpNeighbours
+ bind(BgpNeighbors.class).toProvider(BgpNeighboursProvider.class).in(Singleton.class);
+ expose(BgpNeighbors.class);
}
private void configureRIB() {
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.BgpNeighbors;
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.top.Bgp;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> {
- private static final Logger LOG = LoggerFactory.getLogger(BGPPeerRegistryProvider.class);
+final class BgpNeighboursProvider extends ProviderTrait<BgpNeighbors> {
+ private static final Logger LOG = LoggerFactory.getLogger(BgpNeighboursProvider.class);
private static final String PEERS_CFG = "/bgp-peers.json";
@Inject
private BindingToNormalizedNodeCodec codec;
private BGPOpenConfigMappingService mappingService;
@Inject
private SchemaService schemaService;
+ @Inject
+ private BGPPeerRegistry peerRegistry;
@Override
- protected BGPPeerRegistry create() {
- final BGPPeerRegistry peerRegistry = StrictBGPPeerRegistry.instance();
- final Neighbors neighbors = readNeighbours();
+ protected BgpNeighbors create() {
+ final BgpNeighbors neighbors = readNeighbours();
for (final Neighbor neighbor : neighbors.getNeighbor()) {
if (isApplicationPeer(neighbor)) {
LOG.trace("Starting AppPeer for {}", neighbor);
new BgpPeer(null, peerRegistry).start(globalRib, neighbor, mappingService, null);
}
}
- LOG.debug("Created BGPPeerRegistry with neighbours {}", neighbors);
- return peerRegistry;
+ LOG.debug("BgpNeighbours initialized: {}", neighbors);
+ return neighbors;
}
private Neighbors readNeighbours() {
import io.fd.honeycomb.infra.bgp.BgpConfiguration;
import io.fd.honeycomb.infra.bgp.BgpServerProvider;
import java.util.Set;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighbors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (bgpAttributes.isBgpEnabled()) {
LOG.info("Starting BGP");
injector.getInstance(BgpServerProvider.BgpServer.class);
+ LOG.info("Initializing BgpNeighbours");
+ injector.getInstance(BgpNeighbors.class);
LOG.info("BGP started successfully!");
}