Search in sources :

Example 36 with Instruction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction in project openflowplugin by opendaylight.

the class FlowConvertor method isSetVlanIdActionCasePresent.

// check if set vlanid action is present in the flow
private static boolean isSetVlanIdActionCasePresent(Flow flow) {
    // If yes,then we would need to two flows
    if (flow.getInstructions() != null && flow.getInstructions().getInstruction() != null) {
        for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : flow.getInstructions().getInstruction()) {
            org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
            if (curInstruction instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) {
                org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase applyActionscase = (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase) curInstruction;
                ApplyActions applyActions = applyActionscase.getApplyActions();
                for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : applyActions.getAction()) {
                    if (action.getAction() instanceof SetVlanIdActionCase) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : SetVlanIdActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase) ApplyActionsCase(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.cases.ApplyActionsCase) ApplyActions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions)

Example 37 with Instruction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction in project openflowplugin by opendaylight.

the class FlowConvertor method toInstructions.

private List<Instruction> toInstructions(Flow flow, short version, BigInteger datapathid) {
    final List<Instruction> instructionsList = new ArrayList<>();
    final ActionConvertorData data = new ActionConvertorData(version);
    data.setDatapathId(datapathid);
    data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
    Instructions instructions = flow.getInstructions();
    for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instruction : instructions.getInstruction()) {
        org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction curInstruction = instruction.getInstruction();
        Optional<Instruction> result = PROCESSOR.process(curInstruction, data, getConvertorExecutor());
        if (result.isPresent()) {
            instructionsList.add(result.get());
        }
    }
    return instructionsList;
}
Also used : ArrayList(java.util.ArrayList) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) Instructions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction)

Example 38 with Instruction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction in project bgpcep by opendaylight.

the class AbstractInstructionExecutor method schedule.

public static FailureCase schedule(final InstructionScheduler scheduler, final AbstractInstructionExecutor fwd) {
    final ListenableFuture<Instruction> listenableFuture;
    try {
        listenableFuture = scheduler.scheduleInstruction(fwd.getInput());
    } catch (final SchedulerException e) {
        LOG.info("Instuction {} failed to schedule", e.getMessage(), e);
        return new FailureCaseBuilder().setFailure(e.getFailure()).build();
    }
    Futures.addCallback(listenableFuture, fwd, MoreExecutors.directExecutor());
    return null;
}
Also used : FailureCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.FailureCaseBuilder) SchedulerException(org.opendaylight.bgpcep.programming.spi.SchedulerException) Instruction(org.opendaylight.bgpcep.programming.spi.Instruction)

Example 39 with Instruction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction in project bgpcep by opendaylight.

the class InstructionImpl method cancelInstrunction.

private synchronized void cancelInstrunction() {
    final List<InstructionId> ids = new ArrayList<>();
    for (final InstructionImpl instruction : this.dependencies) {
        if (instruction.getStatus() != InstructionStatus.Successful) {
            ids.add(instruction.getId());
        }
    }
    cancel(new DetailsBuilder().setUnmetDependencies(ids).build());
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) ArrayList(java.util.ArrayList) DetailsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)

Example 40 with Instruction

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction in project bgpcep by opendaylight.

the class InstructionImpl method checkDependencies.

private Boolean checkDependencies() {
    boolean ready = true;
    final List<InstructionId> unmet = new ArrayList<>();
    for (final InstructionImpl instruction : this.dependencies) {
        switch(instruction.getStatus()) {
            case Cancelled:
            case Failed:
            case Unknown:
                unmet.add(instruction.getId());
                break;
            case Executing:
            case Queued:
            case Scheduled:
                ready = false;
                break;
            case Successful:
                // No-op
                break;
            default:
                break;
        }
    }
    if (!unmet.isEmpty()) {
        LOG.warn("Instruction {} was Queued, while some dependencies were resolved unsuccessfully, cancelling it", this.id);
        cancel(new DetailsBuilder().setUnmetDependencies(unmet).build());
        return false;
    }
    return ready;
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) ArrayList(java.util.ArrayList) DetailsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)

Aggregations

ArrayList (java.util.ArrayList)163 Instruction (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)154 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)109 InstructionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder)106 InstructionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder)102 ApplyActionsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder)96 ApplyActionsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder)96 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)92 DropActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder)82 GroupActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder)82 ControllerActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder)81 DropAction (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction)81 PushMplsActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder)81 PushPbbActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder)81 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)81 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)77 InstructionKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey)77 SetNwSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder)76 FloodAllActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder)74 SetDlSrcActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder)74