use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.DeviceKey in project netconf by opendaylight.
the class IetfZeroTouchCallHomeServerProvider method readAndUpdateStatus.
private void readAndUpdateStatus(final Device cfgDevice) throws InterruptedException, ExecutionException {
InstanceIdentifier<Device> deviceIID = InstanceIdentifier.create(NetconfCallhomeServer.class).child(AllowedDevices.class).child(Device.class, new DeviceKey(cfgDevice.getUniqueId()));
ReadWriteTransaction tx = dataBroker.newReadWriteTransaction();
ListenableFuture<Optional<Device>> deviceFuture = tx.read(LogicalDatastoreType.OPERATIONAL, deviceIID);
final Device1 devStatus;
Optional<Device> opDevGet = deviceFuture.get();
if (opDevGet.isPresent()) {
devStatus = opDevGet.get().augmentation(Device1.class);
} else {
devStatus = new Device1Builder().setDeviceStatus(Device1.DeviceStatus.DISCONNECTED).build();
}
final Device opDevice = createOperationalDevice(cfgDevice, devStatus);
tx.merge(LogicalDatastoreType.OPERATIONAL, deviceIID, opDevice);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.debug("Device {} status update committed", cfgDevice.key());
}
@Override
public void onFailure(final Throwable cause) {
LOG.warn("Failed to commit device {} status update", cfgDevice.key(), cause);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.DeviceKey in project netconf by opendaylight.
the class CallhomeStatusReporter method newDevice.
private static Device newDevice(final String id, final PublicKey serverKey, final Device1.DeviceStatus status) {
// used only for netconf devices that are connected via SSH transport and global credentials
String sshEncodedKey = serverKey.toString();
try {
sshEncodedKey = AuthorizedKeysDecoder.encodePublicKey(serverKey);
} catch (IOException e) {
LOG.warn("Unable to encode public key to ssh format.", e);
}
final SshClientParams sshParams = new SshClientParamsBuilder().setHostKey(sshEncodedKey).build();
final Transport transport = new SshBuilder().setSshClientParams(sshParams).build();
return new DeviceBuilder().setUniqueId(id).withKey(new DeviceKey(id)).setTransport(transport).addAugmentation(new Device1Builder().setDeviceStatus(status).build()).build();
}
Aggregations