- CheckedFuture<Optional<Node>, ReadFailedException> submitFuture =
- transaction.read(LogicalDatastoreType.CONFIGURATION, nodeIid);
- Optional<Node> optional = submitFuture.checkedGet();
- if (optional != null && optional.isPresent()) {
- Node node = optional.get();
- if (node != null) {
- NetconfNode netconfNode = getNodeAugmentation(node);
- if (netconfNode != null && netconfNode.getHost() != null) {
- IpAddress ipAddress = netconfNode.getHost().getIpAddress();
- if (ipAddress != null && ipAddress.getIpv4Address() != null) {
- return ipAddress.getIpv4Address().getValue();
- }
- return null;
- }
- }
- } else {
- LOG.debug("Failed to read. {}", Thread.currentThread().getStackTrace()[1]);
+ Optional<Node> nodeOptional = submitFuture.checkedGet();
+ if (nodeOptional.isPresent()) {
+ NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get());
+ return java.util.Optional.ofNullable(netconfNode)
+ .map(NetconfNodeConnectionParameters::getHost)
+ .map(Host::getIpAddress)
+ .map(IpAddress::getIpv4Address)
+ .map(Ipv4Address::getValue)
+ .orElse(null);