import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global.MountPointNamingStrategy;
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.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.ssh.SshClientParams;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
if (deviceSpecific != null) {
sessionName = deviceSpecific.getUniqueId();
- deviceCred = deviceSpecific.getCredentials();
+ if (deviceSpecific.getTransport() instanceof Ssh) {
+ final SshClientParams clientParams = ((Ssh) deviceSpecific.getTransport()).getSshClientParams();
+ deviceCred = clientParams.getCredentials();
+ } else {
+ deviceCred = deviceSpecific.getCredentials();
+ }
} else {
String syntheticId = fromRemoteAddress(remoteAddress);
if (globalConfig.allowedUnknownKeys()) {
private void deleteDevice(final Device dataBefore) {
if (dataBefore != null) {
- final String publicKey = dataBefore.getSshHostKey();
+ final String publicKey = getHostPublicKey(dataBefore);
if (publicKey != null) {
LOG.debug("Removing device {}", dataBefore.getUniqueId());
removeDevice(publicKey, dataBefore);
}
private void writeDevice(final Device dataAfter) {
- final String publicKey = dataAfter.getSshHostKey();
+ final String publicKey = getHostPublicKey(dataAfter);
if (publicKey != null) {
LOG.debug("Adding device {}", dataAfter.getUniqueId());
addDevice(publicKey, dataAfter);
}
}
+ private String getHostPublicKey(final Device device) {
+ if (device.getTransport() instanceof Ssh) {
+ return ((Ssh) device.getTransport()).getSshClientParams().getHostKey();
+ } else {
+ return device.getSshHostKey();
+ }
+ }
+
abstract void addDevice(String publicKey, Device device);
abstract void removeDevice(String publicKey, Device device);