Search in sources :

Example 6 with GetEgressActionsForInterfaceOutput

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

the class NatUtil method getEgressActionsForInterface.

@Nonnull
public static List<ActionInfo> getEgressActionsForInterface(OdlInterfaceRpcService interfaceManager, String ifName, Long tunnelKey, int pos) {
    LOG.debug("getEgressActionsForInterface : called for interface {}", ifName);
    GetEgressActionsForInterfaceInputBuilder egressActionsBuilder = new GetEgressActionsForInterfaceInputBuilder().setIntfName(ifName);
    if (tunnelKey != null) {
        egressActionsBuilder.setTunnelKey(tunnelKey);
    }
    List<ActionInfo> listActionInfo = new ArrayList<>();
    try {
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManager.getEgressActionsForInterface(egressActionsBuilder.build());
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.error("getEgressActionsForInterface : RPC Call to Get egress actions for interface {} " + "returned with Errors {}", ifName, rpcResult.getErrors());
        } else {
            List<Action> actions = rpcResult.getResult().getAction();
            for (Action action : actions) {
                org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionClass = action.getAction();
                if (actionClass instanceof OutputActionCase) {
                    listActionInfo.add(new ActionOutput(pos++, ((OutputActionCase) actionClass).getOutputAction().getOutputNodeConnector()));
                } else if (actionClass instanceof PushVlanActionCase) {
                    listActionInfo.add(new ActionPushVlan(pos++));
                } else if (actionClass instanceof SetFieldCase) {
                    if (((SetFieldCase) actionClass).getSetField().getVlanMatch() != null) {
                        int vlanVid = ((SetFieldCase) actionClass).getSetField().getVlanMatch().getVlanId().getVlanId().getValue();
                        listActionInfo.add(new ActionSetFieldVlanVid(pos++, vlanVid));
                    }
                } else if (actionClass instanceof NxActionResubmitRpcAddGroupCase) {
                    Short tableId = ((NxActionResubmitRpcAddGroupCase) actionClass).getNxResubmit().getTable();
                    listActionInfo.add(new ActionNxResubmit(pos++, tableId));
                } else if (actionClass instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
                    NxRegLoad nxRegLoad = ((NxActionRegLoadNodesNodeTableFlowApplyActionsCase) actionClass).getNxRegLoad();
                    listActionInfo.add(new ActionRegLoad(pos++, NxmNxReg6.class, nxRegLoad.getDst().getStart(), nxRegLoad.getDst().getEnd(), nxRegLoad.getValue().longValue()));
                }
            }
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Exception when egress actions for interface {}", ifName, e);
    }
    return listActionInfo;
}
Also used : NxActionResubmitRpcAddGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase) 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) SetFieldCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase) NxActionRegLoadNodesNodeTableFlowApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase) ArrayList(java.util.ArrayList) PushVlanActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase) ActionSetFieldVlanVid(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid) ActionInfo(org.opendaylight.genius.mdsalutil.ActionInfo) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) ActionNxResubmit(org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit) ExecutionException(java.util.concurrent.ExecutionException) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) ActionOutput(org.opendaylight.genius.mdsalutil.actions.ActionOutput) NxRegLoad(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad) NxmNxReg6(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) ActionRegLoad(org.opendaylight.genius.mdsalutil.actions.ActionRegLoad) ActionPushVlan(org.opendaylight.genius.mdsalutil.actions.ActionPushVlan) Nonnull(javax.annotation.Nonnull)

Example 7 with GetEgressActionsForInterfaceOutput

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

the class NexthopManager method getEgressActions.

private List<Action> getEgressActions(String interfaceName, int actionKey) {
    List<Action> actions = Collections.emptyList();
    try {
        GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName).setActionKey(actionKey);
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManager.getEgressActionsForInterface(egressAction.build());
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
        } else {
            actions = rpcResult.getResult().getAction();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
    }
    return actions;
}
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) 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 8 with GetEgressActionsForInterfaceOutput

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

the class ArpUtilImpl method getEgressAction.

private List<Action> getEgressAction(String interfaceName) {
    List<Action> actions = new ArrayList<>();
    try {
        GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
        OdlInterfaceRpcService intfRpc = odlInterfaceRpcService;
        if (intfRpc == null) {
            LOG.error("Unable to obtain interfaceMgrRpc service, ignoring egress actions for interfaceName {}", interfaceName);
            return actions;
        }
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = intfRpc.getEgressActionsForInterface(egressAction.build());
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
        } else {
            actions = rpcResult.getResult().getAction();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Exception when egress actions for interface {}", interfaceName, e);
    }
    return actions;
}
Also used : OdlInterfaceRpcService(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService) 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) 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 9 with GetEgressActionsForInterfaceOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput 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)8 GetEgressActionsForInterfaceInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder)8 GetEgressActionsForInterfaceOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput)8 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)8 ExecutionException (java.util.concurrent.ExecutionException)7 ArrayList (java.util.ArrayList)5 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)3 ActionOutput (org.opendaylight.genius.mdsalutil.actions.ActionOutput)3 GetEgressActionsForInterfaceInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)2 ActionNxResubmit (org.opendaylight.genius.mdsalutil.actions.ActionNxResubmit)2 ActionPushVlan (org.opendaylight.genius.mdsalutil.actions.ActionPushVlan)2 ActionRegLoad (org.opendaylight.genius.mdsalutil.actions.ActionRegLoad)2 ActionSetFieldVlanVid (org.opendaylight.genius.mdsalutil.actions.ActionSetFieldVlanVid)2 OutputActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase)2 PushVlanActionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase)2 SetFieldCase (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase)2 NxmNxReg6 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg6)2 NxActionResubmitRpcAddGroupCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.add.group.input.buckets.bucket.action.action.NxActionResubmitRpcAddGroupCase)2 NxActionRegLoadNodesNodeTableFlowApplyActionsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase)2