Search in sources :

Example 26 with FlowId

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

the class LearningSwitchHandlerSimpleImpl method addBridgeFlow.

private void addBridgeFlow(MacAddress srcMac, MacAddress dstMac, NodeConnectorRef destNodeConnector) {
    synchronized (coveredMacPaths) {
        String macPath = srcMac.toString() + dstMac.toString();
        if (!coveredMacPaths.contains(macPath)) {
            LOG.debug("covering mac path: {} by [{}]", macPath, destNodeConnector.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId());
            coveredMacPaths.add(macPath);
            FlowId flowId = new FlowId(String.valueOf(flowIdInc.getAndIncrement()));
            FlowKey flowKey = new FlowKey(flowId);
            /**
             * Path to the flow we want to program.
             */
            InstanceIdentifier<Flow> flowPath = InstanceIdentifierUtils.createFlowPath(tablePath, flowKey);
            Short tableId = InstanceIdentifierUtils.getTableId(tablePath);
            FlowBuilder srcToDstFlow = FlowUtils.createDirectMacToMacFlow(tableId, DIRECT_FLOW_PRIORITY, srcMac, dstMac, destNodeConnector);
            srcToDstFlow.setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement())));
            dataStoreAccessor.writeFlowToConfig(flowPath, srcToDstFlow.build());
        }
    }
}
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) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)

Example 27 with FlowId

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

the class Activator method createFlow.

private static Flow createFlow(String flowId, long groupId, int priority, short tableId) {
    MatchBuilder matchBuilder = new MatchBuilder();
    matchBuilder.setEthernetMatch(new EthernetMatchBuilder().setEthernetType(new EthernetTypeBuilder().setType(new EtherType(2048L)).build()).build());
    FlowBuilder flowBuilder = new FlowBuilder();
    flowBuilder.setMatch(matchBuilder.build());
    flowBuilder.setInstructions(createGroupInstructions(groupId).build());
    flowBuilder.setPriority(priority);
    flowBuilder.setCookie(new FlowCookie(new BigInteger(flowId + "" + priority)));
    FlowKey key = new FlowKey(new FlowId(flowId));
    flowBuilder.setHardTimeout(0);
    flowBuilder.setIdleTimeout(0);
    flowBuilder.setStrict(false);
    flowBuilder.setContainerName(null);
    flowBuilder.setId(new FlowId(flowId));
    flowBuilder.setTableId(tableId);
    flowBuilder.setKey(key);
    flowBuilder.setFlowName("FlowWithGroupInstruction");
    return flowBuilder.build();
}
Also used : FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) EthernetTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder) BigInteger(java.math.BigInteger) EtherType(org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType) EthernetMatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder) Ipv4MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder) 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 28 with FlowId

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

the class LLDPPacketPuntEnforcer method createFlow.

static Flow createFlow() {
    FlowBuilder flowBuilder = new FlowBuilder();
    flowBuilder.setMatch(new MatchBuilder().build());
    flowBuilder.setInstructions(createSendToControllerInstructions().build());
    flowBuilder.setPriority(0);
    FlowKey key = new FlowKey(new FlowId(DEFAULT_FLOW_ID));
    flowBuilder.setBarrier(Boolean.FALSE);
    flowBuilder.setBufferId(OFConstants.OFP_NO_BUFFER);
    BigInteger value = BigInteger.valueOf(10L);
    flowBuilder.setCookie(new FlowCookie(value));
    flowBuilder.setCookieMask(new FlowCookie(value));
    flowBuilder.setHardTimeout(0);
    flowBuilder.setIdleTimeout(0);
    flowBuilder.setInstallHw(false);
    flowBuilder.setStrict(false);
    flowBuilder.setContainerName(null);
    flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
    flowBuilder.setId(new FlowId("12"));
    flowBuilder.setTableId(TABLE_ID);
    flowBuilder.setKey(key);
    flowBuilder.setFlowName(LLDP_PUNT_WHOLE_PACKET_FLOW);
    return flowBuilder.build();
}
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) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)

Example 29 with FlowId

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

the class FlowStatNotificationSupplierImpl method createNotification.

@Override
public FlowsStatisticsUpdate createNotification(final FlowStatistics flowStatistics, final InstanceIdentifier<FlowStatistics> path) {
    Preconditions.checkArgument(flowStatistics != null);
    Preconditions.checkArgument(path != null);
    final FlowAndStatisticsMapListBuilder fsmlBuilder = new FlowAndStatisticsMapListBuilder(flowStatistics);
    fsmlBuilder.setFlowId(new FlowId(path.firstKeyOf(Flow.class, FlowKey.class).getId().getValue()));
    final FlowsStatisticsUpdateBuilder builder = new FlowsStatisticsUpdateBuilder();
    builder.setId(getNodeId(path));
    builder.setMoreReplies(Boolean.FALSE);
    // NOTE : fix if it needs, but we have to ask DataStore for the NodeConnector list
    builder.setNodeConnector(Collections.<NodeConnector>emptyList());
    builder.setFlowAndStatisticsMapList(Collections.singletonList(fsmlBuilder.build()));
    return builder.build();
}
Also used : FlowAndStatisticsMapListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapListBuilder) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId) FlowsStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdateBuilder)

Example 30 with FlowId

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

the class OpenflowpluginTestCommandProvider method _testAllFlows.

/*
     * usage testAllFlows <dp>
     * ex: _perfFlowTest 1
     */
@SuppressWarnings("checkstyle:IllegalCatch")
public void _testAllFlows(final CommandInterpreter ci) {
    String dataPathID = ci.nextArgument();
    final int numberOfFlows = 82;
    if (dataPathID == null || dataPathID.trim().equals("")) {
        dataPathID = "1";
    }
    ci.println("*     Test All Flows    *");
    ci.println("*     dataPathID:::" + dataPathID + "");
    final String dataPath = "openflow:" + dataPathID;
    final String tableId = "0";
    final NodeBuilder tn = createTestNode(dataPath);
    FlowBuilder tf;
    for (int flow = 1; flow < numberOfFlows; flow++) {
        final String flowID = "f" + flow;
        try {
            tf = createTestFlow(tn, flowID, tableId);
            writeFlow(ci, tf, tn);
        } catch (RuntimeException e) {
            ci.println("--Test Failed--Issue found while adding flow" + flow);
            break;
        }
    }
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) NodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder)

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