Search in sources :

Example 1 with GetEgressActionsForInterfaceInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput 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 2 with GetEgressActionsForInterfaceInput

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

the class ElanItmUtils method buildItmEgressActions.

/**
 * Builds the list of actions to be taken when sending the packet over external port such as tunnel, physical
 * port etc.
 *
 * @param interfaceName
 *            the interface name
 * @param tunnelKey
 *            can be VNI for VxLAN tunnel interfaces, Gre Key for GRE
 *            tunnels, etc.
 * @return the list
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> buildItmEgressActions(String interfaceName, Long tunnelKey) {
    List<Action> result = Collections.emptyList();
    try {
        GetEgressActionsForInterfaceInput getEgressActInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setTunnelKey(tunnelKey).build();
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> egressActionsOutputFuture = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActInput);
        if (egressActionsOutputFuture.get().isSuccessful()) {
            GetEgressActionsForInterfaceOutput egressActionsOutput = egressActionsOutputFuture.get().getResult();
            result = egressActionsOutput.getAction();
        }
    } catch (Exception e) {
        LOG.error("Error in RPC call getEgressActionsForInterface {}", e);
    }
    if (result == null || result.isEmpty()) {
        LOG.warn("Could not build Egress actions for interface {} and tunnelId {}", interfaceName, tunnelKey);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with GetEgressActionsForInterfaceInput

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

the class ElanUtils method getEgressActionsForInterface.

/**
 * Returns the list of Actions to be taken when sending the packet through
 * an Elan interface. Note that this interface can refer to an ElanInterface
 * where the Elan VM is attached to a DPN or an ITM tunnel interface where
 * Elan traffic can be sent through. In this latter case, the tunnelKey is
 * mandatory and it can hold serviceId for internal tunnels or the VNI for
 * external tunnels.
 *
 * @param ifName
 *            the if name
 * @param tunnelKey
 *            the tunnel key
 * @return the egress actions for interface
 */
@SuppressWarnings("checkstyle:IllegalCatch")
public List<Action> getEgressActionsForInterface(String ifName, Long tunnelKey) {
    List<Action> listAction = new ArrayList<>();
    try {
        GetEgressActionsForInterfaceInput getEgressActionInput = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName).setTunnelKey(tunnelKey).build();
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpcService.getEgressActionsForInterface(getEgressActionInput);
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.debug("RPC Call to Get egress actions for interface {} returned with Errors {}", ifName, rpcResult.getErrors());
        } else {
            List<Action> actions = rpcResult.getResult().getAction();
            listAction = actions;
        }
    } catch (Exception e) {
        LOG.warn("Exception when egress actions for interface {}", ifName, e);
    }
    return listAction;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) ArrayList(java.util.ArrayList) GetEgressActionsForInterfaceInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) ExecutionException(java.util.concurrent.ExecutionException) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) ElanException(org.opendaylight.netvirt.elan.ElanException)

Example 4 with GetEgressActionsForInterfaceInput

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

the class TestOdlInterfaceRpcService method getEgressActionsForInterface.

@Override
public Future<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(GetEgressActionsForInterfaceInput input) {
    RpcResultBuilder<GetEgressActionsForInterfaceOutput> rpcResultBuilder;
    List<ActionInfo> listActionInfo = new ArrayList<>();
    List<Action> actionsList = new ArrayList<>();
    listActionInfo.add(new ActionOutput(1, new Uri(URI)));
    for (ActionInfo actionInfo : listActionInfo) {
        actionsList.add(actionInfo.buildAction());
    }
    GetEgressActionsForInterfaceOutputBuilder output = new GetEgressActionsForInterfaceOutputBuilder().setAction(actionsList);
    rpcResultBuilder = RpcResultBuilder.success();
    rpcResultBuilder.withResult(output.build());
    return Futures.immediateFuture(rpcResultBuilder.build());
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) ArrayList(java.util.ArrayList) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) GetEgressActionsForInterfaceOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutputBuilder) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)

Aggregations

Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 GetEgressActionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput)3 GetEgressActionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder)3 GetEgressActionsForInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput)3 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 ArrayList (java.util.ArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)1 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)1 ActionOutput (org.opendaylight.genius.mdsalutil.actions.ActionOutput)1 ElanException (org.opendaylight.netvirt.elan.ElanException)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)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 GetEgressActionsForInterfaceOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutputBuilder)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