use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutputBuilder in project netvirt by opendaylight.
the class ElanStatisticsImpl method getElanInterfaceStatistics.
@Override
public Future<RpcResult<GetElanInterfaceStatisticsOutput>> getElanInterfaceStatistics(GetElanInterfaceStatisticsInput input) {
String interfaceName = input.getInterfaceName();
LOG.debug("getElanInterfaceStatistics is called for elan interface {}", interfaceName);
RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder = null;
if (interfaceName == null) {
rpcResultBuilder = RpcResultBuilder.failed();
return getFutureWithAppErrorMessage(rpcResultBuilder, "Interface name is not provided");
}
Optional<ElanInterface> elanInterface = elanInterfaceCache.get(interfaceName);
if (!elanInterface.isPresent()) {
rpcResultBuilder = RpcResultBuilder.failed();
return getFutureWithAppErrorMessage(rpcResultBuilder, String.format("Interface %s is not a ELAN interface", interfaceName));
}
String elanInstanceName = elanInterface.get().getElanInstanceName();
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
// FIXME [ELANBE] Get this API Later
short tableId = 0;
// }
if (!interfaceInfo.isOperational()) {
LOG.debug("interface {} is down and returning with no statistics", interfaceName);
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(new GetElanInterfaceStatisticsOutputBuilder().setStatResult(new StatResultBuilder().setStatResultCode(ResultCode.NotFound).setByteRxCount(0L).setByteTxCount(0L).setPacketRxCount(0L).setPacketTxCount(0L).build()).build()).build());
}
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
}
Aggregations