From: Sasidharan Sambasivam Date: Wed, 6 Jan 2016 11:49:55 +0000 (+0530) Subject: Using latest RPC from interface mgr X-Git-Tag: release/beryllium~61^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=vpnservice.git;a=commitdiff_plain;h=fe85aaf7681699f79ebd89d8895238954565e5e5 Using latest RPC from interface mgr Change-Id: I66ae36036aa9d0720735c58e4ab9b482b589fad6 Signed-off-by: Sasidharan Sambasivam --- diff --git a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerARP.java b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerARP.java index 33fb6ad9..d125ff06 100644 --- a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerARP.java +++ b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerARP.java @@ -14,6 +14,7 @@ import java.math.BigInteger; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import org.opendaylight.controller.liblldp.Packet; @@ -27,6 +28,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.IpAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.configs.MonitoringInfo; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.OdlArputilService; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpRequestInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpRequestInputBuilder; @@ -79,12 +83,21 @@ public class AlivenessProtocolHandlerARP extends AbstractAlivenessProtocolHandle BigInteger metadata = packetReceived.getMatch().getMetadata().getMetadata(); int portTag = MetaDataUtil.getLportFromMetadata(metadata).intValue(); String interfaceName = null; - NodeConnectorId connId = packetReceived.getMatch().getInPort(); -// try { -// interfaceName = serviceProvider.getInterfaceManager().getInterfaceNameForInterfaceTag(portTag); -// } catch(InterfaceNotFoundException e) { -// LOG.warn("Error retrieving interface Name for tag {}", portTag, e); -// } + + try { + GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build(); + Future> output = serviceProvider.getInterfaceManager().getInterfaceFromIfIndex(input); + RpcResult 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 = toStringIpAddress(packet.getSenderProtocolAddress()); String targetIp = toStringIpAddress(packet.getTargetProtocolAddress()); diff --git a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerLLDP.java b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerLLDP.java index d0391519..d0d7511b 100644 --- a/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerLLDP.java +++ b/alivenessmonitor/alivenessmonitor-impl/src/main/java/org/opendaylight/vpnservice/alivenessmonitor/internal/AlivenessProtocolHandlerLLDP.java @@ -36,11 +36,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.endpoint.endpoint.type.Interface; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.configs.MonitoringInfo; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel; -//import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetDpidFromInterfaceOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceOutput; @@ -122,12 +124,21 @@ public class AlivenessProtocolHandlerLLDP extends AbstractAlivenessProtocolHandl } String destInterfaceName = null; - //TODO: Use latest interface RPC -// try { -// destInterfaceName = serviceProvider.getInterfaceManager().getInterfaceNameForInterfaceTag(portTag); -// } catch(InterfaceNotFoundException e) { -// LOG.warn("Error retrieving interface Name for tag {}", portTag, e); -// } + + try { + GetInterfaceFromIfIndexInput input = new GetInterfaceFromIfIndexInputBuilder().setIfIndex(portTag).build(); + Future> output = serviceProvider.getInterfaceManager().getInterfaceFromIfIndex(input); + RpcResult result = output.get(); + if(result.isSuccessful()) { + GetInterfaceFromIfIndexOutput ifIndexOutput = result.getResult(); + destInterfaceName = 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 monitorKey = new StringBuilder().append(interfaceName).append(EtherTypes.LLDP).toString(); @@ -186,7 +197,7 @@ public class AlivenessProtocolHandlerLLDP extends AbstractAlivenessProtocolHandl return; } }catch(InterruptedException | ExecutionException e) { - LOG.error("Failed to retrieve RPC Result ", e); + LOG.error("Failed to retrieve interface service RPC Result ", e); return; }