From daa96894dce0ce1a72b4706c64d681e29b4f6cb8 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Apr 2023 11:24:15 +0200 Subject: [PATCH] Remove netconf.util.NetconfConfiguration This class is not really used, nor is the configuration file. Remove the interface and all implementation details. Change-Id: I8d8458c96509fb21c9f9bac7cf59d3567277ceb3 Signed-off-by: Robert Varga --- artifacts/pom.xml | 7 -- features/netconf/odl-netconf-util/pom.xml | 7 -- .../src/main/feature/feature.xml | 3 - .../opendaylight/netconf/ssh/EchoServer.java | 3 +- .../opendaylight/netconf/ssh/ProxyServer.java | 3 +- .../netconf/ssh/SSHServerTest.java | 4 +- .../org/opendaylight/netconf/ssh/SSHTest.java | 4 +- protocol/netconf-util/pom.xml | 30 ----- .../netconf/util/NetconfConfiguration.java | 50 -------- .../util/NetconfConfigurationHolder.java | 38 ------ .../util/NetconfConfigurationImpl.java | 111 ------------------ .../src/main/resources/netconf.cfg | 10 -- 12 files changed, 6 insertions(+), 264 deletions(-) delete mode 100644 protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfiguration.java delete mode 100644 protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationHolder.java delete mode 100644 protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationImpl.java delete mode 100644 protocol/netconf-util/src/main/resources/netconf.cfg diff --git a/artifacts/pom.xml b/artifacts/pom.xml index 8e734a8629..56dcf9877e 100644 --- a/artifacts/pom.xml +++ b/artifacts/pom.xml @@ -105,13 +105,6 @@ netconf-util ${project.version} - - ${project.groupId} - netconf-util - ${project.version} - config - cfg - ${project.groupId} sal-netconf-connector diff --git a/features/netconf/odl-netconf-util/pom.xml b/features/netconf/odl-netconf-util/pom.xml index 0b519d079a..a301a4ddf5 100644 --- a/features/netconf/odl-netconf-util/pom.xml +++ b/features/netconf/odl-netconf-util/pom.xml @@ -30,12 +30,5 @@ org.opendaylight.netconf netconf-util - - - org.opendaylight.netconf - netconf-util - cfg - config - diff --git a/features/netconf/odl-netconf-util/src/main/feature/feature.xml b/features/netconf/odl-netconf-util/src/main/feature/feature.xml index ffad979398..7ea41309d0 100644 --- a/features/netconf/odl-netconf-util/src/main/feature/feature.xml +++ b/features/netconf/odl-netconf-util/src/main/feature/feature.xml @@ -8,9 +8,6 @@ --> - - mvn:org.opendaylight.netconf/netconf-util/${project.version}/cfg/config - odl-yangtools-codec diff --git a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java index 6013f77ec4..55711776cc 100644 --- a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java +++ b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java @@ -21,7 +21,6 @@ import io.netty.handler.logging.LoggingHandler; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import org.opendaylight.netconf.util.NetconfConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +49,7 @@ public class EchoServer implements Runnable { }); // Start the server. - LocalAddress localAddress = NetconfConfiguration.NETCONF_LOCAL_ADDRESS; + LocalAddress localAddress = new LocalAddress("netconf"); ChannelFuture future = bootstrap.bind(localAddress).sync(); // Wait until the server socket is closed. diff --git a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java index 50bb8b29ee..7283fe2f14 100644 --- a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java +++ b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java @@ -20,7 +20,6 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.logging.LogLevel; import io.netty.handler.logging.LoggingHandler; import java.net.InetSocketAddress; -import org.opendaylight.netconf.util.NetconfConfiguration; public class ProxyServer implements Runnable { private final ProxyHandlerFactory proxyHandlerFactory; @@ -35,7 +34,7 @@ public class ProxyServer implements Runnable { final EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { - final LocalAddress localAddress = NetconfConfiguration.NETCONF_LOCAL_ADDRESS; + final LocalAddress localAddress = new LocalAddress("netconf"); ServerBootstrap serverBootstrap = new ServerBootstrap(); serverBootstrap.group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class) diff --git a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java index ff085de5c5..15c418de33 100644 --- a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java +++ b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java @@ -8,6 +8,7 @@ package org.opendaylight.netconf.ssh; import io.netty.channel.EventLoopGroup; +import io.netty.channel.local.LocalAddress; import io.netty.channel.nio.NioEventLoopGroup; import java.io.File; import java.net.InetSocketAddress; @@ -23,7 +24,6 @@ import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture; import org.opendaylight.netconf.shaded.sshd.client.future.ConnectFuture; import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession; import org.opendaylight.netconf.shaded.sshd.common.util.security.SecurityUtils; -import org.opendaylight.netconf.util.NetconfConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +51,7 @@ public class SSHServerTest { final InetSocketAddress addr = InetSocketAddress.createUnresolved(HOST, PORT); server = new SshProxyServer(minaTimerEx, clientGroup, nioExec); server.bind(new SshProxyServerConfigurationBuilder() - .setBindingAddress(addr).setLocalAddress(NetconfConfiguration.NETCONF_LOCAL_ADDRESS) + .setBindingAddress(addr).setLocalAddress(new LocalAddress("netconf")) .setAuthenticator((username, password) -> true) .setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(sshKeyPair.toPath())) .setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration()); diff --git a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java index 5673c592db..d39c429ae3 100644 --- a/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java +++ b/netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java @@ -15,6 +15,7 @@ import com.google.common.base.Stopwatch; import io.netty.bootstrap.Bootstrap; import io.netty.channel.ChannelInitializer; import io.netty.channel.EventLoopGroup; +import io.netty.channel.local.LocalAddress; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.HashedWheelTimer; @@ -32,7 +33,6 @@ import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswo import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler; import org.opendaylight.netconf.shaded.sshd.common.util.security.SecurityUtils; import org.opendaylight.netconf.ssh.EchoClientHandler.State; -import org.opendaylight.netconf.util.NetconfConfiguration; public class SSHTest { public static final String AHOJ = "ahoj\n"; @@ -67,7 +67,7 @@ public class SSHTest { final InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 10831); try (var sshProxyServer = new SshProxyServer(minaTimerEx, nettyGroup, nioExec)) { sshProxyServer.bind(new SshProxyServerConfigurationBuilder() - .setBindingAddress(addr).setLocalAddress(NetconfConfiguration.NETCONF_LOCAL_ADDRESS) + .setBindingAddress(addr).setLocalAddress(new LocalAddress("netconf")) .setAuthenticator((username, password) -> true) .setKeyPairProvider(SecurityUtils.createGeneratorHostKeyProvider(sshKeyPair.toPath())) .setIdleTimeout(Integer.MAX_VALUE).createSshProxyServerConfiguration()); diff --git a/protocol/netconf-util/pom.xml b/protocol/netconf-util/pom.xml index c91b0b2f46..8fd220244a 100644 --- a/protocol/netconf-util/pom.xml +++ b/protocol/netconf-util/pom.xml @@ -82,14 +82,6 @@ org.opendaylight.netconf netconf-api - - org.osgi - org.osgi.service.component.annotations - - - org.osgi - org.osgi.service.metatype.annotations - org.opendaylight.yangtools @@ -123,28 +115,6 @@ org.apache.felix maven-bundle-plugin - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/netconf.cfg - cfg - config - - - - - - maven-jar-plugin diff --git a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfiguration.java b/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfiguration.java deleted file mode 100644 index 6cada7f7ee..0000000000 --- a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfiguration.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017 Inocybe Technologies and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.netconf.util; - -import io.netty.channel.local.LocalAddress; -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; - -/** - * Configuration for NETCONF northbound. - */ -public interface NetconfConfiguration { - - /** - * LocalAddress constant for NETCONF northbound. - */ - LocalAddress NETCONF_LOCAL_ADDRESS = new LocalAddress("netconf"); - - /** - * Default timeout for NETCONF northbound connections. - */ - long DEFAULT_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(30); - - /** - * NETCONF SSH server address. - * - * @return NETCONF SSH server address - */ - InetSocketAddress getSshServerAddress(); - - /** - * NETCONF TCP server address. - * - * @return NETCONF TCP server address. - */ - InetSocketAddress getTcpServerAddress(); - - /** - * Private key path for NETCONF. - * - * @return Private key path for NETCONF. - */ - String getPrivateKeyPath(); -} diff --git a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationHolder.java b/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationHolder.java deleted file mode 100644 index 28f2b87c48..0000000000 --- a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationHolder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.netconf.util; - -import java.net.InetSocketAddress; - -final class NetconfConfigurationHolder { - - private final InetSocketAddress tcpServerAddress; - private final InetSocketAddress sshServerAddress; - private final String privateKeyPath; - - NetconfConfigurationHolder(final InetSocketAddress tcpServerAddress, - final InetSocketAddress sshServerAddress, - final String privateKeyPath) { - this.tcpServerAddress = tcpServerAddress; - this.sshServerAddress = sshServerAddress; - this.privateKeyPath = privateKeyPath; - } - - String getPrivateKeyPath() { - return privateKeyPath; - } - - InetSocketAddress getSshServerAddress() { - return sshServerAddress; - } - - InetSocketAddress getTcpServerAddress() { - return tcpServerAddress; - } -} diff --git a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationImpl.java b/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationImpl.java deleted file mode 100644 index 6c440a3901..0000000000 --- a/protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/NetconfConfigurationImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.util; - -import java.lang.annotation.Annotation; -import java.net.InetSocketAddress; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.osgi.service.metatype.annotations.AttributeDefinition; -import org.osgi.service.metatype.annotations.Designate; -import org.osgi.service.metatype.annotations.ObjectClassDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Component(immediate = true, configurationPid = "netconf") -@Designate(ocd = NetconfConfigurationImpl.Configuration.class) -public class NetconfConfigurationImpl implements NetconfConfiguration { - @ObjectClassDefinition - public @interface Configuration { - @AttributeDefinition(name = "tcp-address") - String tcpAddress() default "127.0.0.1"; - @AttributeDefinition(name = "tcp-port", min = "0", max = "65535") - int tcpPort() default 8383; - @AttributeDefinition(name = "ssh-address") - String sshAddress() default "0.0.0.0"; - @AttributeDefinition(name = "ssh-port", min = "0", max = "65535") - int sshPort() default 1830; - @AttributeDefinition(name = "sshpk-path") - String sshPrivateKeyPath() default "./configuration/RSA.pk"; - } - - private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigurationImpl.class); - - private NetconfConfigurationHolder netconfConfiguration; - - public NetconfConfigurationImpl() { - // for DI - } - - public NetconfConfigurationImpl(final String tcpServerAddress, final int tcpServerPort, - final String sshServerAddress, final int sshServerPort, - final String privateKeyPath) { - activate(new Configuration() { - @Override - public Class annotationType() { - return Configuration.class; - } - - @Override - public String tcpAddress() { - return tcpServerAddress; - } - - @Override - public int tcpPort() { - return tcpServerPort; - } - - @Override - public String sshAddress() { - return sshServerAddress; - } - - @Override - public int sshPort() { - return sshServerPort; - } - - @Override - public String sshPrivateKeyPath() { - return privateKeyPath; - } - }); - } - - @Activate - void activate(final Configuration config) { - final InetSocketAddress sshServerAddress = new InetSocketAddress(config.sshAddress(), config.sshPort()); - final InetSocketAddress tcpServerAddress = new InetSocketAddress(config.tcpAddress(), config.tcpPort()); - - netconfConfiguration = new NetconfConfigurationHolder(tcpServerAddress, sshServerAddress, - config.sshPrivateKeyPath()); - LOG.debug("CSS netconf server configuration was updated"); - } - - @Deactivate - void deactivate(final Configuration config) { - netconfConfiguration = null; - } - - @Override - public InetSocketAddress getSshServerAddress() { - return netconfConfiguration.getSshServerAddress(); - } - - @Override - public InetSocketAddress getTcpServerAddress() { - return netconfConfiguration.getTcpServerAddress(); - } - - @Override - public String getPrivateKeyPath() { - return netconfConfiguration.getPrivateKeyPath(); - } -} diff --git a/protocol/netconf-util/src/main/resources/netconf.cfg b/protocol/netconf-util/src/main/resources/netconf.cfg deleted file mode 100644 index 01d92ec636..0000000000 --- a/protocol/netconf-util/src/main/resources/netconf.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# netconf-tcp: -#tcp-address=127.0.0.1 -#tcp-port=8383 - -# netconf-ssh: -#ssh-address=0.0.0.0 -#ssh-port=1830 - -# Use Linux style path -#ssh-pk-path = ./configuration/RSA.pk \ No newline at end of file -- 2.36.6