- private static <U extends DataObject> U checkWritten(final ReadOnlyTransaction transaction,
- final InstanceIdentifier<U> readIID) {
- for (int attempt = 1; attempt <= 5; attempt++) {
- try {
- final CheckedFuture<Optional<U>, ReadFailedException> submitFuture =
- transaction.read(LogicalDatastoreType.CONFIGURATION, readIID);
- final Optional<U> optional = submitFuture.checkedGet();
- if (optional != null && optional.isPresent()) {
- transaction.close(); // Release lock
- return optional.get();
- } else {
- // Could take some time until specific configuration appears on device, try to read a few times
- Thread.sleep(2000L);
- }
- } catch (InterruptedException i) {
- LOG.error("Thread interrupted while waiting ... {} ", i);
- } catch (ReadFailedException e) {
- LOG.warn("Read transaction failed to {} ", e);
- } catch (Exception e) {
- LOG.error("Failed to .. {}", e.getMessage());
- }
+ private static <U extends DataObject> U netconfRead(final DataBroker mountpoint,
+ final InstanceIdentifier<U> readIID) {
+ final java.util.Optional<ReadOnlyTransaction> optionalReadTransaction =
+ NetconfTransactionCreator.netconfReadOnlyTransaction(mountpoint);
+ if (!optionalReadTransaction.isPresent()) {
+ LOG.warn("Failed to create write-only transaction, mountpoint: {}", mountpoint);
+ return null;