Search in sources :

Example 1 with GetNodeconnectorIdFromInterfaceOutput

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

the class TestOdlInterfaceRpcService method getNodeconnectorIdFromInterface.

@Override
public Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
    String ifName = input.getIntfName();
    // if the ifName is INTERFACE_NAME_NO_EXIST, then an empty response will be returned
    GetNodeconnectorIdFromInterfaceOutputBuilder builder = new GetNodeconnectorIdFromInterfaceOutputBuilder();
    if (ifName == GeniusProviderTestParams.INTERFACE_NAME) {
        builder.setNodeconnectorId(new NodeConnectorId(GeniusProviderTestParams.NODE_CONNECTOR_ID_PREFIX + GeniusProviderTestParams.INTERFACE_NAME));
    } else if (ifName == GeniusProviderTestParams.INTERFACE_NAME_INVALID) {
        return Futures.immediateFuture(RpcResultBuilder.<GetNodeconnectorIdFromInterfaceOutput>failed().withError(ErrorType.APPLICATION, "Invalid data.").build());
    }
    return Futures.immediateFuture(RpcResultBuilder.<GetNodeconnectorIdFromInterfaceOutput>success(builder.build()).build());
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) GetNodeconnectorIdFromInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutputBuilder) GetNodeconnectorIdFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput)

Example 2 with GetNodeconnectorIdFromInterfaceOutput

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

the class GeniusProvider method getNodeConnectorIdFromInterfaceName.

public Optional<String> getNodeConnectorIdFromInterfaceName(String interfaceName) {
    LOG.debug("getDpnIdFromInterfaceName: starting (logical interface={})", interfaceName);
    GetNodeconnectorIdFromInterfaceInputBuilder builder = new GetNodeconnectorIdFromInterfaceInputBuilder();
    builder.setIntfName(interfaceName);
    GetNodeconnectorIdFromInterfaceInput input = builder.build();
    if (interfaceManagerRpcService == null) {
        LOG.error("getNodeConnectorIdFromInterfaceName({}) failed (service couldn't be retrieved)", input);
        return Optional.empty();
    }
    try {
        LOG.debug("getNodeConnectorIdFromInterfaceName: invoking rpc");
        RpcResult<GetNodeconnectorIdFromInterfaceOutput> output = interfaceManagerRpcService.getNodeconnectorIdFromInterface(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getNodeConnectorIdFromInterfaceName({}) failed: {}", input, output);
            return Optional.empty();
        }
        NodeConnectorId nodeConnId = output.getResult().getNodeconnectorId();
        if (nodeConnId == null) {
            return Optional.empty();
        }
        LOG.debug("getNodeConnectorIdFromInterfaceName({}) succeeded: {}", input, output);
        return Optional.ofNullable(nodeConnId.getValue());
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getNodeConnectorIdFromInterfaceName failed to retrieve target interface name: ", e);
    }
    return Optional.empty();
}
Also used : GetNodeconnectorIdFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) GetNodeconnectorIdFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput) ExecutionException(java.util.concurrent.ExecutionException) GetNodeconnectorIdFromInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput)

Example 3 with GetNodeconnectorIdFromInterfaceOutput

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

the class InterfaceManagerConfigurationTest method checkVlanRpcs.

private void checkVlanRpcs() throws Exception {
    // 1. Test dpn-id fetching from interface
    GetDpidFromInterfaceInput dpidFromInterfaceInput = new GetDpidFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetDpidFromInterfaceOutput>> dpidFromInterfaceOutput = odlInterfaceRpcService.getDpidFromInterface(dpidFromInterfaceInput);
    Assert.assertEquals(DpnFromInterfaceOutput.newDpnFromInterfaceOutput(), dpidFromInterfaceOutput.get().getResult());
    // 3. Test egress actions fetching for interface
    GetEgressActionsForInterfaceInput egressActionsForInterfaceInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsForInterfaceOutput = odlInterfaceRpcService.getEgressActionsForInterface(egressActionsForInterfaceInput);
    assertEqualBeans(EgressActionsForInterfaceOutput.newEgressActionsForInterfaceOutput(), egressActionsForInterfaceOutput.get().getResult());
    // 4. Test egress instructions fetching for interface
    GetEgressInstructionsForInterfaceInput egressInstructionsForInterfaceInput = new GetEgressInstructionsForInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetEgressInstructionsForInterfaceOutput>> egressInstructionsForInterfaceOutput = odlInterfaceRpcService.getEgressInstructionsForInterface(egressInstructionsForInterfaceInput);
    assertEqualBeans(EgressInstructionsForInterfaceOutput.newEgressInstructionsForInterfaceOutput(), egressInstructionsForInterfaceOutput.get().getResult());
    // 5. Test interface fetching from if-index
    /* FIXME can be tested only once ResourceBatchingManager becomes testable
        GetInterfaceFromIfIndexInput interfaceFromIfIndexInput = new GetInterfaceFromIfIndexInputBuilder()
                .setIfIndex(1).build();
        Future<RpcResult<GetInterfaceFromIfIndexOutput>> interfaceFromIfIndexOutput = odlInterfaceRpcService
            .getInterfaceFromIfIndex(interfaceFromIfIndexInput);
        assertEqualBeans(InterfaceFromIfIndexOutput.newInterfaceFromIfIndexOutput(),
                interfaceFromIfIndexOutput.get().getResult());*/
    // 6. Test interface type fetching from interface-name
    GetInterfaceTypeInput interfaceTypeInput = new GetInterfaceTypeInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetInterfaceTypeOutput>> interfaceTypeOutput = odlInterfaceRpcService.getInterfaceType(interfaceTypeInput);
    assertEqualBeans(InterfaceTypeOutput.newInterfaceTypeOutput(), interfaceTypeOutput.get().getResult());
    // 7. Test get nodeconnector-id from interface-name
    GetNodeconnectorIdFromInterfaceInput nodeconnectorIdFromInterfaceInput = new GetNodeconnectorIdFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetNodeconnectorIdFromInterfaceOutput>> nodeconnectorIdFromInterfaceOutput = odlInterfaceRpcService.getNodeconnectorIdFromInterface(nodeconnectorIdFromInterfaceInput);
    assertEqualBeans(NodeconnectorIdFromInterfaceOutput.newNodeconnectorIdFromInterfaceOutput(), nodeconnectorIdFromInterfaceOutput.get().getResult());
    // 8. Test get port details from interface-name
    GetPortFromInterfaceInput portFromInterfaceInput = new GetPortFromInterfaceInputBuilder().setIntfName(INTERFACE_NAME).build();
    Future<RpcResult<GetPortFromInterfaceOutput>> portFromInterfaceOutput = odlInterfaceRpcService.getPortFromInterface(portFromInterfaceInput);
    assertEqualBeans(PortFromInterfaceOutput.newPortFromInterfaceOutput(), portFromInterfaceOutput.get().getResult());
}
Also used : GetDpidFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput) GetDpidFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInputBuilder) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) GetEgressInstructionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInput) GetNodeconnectorIdFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetPortFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInput) GetPortFromInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetPortFromInterfaceInputBuilder) GetInterfaceTypeInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInput) GetInterfaceTypeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetInterfaceTypeInputBuilder) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) GetNodeconnectorIdFromInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput) GetEgressInstructionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressInstructionsForInterfaceInputBuilder)

Example 4 with GetNodeconnectorIdFromInterfaceOutput

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

the class InterfaceManagerServiceImpl method getNodeconnectorIdFromInterface.

@Override
public ListenableFuture<GetNodeconnectorIdFromInterfaceOutput> getNodeconnectorIdFromInterface(GetNodeconnectorIdFromInterfaceInput input) {
    String interfaceName = input.getIntfName();
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
    String lowerLayerIf = ifState.getLowerLayerIf().get(0);
    NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
    // TODO as above, simplify the success case later, as we have the failure case below
    return Futures.immediateFuture(new GetNodeconnectorIdFromInterfaceOutputBuilder().setNodeconnectorId(nodeConnectorId).build());
}
Also used : Collections(java.util.Collections) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) GetNodeconnectorIdFromInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutputBuilder)

Aggregations

NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)3 GetNodeconnectorIdFromInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInput)2 GetNodeconnectorIdFromInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceInputBuilder)2 GetNodeconnectorIdFromInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutput)2 GetNodeconnectorIdFromInterfaceOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetNodeconnectorIdFromInterfaceOutputBuilder)2 Collections (java.util.Collections)1 ExecutionException (java.util.concurrent.ExecutionException)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 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 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 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1