@Test public void getNodeManagementIpByMountPointIid_absentNode() { NodeId testNodeId = new NodeId(NODE_NAME); InstanceIdentifier mountpointIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(TOPOLOGY_ID))) .child(Node.class, new NodeKey(testNodeId)).build(); java.util.Optional<String> optionalIpAddress = nodeManager.getNodeManagementIpByMountPointIid(mountpointIid); assertFalse(optionalIpAddress.isPresent()); }
java.util.Optional<String> getNodeManagementIpByMountPointIid(final InstanceIdentifier<?> mountpointIid) { final NodeId nodeId = getNodeIdByMountpointIid(mountpointIid); final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(NodeManager.TOPOLOGY_ID))) .child(Node.class, new NodeKey(nodeId)) .build(); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<Node>, ReadFailedException> submitFuture = rTx.read(LogicalDatastoreType.CONFIGURATION, nodeIid); rTx.close(); try { Optional<Node> nodeOptional = submitFuture.checkedGet(); if (nodeOptional.isPresent()) { final NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get()); return java.util.Optional.ofNullable(netconfNode) .map(NetconfNodeConnectionParameters::getHost) .map(Host::getIpAddress) .map(IpAddress::getIpv4Address) .map(Ipv4Address::getValue); } } catch (ReadFailedException e) { LOG.warn("Read node failed {}", nodeId, e); } return java.util.Optional.empty(); }
NodeManager { java.util.Optional<String> getNodeManagementIpByMountPointIid(final InstanceIdentifier<?> mountpointIid) { final NodeId nodeId = getNodeIdByMountpointIid(mountpointIid); final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(NodeManager.TOPOLOGY_ID))) .child(Node.class, new NodeKey(nodeId)) .build(); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<Node>, ReadFailedException> submitFuture = rTx.read(LogicalDatastoreType.CONFIGURATION, nodeIid); rTx.close(); try { Optional<Node> nodeOptional = submitFuture.checkedGet(); if (nodeOptional.isPresent()) { final NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get()); return java.util.Optional.ofNullable(netconfNode) .map(NetconfNodeConnectionParameters::getHost) .map(Host::getIpAddress) .map(IpAddress::getIpv4Address) .map(Ipv4Address::getValue); } } catch (ReadFailedException e) { LOG.warn("Read node failed {}", nodeId, e); } return java.util.Optional.empty(); } }
NodeManager { java.util.Optional<String> getNodeManagementIpByMountPointIid(final InstanceIdentifier<?> mountpointIid) { final NodeId nodeId = getNodeIdByMountpointIid(mountpointIid); final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(NodeManager.TOPOLOGY_ID))) .child(Node.class, new NodeKey(nodeId)) .build(); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<Node>, ReadFailedException> submitFuture = rTx.read(LogicalDatastoreType.CONFIGURATION, nodeIid); rTx.close(); try { Optional<Node> nodeOptional = submitFuture.checkedGet(); if (nodeOptional.isPresent()) { final NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get()); return java.util.Optional.ofNullable(netconfNode) .map(NetconfNodeConnectionParameters::getHost) .map(Host::getIpAddress) .map(IpAddress::getIpv4Address) .map(Ipv4Address::getValue); } } catch (ReadFailedException e) { LOG.warn("Read node failed {}", nodeId, e); } return java.util.Optional.empty(); } NodeManager(final DataBroker dataBroker, final BindingAwareBroker.ProviderContext session); }
NodeManager { java.util.Optional<String> getNodeManagementIpByMountPointIid(final InstanceIdentifier<?> mountpointIid) { final NodeId nodeId = getNodeIdByMountpointIid(mountpointIid); final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(NodeManager.TOPOLOGY_ID))) .child(Node.class, new NodeKey(nodeId)) .build(); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<Node>, ReadFailedException> submitFuture = rTx.read(LogicalDatastoreType.CONFIGURATION, nodeIid); rTx.close(); try { Optional<Node> nodeOptional = submitFuture.checkedGet(); if (nodeOptional.isPresent()) { final NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get()); return java.util.Optional.ofNullable(netconfNode) .map(NetconfNodeConnectionParameters::getHost) .map(Host::getIpAddress) .map(IpAddress::getIpv4Address) .map(Ipv4Address::getValue); } } catch (ReadFailedException e) { LOG.warn("Read node failed {}", nodeId, e); } return java.util.Optional.empty(); } NodeManager(final DataBroker dataBroker, final BindingAwareBroker.ProviderContext session); void syncNodes(final Node dataAfter, final Node dataBefore); }
NodeManager { java.util.Optional<String> getNodeManagementIpByMountPointIid(final InstanceIdentifier<?> mountpointIid) { final NodeId nodeId = getNodeIdByMountpointIid(mountpointIid); final InstanceIdentifier<Node> nodeIid = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(NodeManager.TOPOLOGY_ID))) .child(Node.class, new NodeKey(nodeId)) .build(); final ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); final CheckedFuture<Optional<Node>, ReadFailedException> submitFuture = rTx.read(LogicalDatastoreType.CONFIGURATION, nodeIid); rTx.close(); try { Optional<Node> nodeOptional = submitFuture.checkedGet(); if (nodeOptional.isPresent()) { final NetconfNode netconfNode = getNodeAugmentation(nodeOptional.get()); return java.util.Optional.ofNullable(netconfNode) .map(NetconfNodeConnectionParameters::getHost) .map(Host::getIpAddress) .map(IpAddress::getIpv4Address) .map(Ipv4Address::getValue); } } catch (ReadFailedException e) { LOG.warn("Read node failed {}", nodeId, e); } return java.util.Optional.empty(); } NodeManager(final DataBroker dataBroker, final BindingAwareBroker.ProviderContext session); void syncNodes(final Node dataAfter, final Node dataBefore);  }