summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java5
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java9
-rw-r--r--infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfSshServerProvider.java10
-rw-r--r--infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfTcpServerProvider.java10
4 files changed, 9 insertions, 25 deletions
diff --git a/infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java b/infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java
index 93dddf113..d2dc51af5 100644
--- a/infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java
+++ b/infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertTrue;
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
+import com.google.common.net.InetAddresses;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
@@ -108,8 +109,8 @@ public class BgpDistributionTest {
}
private void assertBgpOpenIsSent(final String peerAddress) throws IOException, InterruptedException {
- final InetAddress bgpHost = InetAddress.getByName(BGP_HOST_ADDRESS);
- final InetAddress bgpPeerAddress = InetAddress.getByName(peerAddress);
+ final InetAddress bgpHost = InetAddresses.forString(BGP_HOST_ADDRESS);
+ final InetAddress bgpPeerAddress = InetAddresses.forString(peerAddress);
try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0);
final InputStream inputStream = localhost.getInputStream()) {
// Wait until bgp message is sent
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 876a39f14..5f9104cf1 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
@@ -17,6 +17,7 @@
package io.fd.honeycomb.infra.bgp;
import com.google.common.base.Preconditions;
+import com.google.common.net.InetAddresses;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
import io.netty.channel.Channel;
@@ -26,7 +27,6 @@ import io.netty.channel.epoll.Epoll;
import io.netty.channel.epoll.EpollChannelOption;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
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.BGPSessionPreferences;
@@ -49,12 +49,7 @@ public final class BgpServerProvider extends ProviderTrait<BgpServerProvider.Bg
@Override
protected BgpServer create() {
// code based on org.opendaylight.controller.config.yang.bgp.rib.impl.BGPPeerAcceptorModule from Boron-SR3
- final InetAddress bindingAddress;
- try {
- bindingAddress = InetAddress.getByName(cfg.bgpBindingAddress.get());
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Illegal BGP binding address", e);
- }
+ final InetAddress bindingAddress = InetAddresses.forString(cfg.bgpBindingAddress.get());
final InetSocketAddress address = new InetSocketAddress(bindingAddress, cfg.bgpPort.get());
LOG.debug("Creating BgpServer for {}", address);
final ChannelFuture localServer = dispatcher.createServer(address);
diff --git a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfSshServerProvider.java b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfSshServerProvider.java
index d44b4f221..02847d733 100644
--- a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfSshServerProvider.java
+++ b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfSshServerProvider.java
@@ -16,6 +16,7 @@
package io.fd.honeycomb.northbound.netconf;
+import com.google.common.net.InetAddresses;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
@@ -30,7 +31,6 @@ import io.netty.util.concurrent.GlobalEventExecutor;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
@@ -74,13 +74,7 @@ public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServ
// TODO(HONEYCOMB-414): the logic below is very similar to
// org.opendaylight.netconf.ssh.NetconfNorthboundSshServer (introduced in Carbon), so consider reusing it
// (requires fixing hardcoded private key path).
- InetAddress sshBindingAddress = null;
- try {
- sshBindingAddress = InetAddress.getByName(cfgAttributes.netconfSshBindingAddress.get());
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Illegal binding address", e);
- }
-
+ final InetAddress sshBindingAddress = InetAddresses.forString(cfgAttributes.netconfSshBindingAddress.get());
final InetSocketAddress bindingAddress =
new InetSocketAddress(sshBindingAddress, cfgAttributes.netconfSshBindingPort.get());
diff --git a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfTcpServerProvider.java b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfTcpServerProvider.java
index c1fc0a594..031f0f9d9 100644
--- a/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfTcpServerProvider.java
+++ b/infra/northbound/netconf/src/main/java/io/fd/honeycomb/northbound/netconf/NetconfTcpServerProvider.java
@@ -16,6 +16,7 @@
package io.fd.honeycomb.northbound.netconf;
+import com.google.common.net.InetAddresses;
import com.google.inject.Inject;
import io.fd.honeycomb.binding.init.ProviderTrait;
import io.fd.honeycomb.infra.distro.InitializationException;
@@ -24,7 +25,6 @@ import io.netty.channel.ChannelFuture;
import io.netty.util.concurrent.GenericFutureListener;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
import org.opendaylight.netconf.api.NetconfServerDispatcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,13 +45,7 @@ public final class NetconfTcpServerProvider extends ProviderTrait<NetconfTcpServ
return null;
}
LOG.info("Starting NETCONF TCP");
- InetAddress name = null;
- try {
- name = InetAddress.getByName(cfgAttributes.netconfTcpBindingAddress.get());
- } catch (UnknownHostException e) {
- throw new IllegalArgumentException("Illegal binding address", e);
- }
-
+ final InetAddress name = InetAddresses.forString(cfgAttributes.netconfTcpBindingAddress.get());
final InetSocketAddress unresolved = new InetSocketAddress(name, cfgAttributes.netconfTcpBindingPort.get());
ChannelFuture tcpServer = dispatcher.createServer(unresolved);