use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.AllowedDevices in project netconf by opendaylight.
the class IetfZeroTouchCallHomeServerProvider method onDataTreeChanged.
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<AllowedDevices>> changes) {
// In case of any changes to the devices datatree, register the changed values with callhome server
// As of now, no way to add a new callhome client key to the CallHomeAuthorization instance since
// its created under CallHomeAuthorizationProvider.
// Will have to redesign a bit here.
// CallHomeAuthorization.
final ListenableFuture<Optional<AllowedDevices>> devicesFuture;
try (ReadTransaction roConfigTx = dataBroker.newReadOnlyTransaction()) {
devicesFuture = roConfigTx.read(LogicalDatastoreType.CONFIGURATION, IetfZeroTouchCallHomeServerProvider.ALL_DEVICES);
}
Set<InstanceIdentifier<?>> deletedDevices = new HashSet<>();
for (DataTreeModification<AllowedDevices> change : changes) {
DataObjectModification<AllowedDevices> rootNode = change.getRootNode();
switch(rootNode.getModificationType()) {
case DELETE:
deletedDevices.add(change.getRootPath().getRootIdentifier());
break;
default:
break;
}
}
handleDeletedDevices(deletedDevices);
try {
for (Device confDevice : getReadDevices(devicesFuture)) {
readAndUpdateStatus(confDevice);
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("Error trying to read the whitelist devices", e);
}
}
Aggregations