Search in sources :

Example 1 with AllowedDevices

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);
    }
}
Also used : Optional(java.util.Optional) Device(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device) AllowedDevices(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.AllowedDevices) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ExecutionException(java.util.concurrent.ExecutionException) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 ExecutionException (java.util.concurrent.ExecutionException)1 ReadTransaction (org.opendaylight.mdsal.binding.api.ReadTransaction)1 AllowedDevices (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.AllowedDevices)1 Device (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1