From d28000626470afb327872660849da79869fdf310 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 14 Jul 2017 09:31:18 +0200 Subject: HONEYCOMB-370: make bgp peers configuration optional Change-Id: I459425f4ee8f43d0bf196d2c762e741c58667907 Signed-off-by: Marek Gradzki --- .../java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'infra/northbound/bgp/src/main/java/io') diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java index 9356b32b4..f79afc9a2 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java @@ -17,7 +17,6 @@ package io.fd.honeycomb.infra.bgp; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; import static io.fd.honeycomb.translate.util.JsonUtils.readContainerEntryJson; import static org.opendaylight.protocol.bgp.openconfig.impl.util.OpenConfigUtil.APPLICATION_PEER_GROUP_NAME; import static org.opendaylight.yangtools.sal.binding.generator.impl.BindingSchemaContextUtils.findDataNodeContainer; @@ -26,6 +25,7 @@ import com.google.common.base.Optional; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; import java.io.InputStream; +import java.util.Collections; import java.util.Map; import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; @@ -40,6 +40,7 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNe 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.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.NeighborsBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey; @@ -94,7 +95,10 @@ final class BgpNeighboursProvider extends ProviderTrait { 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); + if (resourceStream == null) { + LOG.warn("Unable to open {}. Skipping BGP neighbour configuration.", PEERS_CFG); + return new NeighborsBuilder().setNeighbor(Collections.emptyList()).build(); + } final InstanceIdentifier bgpII = InstanceIdentifier.create(NetworkInstances.class) .child(NetworkInstance.class, new NetworkInstanceKey("dummy-value")).child(Protocols.class) -- cgit 1.2.3-korg