Search in sources :

Example 6 with GetPortFromInterfaceOutput

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());
}
Also used : GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) GetPortFromInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)

Example 7 with GetPortFromInterfaceOutput

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());
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) InterfaceAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.ipv6service.ipv6util.rev170210.interfaces.InterfaceAddress) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) BigInteger(java.math.BigInteger) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) Ipv6Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)

Example 8 with GetPortFromInterfaceOutput

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;
}
Also used : GetPortFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 9 with GetPortFromInterfaceOutput

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;
}
Also used : GetPortFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException) GetPortFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput)

Example 10 with GetPortFromInterfaceOutput

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;
}
Also used : GetPortFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetPortFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException) GetPortFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput)

Aggregations

GetPortFromInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutput)9 ExecutionException (java.util.concurrent.ExecutionException)6 GetPortFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 BigInteger (java.math.BigInteger)4 GetPortFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput)4 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)3 UnknownHostException (java.net.UnknownHostException)2 PacketException (org.opendaylight.openflowplugin.libraries.liblldp.PacketException)2 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)2 GetPortFromInterfaceOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceOutputBuilder)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Collections (java.util.Collections)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)1 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)1 InterfaceAddress (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddress)1 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