1 package org.opendaylight.openflowplugin.test;
3 import com.google.common.util.concurrent.CheckedFuture;
4 import com.google.common.util.concurrent.FutureCallback;
5 import com.google.common.util.concurrent.Futures;
6 import java.math.BigInteger;
7 import java.util.ArrayList;
9 import org.eclipse.osgi.framework.console.CommandInterpreter;
10 import org.eclipse.osgi.framework.console.CommandProvider;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
16 import org.opendaylight.controller.sal.binding.api.NotificationService;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.node.error.service.rev140410.NodeErrorListener;
106 import org.opendaylight.yangtools.concepts.Registration;
107 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
108 import org.osgi.framework.BundleContext;
109 import org.slf4j.Logger;
110 import org.slf4j.LoggerFactory;
112 //import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.M
114 public class OpenflowPluginBulkTransactionProvider implements CommandProvider {
116 private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
117 private DataBroker dataBroker;
118 private final BundleContext ctx;
119 private NodeBuilder testNode;
120 private ProviderContext pc;
121 private FlowBuilder testFlow;
122 private final String originalFlowName = "Foo";
123 private final NodeErrorListener nodeErrorListener = new NodeErrorListenerLoggingImpl();
124 private Registration listener1Reg;
125 private Registration listener2Reg;
126 private Node testNode12;
127 private final String originalGroupName = "Foo";
128 private static NotificationService notificationService;
130 public OpenflowPluginBulkTransactionProvider(BundleContext ctx) {
134 public void onSessionInitiated(ProviderContext session) {
136 notificationService = session.getSALService(NotificationService.class);
137 listener2Reg = notificationService.registerNotificationListener(nodeErrorListener);
138 dataBroker = session.getSALService(DataBroker.class);
139 ctx.registerService(CommandProvider.class.getName(), this, null);
140 createTestFlow(createTestNode(null), null, null);
143 private NodeBuilder createTestNode(String nodeId) {
144 if (nodeId == null) {
145 nodeId = OpenflowpluginTestActivator.NODE_ID;
147 NodeRef nodeOne = createNodeRef(nodeId);
148 NodeBuilder builder = new NodeBuilder();
149 builder.setId(new NodeId(nodeId));
150 builder.setKey(new NodeKey(builder.getId()));
155 private static NodeRef createNodeRef(String string) {
156 NodeKey key = new NodeKey(new NodeId(string));
157 InstanceIdentifier<Node> path = InstanceIdentifier.create(Nodes.class).child(Node.class, key);
159 return new NodeRef(path);
163 public String getHelp() {
167 private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
169 FlowBuilder flow = new FlowBuilder();
172 String flowType = flowTypeArg;
173 if (flowType == null) {
180 flow.setMatch(createMatch1().build());
181 flow.setInstructions(createDecNwTtlInstructions().build());
185 flow.setMatch(createMatch2().build());
186 flow.setInstructions(createDropInstructions().build());
190 flow.setMatch(createMatch3().build());
191 flow.setInstructions(createDropInstructions().build());
195 flow.setMatch(createEthernetMatch().build());
196 flow.setInstructions(createDropInstructions().build());
200 flow.setMatch(createMatch1().build());
201 flow.setInstructions(createAppyActionInstruction().build());
205 flow.setMatch(createMatch1().build());
206 flow.setInstructions(createGotoTableInstructions().build());
210 flow.setMatch(createMatch1().build());
211 flow.setInstructions(createMeterInstructions().build());
215 flow.setMatch(createMatch1().build());
216 flow.setInstructions(createAppyActionInstruction7().build());
220 flow.setMatch(createMatch1().build());
221 flow.setInstructions(createAppyActionInstruction2().build());
225 flow.setMatch(createMatch1().build());
226 flow.setInstructions(createAppyActionInstruction3().build());
230 flow.setMatch(createMatch1().build());
231 flow.setInstructions(createAppyActionInstruction16().build());
235 flow.setMatch(createMatch1().build());
236 flow.setInstructions(createAppyActionInstruction160().build());
240 flow.setMatch(createMatch1().build());
241 flow.setInstructions(createAppyActionInstruction26().build());
245 flow.setMatch(createMatch1().build());
246 flow.setInstructions(createAppyActionInstruction27().build());
250 flow.setMatch(createMatch1().build());
251 flow.setInstructions(createAppyActionInstruction28().build());
255 flow.setMatch(createMatch1().build());
256 flow.setInstructions(createAppyActionInstruction34().build());
260 flow.setMatch(createICMPv6Match().build());
261 flow.setInstructions(createDecNwTtlInstructions().build());
265 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
266 flow.setInstructions(createDropInstructions().build());
270 flow.setMatch(createMetadataMatch().build());
271 flow.setInstructions(createDropInstructions().build());
275 flow.setMatch(createL3IPv6Match().build());
276 flow.setInstructions(createDecNwTtlInstructions().build());
280 flow.setMatch(createLLDPMatch().build());
281 flow.setInstructions(createSentToControllerInstructions().build());
286 flow.setMatch(createMatch1().build());
287 flow.setInstructions(createDropInstructions().build());
291 flow.setMatch(createMatch2().build());
292 flow.setInstructions(createDecNwTtlInstructions().build());
296 flow.setMatch(createMatch3().build());
297 flow.setInstructions(createDecNwTtlInstructions().build());
301 flow.setMatch(createEthernetMatch().build());
302 flow.setInstructions(createMeterInstructions().build());
306 flow.setMatch(createMatch1().build());
307 flow.setInstructions(createDecNwTtlInstructions().build());
311 flow.setMatch(createMatch1().build());
312 flow.setInstructions(createAppyActionInstruction7().build());
316 flow.setMatch(createEthernetMatch().build());
317 flow.setInstructions(createAppyActionInstruction6().build());
321 flow.setMatch(createEthernetMatch().build());
322 flow.setInstructions(createAppyActionInstruction7().build());
326 flow.setMatch(createMatch1().build());
327 flow.setInstructions(createAppyActionInstruction9().build());
331 flow.setMatch(createMatch1().build());
332 flow.setInstructions(createAppyActionInstruction9().build());
336 flow.setMatch(createMatch1().build());
337 flow.setInstructions(createAppyActionInstruction6().build());
341 flow.setMatch(createMatch1().build());
342 flow.setInstructions(createDecNwTtlInstructions().build());
346 flow.setMatch(createMatch1().build());
347 flow.setInstructions(createDecNwTtlInstructions().build());
351 flow.setMatch(createMatch1().build());
352 flow.setInstructions(createDecNwTtlInstructions().build());
356 flow.setMatch(createICMPv6Match().build());
357 flow.setInstructions(createDropInstructions().build());
361 flow.setMatch(createInphyportMatch(nodeBuilder.getId()).build());
362 flow.setInstructions(createMeterInstructions().build());
366 flow.setMatch(createMetadataMatch().build());
367 flow.setInstructions(createAppyActionInstruction6().build());
371 flow.setMatch(createMatch1().build());
372 flow.setInstructions(createAppyActionInstruction6().build());
376 flow.setMatch(createMatch1().build());
377 flow.setInstructions(createAppyActionInstruction7().build());
381 flow.setMatch(createMatch1().build());
382 flow.setInstructions(createAppyActionInstruction8().build());
386 flow.setMatch(createMatch3().build());
387 flow.setInstructions(createMeterInstructions().build());
391 flow.setMatch(createMatch1000().build());
392 flow.setInstructions(createAppyActionInstruction6().build());
396 flow.setMatch(createMatch1000().build());
397 flow.setInstructions(createAppyActionInstruction2().build());
401 flow.setMatch(createMatch1000().build());
402 flow.setInstructions(createAppyActionInstruction3().build());
405 LOG.warn("flow type not understood: {}", flowType);
408 FlowKey key = new FlowKey(new FlowId(Long.toString(id)));
409 if (null == flow.isBarrier()) {
410 flow.setBarrier(Boolean.FALSE);
412 // flow.setBufferId(12L);
413 BigInteger value = BigInteger.valueOf(10);
414 BigInteger outputPort = BigInteger.valueOf(4294967295L);
415 flow.setCookie(new FlowCookie(value));
416 flow.setCookieMask(new FlowCookie(value));
417 flow.setHardTimeout(0);
418 flow.setIdleTimeout(0);
419 flow.setInstallHw(false);
420 flow.setStrict(false);
421 flow.setContainerName(null);
422 flow.setFlags(new FlowModFlags(false, false, false, false, true));
423 flow.setId(new FlowId("12"));
424 flow.setTableId(getTableId(tableId));
425 flow.setOutGroup(4294967295L);
426 // set outport to OFPP_NONE (65535) to disable remove restriction for
428 flow.setOutPort(outputPort);
432 flow.setFlowName(originalFlowName + "X" + flowType);
437 private short getTableId(String tableId) {
440 table = Short.parseShort(tableId);
441 } catch (Exception ex) {
442 // ignore exception and continue with default value
449 private void createTestNode() {
450 NodeRef nodeOne = createNodeRef(OpenflowpluginTestActivator.NODE_ID);
451 NodeBuilder builder = new NodeBuilder();
452 builder.setId(new NodeId(OpenflowpluginTestActivator.NODE_ID));
453 builder.setKey(new NodeKey(builder.getId()));
454 testNode12 = builder.build();
457 public void _addFlows(CommandInterpreter ci) {
458 NodeBuilder tn = createTestNode(ci.nextArgument());
459 String flowtype = ci.nextArgument();
460 Integer flowcnt = Integer.parseInt(flowtype);
467 tf = createTestFlow(tn, "f1", "10");
468 tf1 = createTestFlow(tn, "f2", "11");
469 tf2 = createTestFlow(tn, "f3", "12");
470 tf3 = createTestFlow(tn, "f4", "13");
473 tf = createTestFlow(tn, "f3", "3");
474 tf1 = createTestFlow(tn, "f4", "4");
475 tf2 = createTestFlow(tn, "f5", "5");
476 tf3 = createTestFlow(tn, "f6", "6");
479 tf = createTestFlow(tn, "f7", "7");
480 tf1 = createTestFlow(tn, "f8", "8");
481 tf2 = createTestFlow(tn, "f9", "9");
482 tf3 = createTestFlow(tn, "f10", "10");
486 tf = createTestFlow(tn, "f23", "3");
487 tf1 = createTestFlow(tn, "f34", "4");
488 tf2 = createTestFlow(tn, "f35", "5");
489 tf3 = createTestFlow(tn, "f36", "6");
494 tf = createTestFlow(tn, "f230", "3");
495 tf1 = createTestFlow(tn, "f34", "4");
496 tf2 = createTestFlow(tn, "f35", "5");
497 tf3 = createTestFlow(tn, "f36", "6");
501 tf = createTestFlow(tn, "f42", "42");
502 tf1 = createTestFlow(tn, "f43", "43");
503 tf2 = createTestFlow(tn, "f44", "44");
504 tf3 = createTestFlow(tn, "f45", "45");
507 writeFlow(ci, tf, tf1, tf2, tf3, tn);
510 private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
511 return InstanceIdentifier.create(Nodes.class).child(Node.class, node.getKey());
514 public void _modifyFlows(CommandInterpreter ci) {
515 NodeBuilder tn = createTestNode(ci.nextArgument());
516 String flowtype = ci.nextArgument();
517 Integer flowcnt = Integer.parseInt(flowtype);
524 tf = createTestFlow(tn, "f82", "10");
525 tf1 = createTestFlow(tn, "f83", "11");
526 tf2 = createTestFlow(tn, "f84", "12");
527 tf3 = createTestFlow(tn, "f85", "13");
530 tf = createTestFlow(tn, "f700", "3");
531 tf1 = createTestFlow(tn, "f4", "4");
532 tf2 = createTestFlow(tn, "f900", "5");
533 tf3 = createTestFlow(tn, "f86", "6");
537 tf = createTestFlow(tn, "f91", "7");
538 tf1 = createTestFlow(tn, "f92", "8");
539 tf2 = createTestFlow(tn, "f93", "9");
540 tf3 = createTestFlow(tn, "f94", "10");
544 tf = createTestFlow(tn, "f230", "3");
545 tf1 = createTestFlow(tn, "f99", "4");
546 tf2 = createTestFlow(tn, "f100", "5");
547 tf3 = createTestFlow(tn, "f101", "6");
551 tf = createTestFlow(tn, "f23", "3");
552 tf1 = createTestFlow(tn, "f99", "4");
553 tf2 = createTestFlow(tn, "f100", "5");
554 tf3 = createTestFlow(tn, "f101", "6");
558 tf = createTestFlow(tn, "f87", "12");
559 tf1 = createTestFlow(tn, "f88", "13");
560 tf2 = createTestFlow(tn, "f89", "14");
561 tf3 = createTestFlow(tn, "f90", "15");
565 writeFlow(ci, tf, tf1, tf2, tf3, tn);
569 public void _removeFlows(final CommandInterpreter ci) {
570 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
571 NodeBuilder tn = createTestNode(ci.nextArgument());
572 String flowtype = ci.nextArgument();
573 Integer flowcnt = Integer.parseInt(flowtype);
574 FlowBuilder tf = null;
575 FlowBuilder tf1 = null;
576 FlowBuilder tf2 = null;
577 FlowBuilder tf3 = null;
581 tf = createTestFlow(tn, "f1", "10");
582 tf1 = createTestFlow(tn, "f2", "11");
583 tf2 = createTestFlow(tn, "f3", "12");
584 tf3 = createTestFlow(tn, "f4", "13");
588 tf = createTestFlow(tn, "f82", "10");
589 tf1 = createTestFlow(tn, "f83", "11");
590 tf2 = createTestFlow(tn, "f84", "12");
591 tf3 = createTestFlow(tn, "f85", "13");
595 tf = createTestFlow(tn, "f3", "3");
596 tf1 = createTestFlow(tn, "f4", "4");
597 tf2 = createTestFlow(tn, "f5", "5");
598 tf3 = createTestFlow(tn, "f6", "6");
602 tf = createTestFlow(tn, "f700", "3");
603 tf1 = createTestFlow(tn, "f4", "4");
604 tf2 = createTestFlow(tn, "f900", "5");
605 tf3 = createTestFlow(tn, "f86", "6");
609 tf = createTestFlow(tn, "f7", "7");
610 tf1 = createTestFlow(tn, "f8", "8");
611 tf2 = createTestFlow(tn, "f9", "9");
612 tf3 = createTestFlow(tn, "f10", "10");
616 tf = createTestFlow(tn, "f91", "7");
617 tf1 = createTestFlow(tn, "f92", "8");
618 tf2 = createTestFlow(tn, "f93", "9");
619 tf3 = createTestFlow(tn, "f94", "10");
623 tf = createTestFlow(tn, "f23", "3");
624 tf1 = createTestFlow(tn, "f34", "4");
625 tf2 = createTestFlow(tn, "f35", "5");
626 tf3 = createTestFlow(tn, "f36", "6");
631 tf = createTestFlow(tn, "f23", "3");
632 tf1 = createTestFlow(tn, "f99", "4");
633 tf2 = createTestFlow(tn, "f100", "5");
634 tf3 = createTestFlow(tn, "f101", "6");
638 tf = createTestFlow(tn, "f700", "7");
639 tf1 = createTestFlow(tn, "f230", "23");
640 tf2 = createTestFlow(tn, "f900", "9");
641 tf3 = createTestFlow(tn, "f1000", "10");
645 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
646 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
647 .child(Flow.class, tf.getKey());
648 modification.delete(LogicalDatastoreType.OPERATIONAL, path1);
649 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
650 modification.delete(LogicalDatastoreType.CONFIGURATION, path1);
651 InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
652 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf1.getTableId()))
653 .child(Flow.class, tf1.getKey());
654 modification.delete(LogicalDatastoreType.OPERATIONAL, path2);
655 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
656 modification.delete(LogicalDatastoreType.CONFIGURATION, path2);
658 InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
659 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf2.getTableId()))
660 .child(Flow.class, tf2.getKey());
661 modification.delete(LogicalDatastoreType.OPERATIONAL, path3);
662 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
663 modification.delete(LogicalDatastoreType.CONFIGURATION, path3);
664 InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class).child(Node.class, tn.getKey())
665 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf3.getTableId()))
666 .child(Flow.class, tf3.getKey());
667 modification.delete(LogicalDatastoreType.OPERATIONAL, path4);
668 modification.delete(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(tn));
669 modification.delete(LogicalDatastoreType.CONFIGURATION, path4);
670 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
671 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
673 public void onSuccess(Void aVoid) {
674 ci.println("Status of Group Data Loaded Transaction: success.");
678 public void onFailure(Throwable throwable) {
679 LOG.error(throwable.getMessage(), throwable);
680 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
686 private void writeFlow(final CommandInterpreter ci, FlowBuilder flow, FlowBuilder flow1, FlowBuilder flow2,
687 FlowBuilder flow3, NodeBuilder nodeBuilder) {
688 ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
689 InstanceIdentifier<Flow> path1 = InstanceIdentifier.create(Nodes.class)
690 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
691 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey());
692 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
693 modification.merge(LogicalDatastoreType.OPERATIONAL, path1, flow.build(), true);
694 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
695 modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
696 InstanceIdentifier<Flow> path2 = InstanceIdentifier.create(Nodes.class)
697 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
698 .child(Table.class, new TableKey(flow1.getTableId())).child(Flow.class, flow1.getKey());
699 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
700 modification.merge(LogicalDatastoreType.OPERATIONAL, path2, flow1.build(), true);
701 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
702 modification.merge(LogicalDatastoreType.CONFIGURATION, path2, flow1.build(), true);
704 InstanceIdentifier<Flow> path3 = InstanceIdentifier.create(Nodes.class)
705 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
706 .child(Table.class, new TableKey(flow2.getTableId())).child(Flow.class, flow2.getKey());
707 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
708 modification.merge(LogicalDatastoreType.OPERATIONAL, path3, flow2.build(), true);
709 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
710 modification.merge(LogicalDatastoreType.CONFIGURATION, path3, flow2.build(), true);
712 InstanceIdentifier<Flow> path4 = InstanceIdentifier.create(Nodes.class)
713 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
714 .child(Table.class, new TableKey(flow3.getTableId())).child(Flow.class, flow3.getKey());
715 modification.merge(LogicalDatastoreType.OPERATIONAL, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
716 modification.merge(LogicalDatastoreType.OPERATIONAL, path4, flow3.build(), true);
717 modification.merge(LogicalDatastoreType.CONFIGURATION, nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build(), true);
718 modification.merge(LogicalDatastoreType.CONFIGURATION, path4, flow3.build(), true);
719 CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
720 Futures.addCallback(commitFuture, new FutureCallback<Void>() {
722 public void onSuccess(Void aVoid) {
723 ci.println("Status of Group Data Loaded Transaction: success.");
727 public void onFailure(Throwable throwable) {
728 LOG.error(throwable.getMessage(), throwable);
729 ci.println(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
737 private static InstructionsBuilder createDecNwTtlInstructions() {
738 DecNwTtlBuilder ta = new DecNwTtlBuilder();
739 DecNwTtl decNwTtl = ta.build();
740 ActionBuilder ab = new ActionBuilder();
741 ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
743 // Add our drop action to a list
744 List<Action> actionList = new ArrayList<Action>();
745 actionList.add(ab.build());
747 // Create an Apply Action
748 ApplyActionsBuilder aab = new ApplyActionsBuilder();
749 aab.setAction(actionList);
751 // Wrap our Apply Action in an Instruction
752 InstructionBuilder ib = new InstructionBuilder();
753 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
754 ib.setKey(new InstructionKey(0));
757 // Put our Instruction in a list of Instructions
758 InstructionsBuilder isb = new InstructionsBuilder();
759 List<Instruction> instructions = new ArrayList<Instruction>();
760 instructions.add(ib.build());
761 isb.setInstruction(instructions);
768 private static InstructionsBuilder createMeterInstructions() {
770 MeterBuilder aab = new MeterBuilder();
771 aab.setMeterId(new MeterId(1L));
773 InstructionBuilder ib = new InstructionBuilder();
774 ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
776 // Put our Instruction in a list of Instructions
777 InstructionsBuilder isb = new InstructionsBuilder();
778 List<Instruction> instructions = new ArrayList<Instruction>();
779 instructions.add(ib.build());
780 isb.setInstruction(instructions);
784 private static InstructionsBuilder createGotoTableInstructions() {
786 GoToTableBuilder aab = new GoToTableBuilder();
787 aab.setTableId((short) 2);
789 InstructionBuilder ib = new InstructionBuilder();
790 ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
792 // Put our Instruction in a list of Instructions
793 InstructionsBuilder isb = new InstructionsBuilder();
794 List<Instruction> instructions = new ArrayList<Instruction>();
795 instructions.add(ib.build());
796 isb.setInstruction(instructions);
800 private static InstructionsBuilder createDropInstructions() {
801 DropActionBuilder dab = new DropActionBuilder();
802 DropAction dropAction = dab.build();
803 ActionBuilder ab = new ActionBuilder();
804 ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
806 // Add our drop action to a list
807 List<Action> actionList = new ArrayList<Action>();
808 actionList.add(ab.build());
810 // Create an Apply Action
811 ApplyActionsBuilder aab = new ApplyActionsBuilder();
812 aab.setAction(actionList);
814 // Wrap our Apply Action in an Instruction
815 InstructionBuilder ib = new InstructionBuilder();
816 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
818 // Put our Instruction in a list of Instructions
819 InstructionsBuilder isb = new InstructionsBuilder();
820 List<Instruction> instructions = new ArrayList<Instruction>();
821 instructions.add(ib.build());
822 isb.setInstruction(instructions);
826 private static InstructionsBuilder createAppyActionInstruction() {
828 List<Action> actionList = new ArrayList<Action>();
829 ActionBuilder ab = new ActionBuilder();
830 ControllerActionBuilder controller = new ControllerActionBuilder();
831 controller.setMaxLength(5);
832 ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
833 actionList.add(ab.build());
834 // Create an Apply Action
835 ApplyActionsBuilder aab = new ApplyActionsBuilder();
836 aab.setAction(actionList);
838 // Wrap our Apply Action in an Instruction
839 InstructionBuilder ib = new InstructionBuilder();
840 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
842 // Put our Instruction in a list of Instructions
843 InstructionsBuilder isb = new InstructionsBuilder();
844 List<Instruction> instructions = new ArrayList<Instruction>();
845 instructions.add(ib.build());
846 isb.setInstruction(instructions);
850 private static InstructionsBuilder createSentToControllerInstructions() {
851 List<Action> actionList = new ArrayList<Action>();
852 ActionBuilder ab = new ActionBuilder();
854 OutputActionBuilder output = new OutputActionBuilder();
855 output.setMaxLength(0xffff);
856 Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
857 output.setOutputNodeConnector(value);
858 ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
860 ab.setKey(new ActionKey(0));
861 actionList.add(ab.build());
862 // Create an Apply Action
863 ApplyActionsBuilder aab = new ApplyActionsBuilder();
864 aab.setAction(actionList);
866 // Wrap our Apply Action in an Instruction
867 InstructionBuilder ib = new InstructionBuilder();
868 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
870 ib.setKey(new InstructionKey(0));
872 // Put our Instruction in a list of Instructions
873 InstructionsBuilder isb = new InstructionsBuilder();
874 List<Instruction> instructions = new ArrayList<Instruction>();
875 instructions.add(ib.build());
876 isb.setInstruction(instructions);
880 private static InstructionsBuilder createAppyActionInstruction2() {
882 List<Action> actionList = new ArrayList<Action>();
883 ActionBuilder ab = new ActionBuilder();
885 PushMplsActionBuilder push = new PushMplsActionBuilder();
886 push.setEthernetType(0x8847);
887 ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
888 actionList.add(ab.build());
889 // Create an Apply Action
890 ApplyActionsBuilder aab = new ApplyActionsBuilder();
891 aab.setAction(actionList);
893 // Wrap our Apply Action in an Instruction
894 InstructionBuilder ib = new InstructionBuilder();
895 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
897 // Put our Instruction in a list of Instructions
898 InstructionsBuilder isb = new InstructionsBuilder();
899 List<Instruction> instructions = new ArrayList<Instruction>();
900 instructions.add(ib.build());
901 isb.setInstruction(instructions);
905 private static InstructionsBuilder createAppyActionInstruction3() {
907 List<Action> actionList = new ArrayList<Action>();
908 ActionBuilder ab = new ActionBuilder();
910 PushPbbActionBuilder pbb = new PushPbbActionBuilder();
911 pbb.setEthernetType(0x88E7);
912 ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
913 actionList.add(ab.build());
914 // Create an Apply Action
915 ApplyActionsBuilder aab = new ApplyActionsBuilder();
916 aab.setAction(actionList);
918 // Wrap our Apply Action in an Instruction
919 InstructionBuilder ib = new InstructionBuilder();
920 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
922 // Put our Instruction in a list of Instructions
923 InstructionsBuilder isb = new InstructionsBuilder();
924 List<Instruction> instructions = new ArrayList<Instruction>();
925 instructions.add(ib.build());
926 isb.setInstruction(instructions);
930 private static InstructionsBuilder createAppyActionInstruction6() {
932 List<Action> actionList = new ArrayList<Action>();
933 ActionBuilder ab = new ActionBuilder();
935 SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
936 src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
937 ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
938 actionList.add(ab.build());
940 // Create an Apply Action
941 ApplyActionsBuilder aab = new ApplyActionsBuilder();
942 aab.setAction(actionList);
944 // Wrap our Apply Action in an Instruction
945 InstructionBuilder ib = new InstructionBuilder();
946 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
948 // Put our Instruction in a list of Instructions
949 InstructionsBuilder isb = new InstructionsBuilder();
950 List<Instruction> instructions = new ArrayList<Instruction>();
951 instructions.add(ib.build());
952 isb.setInstruction(instructions);
956 private static InstructionsBuilder createAppyActionInstruction7() {
958 List<Action> actionList = new ArrayList<Action>();
959 ActionBuilder ab = new ActionBuilder();
961 SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
962 VlanId a = new VlanId(4012);
964 ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
965 actionList.add(ab.build());
966 // Create an Apply Action
967 ApplyActionsBuilder aab = new ApplyActionsBuilder();
968 aab.setAction(actionList);
970 // Wrap our Apply Action in an Instruction
971 InstructionBuilder ib = new InstructionBuilder();
972 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
974 // Put our Instruction in a list of Instructions
975 InstructionsBuilder isb = new InstructionsBuilder();
976 List<Instruction> instructions = new ArrayList<Instruction>();
977 instructions.add(ib.build());
978 isb.setInstruction(instructions);
982 private static InstructionsBuilder createAppyActionInstruction8() {
984 List<Action> actionList = new ArrayList<Action>();
985 ActionBuilder ab = new ActionBuilder();
987 SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
988 VlanPcp pcp1 = new VlanPcp((short) 2);
989 pcp.setVlanPcp(pcp1);
990 ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
991 actionList.add(ab.build());
992 // Create an Apply Action
993 ApplyActionsBuilder aab = new ApplyActionsBuilder();
994 aab.setAction(actionList);
996 // Wrap our Apply Action in an Instruction
997 InstructionBuilder ib = new InstructionBuilder();
998 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1000 // Put our Instruction in a list of Instructions
1001 InstructionsBuilder isb = new InstructionsBuilder();
1002 List<Instruction> instructions = new ArrayList<Instruction>();
1003 instructions.add(ib.build());
1004 isb.setInstruction(instructions);
1008 private static InstructionsBuilder createAppyActionInstruction9() {
1010 List<Action> actionList = new ArrayList<Action>();
1011 ActionBuilder ab = new ActionBuilder();
1013 CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1014 ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1015 actionList.add(ab.build());
1016 // Create an Apply Action
1017 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1018 aab.setAction(actionList);
1020 // Wrap our Apply Action in an Instruction
1021 InstructionBuilder ib = new InstructionBuilder();
1022 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1024 // Put our Instruction in a list of Instructions
1025 InstructionsBuilder isb = new InstructionsBuilder();
1026 List<Instruction> instructions = new ArrayList<Instruction>();
1027 instructions.add(ib.build());
1028 isb.setInstruction(instructions);
1032 private static InstructionsBuilder createAppyActionInstruction16() {
1034 List<Action> actionList = new ArrayList<Action>();
1035 ActionBuilder ab = new ActionBuilder();
1037 GroupActionBuilder groupActionB = new GroupActionBuilder();
1038 groupActionB.setGroupId(1L);
1039 groupActionB.setGroup("0");
1040 ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1041 actionList.add(ab.build());
1043 // Create an Apply Action
1044 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1045 aab.setAction(actionList);
1047 // Wrap our Apply Action in an Instruction
1048 InstructionBuilder ib = new InstructionBuilder();
1049 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1051 // Put our Instruction in a list of Instructions
1052 InstructionsBuilder isb = new InstructionsBuilder();
1053 List<Instruction> instructions = new ArrayList<Instruction>();
1054 instructions.add(ib.build());
1055 isb.setInstruction(instructions);
1059 private static InstructionsBuilder createAppyActionInstruction160() {
1061 List<Action> actionList = new ArrayList<Action>();
1062 ActionBuilder ab = new ActionBuilder();
1064 FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1065 ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1066 actionList.add(ab.build());
1067 // Create an Apply Action
1068 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1069 aab.setAction(actionList);
1071 // Wrap our Apply Action in an Instruction
1072 InstructionBuilder ib = new InstructionBuilder();
1073 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1075 // Put our Instruction in a list of Instructions
1076 InstructionsBuilder isb = new InstructionsBuilder();
1077 List<Instruction> instructions = new ArrayList<Instruction>();
1078 instructions.add(ib.build());
1079 isb.setInstruction(instructions);
1083 private static InstructionsBuilder createAppyActionInstruction26() {
1085 List<Action> actionList = new ArrayList<Action>();
1086 ActionBuilder ab = new ActionBuilder();
1088 SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1089 Ipv4Builder ipdst = new Ipv4Builder();
1090 Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1091 ipdst.setIpv4Address(prefixdst);
1092 setNwDstActionBuilder.setAddress(ipdst.build());
1093 ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1094 actionList.add(ab.build());
1096 // Create an Apply Action
1097 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1098 aab.setAction(actionList);
1100 // Wrap our Apply Action in an Instruction
1101 InstructionBuilder ib = new InstructionBuilder();
1102 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1104 // Put our Instruction in a list of Instructions
1105 InstructionsBuilder isb = new InstructionsBuilder();
1106 List<Instruction> instructions = new ArrayList<Instruction>();
1107 instructions.add(ib.build());
1108 isb.setInstruction(instructions);
1112 private static InstructionsBuilder createAppyActionInstruction27() {
1114 List<Action> actionList = new ArrayList<Action>();
1115 ActionBuilder ab = new ActionBuilder();
1117 SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1118 Ipv4Builder ipsrc = new Ipv4Builder();
1119 Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1120 ipsrc.setIpv4Address(prefixsrc);
1121 setNwsrcActionBuilder.setAddress(ipsrc.build());
1122 ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1123 actionList.add(ab.build());
1125 // Create an Apply Action
1126 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1127 aab.setAction(actionList);
1129 // Wrap our Apply Action in an Instruction
1130 InstructionBuilder ib = new InstructionBuilder();
1131 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1133 // Put our Instruction in a list of Instructions
1134 InstructionsBuilder isb = new InstructionsBuilder();
1135 List<Instruction> instructions = new ArrayList<Instruction>();
1136 instructions.add(ib.build());
1137 isb.setInstruction(instructions);
1141 private static InstructionsBuilder createAppyActionInstruction28() {
1143 List<Action> actionList = new ArrayList<Action>();
1144 ActionBuilder ab = new ActionBuilder();
1146 SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1147 setNwTosActionBuilder.setTos(8);
1148 ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1149 actionList.add(ab.build());
1150 // Create an Apply Action
1151 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1152 aab.setAction(actionList);
1154 // Wrap our Apply Action in an Instruction
1155 InstructionBuilder ib = new InstructionBuilder();
1156 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1158 // Put our Instruction in a list of Instructions
1159 InstructionsBuilder isb = new InstructionsBuilder();
1160 List<Instruction> instructions = new ArrayList<Instruction>();
1161 instructions.add(ib.build());
1162 isb.setInstruction(instructions);
1166 private static InstructionsBuilder createAppyActionInstruction34() {
1168 List<Action> actionList = new ArrayList<Action>();
1169 ActionBuilder ab = new ActionBuilder();
1171 SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1172 ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1173 actionList.add(ab.build());
1175 // Create an Apply Action
1176 ApplyActionsBuilder aab = new ApplyActionsBuilder();
1177 aab.setAction(actionList);
1179 // Wrap our Apply Action in an Instruction
1180 InstructionBuilder ib = new InstructionBuilder();
1181 ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1183 // Put our Instruction in a list of Instructions
1184 InstructionsBuilder isb = new InstructionsBuilder();
1185 List<Instruction> instructions = new ArrayList<Instruction>();
1186 instructions.add(ib.build());
1187 isb.setInstruction(instructions);
1191 private static MatchBuilder createLLDPMatch() {
1192 MatchBuilder match = new MatchBuilder();
1193 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1194 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1195 ethTypeBuilder.setType(new EtherType(0x88ccL));
1196 eth.setEthernetType(ethTypeBuilder.build());
1197 match.setEthernetMatch(eth.build());
1204 private static MatchBuilder createMatch1() {
1205 MatchBuilder match = new MatchBuilder();
1206 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1207 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1208 ipv4Match.setIpv4Destination(prefix);
1209 Ipv4Match i4m = ipv4Match.build();
1210 match.setLayer3Match(i4m);
1212 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1213 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1214 ethTypeBuilder.setType(new EtherType(0x0800L));
1215 eth.setEthernetType(ethTypeBuilder.build());
1216 match.setEthernetMatch(eth.build());
1220 private static MatchBuilder createMatch1000() {
1221 MatchBuilder match = new MatchBuilder();
1222 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1223 Ipv4Prefix prefix = new Ipv4Prefix("10.1.1.1/24");
1224 ipv4Match.setIpv4Destination(prefix);
1225 Ipv4Match i4m = ipv4Match.build();
1226 match.setLayer3Match(i4m);
1228 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1229 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1230 ethTypeBuilder.setType(new EtherType(0x0800L));
1231 eth.setEthernetType(ethTypeBuilder.build());
1232 match.setEthernetMatch(eth.build());
1239 private static MatchBuilder createMatch2() {
1240 MatchBuilder match = new MatchBuilder();
1241 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1242 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
1243 ipv4Match.setIpv4Source(prefix);
1244 Ipv4Match i4m = ipv4Match.build();
1245 match.setLayer3Match(i4m);
1247 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1248 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1249 ethTypeBuilder.setType(new EtherType(0x0800L));
1250 eth.setEthernetType(ethTypeBuilder.build());
1251 match.setEthernetMatch(eth.build());
1258 private static MatchBuilder createMatch3() {
1259 MatchBuilder match = new MatchBuilder();
1260 EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
1261 EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
1262 ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
1263 ethernetMatch.setEthernetSource(ethSourceBuilder.build());
1264 match.setEthernetMatch(ethernetMatch.build());
1269 private static MatchBuilder createMatch33() {
1271 MatchBuilder match = new MatchBuilder();
1272 Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
1273 Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10");
1274 ipv4Match.setIpv4Source(prefix);
1275 Ipv4Match i4m = ipv4Match.build();
1276 match.setLayer3Match(i4m);
1278 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1279 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1280 ethTypeBuilder.setType(new EtherType(0xfffeL));
1281 eth.setEthernetType(ethTypeBuilder.build());
1282 match.setEthernetMatch(eth.build());
1286 private static MatchBuilder createInphyportMatch(NodeId nodeId) {
1287 MatchBuilder match = new MatchBuilder();
1288 match.setInPort(new NodeConnectorId(nodeId + ":202"));
1289 match.setInPhyPort(new NodeConnectorId(nodeId + ":10122"));
1293 private static MatchBuilder createEthernetMatch() {
1294 MatchBuilder match = new MatchBuilder();
1296 byte[] mask1 = new byte[]{(byte) -1, (byte) -1, 0, 0, 0, 0};
1297 byte[] mask2 = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0};
1299 EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
1301 EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
1302 EtherType type = new EtherType(0x0800L);
1303 ethmatch.setEthernetType(ethtype.setType(type).build());
1305 EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
1308 MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
1309 ethdest.setAddress(macdest);
1310 // ethdest.setMask(mask1);
1312 ethmatch.setEthernetDestination(ethdest.build());
1314 EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
1315 MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
1316 ethsrc.setAddress(macsrc);
1317 // ethsrc.setMask(mask2);
1319 ethmatch.setEthernetSource(ethsrc.build());
1320 match.setEthernetMatch(ethmatch.build());
1328 private static MatchBuilder createL3IPv6Match() {
1329 MatchBuilder match = new MatchBuilder();
1331 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1332 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1333 ethTypeBuilder.setType(new EtherType(0x86ddL));
1334 eth.setEthernetType(ethTypeBuilder.build());
1335 match.setEthernetMatch(eth.build());
1337 Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
1338 Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
1339 Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
1340 MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
1341 MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
1342 Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
1343 nextheader.setIpv6Exthdr(58);
1344 Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
1345 Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
1346 ipv6label.setIpv6Flabel(label);
1347 // ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
1349 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
1351 icmpv6match.setIcmpv6Type((short) 135);
1352 icmpv6match.setIcmpv6Code((short) 0);
1353 match.setIcmpv6Match(icmpv6match.build());
1355 Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
1356 // ipv6match.setIpv6Source(srcip6);
1357 // ipv6match.setIpv6Destination(dstip6);
1358 // ipv6match.setIpv6ExtHeader(nextheader.build());
1359 ipv6match.setIpv6NdSll(ndsll);
1360 ipv6match.setIpv6NdTll(ndtll);
1361 // ipv6match.setIpv6NdTarget(ndtarget);
1362 ipv6match.setIpv6Label(ipv6label.build());
1364 match.setLayer3Match(ipv6match.build());
1372 private static MatchBuilder createICMPv6Match() {
1374 MatchBuilder match = new MatchBuilder();
1375 EthernetMatchBuilder eth = new EthernetMatchBuilder();
1376 EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1377 ethTypeBuilder.setType(new EtherType(0x86ddL));
1378 eth.setEthernetType(ethTypeBuilder.build());
1379 match.setEthernetMatch(eth.build());
1381 IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
1382 ipmatch.setIpProtocol((short) 58);
1383 match.setIpMatch(ipmatch.build());
1385 Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
1387 icmpv6match.setIcmpv6Type((short) 135);
1388 icmpv6match.setIcmpv6Code((short) 1);
1389 match.setIcmpv6Match(icmpv6match.build());
1397 private static MatchBuilder createMetadataMatch() {
1398 MatchBuilder match = new MatchBuilder();
1399 byte[] metamask = new byte[]{(byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1};
1400 MetadataBuilder metadata = new MetadataBuilder(); // metadata match
1401 metadata.setMetadata(BigInteger.valueOf(500L));
1402 // metadata.setMetadataMask(metamask);
1403 match.setMetadata(metadata.build());