<artifactId>netconf-util</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>netconf-util</artifactId>
- <version>${project.version}</version>
- <classifier>config</classifier>
- <type>cfg</type>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sal-netconf-connector</artifactId>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-util</artifactId>
</dependency>
- <dependency>
- <!-- finalname="etc/netconf.cfg" -->
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-util</artifactId>
- <type>cfg</type>
- <classifier>config</classifier>
- </dependency>
</dependencies>
</project>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="odl-netconf-${project.version}">
<feature name="odl-netconf-util" version="${project.version}">
- <configfile finalname="etc/netconf.cfg">
- mvn:org.opendaylight.netconf/netconf-util/${project.version}/cfg/config
- </configfile>
<feature version="[10,11)">odl-yangtools-codec</feature>
</feature>
</features>
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;
});
// 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.
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;
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)
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;
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;
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());
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;
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";
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());
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.metatype.annotations</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/netconf.cfg</file>
- <type>cfg</type>
- <classifier>config</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
+++ /dev/null
-/*
- * 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();
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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<? extends Annotation> 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();
- }
-}
+++ /dev/null
-# 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