diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-05-18 16:46:46 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-05-29 08:36:30 +0200 |
commit | 685bffccd16d58fc5c1dd5c118ee74aa39effa68 (patch) | |
tree | a9e9dd8277e818d6bb3c6ced7ad5ae74bab3c07c | |
parent | 46589c652a58b1cd56dab268b59d96bc20b5dd1f (diff) |
HONEYCOMB-355: move BGP to separate distribution
Given current YangBindingProviderModule implementation (HONEYCOMB-358),
needed to preserve footprint of minimal distro.
The change also:
- reverts logger&persistence config changes
introduced by https://gerrit.fd.io/r/#/c/5972/
- improves logging for BGP component initialization
Change-Id: Ie223833518be21628edb7ace36c7618e427585e0
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
37 files changed, 655 insertions, 175 deletions
diff --git a/infra/bgp-distribution/asciidoc/Readme.adoc b/infra/bgp-distribution/asciidoc/Readme.adoc new file mode 100644 index 000000000..f6222d4d0 --- /dev/null +++ b/infra/bgp-distribution/asciidoc/Readme.adoc @@ -0,0 +1,3 @@ += bgp-distribution + +Honeycomb distribution that adds BGP to NETCONF and RESTCONF northbound intrerfaces provided by minimal-distribution.
\ No newline at end of file diff --git a/infra/bgp_postman_collection.json b/infra/bgp-distribution/bgp_postman_collection.json index 1e7602a2d..1e7602a2d 100644 --- a/infra/bgp_postman_collection.json +++ b/infra/bgp-distribution/bgp_postman_collection.json diff --git a/infra/bgp-distribution/pom.xml b/infra/bgp-distribution/pom.xml new file mode 100644 index 000000000..c70d03017 --- /dev/null +++ b/infra/bgp-distribution/pom.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>io.fd.honeycomb.common</groupId> + <artifactId>minimal-distribution-parent</artifactId> + <version>1.17.07-SNAPSHOT</version> + <relativePath>../../common/minimal-distribution-parent</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <groupId>io.fd.honeycomb</groupId> + <artifactId>bgp-distribution</artifactId> + <name>${project.artifactId}</name> + <version>1.17.07-SNAPSHOT</version> + + <properties> + <main.class>io.fd.honeycomb.infra.bgp.distro.Main</main.class> + <sonar.skip>true</sonar.skip> + <distribution.modules> + io.fd.honeycomb.infra.bgp.BgpModule, + io.fd.honeycomb.infra.bgp.BgpExtensionsModule, + io.fd.honeycomb.infra.bgp.BgpReadersModule, + io.fd.honeycomb.infra.bgp.BgpWritersModule, + io.fd.honeycomb.infra.bgp.BgpConfigurationModule + </distribution.modules> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>groovy-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>minimal-distribution</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- ODL-BGP --> + <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> + <!-- BGP extensions --> + <dependency> + <groupId>org.opendaylight.bgpcep</groupId> + <artifactId>bgp-evpn</artifactId> + </dependency> + <dependency> + <groupId>org.opendaylight.bgpcep</groupId> + <artifactId>bgp-inet</artifactId> + </dependency> + <dependency> + <groupId>org.opendaylight.bgpcep</groupId> + <artifactId>bgp-labeled-unicast</artifactId> + </dependency> + <dependency> + <groupId>org.opendaylight.bgpcep</groupId> + <artifactId>bgp-linkstate</artifactId> + </dependency> + <dependency> + <groupId>org.opendaylight.bgpcep</groupId> + <artifactId>bgp-l3vpn</artifactId> + </dependency> + + <!-- test dependencies --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.mashape.unirest</groupId> + <artifactId>unirest-java</artifactId> + <version>1.4.9</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.jcraft</groupId> + <artifactId>jsch</artifactId> + <version>0.1.54</version> + <scope>test</scope> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPDispatcherImplProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java index 1de26c4f0..c9ec39f35 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPDispatcherImplProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPExtensionConsumerContextProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java index c57440d26..00e99ab99 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPExtensionConsumerContextProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; @@ -25,8 +25,12 @@ import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext; import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext; import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContextActivator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensionConsumerContext> { + private static final Logger LOG = LoggerFactory.getLogger(BGPExtensionConsumerContextProvider.class); + @Inject private Set<BGPExtensionProviderActivator> activators; @@ -35,6 +39,7 @@ final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensi final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext(); final SimpleBGPExtensionProviderContextActivator activator = new SimpleBGPExtensionProviderContextActivator(ctx, new ArrayList<>(activators)); + LOG.debug("Starting BGPExtensionConsumerContext with activators: {}", activators); activator.start(); return ctx; } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPPeerRegistryProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java index 611656a75..217c43823 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPPeerRegistryProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; @@ -57,8 +57,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> { + private static final Logger LOG = LoggerFactory.getLogger(BGPPeerRegistryProvider.class); private static final String PEERS_CFG = "/bgp-peers.json"; @Inject private BindingToNormalizedNodeCodec codec; @@ -75,15 +78,19 @@ final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> { final Neighbors neighbors = readNeighbours(); for (final Neighbor neighbor : neighbors.getNeighbor()) { if (isApplicationPeer(neighbor)) { + LOG.trace("Starting AppPeer for {}", neighbor); new AppPeer().start(globalRib, neighbor, mappingService, null); } else { + LOG.trace("Starting BgpPeer for {}", neighbor); new BgpPeer(null, peerRegistry).start(globalRib, neighbor, mappingService, null); } } + LOG.debug("Created BGPPeerRegistry with neighbours {}", neighbors); return peerRegistry; } private Neighbors readNeighbours() { + LOG.debug("Reading BGP neighbours from {}", PEERS_CFG); final InputStream resourceStream = this.getClass().getResourceAsStream(PEERS_CFG); checkState(resourceStream != null, "Resource %s not found", PEERS_CFG); diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java new file mode 100644 index 000000000..9182dd3a0 --- /dev/null +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java @@ -0,0 +1,68 @@ +/* + * 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.common.base.MoreObjects; +import java.util.Optional; +import net.jmob.guice.conf.core.BindConfig; +import net.jmob.guice.conf.core.InjectConfig; +import net.jmob.guice.conf.core.Syntax; + +/** + * This is the Java equivalent for bgp.json file. We use guice-config library to load all the config attributes + * into this class instance. + * + * The BindConfig annotation tells that bgp.json file should be looked up on classpath root. + */ +@BindConfig(value = "bgp", syntax = Syntax.JSON) +public class BgpConfiguration { + + public boolean isBgpEnabled() { + return Boolean.valueOf(bgpEnabled); + } + + public boolean isBgpMultiplePathsEnabled() { + return Boolean.valueOf(bgpMultiplePaths.get()); + } + + @InjectConfig("bgp-enabled") + public String bgpEnabled; + @InjectConfig("bgp-binding-address") + public Optional<String> bgpBindingAddress; + @InjectConfig("bgp-port") + public Optional<Integer> bgpPort; + @InjectConfig("bgp-as-number") + public Optional<Integer> bgpAsNumber; + @InjectConfig("bgp-receive-multiple-paths") + public Optional<String> bgpMultiplePaths; + @InjectConfig("bgp-send-max-paths") + public Optional<Integer> bgpSendMaxMaths; + @InjectConfig("bgp-netty-threads") + public Integer bgpNettyThreads; + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("bgpEnabled", bgpEnabled) + .add("bgpBindingAddress", bgpBindingAddress) + .add("bgpPort", bgpPort) + .add("bgp-as-number", bgpAsNumber) + .add("bgp-netty-threads", bgpNettyThreads) + .add("bgp-receive-multiple-paths", bgpMultiplePaths) + .add("bgp-send-max-paths", bgpSendMaxMaths) + .toString(); + } +} diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java new file mode 100644 index 000000000..a1c2e765b --- /dev/null +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java @@ -0,0 +1,33 @@ +/* + * 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.AbstractModule; +import net.jmob.guice.conf.core.ConfigurationModule; + +/** + * Load the configuration from json into HoneycombConfiguration and make it available. + */ +public class BgpConfigurationModule extends AbstractModule { + + protected void configure() { + install(ConfigurationModule.create()); + // Inject non-dependency configuration + requestInjection(BgpConfiguration.class); + } + +} diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpExtensionsModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java index 19402248c..461fb8918 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpExtensionsModule.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.AbstractModule; import com.google.inject.multibindings.Multibinder; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java index ca6b065b0..128e9f0de 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpModule.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.CONFIG; import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.OPERATIONAL; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpNettyThreadGroupProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNettyThreadGroupProvider.java index b4ac322b2..8208a4320 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpNettyThreadGroupProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNettyThreadGroupProvider.java @@ -14,18 +14,17 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import io.netty.channel.nio.NioEventLoopGroup; final class BgpNettyThreadGroupProvider extends ProviderTrait<NioEventLoopGroup> { @Inject - private HoneycombConfiguration cfgAttributes; + private BgpConfiguration cfgAttributes; @Override protected NioEventLoopGroup create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpRIBProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java index f161e952c..11ee4cf8d 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpRIBProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java @@ -14,12 +14,11 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -51,11 +50,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; final class BgpRIBProvider extends ProviderTrait<RIB> { - + private static final Logger LOG = LoggerFactory.getLogger(BgpRIBProvider.class); private static final String HC_BGP_INSTANCE_NAME = "hc-bgp-instance"; @Inject - private HoneycombConfiguration cfg; + private BgpConfiguration cfg; @Inject private RIBExtensionConsumerContext extensions; @Inject @@ -74,6 +73,7 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { final AsNumber asNumber = new AsNumber(cfg.bgpAsNumber.get().longValue()); final Ipv4Address routerId = new Ipv4Address(cfg.bgpBindingAddress.get()); final ClusterIdentifier clusterId = new ClusterIdentifier(routerId); + LOG.debug("Creating BGP RIB: routerId={}, asNumber={}", routerId, asNumber); // TODO configure other BGP Multiprotocol extensions: final List<AfiSafi> afiSafi = ImmutableList.of(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class) .addAugmentation(AfiSafi2.class, @@ -91,6 +91,8 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { // required for proper RIB's CodecRegistry initialization (based on RIBImpl.start) schemaService.registerSchemaContextListener(rib); + + LOG.debug("BGP RIB created successfully: {}", rib); return rib; } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReaderFactoryProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReaderFactoryProvider.java index 2e8ef8ff3..b79074f10 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReaderFactoryProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReaderFactoryProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import com.google.inject.name.Named; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReadersModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java index b61cf37a0..745a94269 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReadersModule.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.AbstractModule; import com.google.inject.Singleton; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpServerProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java index 4ade07fc1..27dad8840 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpServerProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java @@ -14,12 +14,11 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.common.base.Preconditions; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; import io.netty.channel.ChannelFuture; @@ -35,10 +34,13 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener; import org.opendaylight.protocol.concepts.KeyMapping; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.BgpServer> { + private static final Logger LOG = LoggerFactory.getLogger(BgpServerProvider.class); @Inject - private HoneycombConfiguration cfg; + private BgpConfiguration cfg; @Inject private BGPPeerRegistry peerRegistry; @Inject @@ -54,6 +56,7 @@ public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.Bg throw new IllegalArgumentException("Illegal BGP binding address", e); } final InetSocketAddress address = new InetSocketAddress(bindingAddress, cfg.bgpPort.get()); + LOG.debug("Creating BgpServer for {}", address); final ChannelFuture localServer = dispatcher.createServer(peerRegistry, address); localServer.addListener(future -> { Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", address, future.cause()); @@ -62,7 +65,9 @@ public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.Bg peerRegistry.registerPeerRegisterListener(new PeerRegistryListenerImpl(channel.config())); } }); - return new BgpServer(localServer); + final BgpServer server = new BgpServer(localServer); + LOG.debug("BgpServer successfully created."); + return server; } public static final class BgpServer { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWriterFactoryProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWriterFactoryProvider.java index 0441ec080..081fbd782 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWriterFactoryProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWriterFactoryProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.common.collect.Sets; import com.google.inject.Inject; @@ -64,7 +64,7 @@ final class BgpWriterFactoryProvider extends ProviderTrait<WriterFactory> { this.dataBroker = dataBroker; } - // TODO + // TODO (HONEYCOMB-359): // BGP models are huge, we need some kind of wildcarded subtree writer, that works for whole subtree. // 1) we can either move checking handledTypes to writers (getHandledTypes, isAffected, writer.getHandedTypes, ...) // but then precondition check in flatWriterRegistry might be slower (we need to check if we have all writers diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWritersModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java index f9e2e4c5b..f1e92c4ba 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWritersModule.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.AbstractModule; import com.google.inject.Singleton; diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/RIBExtensionConsumerContextProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java index 480caa0eb..b90b7880c 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/RIBExtensionConsumerContextProvider.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.fd.honeycomb.infra.distro.bgp; +package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import io.fd.honeycomb.infra.distro.ProviderTrait; @@ -25,8 +25,11 @@ import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator; import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext; import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext; import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContextActivator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtensionConsumerContext> { + private static final Logger LOG = LoggerFactory.getLogger(RIBExtensionConsumerContextProvider.class); @Inject private Set<RIBExtensionProviderActivator> activators; @@ -35,6 +38,7 @@ public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtens final RIBExtensionProviderContext ctx = new SimpleRIBExtensionProviderContext(); final SimpleRIBExtensionProviderContextActivator activator = new SimpleRIBExtensionProviderContextActivator(ctx, new ArrayList<>(activators)); + LOG.debug("Starting RIBExtensionConsumerContext with activators: {}", activators); activator.start(); return ctx; } diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java new file mode 100644 index 000000000..0204e1f5c --- /dev/null +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java @@ -0,0 +1,73 @@ +/* + * 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.distro; + +import static io.fd.honeycomb.infra.distro.ActiveModuleProvider.STANDARD_MODULES_RELATIVE_PATH; +import static io.fd.honeycomb.infra.distro.ActiveModuleProvider.aggregateResources; +import static io.fd.honeycomb.infra.distro.ActiveModuleProvider.loadActiveModules; + +import com.google.inject.ConfigurationException; +import com.google.inject.CreationException; +import com.google.inject.Injector; +import com.google.inject.Module; +import com.google.inject.ProvisionException; +import io.fd.honeycomb.infra.bgp.BgpConfiguration; +import io.fd.honeycomb.infra.bgp.BgpServerProvider; +import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class Main { + + private static final Logger LOG = LoggerFactory.getLogger(Main.class); + + private Main() { + } + + public static void main(String[] args) { + final ClassLoader classLoader = Main.class.getClassLoader(); + init(loadActiveModules(aggregateResources(STANDARD_MODULES_RELATIVE_PATH, classLoader))); + } + + /** + * Initialize the Honeycomb with provided modules + */ + public static Injector init(final Set<? extends Module> modules) { + try { + Injector injector = io.fd.honeycomb.infra.distro.Main.init(modules); + final BgpConfiguration bgpAttributes = injector.getInstance(BgpConfiguration.class); + + if (bgpAttributes.isBgpEnabled()) { + LOG.info("Starting BGP"); + injector.getInstance(BgpServerProvider.BgpServer.class); + LOG.info("BGP started successfully!"); + } + + return injector; + } catch (CreationException | ProvisionException | ConfigurationException e) { + LOG.error("Failed to initialize Honeycomb components", e); + throw e; + } catch (RuntimeException e) { + LOG.error("Unexpected initialization failure", e); + throw e; + } finally { + // Trigger gc to force collect initial garbage + dedicated classloader + System.gc(); + } + } + +} diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json b/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json index 6de2065b8..6de2065b8 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json +++ b/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json diff --git a/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json b/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json new file mode 100644 index 000000000..2664c9ed6 --- /dev/null +++ b/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json @@ -0,0 +1,9 @@ +{ + "bgp-enabled": "true", + "bgp-binding-address": "127.0.0.1", + "bgp-port": 1790, + "bgp-as-number": 65000, + "bgp-receive-multiple-paths": "true", + "bgp-send-max-paths": 0, + "bgp-netty-threads": 2 +}
\ No newline at end of file diff --git a/infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java b/infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java new file mode 100644 index 000000000..095d61c39 --- /dev/null +++ b/infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2016 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.distro; + +import static com.google.common.collect.ImmutableSet.of; + +import com.google.common.io.ByteStreams; +import com.google.inject.Module; +import com.mashape.unirest.http.Unirest; +import io.fd.honeycomb.infra.bgp.BgpConfigurationModule; +import io.fd.honeycomb.infra.bgp.BgpExtensionsModule; +import io.fd.honeycomb.infra.bgp.BgpModule; +import io.fd.honeycomb.infra.bgp.BgpReadersModule; +import io.fd.honeycomb.infra.bgp.BgpWritersModule; +import io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule; +import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule; +import io.fd.honeycomb.infra.distro.initializer.InitializerPipelineModule; +import io.fd.honeycomb.infra.distro.netconf.NetconfModule; +import io.fd.honeycomb.infra.distro.netconf.NetconfReadersModule; +import io.fd.honeycomb.infra.distro.restconf.RestconfModule; +import io.fd.honeycomb.infra.distro.schema.SchemaModule; +import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule; +import java.io.IOException; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.util.Set; +import javax.net.ssl.SSLContext; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContexts; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BgpDistributionTest { + + private static final Logger LOG = LoggerFactory.getLogger(BgpDistributionTest.class); + private static final String CERT_PASSWORD = "testing"; + private static final int HELLO_WAIT = 2500; + + private static final int BGP_MSG_TYPE_OFFSET = 18; // 16 (MARKER) + 2 (LENGTH); + private static final byte BGP_OPEN_MSG_TYPE = 1; + private static final int BGP_PORT = 1790; + + public static final Set<Module> BASE_MODULES = of( + new YangBindingProviderModule(), + new SchemaModule(), + new ConfigAndOperationalPipelineModule(), + new ContextPipelineModule(), + new InitializerPipelineModule(), + new NetconfModule(), + new NetconfReadersModule(), + new RestconfModule(), + new CfgAttrsModule(), + new BgpModule(), + new BgpExtensionsModule(), + new BgpReadersModule(), + new BgpWritersModule(), + new BgpConfigurationModule()); + + @Before + public void setUp() throws Exception { + SSLContext sslcontext = SSLContexts.custom() + .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"), + CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy()) + .build(); + + SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext); + CloseableHttpClient httpclient = HttpClients.custom() + .setSSLSocketFactory(sslsf) + .build(); + Unirest.setHttpClient(httpclient); + } + + @Test(timeout = 60000) + public void test() throws Exception { + io.fd.honeycomb.infra.bgp.distro.Main.init(BASE_MODULES); + LOG.info("Testing Honeycomb BGP distribution"); + assertBgp(); + } + + private byte[] readMessage(final InputStream inputStream) throws IOException { + final int available = inputStream.available(); + final byte[] msg = new byte[available]; + ByteStreams.read(inputStream, msg, 0, available); + return msg; + } + + private void assertBgp() throws Exception { + // Wait until BGP server is started + Thread.sleep(HELLO_WAIT); + final InetAddress bgpHost = InetAddress.getByName("127.0.0.1"); + final InetAddress bgpPeerAddress = InetAddress.getByName("127.0.0.2"); + try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0); + final InputStream inputStream = localhost.getInputStream()) { + // Wait until bgp message is sent + Thread.sleep(HELLO_WAIT); + + final byte[] msg = readMessage(inputStream); + LOG.info("Received BGP message: {}", msg); + + Assert.assertEquals(BGP_OPEN_MSG_TYPE, msg[BGP_MSG_TYPE_OFFSET]); + } + } +}
\ No newline at end of file diff --git a/infra/bgp-distribution/src/test/resources/WEB-INF/web.xml b/infra/bgp-distribution/src/test/resources/WEB-INF/web.xml new file mode 100644 index 000000000..6cf487170 --- /dev/null +++ b/infra/bgp-distribution/src/test/resources/WEB-INF/web.xml @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + ~ Copyright (c) 2016 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. + --> + +<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> + + <servlet> + <servlet-name>JAXRSRestconf</servlet-name> + <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> + <init-param> + <param-name>javax.ws.rs.Application</param-name> + <param-value>org.opendaylight.netconf.sal.rest.impl.RestconfApplication</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>JAXRSRestconf</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <filter> + <filter-name>cross-origin-restconf</filter-name> + <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class> + <init-param> + <param-name>allowedOrigins</param-name> + <param-value>*</param-value> + </init-param> + <init-param> + <param-name>allowedMethods</param-name> + <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value> + </init-param> + <init-param> + <param-name>allowedHeaders</param-name> + <param-value>origin, content-type, accept, authorization</param-value> + </init-param> + <init-param> + <param-name>exposedHeaders</param-name> + <param-value>location</param-value> + </init-param> + </filter> + <filter-mapping> + <filter-name>cross-origin-restconf</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + + <security-constraint> + <web-resource-collection> + <web-resource-name>NB api</web-resource-name> + <url-pattern>/*</url-pattern> + <http-method>POST</http-method> + <http-method>GET</http-method> + <http-method>PUT</http-method> + <http-method>PATCH</http-method> + <http-method>DELETE</http-method> + <http-method>HEAD</http-method> + </web-resource-collection> + </security-constraint> + +</web-app> diff --git a/infra/minimal-distribution/src/test/resources/bgp-peers.json b/infra/bgp-distribution/src/test/resources/bgp-peers.json index 3a7e01060..3a7e01060 100644 --- a/infra/minimal-distribution/src/test/resources/bgp-peers.json +++ b/infra/bgp-distribution/src/test/resources/bgp-peers.json diff --git a/infra/bgp-distribution/src/test/resources/bgp.json b/infra/bgp-distribution/src/test/resources/bgp.json new file mode 100644 index 000000000..494b6a965 --- /dev/null +++ b/infra/bgp-distribution/src/test/resources/bgp.json @@ -0,0 +1,9 @@ + { + "bgp-enabled": "true", + "bgp-binding-address": "127.0.0.1", + "bgp-port": 1790, + "bgp-as-number": 65000, + "bgp-receive-multiple-paths": "true", + "bgp-send-max-paths": 0, + "bgp-netty-threads": 2 +}
\ No newline at end of file diff --git a/infra/bgp-distribution/src/test/resources/honeycomb-keystore b/infra/bgp-distribution/src/test/resources/honeycomb-keystore Binary files differnew file mode 100644 index 000000000..44093dc09 --- /dev/null +++ b/infra/bgp-distribution/src/test/resources/honeycomb-keystore diff --git a/infra/bgp-distribution/src/test/resources/honeycomb.json b/infra/bgp-distribution/src/test/resources/honeycomb.json new file mode 100644 index 000000000..a0b2a633c --- /dev/null +++ b/infra/bgp-distribution/src/test/resources/honeycomb.json @@ -0,0 +1,40 @@ + { + "persisted-context-path": "/tmp/honeycomb/persist/context/data.json", + "persisted-context-restoration-type": "Merge", + "persisted-config-path": "/tmp/honeycomb/persist/config/data.json", + "persisted-config-restoration-type": "Merge", + + "notification-service-queue-depth": 1, + + "restconf-http-enabled": "true", + "restconf-root-path": "/restconf", + "restconf-binding-address": "127.0.0.1", + "restconf-port": 8182, + "restconf-https-enabled": "true", + "restconf-https-binding-address": "127.0.0.1", + "restconf-https-port": 8444, + "restconf-keystore": "/honeycomb-keystore", + "restconf-keystore-password": "testing", + "restconf-keystore-manager-password": "testing", + "restconf-truststore": "/honeycomb-keystore", + "restconf-truststore-password": "testing", + "restconf-websocket-port": 7780, + "restconf-pool-max-size": 10, + "restconf-pool-min-size": 1, + "restconf-acceptors-size": 1, + "restconf-selectors-size": 1, + "restconf-https-acceptors-size": 1, + "restconf-https-selectors-size": 1, + + "netconf-netty-threads": 2, + "netconf-tcp-enabled" : "true", + "netconf-tcp-binding-address": "127.0.0.1", + "netconf-tcp-binding-port": 7778, + "netconf-ssh-enabled" : "true", + "netconf-ssh-binding-address": "127.0.0.1", + "netconf-ssh-binding-port": 2832, + "netconf-notification-stream-name": "honeycomb", + + "username": "admin", + "password": "admin" +}
\ No newline at end of file diff --git a/infra/bgp-distribution/src/test/resources/logback.xml b/infra/bgp-distribution/src/test/resources/logback.xml new file mode 100644 index 000000000..2ee89db4e --- /dev/null +++ b/infra/bgp-distribution/src/test/resources/logback.xml @@ -0,0 +1,31 @@ + <!-- + ~ Copyright (c) 2016 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. + --> + +<configuration scan="true"> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern> + </encoder> + </appender> + + <root level="warn"> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.opendaylight" level="INFO"/> + <logger name="io.fd" level="INFO"/> +</configuration> diff --git a/infra/minimal-distribution/pom.xml b/infra/minimal-distribution/pom.xml index 342bcf670..637640723 100644 --- a/infra/minimal-distribution/pom.xml +++ b/infra/minimal-distribution/pom.xml @@ -39,10 +39,6 @@ io.fd.honeycomb.infra.distro.netconf.NetconfModule, io.fd.honeycomb.infra.distro.netconf.NetconfReadersModule, io.fd.honeycomb.infra.distro.restconf.RestconfModule, - io.fd.honeycomb.infra.distro.bgp.BgpModule, - io.fd.honeycomb.infra.distro.bgp.BgpExtensionsModule, - io.fd.honeycomb.infra.distro.bgp.BgpReadersModule, - io.fd.honeycomb.infra.distro.bgp.BgpWritersModule, io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule </distribution.modules> </properties> @@ -104,44 +100,6 @@ <groupId>org.opendaylight.netconf</groupId> <artifactId>ietf-netconf-monitoring-extension</artifactId> </dependency> - <!-- ODL-BGP --> - <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> - <!-- BGP extensions --> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-evpn</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-inet</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-labeled-unicast</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-linkstate</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.bgpcep</groupId> - <artifactId>bgp-l3vpn</artifactId> - </dependency> - <!-- Jersey + Jetty for RESTCONF --> <dependency> <groupId>org.eclipse.jetty</groupId> diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java index fc8fb0e0c..4769b570d 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java @@ -31,7 +31,6 @@ import com.google.inject.ProvisionException; import com.google.inject.name.Names; import io.fd.honeycomb.data.init.DataTreeInitializer; import io.fd.honeycomb.data.init.InitializerRegistry; -import io.fd.honeycomb.infra.distro.bgp.BgpServerProvider; import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; import io.fd.honeycomb.infra.distro.initializer.InitializerPipelineModule; import io.fd.honeycomb.infra.distro.netconf.HoneycombNotification2NetconfProvider; @@ -120,11 +119,6 @@ public final class Main { injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class); } - if (cfgAttributes.isBgpEnabled()) { - LOG.info("Starting BGP"); - injector.getInstance(BgpServerProvider.BgpServer.class); - } - try { LOG.info("Initializing configuration"); injector.getInstance(Key.get(InitializerRegistry.class, diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java index c3d406c9f..cc46f7b8e 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java @@ -55,10 +55,6 @@ public class HoneycombConfiguration { return isNetconfTcpEnabled() || isNetconfSshEnabled(); } - public boolean isBgpEnabled() { - return Boolean.valueOf(bgpEnabled); - } - public boolean isConfigPersistenceEnabled() { return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get()); } @@ -66,10 +62,6 @@ public class HoneycombConfiguration { return persistContext.isPresent() && Boolean.valueOf(persistContext.get()); } - public boolean isBgpMultiplePathsEnabled() { - return Boolean.valueOf(bgpMultiplePaths.get()); - } - @InjectConfig("persist-context") public Optional<String> persistContext = Optional.of("true"); @InjectConfig("persisted-context-path") @@ -146,20 +138,6 @@ public class HoneycombConfiguration { public Optional<Integer> netconfSshBindingPort; @InjectConfig("netconf-notification-stream-name") public Optional<String> netconfNotificationStreamName = Optional.of("honeycomb"); - @InjectConfig("bgp-enabled") - public String bgpEnabled; - @InjectConfig("bgp-binding-address") - public Optional<String> bgpBindingAddress; - @InjectConfig("bgp-port") - public Optional<Integer> bgpPort; - @InjectConfig("bgp-as-number") - public Optional<Integer> bgpAsNumber; - @InjectConfig("bgp-receive-multiple-paths") - public Optional<String> bgpMultiplePaths; - @InjectConfig("bgp-send-max-paths") - public Optional<Integer> bgpSendMaxMaths; - @InjectConfig("bgp-netty-threads") - public Integer bgpNettyThreads; @InjectConfig("username") public String username; @InjectConfig("password") @@ -200,13 +178,6 @@ public class HoneycombConfiguration { .add("netconfSshBindingAddress", netconfSshBindingAddress) .add("netconfSshBindingPort", netconfSshBindingPort) .add("netconfNotificationStreamName", netconfNotificationStreamName) - .add("bgpEnabled", bgpEnabled) - .add("bgpBindingAddress", bgpBindingAddress) - .add("bgpPort", bgpPort) - .add("bgp-as-number", bgpAsNumber) - .add("bgp-netty-threads", bgpNettyThreads) - .add("bgp-receive-multiple-paths", bgpMultiplePaths) - .add("bgp-send-max-paths", bgpSendMaxMaths) .add("username", username) .add("password", password) .toString(); diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json index 95ab71292..1199f85bc 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json +++ b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json @@ -1,8 +1,8 @@ { - "persist-context": "false", + "persist-context": "true", "persisted-context-path": "/var/lib/honeycomb/persist/context/data.json", "persisted-context-restoration-type": "Merge", - "persist-config": "false", + "persist-config": "true", "persisted-config-path": "/var/lib/honeycomb/persist/config/data.json", "persisted-config-restoration-type": "Merge", @@ -37,14 +37,6 @@ "netconf-ssh-binding-port": 2831, "netconf-notification-stream-name": "honeycomb", - "bgp-enabled": "true", - "bgp-binding-address": "127.0.0.1", - "bgp-port": 1790, - "bgp-as-number": 65000, - "bgp-receive-multiple-paths": "true", - "bgp-send-max-paths": 0, - "bgp-netty-threads": 2, - "username": "admin", "password": "admin" }
\ No newline at end of file diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/logback.xml b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/logback.xml index 02e801d00..6dd4d4fc0 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/logback.xml +++ b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/logback.xml @@ -6,10 +6,10 @@ </encoder> </appender> <appender name="honeycomb.log" class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>honeycomb.log</file> + <file>/var/log/honeycomb/honeycomb.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> - <fileNamePattern>logs/honeycomb.%d.log.zip</fileNamePattern> + <fileNamePattern>/var/log/honeycomb/logs/honeycomb.%d.log.zip</fileNamePattern> <maxHistory>1</maxHistory> </rollingPolicy> diff --git a/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java b/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java index fdd265b79..ced29590b 100644 --- a/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java +++ b/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java @@ -18,7 +18,6 @@ package io.fd.honeycomb.infra.distro; import static com.google.common.collect.ImmutableSet.of; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -31,10 +30,6 @@ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; -import io.fd.honeycomb.infra.distro.bgp.BgpExtensionsModule; -import io.fd.honeycomb.infra.distro.bgp.BgpModule; -import io.fd.honeycomb.infra.distro.bgp.BgpReadersModule; -import io.fd.honeycomb.infra.distro.bgp.BgpWritersModule; import io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule; import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule; @@ -46,7 +41,6 @@ import io.fd.honeycomb.infra.distro.schema.SchemaModule; import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule; import java.io.IOException; import java.io.InputStream; -import java.net.InetAddress; import java.net.Socket; import java.util.Properties; import java.util.Set; @@ -75,36 +69,28 @@ public class BaseMinimalDistributionTest { private static final String NETCONF_NAMESPACE = "urn:ietf:params:xml:ns:netconf:base:1.0"; private static final int HELLO_WAIT = 2500; - private static final int BGP_MSG_TYPE_OFFSET = 18; // 16 (MARKER) + 2 (LENGTH); - private static final byte BGP_OPEN_MSG_TYPE = 1; - private static final int BGP_PORT = 1790; - public static final Set<Module> BASE_MODULES = of( - new YangBindingProviderModule(), - new SchemaModule(), - new ConfigAndOperationalPipelineModule(), - new ContextPipelineModule(), - new InitializerPipelineModule(), - new NetconfModule(), - new NetconfReadersModule(), - new RestconfModule(), - new BgpModule(), - new BgpExtensionsModule(), - new BgpReadersModule(), - new BgpWritersModule(), - new CfgAttrsModule()); + new YangBindingProviderModule(), + new SchemaModule(), + new ConfigAndOperationalPipelineModule(), + new ContextPipelineModule(), + new InitializerPipelineModule(), + new NetconfModule(), + new NetconfReadersModule(), + new RestconfModule(), + new CfgAttrsModule()); @Before public void setUp() throws Exception { SSLContext sslcontext = SSLContexts.custom() - .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"), - CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy()) - .build(); + .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"), + CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy()) + .build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext); CloseableHttpClient httpclient = HttpClients.custom() - .setSSLSocketFactory(sslsf) - .build(); + .setSSLSocketFactory(sslsf) + .build(); Unirest.setHttpClient(httpclient); } @@ -124,8 +110,6 @@ public class BaseMinimalDistributionTest { assertRestconfHttp(); LOG.info("Testing RESTCONF HTTPS"); assertRestconfHttps(); - LOG.info("Testing BGP"); - assertBgp(); } private void assertNetconfTcp() throws Exception { @@ -182,13 +166,13 @@ public class BaseMinimalDistributionTest { private void assertRestconfHttp() throws Exception { final String url = - "http://127.0.0.1:" + HTTP_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state"; + "http://127.0.0.1:" + HTTP_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state"; LOG.info("RESTCONF HTTP GET to {}", url); final HttpResponse<String> jsonNodeHttpResponse = Unirest.get(url) - .basicAuth(UNAME, PASSWORD) - .asString(); + .basicAuth(UNAME, PASSWORD) + .asString(); LOG.info("RESTCONF HTTP GET to {}, status: {}, data: {}", - url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody()); + url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody()); assertSuccessStatus(jsonNodeHttpResponse); assertSuccessResponseForNetconfMonitoring(jsonNodeHttpResponse); @@ -196,13 +180,13 @@ public class BaseMinimalDistributionTest { private void assertRestconfHttps() throws Exception { final String url = - "https://127.0.0.1:" + HTTPS_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state"; + "https://127.0.0.1:" + HTTPS_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state"; LOG.info("RESTCONF HTTPS GET to {}", url); final HttpResponse<String> jsonNodeHttpResponse = Unirest.get(url) - .basicAuth(UNAME, PASSWORD) - .asString(); + .basicAuth(UNAME, PASSWORD) + .asString(); LOG.info("RESTCONF HTTPS GET to {}, status: {}, data: {}", - url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody()); + url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody()); assertSuccessStatus(jsonNodeHttpResponse); assertSuccessResponseForNetconfMonitoring(jsonNodeHttpResponse); @@ -217,19 +201,4 @@ public class BaseMinimalDistributionTest { assertTrue(jsonNodeHttpResponse.getStatus() >= 200); assertTrue(jsonNodeHttpResponse.getStatus() < 400); } - - private void assertBgp() throws Exception { - final InetAddress bgpHost = InetAddress.getByName("127.0.0.1"); - final InetAddress bgpPeerAddress = InetAddress.getByName("127.0.0.2"); - try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0); - final InputStream inputStream = localhost.getInputStream()) { - // wait until bgp message is sent - Thread.sleep(HELLO_WAIT); - - final byte[] msg = readMessage(inputStream); - LOG.info("Received BGP message: {}", msg); - - assertEquals(BGP_OPEN_MSG_TYPE, msg[BGP_MSG_TYPE_OFFSET]); - } - } }
\ No newline at end of file diff --git a/infra/minimal-distribution/src/test/resources/honeycomb.json b/infra/minimal-distribution/src/test/resources/honeycomb.json index be627747b..a0b2a633c 100644 --- a/infra/minimal-distribution/src/test/resources/honeycomb.json +++ b/infra/minimal-distribution/src/test/resources/honeycomb.json @@ -35,14 +35,6 @@ "netconf-ssh-binding-port": 2832, "netconf-notification-stream-name": "honeycomb", - "bgp-enabled": "true", - "bgp-binding-address": "127.0.0.1", - "bgp-port": 1790, - "bgp-as-number": 65000, - "bgp-receive-multiple-paths": "true", - "bgp-send-max-paths": 0, - "bgp-netty-threads": 2, - "username": "admin", "password": "admin" }
\ No newline at end of file diff --git a/infra/pom.xml b/infra/pom.xml index a32defa7d..1a49fbad6 100644 --- a/infra/pom.xml +++ b/infra/pom.xml @@ -41,6 +41,7 @@ <module>cfg-init</module> <module>impl</module> <module>minimal-distribution</module> + <module>bgp-distribution</module> <module>it</module> <module>test-utils</module> <module>rpc</module> diff --git a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java index c9be4ae54..f06e6ae2f 100644 --- a/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java +++ b/infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java @@ -33,9 +33,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; /** * Simple DataBroker backed writer allowing to delegate writes to different brokers. */ -public final class BindingBrokerWriter<D extends DataObject> - implements Writer<D> { - +public final class BindingBrokerWriter<D extends DataObject> implements Writer<D> { private final InstanceIdentifier<D> instanceIdentifier; private final DataBroker dataBroker; |