Search in sources :

Example 1 with GetElanInterfaceStatisticsOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutput 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());
}
Also used : GetElanInterfaceStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutput) GetElanInterfaceStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutputBuilder) ElanInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface) StatResultBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.get.elan._interface.statistics.output.StatResultBuilder) InterfaceInfo(org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)

Aggregations

InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)1 ElanInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface)1 GetElanInterfaceStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutput)1 GetElanInterfaceStatisticsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.GetElanInterfaceStatisticsOutputBuilder)1 StatResultBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.statistics.rev150824.get.elan._interface.statistics.output.StatResultBuilder)1