X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fcallhome-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fcallhome%2Fmount%2FIetfZeroTouchCallHomeServerProvider.java;h=e2a99a34c34e683c7bcf607814ca67c34d6e79bf;hb=aab675bb3b93911cfd28f94e6102ddfa772db77a;hp=eb20f0c483d99900067e5659c81015ded4274d3c;hpb=4ac4b04b18e2667d43109b730dcd362038f9d4f9;p=netconf.git diff --git a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java index eb20f0c483..e2a99a34c3 100644 --- a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java +++ b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/IetfZeroTouchCallHomeServerProvider.java @@ -40,6 +40,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.Device; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.DeviceBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.DeviceKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.device.Transport; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.device.transport.Ssh; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.device.transport.SshBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParams; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.device.transport.ssh.SshClientParamsBuilder; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -220,9 +225,8 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build(); } - tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIID, new DeviceBuilder() - .addAugmentation(devStatus).setSshHostKey(cfgDevice.getSshHostKey()) - .setUniqueId(cfgDevice.getUniqueId()).build()); + final Device opDevice = createOperationalDevice(cfgDevice, devStatus); + tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIID, opDevice); tx.commit().addCallback(new FutureCallback() { @Override public void onSuccess(final CommitInfo result) { @@ -235,4 +239,19 @@ public class IetfZeroTouchCallHomeServerProvider implements AutoCloseable, DataT } }, MoreExecutors.directExecutor()); } + + private Device createOperationalDevice(final Device cfgDevice, final Device1 devStatus) { + final DeviceBuilder deviceBuilder = new DeviceBuilder() + .addAugmentation(devStatus) + .setUniqueId(cfgDevice.getUniqueId()); + if (cfgDevice.getTransport() instanceof Ssh) { + final String hostKey = ((Ssh) cfgDevice.getTransport()).getSshClientParams().getHostKey(); + final SshClientParams params = new SshClientParamsBuilder().setHostKey(hostKey).build(); + final Transport sshTransport = new SshBuilder().setSshClientParams(params).build(); + deviceBuilder.setTransport(sshTransport); + } else if (cfgDevice.getSshHostKey() != null) { + deviceBuilder.setSshHostKey(cfgDevice.getSshHostKey()); + } + return deviceBuilder.build(); + } }