use of org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.GetTopologiesOutput in project lighty-netconf-simulator by PANTHEONtech.
the class NetworkTopologyServiceImpl method getTopologies.
@Override
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
public ListenableFuture<RpcResult<GetTopologiesOutput>> getTopologies(final GetTopologiesInput input) {
Preconditions.checkNotNull(this.dataBrokerService);
LOG.info("Searching data for all topologies");
final SettableFuture<RpcResult<GetTopologiesOutput>> result = SettableFuture.create();
this.executor.submit(new Callable<RpcResult<GetTopologiesOutput>>() {
@Override
public RpcResult<GetTopologiesOutput> call() throws Exception {
try (ReadTransaction readTx = NetworkTopologyServiceImpl.this.dataBrokerService.newReadOnlyTransaction()) {
final InstanceIdentifier<NetworkTopology> tii = InstanceIdentifier.builder(NetworkTopology.class).build();
final Optional<NetworkTopology> networkTopology = readTx.read(LogicalDatastoreType.CONFIGURATION, tii).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
if (networkTopology.isPresent()) {
final org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.topology.data.TopologyBuilder topologyBuilder = new org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.topology.data.TopologyBuilder();
final Collection<Topology> topologyList = networkTopology.get().nonnullTopology().values();
final Map<org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.topology.data.TopologyKey, org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.topology.data.Topology> topologyMapFinal = new HashMap<>();
for (final Topology t : topologyList) {
final Map<NodeKey, Node> nodeMap = new HashMap<>();
if (t.getNode() != null) {
for (final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node n : t.nonnullNode().values()) {
final NodeKey nk = new NodeKey(n.getNodeId());
final Node nb = buildNode(nk, n);
nodeMap.put(nb.key(), nb);
}
}
final org.opendaylight.yang.gen.v1.urn.tech.pantheon.netconfdevice.network.topology.rpcs.rev180320.topology.data.Topology tp = topologyBuilder.withKey(new TopologyKey(t.getTopologyId())).setTopologyId(t.getTopologyId()).setNode(nodeMap).build();
topologyMapFinal.put(tp.key(), tp);
}
final GetTopologiesOutput getTopologiesOutput = new GetTopologiesOutputBuilder().setNetworkTopology(new NetworkTopologyBuilder().setTopology(topologyMapFinal).build()).build();
final RpcResult<GetTopologiesOutput> rpcResult = RpcResultBuilder.success(getTopologiesOutput).build();
result.set(rpcResult);
return rpcResult;
}
final RpcResult<GetTopologiesOutput> rpcResult = RpcResultBuilder.success(new GetTopologiesOutputBuilder().build()).build();
result.set(rpcResult);
return rpcResult;
}
}
});
return result;
}
Aggregations