Search in sources :

Example 86 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlowDirectStatisticsService method buildReply.

@Override
protected GetFlowStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
    final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
    if (success) {
        for (final MultipartReply mpReply : input) {
            final MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
            final MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
            final Optional<List<FlowAndStatisticsMapList>> statsListPart = getConvertorExecutor().convert(replyBody.getFlowStats(), data);
            statsListPart.ifPresent(flowAndStatisticsMapLists -> {
                for (final FlowAndStatisticsMapList part : flowAndStatisticsMapLists) {
                    final FlowId flowId = new FlowId(generateFlowId(part).getValue());
                    statsList.add(new FlowAndStatisticsMapListBuilder(part).setKey(new FlowAndStatisticsMapListKey(flowId)).setFlowId(flowId).build());
                }
            });
        }
    }
    return new GetFlowStatisticsOutputBuilder().setFlowAndStatisticsMapList(statsList).build();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId) FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) ArrayList(java.util.ArrayList) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) FlowAndStatisticsMapListKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListKey) ArrayList(java.util.ArrayList) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) GetFlowStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutputBuilder)

Example 87 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class OFPluginFlowTest method createTestFlow.

static FlowBuilder createTestFlow() {
    short tableId = 0;
    FlowBuilder flow = new FlowBuilder();
    flow.setMatch(createMatch1().build());
    flow.setInstructions(createDecNwTtlInstructions().build());
    FlowId flowId = new FlowId("127");
    FlowKey key = new FlowKey(flowId);
    if (null == flow.isBarrier()) {
        flow.setBarrier(Boolean.FALSE);
    }
    BigInteger value = BigInteger.TEN;
    flow.setCookie(new FlowCookie(value));
    flow.setCookieMask(new FlowCookie(value));
    flow.setHardTimeout(0);
    flow.setIdleTimeout(0);
    flow.setInstallHw(false);
    flow.setStrict(false);
    flow.setContainerName(null);
    flow.setFlags(new FlowModFlags(false, false, false, false, true));
    flow.setId(flowId);
    flow.setTableId(tableId);
    flow.setKey(key);
    flow.setFlowName("Foo" + "X" + "f1");
    return flow;
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) BigInteger(java.math.BigInteger)

Example 88 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class SalFlowServiceImplTest method mockingFlowRegistryLookup.

private void mockingFlowRegistryLookup() {
    FlowDescriptor mockedFlowDescriptor = mock(FlowDescriptor.class);
    FlowId flowId = new FlowId(DUMMY_FLOW_ID);
    when(mockedFlowDescriptor.getFlowId()).thenReturn(flowId);
    when(mockedFlowDescriptor.getTableKey()).thenReturn(new TableKey(DUMMY_TABLE_ID));
    when(deviceFlowRegistry.retrieveDescriptor(Matchers.any(FlowRegistryKey.class))).thenReturn(mockedFlowDescriptor);
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)

Example 89 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlowUtils method createFwdAllToControllerFlow.

/**
 * Returns a{@link FlowBuilder} forwarding all packets to controller port.
 */
public static FlowBuilder createFwdAllToControllerFlow(final Short tableId, final int priority, final FlowId flowId) {
    // Create output action -> send to controller
    OutputActionBuilder output = new OutputActionBuilder();
    output.setMaxLength(Integer.valueOf(0xffff));
    Uri controllerPort = new Uri(OutputPortValues.CONTROLLER.toString());
    output.setOutputNodeConnector(controllerPort);
    ActionBuilder ab = new ActionBuilder();
    ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
    ab.setOrder(0);
    ab.setKey(new ActionKey(0));
    List<Action> actionList = new ArrayList<>();
    actionList.add(ab.build());
    // Create an Apply Action
    ApplyActionsBuilder aab = new ApplyActionsBuilder();
    aab.setAction(actionList);
    // Wrap our Apply Action in an Instruction
    InstructionBuilder ib = new InstructionBuilder();
    ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
    ib.setOrder(0);
    ib.setKey(new InstructionKey(0));
    // Put our Instruction in a list of Instructions
    InstructionsBuilder isb = new InstructionsBuilder();
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(ib.build());
    isb.setInstruction(instructions);
    MatchBuilder matchBuilder = new MatchBuilder();
    FlowBuilder allToCtrlFlow = new FlowBuilder().setTableId(tableId).setFlowName("allPacketsToCtrl").setId(flowId).setKey(new FlowKey(flowId));
    allToCtrlFlow.setMatch(matchBuilder.build()).setInstructions(isb.build()).setPriority(priority).setBufferId(OFConstants.OFP_NO_BUFFER).setHardTimeout(0).setIdleTimeout(0).setFlags(new FlowModFlags(false, false, false, false, false));
    return allToCtrlFlow;
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags) ArrayList(java.util.ArrayList) InstructionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey) ActionKey(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder)

Example 90 with FlowId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId in project openflowplugin by opendaylight.

the class FlowDescriptorDtoTest method testCreate.

@Test
public void testCreate() throws Exception {
    final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 1, new FlowId("unit:1"));
    Assert.assertNotNull(flowDescriptor);
    Assert.assertNotNull(flowDescriptor.getFlowId());
    Assert.assertNotNull(flowDescriptor.getTableKey());
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) Test(org.junit.Test)

Aggregations

FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)79 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)53 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)46 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)43 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)25 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)24 ArrayList (java.util.ArrayList)22 BigInteger (java.math.BigInteger)21 Test (org.junit.Test)21 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)21 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)19 MatchInfo (org.opendaylight.genius.mdsalutil.MatchInfo)15 FlowCookie (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie)13 FlowModFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags)10 List (java.util.List)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)8 MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)8