Obsolete non-transport ssh-host-key 82/110082/7
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 29 Jan 2024 17:20:33 +0000 (18:20 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 31 Jan 2024 08:52:58 +0000 (09:52 +0100)
Update the model layout to make 'transport' choice mandatory and
make ssh-host-key obsolete.

JIRA: NETCONF-1243
Change-Id: I178d5d8d7858d6c4074214ac8cce598f5c2b6ec1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountSshAuthProvider.java
apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeMountStatusReporter.java
apps/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/tls/CallHomeMountTlsAuthProvider.java
netconf/callhome-model/src/main/yang/odl-netconf-callhome-server.yang

index c1df4d4def4d00f7c1ab53b993c9081dc89fc92c..d4a5857f2808ae93470dced180e7789d8bc60828 100644 (file)
@@ -26,14 +26,13 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.netconf.callhome.server.ssh.CallHomeSshAuthProvider;
 import org.opendaylight.netconf.callhome.server.ssh.CallHomeSshAuthSettings;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.NetconfCallhomeServer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.credentials.Credentials;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.AllowedDevices;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.Global;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.Global.MountPointNamingStrategy;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.Device;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.device.transport.Ssh;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.NetconfCallhomeServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.credentials.Credentials;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.AllowedDevices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.Global;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.Global.MountPointNamingStrategy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.Device;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.device.transport.Ssh;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.service.component.annotations.Activate;
@@ -80,18 +79,14 @@ public final class CallHomeMountSshAuthProvider implements CallHomeSshAuthProvid
 
     @Override
     public CallHomeSshAuthSettings provideAuth(final SocketAddress remoteAddress, final PublicKey serverKey) {
-        Device deviceSpecific = deviceConfig.get(serverKey);
-        String id;
-        Credentials deviceCred;
+        final String id;
+        final Credentials deviceCred;
 
+        final var deviceSpecific = deviceConfig.get(serverKey);
         if (deviceSpecific != null) {
             id = deviceSpecific.getUniqueId();
-            if (deviceSpecific.getTransport() instanceof Ssh ssh) {
-                final SshClientParams clientParams = ssh.getSshClientParams();
-                deviceCred = clientParams.getCredentials();
-            } else {
-                deviceCred = deviceSpecific.getCredentials();
-            }
+            deviceCred = deviceSpecific.getTransport() instanceof Ssh ssh ? ssh.getSshClientParams().getCredentials()
+                : null;
         } else {
             String syntheticId = fromRemoteAddress(remoteAddress);
             if (globalConfig.allowedUnknownKeys()) {
@@ -109,8 +104,7 @@ public final class CallHomeMountSshAuthProvider implements CallHomeSshAuthProvid
             }
         }
 
-        final Credentials credentials = deviceCred != null ? deviceCred : globalConfig.getCredentials();
-
+        final var credentials = deviceCred != null ? deviceCred : globalConfig.getCredentials();
         if (credentials == null) {
             LOG.info("No credentials found for {}, rejecting.", id);
             return null;
@@ -183,11 +177,7 @@ public final class CallHomeMountSshAuthProvider implements CallHomeSshAuthProvid
         }
 
         private static String getHostPublicKey(final Device device) {
-            if (device.getTransport() instanceof Ssh ssh) {
-                return ssh.getSshClientParams().getHostKey();
-            } else {
-                return device.getSshHostKey();
-            }
+            return device.getTransport() instanceof Ssh ssh ? ssh.nonnullSshClientParams().getHostKey() : null;
         }
 
         abstract void addDevice(String publicKey, Device device);
index d279ff90f0b9047ea6b853e91f32cb084a1ae174..6244662068d846de3296b66cffc56238e63a83b2 100644 (file)
@@ -25,14 +25,14 @@ import org.opendaylight.mdsal.binding.api.DataTreeModification;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.netconf.callhome.server.CallHomeStatusRecorder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.NetconfCallhomeServer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.AllowedDevices;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.Device;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.Device.DeviceStatus;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.DeviceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.DeviceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.device.transport.SshBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParamsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.NetconfCallhomeServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.AllowedDevices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.Device;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.Device.DeviceStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.DeviceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.DeviceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.device.transport.SshBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParamsBuilder;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.service.component.annotations.Activate;
index 843c0d9060f71b63a691263b92b501555fbcc30b..0f73840a0c6e304fa5ecbb4b2bf7519b33f23c6f 100644 (file)
@@ -38,10 +38,10 @@ import org.opendaylight.netconf.client.SslHandlerFactory;
 import org.opendaylight.netconf.client.mdsal.api.SslHandlerFactoryProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.trusted.certificates.TrustedCertificate;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.NetconfCallhomeServer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.AllowedDevices;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.Device;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev230428.netconf.callhome.server.allowed.devices.device.transport.Tls;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.NetconfCallhomeServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.AllowedDevices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.Device;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev240129.netconf.callhome.server.allowed.devices.device.transport.Tls;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.service.component.annotations.Activate;
index dab83dd79e1129757eaf542f989bbb4a5a2c202f..74989cf6b7d6ceaaa8ca71a74b347824283f06b6 100644 (file)
@@ -12,6 +12,14 @@ module odl-netconf-callhome-server {
   description
    "This module defines the northbound interface for OpenDaylight NETCONF Callhome.";
 
+  revision 2024-01-29 {
+    description
+      "A number of improvements to the sematics of this model. In concrete terms:
+       - every device now has to have a transport
+       - previously-deprecated 'ssh-host-key' is now obsolete
+       - 'credentials; is obsoleted as well";
+  }
+
   revision 2023-04-28 {
     description "This revision integrates device-status leaf, formerly hosted in callhome-device.yang";
   }
@@ -57,8 +65,8 @@ module odl-netconf-callhome-server {
 
       leaf mount-point-naming-strategy {
         type enumeration {
-            enum IP_PORT;
-            enum IP_ONLY;
+          enum IP_PORT;
+          enum IP_ONLY;
         }
         default IP_PORT;
         description "Mount name will be chosen as per this strategy in the absence of per device settings. Default is IP_PORT";
@@ -73,17 +81,11 @@ module odl-netconf-callhome-server {
           description "Identifier of device, which will be used to identify device.";
           type string;
         }
-        leaf ssh-host-key {
-          description "BASE-64 encoded public key which device will use during connection.
-                       Deprecated, a 'host-key' from the  'ssh-client-params' containers should be used instead.";
-          status deprecated;
-          type string;
-        }
-        unique ssh-host-key;
-        uses credentials;
 
         choice transport {
           description "Provides connectivity details for one of the supported transport protocols";
+          mandatory true;
+
           case ssh {
             container ssh-client-params {
               leaf host-key {
@@ -123,6 +125,16 @@ module odl-netconf-callhome-server {
           }
           default DISCONNECTED;
         }
+
+        leaf ssh-host-key {
+          description "Obsolete, a 'host-key' from the 'ssh-client-params' containers should be used instead.";
+          status obsolete;
+          type string;
+        }
+        unique ssh-host-key;
+        uses credentials {
+          status obsolete;
+        }
       }
     }
   }