Make netconf node tcp-only leaf have default value 37/80137/3
authorJakub Morvay <jmorvay@frinx.io>
Sat, 2 Feb 2019 17:40:27 +0000 (18:40 +0100)
committerJakub Morvay <jakub.morvay@gmail.com>
Mon, 4 Feb 2019 19:54:23 +0000 (19:54 +0000)
Netconf node tcp-only leaf defines if we should use SSH or TCP as an
underlying protocol for netconf session to a netconf device.

Currently it does not have any default value defined. That means if we
forgot to fill in tcp-only field when configuring netconf mount point,
netconf topology implementation will not know what protocol to use and
will throw NPE. However, it would be more user friendly to have some
default protocol defined. We should aim to use SSH by default as it is
more secure protocol than just plain TCP.

Make tcp-only field default to false.

JIRA: NETCONF-488
Change-Id: I99d17ad54db55089b9ec3e417d69e711058c760a
Signed-off-by: Jakub Morvay <jmorvay@frinx.io>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/RemoteDeviceConnectorImpl.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/utils/NetconfTopologyUtils.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/AbstractNetconfTopology.java
netconf/sal-netconf-connector/src/main/yang/netconf-node-topology.yang

index 8ff961885e0c027cb215427d8e3fe7a222725c9f..6c05cf1fd53b190b2cb55f61a02b6ca0a75be65a 100644 (file)
@@ -109,7 +109,6 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
         final NodeId nodeId = netconfTopologyDeviceSetup.getNode().getNodeId();
         Preconditions.checkNotNull(netconfNode.getHost());
         Preconditions.checkNotNull(netconfNode.getPort());
-        Preconditions.checkNotNull(netconfNode.isTcpOnly());
 
         this.deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode, deviceHandler);
         final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
@@ -276,6 +275,8 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
                 ? NetconfTopologyUtils.DEFAULT_MAX_CONNECTION_ATTEMPTS : node.getMaxConnectionAttempts();
         final int betweenAttemptsTimeoutMillis = node.getBetweenAttemptsTimeoutMillis() == null
                 ? NetconfTopologyUtils.DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS : node.getBetweenAttemptsTimeoutMillis();
+        final boolean isTcpOnly = node.isTcpOnly() == null
+                ? NetconfTopologyUtils.DEFAULT_IS_TCP_ONLY : node.isTcpOnly();
         final BigDecimal sleepFactor = node.getSleepFactor() == null
                 ? NetconfTopologyUtils.DEFAULT_SLEEP_FACTOR : node.getSleepFactor();
 
@@ -288,7 +289,7 @@ public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
 
         final NetconfReconnectingClientConfigurationBuilder reconnectingClientConfigurationBuilder;
         final Protocol protocol = node.getProtocol();
-        if (node.isTcpOnly()) {
+        if (isTcpOnly) {
             reconnectingClientConfigurationBuilder = NetconfReconnectingClientConfigurationBuilder.create()
                     .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP)
                     .withAuthHandler(getHandlerFromCredentials(node.getCredentials()));
index 4f70d88a7dc88111ddf329adec070554c180f530..1b7cd2be30d9a177f0538504100b6aefd6b14408 100644 (file)
@@ -53,6 +53,7 @@ public final class NetconfTopologyUtils {
     public static final long DEFAULT_REQUEST_TIMEOUT_MILLIS = 60000L;
     public static final int DEFAULT_KEEPALIVE_DELAY = 0;
     public static final boolean DEFAULT_RECONNECT_ON_CHANGED_SCHEMA = false;
+    public static final boolean DEFAULT_IS_TCP_ONLY = false;
     public static final int DEFAULT_CONCURRENT_RPC_LIMIT = 0;
     public static final int DEFAULT_MAX_CONNECTION_ATTEMPTS = 0;
     public static final int DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS = 2000;
index a625dd3a49bd3e7077b0813bd9b06b7d899a3843..3bb3fcf68250099a32dc5595499d5cf31a7d7a38 100644 (file)
@@ -101,6 +101,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
     protected static final int DEFAULT_KEEPALIVE_DELAY = 0;
     protected static final boolean DEFAULT_RECONNECT_ON_CHANGED_SCHEMA = false;
     protected static final int DEFAULT_CONCURRENT_RPC_LIMIT = 0;
+    private static final boolean DEFAULT_IS_TCP_ONLY = false;
     private static final int DEFAULT_MAX_CONNECTION_ATTEMPTS = 0;
     private static final int DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS = 2000;
     private static final long DEFAULT_CONNECTION_TIMEOUT_MILLIS = 20000L;
@@ -263,7 +264,6 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
 
         Preconditions.checkNotNull(netconfNode.getHost());
         Preconditions.checkNotNull(netconfNode.getPort());
-        Preconditions.checkNotNull(netconfNode.isTcpOnly());
 
         final NetconfConnectorDTO deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode);
         final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
@@ -477,6 +477,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
                 ? DEFAULT_MAX_CONNECTION_ATTEMPTS : node.getMaxConnectionAttempts();
         final int betweenAttemptsTimeoutMillis = node.getBetweenAttemptsTimeoutMillis() == null
                 ? DEFAULT_BETWEEN_ATTEMPTS_TIMEOUT_MILLIS : node.getBetweenAttemptsTimeoutMillis();
+        final boolean useTcp = node.isTcpOnly() == null ? DEFAULT_IS_TCP_ONLY : node.isTcpOnly();
         final BigDecimal sleepFactor = node.getSleepFactor() == null ? DEFAULT_SLEEP_FACTOR : node.getSleepFactor();
 
         final InetSocketAddress socketAddress = getSocketAddress(node.getHost(), node.getPort().getValue());
@@ -486,7 +487,7 @@ public abstract class AbstractNetconfTopology implements NetconfTopology {
 
         final NetconfReconnectingClientConfigurationBuilder reconnectingClientConfigurationBuilder;
         final Protocol protocol = node.getProtocol();
-        if (node.isTcpOnly()) {
+        if (useTcp) {
             reconnectingClientConfigurationBuilder = NetconfReconnectingClientConfigurationBuilder.create()
                     .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.TCP)
                     .withAuthHandler(getHandlerFromCredentials(node.getCredentials()));
index 78fb0422e41ac4c269e8d0ac0c6e4ddf662b370b..143cc2a3b2a5438c0575e4db1eafc0844c0cf924 100644 (file)
@@ -79,6 +79,7 @@ module netconf-node-topology {
         leaf tcp-only {
             config true;
             type boolean;
+            default false;
         }
 
         container protocol {