Search in sources :

Example 6 with GetInterfaceFromIfIndexInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder in project genius by opendaylight.

the class ArpUtilImpl method getInterfaceName.

private String getInterfaceName(Metadata metadata) throws InterruptedException, ExecutionException {
    LOG.debug("metadata received is {} ", metadata);
    GetInterfaceFromIfIndexInputBuilder ifIndexInputBuilder = new GetInterfaceFromIfIndexInputBuilder();
    BigInteger lportTag = MetaDataUtil.getLportFromMetadata(metadata.getMetadata());
    ifIndexInputBuilder.setIfIndex(lportTag.intValue());
    GetInterfaceFromIfIndexInput input = ifIndexInputBuilder.build();
    Future<RpcResult<GetInterfaceFromIfIndexOutput>> interfaceFromIfIndex = odlInterfaceRpcService.getInterfaceFromIfIndex(input);
    GetInterfaceFromIfIndexOutput interfaceFromIfIndexOutput = interfaceFromIfIndex.get().getResult();
    return interfaceFromIfIndexOutput.getInterfaceName();
}
Also used : GetInterfaceFromIfIndexInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInput) GetInterfaceFromIfIndexInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BigInteger(java.math.BigInteger) GetInterfaceFromIfIndexOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput)

Example 7 with GetInterfaceFromIfIndexInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder in project genius by opendaylight.

the class AlivenessProtocolHandlerARP method handlePacketIn.

@Override
public String handlePacketIn(ARP packet, PacketReceived packetReceived) {
    short tableId = packetReceived.getTableId().getValue();
    int arpType = packet.getOpCode();
    if (LOG.isTraceEnabled()) {
        LOG.trace("packet: {}, tableId {}, arpType {}", packetReceived, tableId, arpType);
    }
    if (arpType == ARP.REPLY) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("packet: {}", packetReceived);
        }
        BigInteger metadata = packetReceived.getMatch().getMetadata().getMetadata();
        int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue();
        String interfaceName = null;
        try {
            GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build();
            Future<RpcResult<GetInterfaceFromIfIndexOutput>> output = interfaceManager.getInterfaceFromIfIndex(input);
            RpcResult<GetInterfaceFromIfIndexOutput> result = output.get();
            if (result.isSuccessful()) {
                GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult();
                interfaceName = ifIndexOutput.getInterfaceName();
            } else {
                LOG.warn("RPC call to get interface name for if index {} failed with errors {}", portTag, result.getErrors());
                return null;
            }
        } catch (InterruptedException | ExecutionException e) {
            LOG.warn("Error retrieving interface Name for tag {}", portTag, e);
        }
        if (!Strings.isNullOrEmpty(interfaceName)) {
            String sourceIp = NWUtil.toStringIpAddress(packet.getSenderProtocolAddress());
            String targetIp = NWUtil.toStringIpAddress(packet.getTargetProtocolAddress());
            return getMonitoringKey(interfaceName, targetIp, sourceIp);
        } else {
            LOG.debug("No interface associated with tag {} to interpret the received ARP Reply", portTag);
        }
    }
    return null;
}
Also used : GetInterfaceFromIfIndexInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInput) GetInterfaceFromIfIndexInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BigInteger(java.math.BigInteger) ExecutionException(java.util.concurrent.ExecutionException) GetInterfaceFromIfIndexOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)7 GetInterfaceFromIfIndexInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInput)6 GetInterfaceFromIfIndexInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexInputBuilder)6 GetInterfaceFromIfIndexOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceFromIfIndexOutput)6 ExecutionException (java.util.concurrent.ExecutionException)4 BigInteger (java.math.BigInteger)3 GetDpidFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput)1 GetDpidFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder)1 GetEgressActionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput)1 GetEgressActionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder)1 GetEgressInstructionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInput)1 GetEgressInstructionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInputBuilder)1 GetInterfaceTypeInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInput)1 GetInterfaceTypeInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInputBuilder)1 GetNodeconnectorIdFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput)1 GetNodeconnectorIdFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder)1 GetPortFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput)1 GetPortFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder)1