use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput in project genius by opendaylight.
the class TestOdlInterfaceRpcService method getPortFromInterface.
@Override
public Future<RpcResult<GetPortFromInterfaceOutput>> getPortFromInterface(GetPortFromInterfaceInput input) {
RpcResultBuilder<GetPortFromInterfaceOutput> rpcResultBuilder;
GetPortFromInterfaceOutputBuilder output = new GetPortFromInterfaceOutputBuilder().setDpid(DPN_ID).setPortname(INTERFACE_NAME).setPortno(PORT_NUMBER).setPhyAddress("1F:1F:1F:1F:1F:1F");
rpcResultBuilder = RpcResultBuilder.success();
rpcResultBuilder.withResult(output.build());
return Futures.immediateFuture(rpcResultBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput in project netvirt by opendaylight.
the class Ipv6NdUtilServiceImpl method sendNeighborSolicitation.
@Override
public Future<RpcResult<Void>> sendNeighborSolicitation(SendNeighborSolicitationInput ndInput) {
RpcResultBuilder<Void> failureBuilder = RpcResultBuilder.failed();
RpcResultBuilder<Void> successBuilder = RpcResultBuilder.success();
Ipv6Address targetIpv6Address = null;
Ipv6Address srcIpv6Address;
String interfaceName = null;
String macAddr = null;
BigInteger dpnId;
int localErrorCount = 0;
targetIpv6Address = ndInput.getTargetIpAddress();
for (InterfaceAddress interfaceAddress : ndInput.getInterfaceAddress()) {
try {
interfaceName = interfaceAddress.getInterface();
srcIpv6Address = interfaceAddress.getSrcIpAddress();
GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
checkNotNull(portResult);
dpnId = portResult.getDpid();
Long portid = portResult.getPortno();
checkArgument(null != dpnId && BigInteger.ZERO != dpnId, DPN_NOT_FOUND_ERROR, interfaceName);
NodeConnectorRef nodeRef = MDSALUtil.getNodeConnRef(dpnId, portid.toString());
checkNotNull(nodeRef, NODE_CONNECTOR_NOT_FOUND_ERROR, interfaceName);
if (interfaceAddress.getSrcMacAddress() != null) {
macAddr = interfaceAddress.getSrcMacAddress().getValue();
}
checkNotNull(macAddr, FAILED_TO_GET_SRC_MAC_FOR_INTERFACE, interfaceName, nodeRef.getValue());
ipv6NeighborSolicitation.transmitNeighborSolicitation(dpnId, nodeRef, new MacAddress(macAddr), srcIpv6Address, targetIpv6Address);
} catch (NullPointerException | IllegalArgumentException e) {
LOG.trace("Failed to send Neighbor Solicitation for {} on interface {}", ndInput.getTargetIpAddress(), interfaceName);
failureBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
successBuilder.withError(RpcError.ErrorType.APPLICATION, FAILED_TO_SEND_NS_FOR_INTERFACE + interfaceName, e);
localErrorCount++;
}
}
if (localErrorCount == ndInput.getInterfaceAddress().size()) {
// Failed to send IPv6 Neighbor Solicitation on all the interfaces, return failure.
return Futures.immediateFuture(failureBuilder.build());
}
return Futures.immediateFuture(successBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput in project netvirt by opendaylight.
the class Ipv6NdUtilServiceImpl method getPortFromInterface.
private GetPortFromInterfaceOutput getPortFromInterface(String interfaceName) {
GetPortFromInterfaceInputBuilder getPortFromInterfaceInputBuilder = new GetPortFromInterfaceInputBuilder();
getPortFromInterfaceInputBuilder.setIntfName(interfaceName);
GetPortFromInterfaceOutput result = null;
Future<RpcResult<GetPortFromInterfaceOutput>> portFromInterface = odlInterfaceRpcService.getPortFromInterface(getPortFromInterfaceInputBuilder.build());
try {
result = portFromInterface.get().getResult();
LOG.trace("getPortFromInterface rpc result is {} ", result);
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error while retrieving the interfaceName from tag using getInterfaceFromIfIndex RPC");
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput in project netvirt by opendaylight.
the class QosNeutronUtils method getPortNumberForInterface.
public String getPortNumberForInterface(String ifName) {
GetPortFromInterfaceInput portNumberInput = new GetPortFromInterfaceInputBuilder().setIntfName(ifName).build();
Future<RpcResult<GetPortFromInterfaceOutput>> portNumberOutput = odlInterfaceRpcService.getPortFromInterface(portNumberInput);
try {
RpcResult<GetPortFromInterfaceOutput> portResult = portNumberOutput.get();
if (portResult.isSuccessful()) {
return portResult.getResult().getPortno().toString();
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.warn("Exception when getting port for interface {}", e);
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput in project genius by opendaylight.
the class InterfacemgrProvider method getPortForInterface.
@Override
public Long getPortForInterface(Interface intf) {
GetPortFromInterfaceInput input = new GetPortFromInterfaceInputBuilder().setIntfName(intf.getName()).build();
Future<RpcResult<GetPortFromInterfaceOutput>> output = interfaceManagerRpcService.getPortFromInterface(input);
try {
RpcResult<GetPortFromInterfaceOutput> port = output.get();
if (port.isSuccessful()) {
return port.getResult().getPortno();
}
} catch (NullPointerException | InterruptedException | ExecutionException e) {
LOG.warn("Exception when getting port for interface", e);
}
return null;
}
Aggregations