Updating TestProvider with PortStatus Listener
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / OpenflowpluginTestCommandProvider.java
1 /*
2  * Copyright (c) 2013 Ericsson , Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowplugin.test;
10
11 import java.math.BigInteger;
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.concurrent.ExecutionException;
15 import java.util.concurrent.Future;
16
17 import org.eclipse.osgi.framework.console.CommandInterpreter;
18 import org.eclipse.osgi.framework.console.CommandProvider;
19 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
20 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
21 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
22 import org.opendaylight.controller.sal.binding.api.NotificationService;
23 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
24 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
29 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
30 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
31 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCaseBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCaseBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCaseBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCaseBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTtlActionCaseBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetQueueActionCaseBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.StripVlanActionCaseBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.in._case.CopyTtlInBuilder;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.copy.ttl.out._case.CopyTtlOutBuilder;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.mpls.ttl._case.DecMplsTtlBuilder;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.mpls.ttl.action._case.SetMplsTtlActionBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.ttl.action._case.SetNwTtlActionBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.queue.action._case.SetQueueActionBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.strip.vlan.action._case.StripVlanActionBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRemoved;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryListener;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6LabelBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
162 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
163 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
164 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
165 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
166 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
167 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
168 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
169 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
170 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
171 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
172 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
173 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatchBuilder;
174 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
175 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
176 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
177 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
178 import org.opendaylight.yangtools.concepts.Registration;
179 import org.opendaylight.yangtools.yang.binding.DataObject;
180 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
181 import org.opendaylight.yangtools.yang.common.RpcResult;
182 import org.osgi.framework.BundleContext;
183 import org.slf4j.Logger;
184 import org.slf4j.LoggerFactory;
185
186 public class OpenflowpluginTestCommandProvider implements CommandProvider {
187
188     private static final Logger LOG = LoggerFactory.getLogger(OpenflowpluginTestCommandProvider.class);
189
190     private DataBrokerService dataBrokerService;
191     private ProviderContext pc;
192     private final BundleContext ctx;
193     private FlowBuilder testFlow;
194     private NodeBuilder testNode;
195     private final String originalFlowName = "Foo";
196     private final String updatedFlowName = "Bar";
197     private final FlowEventListener flowEventListener = new FlowEventListener();
198     private final PortEventListener portEventListener = new PortEventListener();
199     private static NotificationService notificationService;
200     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener1Reg;
201     private Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> listener2Reg;
202
203     public OpenflowpluginTestCommandProvider(BundleContext ctx) {
204         this.ctx = ctx;
205     }
206
207     public void onSessionInitiated(ProviderContext session) {
208         pc = session;
209         notificationService = session.getSALService(NotificationService.class);
210         // For switch events
211         listener1Reg = notificationService.registerNotificationListener(flowEventListener);
212         listener2Reg = notificationService.registerNotificationListener(portEventListener);
213         dataBrokerService = session.getSALService(DataBrokerService.class);
214         ctx.registerService(CommandProvider.class.getName(), this, null);
215         createTestFlow(createTestNode(null), null, null);
216     }
217
218     private NodeBuilder createTestNode(String nodeId) {
219         if (nodeId == null) {
220             nodeId = OpenflowpluginTestActivator.NODE_ID;
221         }
222         NodeRef nodeOne = createNodeRef(nodeId);
223         NodeBuilder builder = new NodeBuilder();
224         builder.setId(new NodeId(nodeId));
225         builder.setKey(new NodeKey(builder.getId()));
226         testNode = builder;
227         return builder;
228     }
229
230     final class FlowEventListener implements SalFlowListener {
231
232         List<FlowAdded> addedFlows = new ArrayList<>();
233         List<FlowRemoved> removedFlows = new ArrayList<>();
234         List<FlowUpdated> updatedFlows = new ArrayList<>();
235
236         @Override
237         public void onFlowAdded(FlowAdded notification) {
238             System.out.println("flow to be added.........................." + notification.toString());
239             System.out.println("added flow Xid........................." + notification.getTransactionId().getValue());
240             System.out.println("-----------------------------------------------------------------------------------");
241             addedFlows.add(notification);
242         }
243
244         @Override
245         public void onFlowRemoved(FlowRemoved notification) {
246             System.out.println("removed flow.........................." + notification.toString());
247             System.out.println("remove flow Xid........................." + notification.getTransactionId().getValue());
248             System.out.println("-----------------------------------------------------------------------------------");
249             removedFlows.add(notification);
250         };
251
252         @Override
253         public void onFlowUpdated(FlowUpdated notification) {
254             System.out.println("updated flow.........................." + notification.toString());
255             System.out
256                     .println("updated flow Xid........................." + notification.getTransactionId().getValue());
257             System.out.println("-----------------------------------------------------------------------------------");
258             updatedFlows.add(notification);
259         }
260
261         @Override
262         public void onNodeErrorNotification(NodeErrorNotification notification) {
263             System.out.println("Error notification  flow Xid........................."
264                     + notification.getTransactionId().getValue());
265             System.out.println("-----------------------------------------------------------------------------------");
266         }
267
268         @Override
269         public void onNodeExperimenterErrorNotification(NodeExperimenterErrorNotification notification) {
270             // TODO Auto-generated method stub
271
272         }
273
274         @Override
275         public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
276             System.out
277                     .println("Switch flow removed : Cookies..................." + notification.getCookie().toString());
278             System.out.println("-----------------------------------------------------------------------------------");
279         }
280
281     }
282
283     final class PortEventListener implements OpendaylightInventoryListener {
284
285         @Override
286         public void onNodeConnectorRemoved(NodeConnectorRemoved notification) {
287             System.out.println("PortStatusMessage: NodeConnectorRemoved ...................");
288             System.out.println(notification.getNodeConnectorRef());
289             System.out.println("----------------------------------------------------------------------");
290         }
291
292         @Override
293         public void onNodeConnectorUpdated(NodeConnectorUpdated notification) {
294             System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
295             System.out.println(notification.getNodeConnectorRef());
296             System.out.println("----------------------------------------------------------------------");
297         }
298
299         @Override
300         public void onNodeRemoved(NodeRemoved notification) {
301             System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
302             System.out.println(notification.getNodeRef());
303             System.out.println("----------------------------------------------------------------------");
304         }
305
306         @Override
307         public void onNodeUpdated(NodeUpdated notification) {
308             System.out.println("PortStatusMessage: NodeConnectorUpdated ...................");
309             System.out.println(notification.getNodeRef());
310             System.out.println("----------------------------------------------------------------------");
311         }
312
313     }
314
315     private InstanceIdentifier<Node> nodeBuilderToInstanceId(NodeBuilder node) {
316         return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
317     }
318
319     private FlowBuilder createTestFlow(NodeBuilder nodeBuilder, String flowTypeArg, String tableId) {
320
321         FlowBuilder flow = new FlowBuilder();
322         long id = 123;
323
324         String flowType = flowTypeArg;
325         if (flowType == null) {
326             flowType = "f1";
327         }
328
329         switch (flowType) {
330         case "f1":
331             id += 1;
332             flow.setMatch(createMatch1().build());
333             flow.setInstructions(createDecNwTtlInstructions().build());
334             break;
335         case "f2":
336             id += 2;
337             flow.setMatch(createMatch2().build());
338             flow.setInstructions(createDropInstructions().build());
339             break;
340         case "f3":
341             id += 3;
342             flow.setMatch(createMatch3().build());
343             flow.setInstructions(createDropInstructions().build());
344             break;
345         case "f4":
346             id += 4;
347             flow.setMatch(createEthernetMatch().build());
348             flow.setInstructions(createDropInstructions().build());
349             break;
350         case "f5":
351             id += 5;
352             flow.setMatch(createMatch1().build());
353             flow.setInstructions(createAppyActionInstruction().build());
354             break;
355         case "f6":
356             id += 6;
357             flow.setMatch(createMatch1().build());
358             flow.setInstructions(createGotoTableInstructions().build());
359             break;
360         case "f7":
361             id += 7;
362             flow.setMatch(createMatch1().build());
363             flow.setInstructions(createMeterInstructions().build());
364             break;
365         case "f8":
366             id += 8;
367             flow.setMatch(createMatch1().build());
368             flow.setInstructions(createAppyActionInstruction1().build());
369             break;
370         case "f9":
371             id += 9;
372             flow.setMatch(createMatch1().build());
373             flow.setInstructions(createAppyActionInstruction2().build());
374             break;
375         case "f10":
376             id += 10;
377             flow.setMatch(createMatch1().build());
378             flow.setInstructions(createAppyActionInstruction3().build());
379             break;
380         case "f11":
381             id += 11;
382             flow.setMatch(createMatch1().build());
383             flow.setInstructions(createAppyActionInstruction4().build());
384             break;
385         case "f12":
386             id += 12;
387             flow.setMatch(createMatch1().build());
388             flow.setInstructions(createAppyActionInstruction5().build());
389             break;
390         case "f13":
391             id += 13;
392             flow.setMatch(createMatch1().build());
393             flow.setInstructions(createAppyActionInstruction6().build());
394             break;
395         case "f14":
396             id += 14;
397             flow.setMatch(createMatch1().build());
398             flow.setInstructions(createAppyActionInstruction7().build());
399             break;
400         case "f15":
401             id += 15;
402             flow.setMatch(createMatch1().build());
403             flow.setInstructions(createAppyActionInstruction8().build());
404             break;
405         case "f16":
406             id += 16;
407             flow.setMatch(createMatch1().build());
408             flow.setInstructions(createAppyActionInstruction9().build());
409             break;
410         case "f17":
411             id += 17;
412             flow.setMatch(createMatch1().build());
413             flow.setInstructions(createAppyActionInstruction10().build());
414             break;
415         case "f18":
416             id += 18;
417             flow.setMatch(createMatch1().build());
418             flow.setInstructions(createAppyActionInstruction11().build());
419             break;
420         case "f19":
421             id += 19;
422             flow.setMatch(createMatch1().build());
423             flow.setInstructions(createAppyActionInstruction12().build());
424             break;
425         case "f20":
426             id += 20;
427             flow.setMatch(createMatch1().build());
428             flow.setInstructions(createAppyActionInstruction13().build());
429             break;
430         case "f21":
431             id += 21;
432             flow.setMatch(createMatch1().build());
433             flow.setInstructions(createAppyActionInstruction14().build());
434             break;
435         case "f22":
436             id += 22;
437             flow.setMatch(createMatch1().build());
438             flow.setInstructions(createAppyActionInstruction15().build());
439             break;
440         case "f23":
441             id += 23;
442             flow.setMatch(createMatch1().build());
443             flow.setInstructions(createAppyActionInstruction16().build());
444             break;
445         case "f24":
446             id += 24;
447             flow.setMatch(createMatch1().build());
448             flow.setInstructions(createAppyActionInstruction17().build());
449             break;
450         case "f25":
451             id += 25;
452             flow.setMatch(createMatch1().build());
453             flow.setInstructions(createAppyActionInstruction18().build());
454             break;
455         case "f26":
456             id += 26;
457             flow.setMatch(createMatch1().build());
458             flow.setInstructions(createAppyActionInstruction19().build());
459             break;
460         case "f27":
461             id += 27;
462             flow.setMatch(createMatch1().build());
463             flow.setInstructions(createMetadataInstructions().build());
464             break;
465         case "f28":
466             id += 28;
467             flow.setMatch(createMatch1().build());
468             flow.setInstructions(createAppyActionInstruction20().build());
469             break;
470         case "f29":
471             id += 29;
472             flow.setMatch(createMatch1().build());
473             flow.setInstructions(createAppyActionInstruction21().build());
474             break;
475         case "f30":
476             id += 30;
477             flow.setMatch(createMatch1().build());
478             flow.setInstructions(createAppyActionInstruction22().build());
479             break;
480         case "f31":
481             id += 31;
482             flow.setMatch(createMatch1().build());
483             flow.setInstructions(createAppyActionInstruction23().build());
484             break;
485         case "f32":
486             id += 32;
487             flow.setMatch(createMatch1().build());
488             flow.setInstructions(createAppyActionInstruction24().build());
489             break;
490         case "f33":
491             id += 33;
492             flow.setMatch(createMatch1().build());
493             flow.setInstructions(createAppyActionInstruction25().build());
494             break;
495         case "f34":
496             id += 34;
497             flow.setMatch(createMatch1().build());
498             flow.setInstructions(createAppyActionInstruction26().build());
499             break;
500         case "f35":
501             id += 35;
502             flow.setMatch(createMatch1().build());
503             flow.setInstructions(createAppyActionInstruction27().build());
504             break;
505         case "f36":
506             id += 36;
507             flow.setMatch(createMatch1().build());
508             flow.setInstructions(createAppyActionInstruction28().build());
509             break;
510         case "f37":
511             id += 37;
512             flow.setMatch(createMatch1().build());
513             flow.setInstructions(createAppyActionInstruction29().build());
514             break;
515         case "f38":
516             id += 38;
517             flow.setMatch(createMatch1().build());
518             flow.setInstructions(createAppyActionInstruction30().build());
519             break;
520         case "f39":
521             id += 39;
522             flow.setMatch(createMatch1().build());
523             flow.setInstructions(createAppyActionInstruction31().build());
524             break;
525         case "f40":
526             id += 40;
527             flow.setMatch(createMatch1().build());
528             flow.setInstructions(createAppyActionInstruction32().build());
529             break;
530         case "f41":
531             id += 41;
532             flow.setMatch(createMatch1().build());
533             flow.setInstructions(createAppyActionInstruction33().build());
534             break;
535         case "f42":
536             id += 42;
537             flow.setMatch(createMatch1().build());
538             flow.setInstructions(createAppyActionInstruction34().build());
539             break;
540         case "f43":
541             id += 43;
542             flow.setMatch(createICMPv6Match().build());
543             flow.setInstructions(createDecNwTtlInstructions().build());
544             break;
545         case "f44":
546             id += 44;
547             flow.setMatch(createInphyportMatch().build());
548             flow.setInstructions(createDropInstructions().build());
549             break;
550         case "f45":
551             id += 45;
552             flow.setMatch(createMetadataMatch().build());
553             flow.setInstructions(createDropInstructions().build());
554             break;
555         case "f46":
556             id += 46;
557             flow.setMatch(createL3IPv6Match().build());
558             flow.setInstructions(createDecNwTtlInstructions().build());
559             break;
560         case "f47":
561             id += 47;
562             flow.setMatch(createL4SCTPMatch().build());
563             flow.setInstructions(createAppyActionInstruction().build());
564             break;
565         case "f48":
566             id += 48;
567             flow.setMatch(createTunnelIDMatch().build());
568             flow.setInstructions(createGotoTableInstructions().build());
569             break;
570         case "f49":
571             id += 49;
572             flow.setMatch(createVlanMatch().build());
573             flow.setInstructions(createMeterInstructions().build());
574             break;
575         case "f50":
576             id += 50;
577             flow.setMatch(createPbbMatch().build());
578             flow.setInstructions(createMeterInstructions().build());
579             break;
580         case "f51":
581             id += 51;
582             flow.setMatch(createVlanMatch().build());
583             flow.setInstructions(createDropInstructions().build());
584             break;
585         case "f52":
586             id += 52;
587             flow.setMatch(createL4TCPMatch().build());
588             flow.setInstructions(createDropInstructions().build());
589             break;
590
591         case "f53":
592             id += 53;
593             flow.setMatch(createL4UDPMatch().build());
594             flow.setInstructions(createDropInstructions().build());
595             break;
596         case "f54":
597             id += 54;
598             flow.setMatch(new MatchBuilder().build());
599             flow.setInstructions(createSentToControllerInstructions().build());
600             break;
601         case "f55":
602             id += 55;
603             flow.setMatch(createToSMatch().build());
604             flow.setInstructions(createDropInstructions().build());
605             break;
606         case "f56":
607             id += 56;
608             flow.setMatch(createToSMatch().build());
609             flow.setInstructions(createOutputInstructions("INPORT", 10).build());
610             break;
611         case "f57":
612             id += 57;
613             flow.setMatch(createToSMatch().build());
614             flow.setInstructions(createOutputInstructions("FLOOD", 20).build());
615             break;
616         case "f58":
617             id += 58;
618             flow.setMatch(createToSMatch().build());
619             flow.setInstructions(createOutputInstructions("ALL", 30).build());
620             break;
621         case "f59":
622             id += 59;
623             flow.setMatch(createToSMatch().build());
624             flow.setInstructions(createOutputInstructions("NORMAL", 40).build());
625             break;
626         case "f60":
627             id += 60;
628             flow.setMatch(createToSMatch().build());
629             flow.setInstructions(createOutputInstructions("LOCAL", 50).build());
630             break;
631         case "f61":
632             id += 61;
633             flow.setMatch(createToSMatch().build());
634             flow.setInstructions(createOutputInstructions("TABLE", 60).build());
635             break;
636         case "f62":
637             id += 62;
638             flow.setMatch(createToSMatch().build());
639             flow.setInstructions(createOutputInstructions("NONE", 70).build());
640             break;
641         case "f63":
642             id += 63;
643             flow.setMatch(createToSMatch().build());
644             flow.setInstructions(createStripVlanInstructions().build());
645             flow.setBarrier(Boolean.TRUE);
646             break;
647         case "f64":
648             id += 64;
649             flow.setMatch(createMatch1().build());
650             flow.setInstructions(createAppyActionInstruction35().build());
651             break;
652         case "f65":
653             id += 65;
654             flow.setMatch(createMatch1().build());
655             flow.setInstructions(createAppyActionInstruction36().build());
656             break;
657         case "f66":
658             id += 66;
659             flow.setMatch(createMatch1().build());
660             flow.setInstructions(createAppyActionInstruction37().build());
661             break;
662         case "f67":
663             id += 67;
664             flow.setMatch(createMatch1().build());
665             flow.setInstructions(createAppyActionInstruction38().build());
666             break;
667         case "f68":
668             id += 68;
669             flow.setMatch(createL4TCPMatch().build());
670             flow.setInstructions(createAppyActionInstruction39().build());
671             break;
672         case "f69":
673             id += 69;
674             flow.setMatch(createL4UDPMatch().build());
675             flow.setInstructions(createAppyActionInstruction40().build());
676             break;
677         case "f70":
678             id += 70;
679             flow.setMatch(createL4SCTPMatch().build());
680             flow.setInstructions(createAppyActionInstruction41().build());
681             break;
682         case "f71":
683             id += 71;
684             flow.setMatch(createICMPv4Match().build());
685             flow.setInstructions(createAppyActionInstruction42().build());
686             break;
687         case "f72":
688             id += 72;
689             flow.setMatch(createArpMatch().build());
690             flow.setInstructions(createAppyActionInstruction43().build());
691             break;
692         case "f73":
693             id += 73;
694             flow.setMatch(createL3IPv6Match().build());
695             flow.setInstructions(createAppyActionInstruction44().build());
696             break;
697         case "f74":
698             id += 74;
699             flow.setMatch(createICMPv6Match().build());
700             flow.setInstructions(createAppyActionInstruction45().build());
701             break;
702         case "f75":
703             id += 75;
704             flow.setMatch(createMplsMatch().build());
705             flow.setInstructions(createAppyActionInstruction46().build());
706             break;
707         case "f76":
708             id += 76;
709             flow.setMatch(createPbbMatch().build());
710             flow.setInstructions(createAppyActionInstruction47().build());
711             break;
712         case "f77":
713             id += 77;
714             flow.setMatch(createTunnelIDMatch().build());
715             flow.setInstructions(createAppyActionInstruction48().build());
716             break;
717         default:
718             LOG.warn("flow type not understood: {}", flowType);
719         }
720
721         FlowKey key = new FlowKey(new FlowId(id));
722         if (null == flow.isBarrier()) {
723             flow.setBarrier(Boolean.FALSE);
724         }
725         // flow.setBufferId(new Long(12));
726         BigInteger value = new BigInteger("10", 10);
727         BigInteger outputPort = new BigInteger("65535", 10);
728         flow.setCookie(value);
729         flow.setCookieMask(value);
730         flow.setHardTimeout(0);
731         flow.setIdleTimeout(0);
732         flow.setInstallHw(false);
733         flow.setStrict(false);
734         flow.setContainerName(null);
735         flow.setFlags(new FlowModFlags(false, false, false, false, true));
736         flow.setId(new FlowId(new Long(12)));
737         flow.setTableId(getTableId(tableId));
738         flow.setOutGroup(new Long(2));
739         // set outport to OFPP_NONE (65535) to disable remove restriction for
740         // flow
741         flow.setOutPort(outputPort);
742
743         flow.setKey(key);
744         flow.setPriority(2);
745         flow.setFlowName(originalFlowName + "X" + flowType);
746         testFlow = flow;
747         return flow;
748     }
749
750     private short getTableId(String tableId) {
751         short table = 2;
752         try {
753             table = Short.parseShort(tableId);
754         } catch (Exception ex) {
755             // ignore exception and continue with default value
756         }
757
758         return table;
759
760     }
761
762     /**
763      * @return
764      */
765     private static InstructionsBuilder createDecNwTtlInstructions() {
766         DecNwTtlBuilder ta = new DecNwTtlBuilder();
767         DecNwTtl decNwTtl = ta.build();
768         ActionBuilder ab = new ActionBuilder();
769         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
770
771         // Add our drop action to a list
772         List<Action> actionList = new ArrayList<Action>();
773         actionList.add(ab.build());
774
775         // Create an Apply Action
776         ApplyActionsBuilder aab = new ApplyActionsBuilder();
777         aab.setAction(actionList);
778
779         // Wrap our Apply Action in an Instruction
780         InstructionBuilder ib = new InstructionBuilder();
781         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
782         ib.setKey(new InstructionKey(0));
783         ib.setOrder(0);
784
785         // Put our Instruction in a list of Instructions
786         InstructionsBuilder isb = new InstructionsBuilder();
787         List<Instruction> instructions = new ArrayList<Instruction>();
788         instructions.add(ib.build());
789         isb.setInstruction(instructions);
790         return isb;
791     }
792
793     /**
794      * @return
795      */
796     private static InstructionsBuilder createMeterInstructions() {
797
798         MeterBuilder aab = new MeterBuilder();
799         aab.setMeterId(new MeterId(new Long(1)));
800
801         InstructionBuilder ib = new InstructionBuilder();
802         ib.setInstruction(new MeterCaseBuilder().setMeter(aab.build()).build());
803
804         // Put our Instruction in a list of Instructions
805         InstructionsBuilder isb = new InstructionsBuilder();
806         List<Instruction> instructions = new ArrayList<Instruction>();
807         instructions.add(ib.build());
808         isb.setInstruction(instructions);
809         return isb;
810     }
811
812     private static InstructionsBuilder createMetadataInstructions() {
813
814         WriteMetadataBuilder aab = new WriteMetadataBuilder();
815         aab.setMetadata(new BigInteger("10", 10));
816         aab.setMetadataMask(new BigInteger("12", 10));
817
818         InstructionBuilder ib = new InstructionBuilder();
819         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
820
821         // Put our Instruction in a list of Instructions
822         InstructionsBuilder isb = new InstructionsBuilder();
823         List<Instruction> instructions = new ArrayList<Instruction>();
824         instructions.add(ib.build());
825         isb.setInstruction(instructions);
826         return isb;
827     }
828
829     private static InstructionsBuilder createGotoTableInstructions() {
830
831         GoToTableBuilder aab = new GoToTableBuilder();
832         aab.setTableId((short) 2);
833
834         InstructionBuilder ib = new InstructionBuilder();
835         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(aab.build()).build());
836
837         // Put our Instruction in a list of Instructions
838         InstructionsBuilder isb = new InstructionsBuilder();
839         List<Instruction> instructions = new ArrayList<Instruction>();
840         instructions.add(ib.build());
841         isb.setInstruction(instructions);
842         return isb;
843     }
844
845     private static InstructionsBuilder createDropInstructions() {
846         DropActionBuilder dab = new DropActionBuilder();
847         DropAction dropAction = dab.build();
848         ActionBuilder ab = new ActionBuilder();
849         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
850
851         // Add our drop action to a list
852         List<Action> actionList = new ArrayList<Action>();
853         actionList.add(ab.build());
854
855         // Create an Apply Action
856         ApplyActionsBuilder aab = new ApplyActionsBuilder();
857         aab.setAction(actionList);
858
859         // Wrap our Apply Action in an Instruction
860         InstructionBuilder ib = new InstructionBuilder();
861         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
862
863         // Put our Instruction in a list of Instructions
864         InstructionsBuilder isb = new InstructionsBuilder();
865         List<Instruction> instructions = new ArrayList<Instruction>();
866         instructions.add(ib.build());
867         isb.setInstruction(instructions);
868         return isb;
869     }
870
871     private static InstructionsBuilder createAppyActionInstruction() {
872
873         List<Action> actionList = new ArrayList<Action>();
874         ActionBuilder ab = new ActionBuilder();
875         ControllerActionBuilder controller = new ControllerActionBuilder();
876         controller.setMaxLength(5);
877         ab.setAction(new ControllerActionCaseBuilder().setControllerAction(controller.build()).build());
878         actionList.add(ab.build());
879         // Create an Apply Action
880         ApplyActionsBuilder aab = new ApplyActionsBuilder();
881         aab.setAction(actionList);
882
883         // Wrap our Apply Action in an Instruction
884         InstructionBuilder ib = new InstructionBuilder();
885         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
886
887         // Put our Instruction in a list of Instructions
888         InstructionsBuilder isb = new InstructionsBuilder();
889         List<Instruction> instructions = new ArrayList<Instruction>();
890         instructions.add(ib.build());
891         isb.setInstruction(instructions);
892         return isb;
893     }
894
895     private static InstructionsBuilder createAppyActionInstruction1() {
896
897         List<Action> actionList = new ArrayList<Action>();
898         ActionBuilder ab = new ActionBuilder();
899
900         OutputActionBuilder output = new OutputActionBuilder();
901         output.setMaxLength(56);
902         Uri value = new Uri("PCEP");
903         output.setOutputNodeConnector(value);
904         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
905         actionList.add(ab.build());
906         // Create an Apply Action
907         ApplyActionsBuilder aab = new ApplyActionsBuilder();
908         aab.setAction(actionList);
909
910         // Wrap our Apply Action in an Instruction
911         InstructionBuilder ib = new InstructionBuilder();
912         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
913
914         // Put our Instruction in a list of Instructions
915         InstructionsBuilder isb = new InstructionsBuilder();
916         List<Instruction> instructions = new ArrayList<Instruction>();
917         instructions.add(ib.build());
918         isb.setInstruction(instructions);
919         return isb;
920     }
921
922     private static InstructionsBuilder createSentToControllerInstructions() {
923         List<Action> actionList = new ArrayList<Action>();
924         ActionBuilder ab = new ActionBuilder();
925
926         OutputActionBuilder output = new OutputActionBuilder();
927         output.setMaxLength(56);
928         Uri value = new Uri("CONTROLLER");
929         output.setOutputNodeConnector(value);
930         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
931         ab.setOrder(0);
932         ab.setKey(new ActionKey(0));
933         actionList.add(ab.build());
934         // Create an Apply Action
935         ApplyActionsBuilder aab = new ApplyActionsBuilder();
936         aab.setAction(actionList);
937
938         // Wrap our Apply Action in an Instruction
939         InstructionBuilder ib = new InstructionBuilder();
940         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
941         ib.setOrder(0);
942         ib.setKey(new InstructionKey(0));
943
944         // Put our Instruction in a list of Instructions
945         InstructionsBuilder isb = new InstructionsBuilder();
946         List<Instruction> instructions = new ArrayList<Instruction>();
947         instructions.add(ib.build());
948         isb.setInstruction(instructions);
949         return isb;
950     }
951
952     private static InstructionsBuilder createOutputInstructions(String outputType, int outputValue) {
953         List<Action> actionList = new ArrayList<Action>();
954         ActionBuilder ab = new ActionBuilder();
955
956         OutputActionBuilder output = new OutputActionBuilder();
957         output.setMaxLength(outputValue);
958         Uri value = new Uri(outputType);
959         output.setOutputNodeConnector(value);
960         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
961         ab.setOrder(0);
962         ab.setKey(new ActionKey(0));
963         actionList.add(ab.build());
964         // Create an Apply Action
965         ApplyActionsBuilder aab = new ApplyActionsBuilder();
966         aab.setAction(actionList);
967
968         // Wrap our Apply Action in an Instruction
969         InstructionBuilder ib = new InstructionBuilder();
970         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
971         ib.setOrder(0);
972         ib.setKey(new InstructionKey(0));
973
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);
979         return isb;
980     }
981
982     private static InstructionsBuilder createStripVlanInstructions() {
983         List<Action> actionList = new ArrayList<Action>();
984         ActionBuilder ab = new ActionBuilder();
985
986         StripVlanActionBuilder stripActionBuilder = new StripVlanActionBuilder();
987         ab.setAction(new StripVlanActionCaseBuilder().setStripVlanAction(stripActionBuilder.build()).build());
988         ab.setOrder(0);
989         ab.setKey(new ActionKey(0));
990         actionList.add(ab.build());
991         // Create an Apply Action
992         ApplyActionsBuilder aab = new ApplyActionsBuilder();
993         aab.setAction(actionList);
994
995         // Wrap our Apply Action in an Instruction
996         InstructionBuilder ib = new InstructionBuilder();
997         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
998         ib.setOrder(0);
999         ib.setKey(new InstructionKey(0));
1000
1001         // Put our Instruction in a list of Instructions
1002         InstructionsBuilder isb = new InstructionsBuilder();
1003         List<Instruction> instructions = new ArrayList<Instruction>();
1004         instructions.add(ib.build());
1005         isb.setInstruction(instructions);
1006         return isb;
1007     }
1008
1009     private static InstructionsBuilder createAppyActionInstruction2() {
1010
1011         List<Action> actionList = new ArrayList<Action>();
1012         ActionBuilder ab = new ActionBuilder();
1013
1014         PushMplsActionBuilder push = new PushMplsActionBuilder();
1015         push.setEthernetType(new Integer(0x8847));
1016         ab.setAction(new PushMplsActionCaseBuilder().setPushMplsAction(push.build()).build());
1017         actionList.add(ab.build());
1018         // Create an Apply Action
1019         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1020         aab.setAction(actionList);
1021
1022         // Wrap our Apply Action in an Instruction
1023         InstructionBuilder ib = new InstructionBuilder();
1024         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1025
1026         // Put our Instruction in a list of Instructions
1027         InstructionsBuilder isb = new InstructionsBuilder();
1028         List<Instruction> instructions = new ArrayList<Instruction>();
1029         instructions.add(ib.build());
1030         isb.setInstruction(instructions);
1031         return isb;
1032     }
1033
1034     private static InstructionsBuilder createAppyActionInstruction3() {
1035
1036         List<Action> actionList = new ArrayList<Action>();
1037         ActionBuilder ab = new ActionBuilder();
1038
1039         PushPbbActionBuilder pbb = new PushPbbActionBuilder();
1040         pbb.setEthernetType(new Integer(0x88E7));
1041         ab.setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pbb.build()).build());
1042         actionList.add(ab.build());
1043         // Create an Apply Action
1044         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1045         aab.setAction(actionList);
1046
1047         // Wrap our Apply Action in an Instruction
1048         InstructionBuilder ib = new InstructionBuilder();
1049         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1050
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);
1056         return isb;
1057     }
1058
1059     private static InstructionsBuilder createAppyActionInstruction4() {
1060
1061         List<Action> actionList = new ArrayList<Action>();
1062         ActionBuilder ab = new ActionBuilder();
1063
1064         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
1065         vlan.setEthernetType(new Integer(0x8100));
1066         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
1067         actionList.add(ab.build());
1068
1069         // Create an Apply Action
1070         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1071         aab.setAction(actionList);
1072
1073         // Wrap our Apply Action in an Instruction
1074         InstructionBuilder ib = new InstructionBuilder();
1075         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1076
1077         // Put our Instruction in a list of Instructions
1078         InstructionsBuilder isb = new InstructionsBuilder();
1079         List<Instruction> instructions = new ArrayList<Instruction>();
1080         instructions.add(ib.build());
1081         isb.setInstruction(instructions);
1082         return isb;
1083     }
1084
1085     private static InstructionsBuilder createAppyActionInstruction5() {
1086
1087         List<Action> actionList = new ArrayList<Action>();
1088         ActionBuilder ab = new ActionBuilder();
1089
1090         SetDlDstActionBuilder setdl = new SetDlDstActionBuilder();
1091         setdl.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1092         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(setdl.build()).build());
1093         actionList.add(ab.build());
1094         // Create an Apply Action
1095         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1096         aab.setAction(actionList);
1097
1098         // Wrap our Apply Action in an Instruction
1099         InstructionBuilder ib = new InstructionBuilder();
1100         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1101
1102         // Put our Instruction in a list of Instructions
1103         InstructionsBuilder isb = new InstructionsBuilder();
1104         List<Instruction> instructions = new ArrayList<Instruction>();
1105         instructions.add(ib.build());
1106         isb.setInstruction(instructions);
1107         return isb;
1108     }
1109
1110     private static InstructionsBuilder createAppyActionInstruction6() {
1111
1112         List<Action> actionList = new ArrayList<Action>();
1113         ActionBuilder ab = new ActionBuilder();
1114
1115         SetDlSrcActionBuilder src = new SetDlSrcActionBuilder();
1116         src.setAddress(new MacAddress("00:05:b9:7c:81:5f"));
1117         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(src.build()).build());
1118         actionList.add(ab.build());
1119
1120         // Create an Apply Action
1121         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1122         aab.setAction(actionList);
1123
1124         // Wrap our Apply Action in an Instruction
1125         InstructionBuilder ib = new InstructionBuilder();
1126         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1127
1128         // Put our Instruction in a list of Instructions
1129         InstructionsBuilder isb = new InstructionsBuilder();
1130         List<Instruction> instructions = new ArrayList<Instruction>();
1131         instructions.add(ib.build());
1132         isb.setInstruction(instructions);
1133         return isb;
1134     }
1135
1136     private static InstructionsBuilder createAppyActionInstruction7() {
1137
1138         List<Action> actionList = new ArrayList<Action>();
1139         ActionBuilder ab = new ActionBuilder();
1140
1141         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
1142         VlanId a = new VlanId(4000);
1143         vl.setVlanId(a);
1144         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
1145         actionList.add(ab.build());
1146         // Create an Apply Action
1147         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1148         aab.setAction(actionList);
1149
1150         // Wrap our Apply Action in an Instruction
1151         InstructionBuilder ib = new InstructionBuilder();
1152         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1153
1154         // Put our Instruction in a list of Instructions
1155         InstructionsBuilder isb = new InstructionsBuilder();
1156         List<Instruction> instructions = new ArrayList<Instruction>();
1157         instructions.add(ib.build());
1158         isb.setInstruction(instructions);
1159         return isb;
1160     }
1161
1162     private static InstructionsBuilder createAppyActionInstruction8() {
1163
1164         List<Action> actionList = new ArrayList<Action>();
1165         ActionBuilder ab = new ActionBuilder();
1166
1167         SetVlanPcpActionBuilder pcp = new SetVlanPcpActionBuilder();
1168         VlanPcp pcp1 = new VlanPcp((short) 2);
1169         pcp.setVlanPcp(pcp1);
1170         ab.setAction(new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(pcp.build()).build());
1171         actionList.add(ab.build());
1172         // Create an Apply Action
1173         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1174         aab.setAction(actionList);
1175
1176         // Wrap our Apply Action in an Instruction
1177         InstructionBuilder ib = new InstructionBuilder();
1178         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1179
1180         // Put our Instruction in a list of Instructions
1181         InstructionsBuilder isb = new InstructionsBuilder();
1182         List<Instruction> instructions = new ArrayList<Instruction>();
1183         instructions.add(ib.build());
1184         isb.setInstruction(instructions);
1185         return isb;
1186     }
1187
1188     private static InstructionsBuilder createAppyActionInstruction9() {
1189
1190         List<Action> actionList = new ArrayList<Action>();
1191         ActionBuilder ab = new ActionBuilder();
1192
1193         CopyTtlInBuilder ttlin = new CopyTtlInBuilder();
1194         ab.setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(ttlin.build()).build());
1195         actionList.add(ab.build());
1196         // Create an Apply Action
1197         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1198         aab.setAction(actionList);
1199
1200         // Wrap our Apply Action in an Instruction
1201         InstructionBuilder ib = new InstructionBuilder();
1202         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1203
1204         // Put our Instruction in a list of Instructions
1205         InstructionsBuilder isb = new InstructionsBuilder();
1206         List<Instruction> instructions = new ArrayList<Instruction>();
1207         instructions.add(ib.build());
1208         isb.setInstruction(instructions);
1209         return isb;
1210     }
1211
1212     private static InstructionsBuilder createAppyActionInstruction10() {
1213
1214         List<Action> actionList = new ArrayList<Action>();
1215         ActionBuilder ab = new ActionBuilder();
1216
1217         CopyTtlOutBuilder ttlout = new CopyTtlOutBuilder();
1218         ab.setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(ttlout.build()).build());
1219         actionList.add(ab.build());
1220         // Create an Apply Action
1221         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1222         aab.setAction(actionList);
1223
1224         // Wrap our Apply Action in an Instruction
1225         InstructionBuilder ib = new InstructionBuilder();
1226         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1227
1228         // Put our Instruction in a list of Instructions
1229         InstructionsBuilder isb = new InstructionsBuilder();
1230         List<Instruction> instructions = new ArrayList<Instruction>();
1231         instructions.add(ib.build());
1232         isb.setInstruction(instructions);
1233         return isb;
1234     }
1235
1236     private static InstructionsBuilder createAppyActionInstruction11() {
1237
1238         List<Action> actionList = new ArrayList<Action>();
1239         ActionBuilder ab = new ActionBuilder();
1240
1241         DecMplsTtlBuilder mpls = new DecMplsTtlBuilder();
1242         ab.setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(mpls.build()).build());
1243         actionList.add(ab.build());
1244         // Create an Apply Action
1245         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1246         aab.setAction(actionList);
1247
1248         // Wrap our Apply Action in an Instruction
1249         InstructionBuilder ib = new InstructionBuilder();
1250         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1251
1252         // Put our Instruction in a list of Instructions
1253         InstructionsBuilder isb = new InstructionsBuilder();
1254         List<Instruction> instructions = new ArrayList<Instruction>();
1255         instructions.add(ib.build());
1256         isb.setInstruction(instructions);
1257         return isb;
1258     }
1259
1260     private static InstructionsBuilder createAppyActionInstruction12() {
1261
1262         List<Action> actionList = new ArrayList<Action>();
1263         ActionBuilder ab = new ActionBuilder();
1264
1265         DecNwTtlBuilder nwttl = new DecNwTtlBuilder();
1266         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(nwttl.build()).build());
1267         actionList.add(ab.build());
1268
1269         // Create an Apply Action
1270         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1271         aab.setAction(actionList);
1272
1273         // Wrap our Apply Action in an Instruction
1274         InstructionBuilder ib = new InstructionBuilder();
1275         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1276
1277         // Put our Instruction in a list of Instructions
1278         InstructionsBuilder isb = new InstructionsBuilder();
1279         List<Instruction> instructions = new ArrayList<Instruction>();
1280         instructions.add(ib.build());
1281         isb.setInstruction(instructions);
1282         return isb;
1283     }
1284
1285     private static InstructionsBuilder createAppyActionInstruction13() {
1286
1287         List<Action> actionList = new ArrayList<Action>();
1288         ActionBuilder ab = new ActionBuilder();
1289
1290         DropActionBuilder drop = new DropActionBuilder();
1291         ab.setAction(new DropActionCaseBuilder().setDropAction(drop.build()).build());
1292         actionList.add(ab.build());
1293
1294         // Create an Apply Action
1295         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1296         aab.setAction(actionList);
1297
1298         // Wrap our Apply Action in an Instruction
1299         InstructionBuilder ib = new InstructionBuilder();
1300         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1301
1302         // Put our Instruction in a list of Instructions
1303         InstructionsBuilder isb = new InstructionsBuilder();
1304         List<Instruction> instructions = new ArrayList<Instruction>();
1305         instructions.add(ib.build());
1306         isb.setInstruction(instructions);
1307         return isb;
1308     }
1309
1310     private static InstructionsBuilder createAppyActionInstruction14() {
1311
1312         List<Action> actionList = new ArrayList<Action>();
1313         ActionBuilder ab = new ActionBuilder();
1314
1315         FloodActionBuilder fld = new FloodActionBuilder();
1316         ab.setAction(new FloodActionCaseBuilder().setFloodAction(fld.build()).build());
1317         actionList.add(ab.build());
1318         // Create an Apply Action
1319         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1320         aab.setAction(actionList);
1321
1322         // Wrap our Apply Action in an Instruction
1323         InstructionBuilder ib = new InstructionBuilder();
1324         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1325
1326         // Put our Instruction in a list of Instructions
1327         InstructionsBuilder isb = new InstructionsBuilder();
1328         List<Instruction> instructions = new ArrayList<Instruction>();
1329         instructions.add(ib.build());
1330         isb.setInstruction(instructions);
1331         return isb;
1332     }
1333
1334     private static InstructionsBuilder createAppyActionInstruction15() {
1335
1336         List<Action> actionList = new ArrayList<Action>();
1337         ActionBuilder ab = new ActionBuilder();
1338
1339         FloodAllActionBuilder fldall = new FloodAllActionBuilder();
1340         ab.setAction(new FloodAllActionCaseBuilder().setFloodAllAction(fldall.build()).build());
1341         actionList.add(ab.build());
1342         // Create an Apply Action
1343         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1344         aab.setAction(actionList);
1345
1346         // Wrap our Apply Action in an Instruction
1347         InstructionBuilder ib = new InstructionBuilder();
1348         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1349
1350         // Put our Instruction in a list of Instructions
1351         InstructionsBuilder isb = new InstructionsBuilder();
1352         List<Instruction> instructions = new ArrayList<Instruction>();
1353         instructions.add(ib.build());
1354         isb.setInstruction(instructions);
1355         return isb;
1356     }
1357
1358     private static InstructionsBuilder createAppyActionInstruction16() {
1359
1360         List<Action> actionList = new ArrayList<Action>();
1361         ActionBuilder ab = new ActionBuilder();
1362
1363         GroupActionBuilder groupActionB = new GroupActionBuilder();
1364         groupActionB.setGroupId(1L);
1365         groupActionB.setGroup("0");
1366         ab.setAction(new GroupActionCaseBuilder().setGroupAction(groupActionB.build()).build());
1367         actionList.add(ab.build());
1368
1369         // Create an Apply Action
1370         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1371         aab.setAction(actionList);
1372
1373         // Wrap our Apply Action in an Instruction
1374         InstructionBuilder ib = new InstructionBuilder();
1375         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1376
1377         // Put our Instruction in a list of Instructions
1378         InstructionsBuilder isb = new InstructionsBuilder();
1379         List<Instruction> instructions = new ArrayList<Instruction>();
1380         instructions.add(ib.build());
1381         isb.setInstruction(instructions);
1382         return isb;
1383     }
1384
1385     private static InstructionsBuilder createAppyActionInstruction17() {
1386
1387         List<Action> actionList = new ArrayList<Action>();
1388         ActionBuilder ab = new ActionBuilder();
1389
1390         HwPathActionBuilder hwPathB = new HwPathActionBuilder();
1391         ab.setAction(new HwPathActionCaseBuilder().setHwPathAction(hwPathB.build()).build());
1392         actionList.add(ab.build());
1393         // Create an Apply Action
1394         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1395         aab.setAction(actionList);
1396
1397         // Wrap our Apply Action in an Instruction
1398         InstructionBuilder ib = new InstructionBuilder();
1399         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1400
1401         // Put our Instruction in a list of Instructions
1402         InstructionsBuilder isb = new InstructionsBuilder();
1403         List<Instruction> instructions = new ArrayList<Instruction>();
1404         instructions.add(ib.build());
1405         isb.setInstruction(instructions);
1406         return isb;
1407     }
1408
1409     private static InstructionsBuilder createAppyActionInstruction18() {
1410
1411         List<Action> actionList = new ArrayList<Action>();
1412         ActionBuilder ab = new ActionBuilder();
1413
1414         LoopbackActionBuilder loopbackActionBuilder = new LoopbackActionBuilder();
1415         ab.setAction(new LoopbackActionCaseBuilder().setLoopbackAction(loopbackActionBuilder.build()).build());
1416         actionList.add(ab.build());
1417
1418         // Create an Apply Action
1419         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1420         aab.setAction(actionList);
1421
1422         // Wrap our Apply Action in an Instruction
1423         InstructionBuilder ib = new InstructionBuilder();
1424         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1425
1426         // Put our Instruction in a list of Instructions
1427         InstructionsBuilder isb = new InstructionsBuilder();
1428         List<Instruction> instructions = new ArrayList<Instruction>();
1429         instructions.add(ib.build());
1430         isb.setInstruction(instructions);
1431         return isb;
1432     }
1433
1434     private static InstructionsBuilder createAppyActionInstruction19() {
1435
1436         List<Action> actionList = new ArrayList<Action>();
1437         ActionBuilder ab = new ActionBuilder();
1438
1439         PopMplsActionBuilder popMplsActionBuilder = new PopMplsActionBuilder();
1440         popMplsActionBuilder.setEthernetType(0XB);
1441         ab.setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMplsActionBuilder.build()).build());
1442         actionList.add(ab.build());
1443         // Create an Apply Action
1444         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1445         aab.setAction(actionList);
1446
1447         // Wrap our Apply Action in an Instruction
1448         InstructionBuilder ib = new InstructionBuilder();
1449         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1450
1451         // Put our Instruction in a list of Instructions
1452         InstructionsBuilder isb = new InstructionsBuilder();
1453         List<Instruction> instructions = new ArrayList<Instruction>();
1454         instructions.add(ib.build());
1455         isb.setInstruction(instructions);
1456         return isb;
1457     }
1458
1459     private static InstructionsBuilder createAppyActionInstruction20() {
1460
1461         List<Action> actionList = new ArrayList<Action>();
1462         ActionBuilder ab = new ActionBuilder();
1463
1464         PopPbbActionBuilder popPbbActionBuilder = new PopPbbActionBuilder();
1465         ab.setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPbbActionBuilder.build()).build());
1466         actionList.add(ab.build());
1467         // Create an Apply Action
1468         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1469         aab.setAction(actionList);
1470
1471         // Wrap our Apply Action in an Instruction
1472         InstructionBuilder ib = new InstructionBuilder();
1473         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1474
1475         // Put our Instruction in a list of Instructions
1476         InstructionsBuilder isb = new InstructionsBuilder();
1477         List<Instruction> instructions = new ArrayList<Instruction>();
1478         instructions.add(ib.build());
1479         isb.setInstruction(instructions);
1480         return isb;
1481     }
1482
1483     private static InstructionsBuilder createAppyActionInstruction21() {
1484
1485         List<Action> actionList = new ArrayList<Action>();
1486         ActionBuilder ab = new ActionBuilder();
1487
1488         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
1489         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
1490         actionList.add(ab.build());
1491
1492         // Create an Apply Action
1493         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1494         aab.setAction(actionList);
1495
1496         // Wrap our Apply Action in an Instruction
1497         InstructionBuilder ib = new InstructionBuilder();
1498         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1499
1500         // Put our Instruction in a list of Instructions
1501         InstructionsBuilder isb = new InstructionsBuilder();
1502         List<Instruction> instructions = new ArrayList<Instruction>();
1503         instructions.add(ib.build());
1504         isb.setInstruction(instructions);
1505         return isb;
1506     }
1507
1508     private static InstructionsBuilder createAppyActionInstruction22() {
1509
1510         List<Action> actionList = new ArrayList<Action>();
1511         ActionBuilder ab = new ActionBuilder();
1512
1513         SetDlTypeActionBuilder setDlTypeActionBuilder = new SetDlTypeActionBuilder();
1514         setDlTypeActionBuilder.setDlType(new EtherType(8L));
1515         ab.setAction(new SetDlTypeActionCaseBuilder().setSetDlTypeAction(setDlTypeActionBuilder.build()).build());
1516         actionList.add(ab.build());
1517
1518         // Create an Apply Action
1519         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1520         aab.setAction(actionList);
1521
1522         // Wrap our Apply Action in an Instruction
1523         InstructionBuilder ib = new InstructionBuilder();
1524         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1525
1526         // Put our Instruction in a list of Instructions
1527         InstructionsBuilder isb = new InstructionsBuilder();
1528         List<Instruction> instructions = new ArrayList<Instruction>();
1529         instructions.add(ib.build());
1530         isb.setInstruction(instructions);
1531         return isb;
1532     }
1533
1534     private static InstructionsBuilder createAppyActionInstruction23() {
1535
1536         List<Action> actionList = new ArrayList<Action>();
1537         ActionBuilder ab = new ActionBuilder();
1538
1539         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1540         setFieldBuilder.setInPort(new Long(2));
1541         actionList.add(ab.build());
1542
1543         // Create an Apply Action
1544         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1545         aab.setAction(actionList);
1546
1547         // Wrap our Apply Action in an Instruction
1548         InstructionBuilder ib = new InstructionBuilder();
1549         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1550
1551         // Put our Instruction in a list of Instructions
1552         InstructionsBuilder isb = new InstructionsBuilder();
1553         List<Instruction> instructions = new ArrayList<Instruction>();
1554         instructions.add(ib.build());
1555         isb.setInstruction(instructions);
1556         return isb;
1557     }
1558
1559     private static InstructionsBuilder createAppyActionInstruction24() {
1560
1561         List<Action> actionList = new ArrayList<Action>();
1562         ActionBuilder ab = new ActionBuilder();
1563
1564         SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
1565         setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
1566         ab.setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionBuilder.build()).build());
1567         actionList.add(ab.build());
1568
1569         // Create an Apply Action
1570         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1571         aab.setAction(actionList);
1572
1573         // Wrap our Apply Action in an Instruction
1574         InstructionBuilder ib = new InstructionBuilder();
1575         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1576
1577         // Put our Instruction in a list of Instructions
1578         InstructionsBuilder isb = new InstructionsBuilder();
1579         List<Instruction> instructions = new ArrayList<Instruction>();
1580         instructions.add(ib.build());
1581         isb.setInstruction(instructions);
1582         return isb;
1583     }
1584
1585     private static InstructionsBuilder createAppyActionInstruction25() {
1586
1587         List<Action> actionList = new ArrayList<Action>();
1588         ActionBuilder ab = new ActionBuilder();
1589
1590         SetNextHopActionBuilder setNextHopActionBuilder = new SetNextHopActionBuilder();
1591         Ipv4Builder ipnext = new Ipv4Builder();
1592         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
1593         ipnext.setIpv4Address(prefix);
1594         setNextHopActionBuilder.setAddress(ipnext.build());
1595         ab.setAction(new SetNextHopActionCaseBuilder().setSetNextHopAction(setNextHopActionBuilder.build()).build());
1596         actionList.add(ab.build());
1597
1598         // Create an Apply Action
1599         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1600         aab.setAction(actionList);
1601
1602         // Wrap our Apply Action in an Instruction
1603         InstructionBuilder ib = new InstructionBuilder();
1604         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1605
1606         // Put our Instruction in a list of Instructions
1607         InstructionsBuilder isb = new InstructionsBuilder();
1608         List<Instruction> instructions = new ArrayList<Instruction>();
1609         instructions.add(ib.build());
1610         isb.setInstruction(instructions);
1611         return isb;
1612     }
1613
1614     private static InstructionsBuilder createAppyActionInstruction26() {
1615
1616         List<Action> actionList = new ArrayList<Action>();
1617         ActionBuilder ab = new ActionBuilder();
1618
1619         SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
1620         Ipv4Builder ipdst = new Ipv4Builder();
1621         Ipv4Prefix prefixdst = new Ipv4Prefix("10.0.0.21/24");
1622         ipdst.setIpv4Address(prefixdst);
1623         setNwDstActionBuilder.setAddress(ipdst.build());
1624         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
1625         actionList.add(ab.build());
1626
1627         // Create an Apply Action
1628         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1629         aab.setAction(actionList);
1630
1631         // Wrap our Apply Action in an Instruction
1632         InstructionBuilder ib = new InstructionBuilder();
1633         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1634
1635         // Put our Instruction in a list of Instructions
1636         InstructionsBuilder isb = new InstructionsBuilder();
1637         List<Instruction> instructions = new ArrayList<Instruction>();
1638         instructions.add(ib.build());
1639         isb.setInstruction(instructions);
1640         return isb;
1641     }
1642
1643     private static InstructionsBuilder createAppyActionInstruction27() {
1644
1645         List<Action> actionList = new ArrayList<Action>();
1646         ActionBuilder ab = new ActionBuilder();
1647
1648         SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
1649         Ipv4Builder ipsrc = new Ipv4Builder();
1650         Ipv4Prefix prefixsrc = new Ipv4Prefix("10.0.23.21/24");
1651         ipsrc.setIpv4Address(prefixsrc);
1652         setNwsrcActionBuilder.setAddress(ipsrc.build());
1653         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
1654         actionList.add(ab.build());
1655
1656         // Create an Apply Action
1657         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1658         aab.setAction(actionList);
1659
1660         // Wrap our Apply Action in an Instruction
1661         InstructionBuilder ib = new InstructionBuilder();
1662         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1663
1664         // Put our Instruction in a list of Instructions
1665         InstructionsBuilder isb = new InstructionsBuilder();
1666         List<Instruction> instructions = new ArrayList<Instruction>();
1667         instructions.add(ib.build());
1668         isb.setInstruction(instructions);
1669         return isb;
1670     }
1671
1672     private static InstructionsBuilder createAppyActionInstruction28() {
1673
1674         List<Action> actionList = new ArrayList<Action>();
1675         ActionBuilder ab = new ActionBuilder();
1676
1677         SetNwTosActionBuilder setNwTosActionBuilder = new SetNwTosActionBuilder();
1678         setNwTosActionBuilder.setTos(8);
1679         ab.setAction(new SetNwTosActionCaseBuilder().setSetNwTosAction(setNwTosActionBuilder.build()).build());
1680         actionList.add(ab.build());
1681         // Create an Apply Action
1682         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1683         aab.setAction(actionList);
1684
1685         // Wrap our Apply Action in an Instruction
1686         InstructionBuilder ib = new InstructionBuilder();
1687         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1688
1689         // Put our Instruction in a list of Instructions
1690         InstructionsBuilder isb = new InstructionsBuilder();
1691         List<Instruction> instructions = new ArrayList<Instruction>();
1692         instructions.add(ib.build());
1693         isb.setInstruction(instructions);
1694         return isb;
1695     }
1696
1697     private static InstructionsBuilder createAppyActionInstruction29() {
1698
1699         List<Action> actionList = new ArrayList<Action>();
1700         ActionBuilder ab = new ActionBuilder();
1701
1702         SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
1703         setNwTtlActionBuilder.setNwTtl((short) 1);
1704         ab.setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
1705         actionList.add(ab.build());
1706
1707         // Create an Apply Action
1708         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1709         aab.setAction(actionList);
1710
1711         // Wrap our Apply Action in an Instruction
1712         InstructionBuilder ib = new InstructionBuilder();
1713         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1714
1715         // Put our Instruction in a list of Instructions
1716         InstructionsBuilder isb = new InstructionsBuilder();
1717         List<Instruction> instructions = new ArrayList<Instruction>();
1718         instructions.add(ib.build());
1719         isb.setInstruction(instructions);
1720         return isb;
1721     }
1722
1723     private static InstructionsBuilder createAppyActionInstruction30() {
1724
1725         List<Action> actionList = new ArrayList<Action>();
1726         ActionBuilder ab = new ActionBuilder();
1727
1728         SetQueueActionBuilder setQueueActionBuilder = new SetQueueActionBuilder();
1729         setQueueActionBuilder.setQueueId(1L);
1730         ab.setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQueueActionBuilder.build()).build());
1731         actionList.add(ab.build());
1732         // Create an Apply Action
1733         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1734         aab.setAction(actionList);
1735
1736         // Wrap our Apply Action in an Instruction
1737         InstructionBuilder ib = new InstructionBuilder();
1738         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1739
1740         // Put our Instruction in a list of Instructions
1741         InstructionsBuilder isb = new InstructionsBuilder();
1742         List<Instruction> instructions = new ArrayList<Instruction>();
1743         instructions.add(ib.build());
1744         isb.setInstruction(instructions);
1745         return isb;
1746     }
1747
1748     private static InstructionsBuilder createAppyActionInstruction31() {
1749
1750         List<Action> actionList = new ArrayList<Action>();
1751         ActionBuilder ab = new ActionBuilder();
1752
1753         SetTpDstActionBuilder setTpDstActionBuilder = new SetTpDstActionBuilder();
1754         setTpDstActionBuilder.setPort(new PortNumber(109));
1755
1756         ab.setAction(new SetTpDstActionCaseBuilder().setSetTpDstAction(setTpDstActionBuilder.build()).build());
1757         actionList.add(ab.build());
1758         // Create an Apply Action
1759         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1760         aab.setAction(actionList);
1761
1762         // Wrap our Apply Action in an Instruction
1763         InstructionBuilder ib = new InstructionBuilder();
1764         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1765
1766         // Put our Instruction in a list of Instructions
1767         InstructionsBuilder isb = new InstructionsBuilder();
1768         List<Instruction> instructions = new ArrayList<Instruction>();
1769         instructions.add(ib.build());
1770         isb.setInstruction(instructions);
1771         return isb;
1772     }
1773
1774     private static InstructionsBuilder createAppyActionInstruction32() {
1775
1776         List<Action> actionList = new ArrayList<Action>();
1777         ActionBuilder ab = new ActionBuilder();
1778
1779         SetTpSrcActionBuilder setTpSrcActionBuilder = new SetTpSrcActionBuilder();
1780         setTpSrcActionBuilder.setPort(new PortNumber(109));
1781         ab.setAction(new SetTpSrcActionCaseBuilder().setSetTpSrcAction(setTpSrcActionBuilder.build()).build());
1782         actionList.add(ab.build());
1783
1784         // Create an Apply Action
1785         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1786         aab.setAction(actionList);
1787
1788         // Wrap our Apply Action in an Instruction
1789         InstructionBuilder ib = new InstructionBuilder();
1790         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1791
1792         // Put our Instruction in a list of Instructions
1793         InstructionsBuilder isb = new InstructionsBuilder();
1794         List<Instruction> instructions = new ArrayList<Instruction>();
1795         instructions.add(ib.build());
1796         isb.setInstruction(instructions);
1797         return isb;
1798     }
1799
1800     private static InstructionsBuilder createAppyActionInstruction33() {
1801
1802         List<Action> actionList = new ArrayList<Action>();
1803         ActionBuilder ab = new ActionBuilder();
1804
1805         SetVlanCfiActionBuilder setVlanCfiActionBuilder = new SetVlanCfiActionBuilder();
1806         setVlanCfiActionBuilder.setVlanCfi(new VlanCfi(2));
1807         ab.setAction(new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(setVlanCfiActionBuilder.build()).build());
1808         actionList.add(ab.build());
1809
1810         // Create an Apply Action
1811         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1812         aab.setAction(actionList);
1813
1814         // Wrap our Apply Action in an Instruction
1815         InstructionBuilder ib = new InstructionBuilder();
1816         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1817
1818         // Put our Instruction in a list of Instructions
1819         InstructionsBuilder isb = new InstructionsBuilder();
1820         List<Instruction> instructions = new ArrayList<Instruction>();
1821         instructions.add(ib.build());
1822         isb.setInstruction(instructions);
1823         return isb;
1824     }
1825
1826     private static InstructionsBuilder createAppyActionInstruction34() {
1827
1828         List<Action> actionList = new ArrayList<Action>();
1829         ActionBuilder ab = new ActionBuilder();
1830
1831         SwPathActionBuilder swPathAction = new SwPathActionBuilder();
1832         ab.setAction(new SwPathActionCaseBuilder().setSwPathAction(swPathAction.build()).build());
1833         actionList.add(ab.build());
1834
1835         // Create an Apply Action
1836         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1837         aab.setAction(actionList);
1838
1839         // Wrap our Apply Action in an Instruction
1840         InstructionBuilder ib = new InstructionBuilder();
1841         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1842
1843         // Put our Instruction in a list of Instructions
1844         InstructionsBuilder isb = new InstructionsBuilder();
1845         List<Instruction> instructions = new ArrayList<Instruction>();
1846         instructions.add(ib.build());
1847         isb.setInstruction(instructions);
1848         return isb;
1849     }
1850
1851     private static InstructionsBuilder createAppyActionInstruction35() {
1852
1853         List<Action> actionList = new ArrayList<Action>();
1854         ActionBuilder ab = new ActionBuilder();
1855         ActionBuilder ab1 = new ActionBuilder();
1856         ActionBuilder ab2 = new ActionBuilder();
1857
1858         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1859         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1860         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1861
1862         // Ethernet
1863         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
1864         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
1865         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
1866         EthernetMatchBuilder ethernetMatch1 = new EthernetMatchBuilder();
1867         EthernetDestinationBuilder ethDestBuilder = new EthernetDestinationBuilder();
1868         ethDestBuilder.setAddress(new MacAddress("00:00:00:00:00:02"));
1869         EthernetMatchBuilder ethernetMatch2 = new EthernetMatchBuilder();
1870         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
1871         ethTypeBuilder.setType(new EtherType(0x86ddL));
1872
1873         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
1874         ethernetMatch1.setEthernetDestination(ethDestBuilder.build());
1875         ethernetMatch2.setEthernetType(ethTypeBuilder.build());
1876         setFieldBuilder.setEthernetMatch(ethernetMatch.build());
1877         setFieldBuilder1.setEthernetMatch(ethernetMatch1.build());
1878         setFieldBuilder2.setEthernetMatch(ethernetMatch2.build());
1879         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1880         ab.setKey(new ActionKey(0));
1881         actionList.add(ab.build());
1882
1883         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1884         ab1.setKey(new ActionKey(1));
1885         actionList.add(ab1.build());
1886
1887         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1888         ab2.setKey(new ActionKey(2));
1889         actionList.add(ab2.build());
1890
1891         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1892         aab.setAction(actionList);
1893
1894         InstructionBuilder ib = new InstructionBuilder();
1895         ib.setKey(new InstructionKey(0));
1896         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1897
1898         // Put our Instruction in a list of Instructions
1899         InstructionsBuilder isb = new InstructionsBuilder();
1900         List<Instruction> instructions = new ArrayList<Instruction>();
1901         instructions.add(ib.build());
1902         isb.setInstruction(instructions);
1903         return isb;
1904     }
1905
1906     private static InstructionsBuilder createAppyActionInstruction36() {
1907
1908         List<Action> actionList = new ArrayList<Action>();
1909         ActionBuilder ab = new ActionBuilder();
1910         ActionBuilder ab1 = new ActionBuilder();
1911
1912         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1913         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1914
1915         // Vlan
1916         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder();
1917         VlanMatchBuilder vlanBuilder1 = new VlanMatchBuilder();
1918         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
1919         VlanId vlanId = new VlanId(10);
1920         VlanPcp vpcp = new VlanPcp((short) 3);
1921         vlanBuilder.setVlanPcp(vpcp);
1922         vlanBuilder1.setVlanId(vlanIdBuilder.setVlanId(vlanId).setVlanIdPresent(true).build());
1923         setFieldBuilder.setVlanMatch(vlanBuilder.build());
1924         setFieldBuilder1.setVlanMatch(vlanBuilder1.build());
1925         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1926         ab.setKey(new ActionKey(0));
1927         actionList.add(ab.build());
1928         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1929         ab1.setKey(new ActionKey(1));
1930         actionList.add(ab1.build());
1931
1932         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1933         aab.setAction(actionList);
1934
1935         InstructionBuilder ib = new InstructionBuilder();
1936         ib.setKey(new InstructionKey(0));
1937         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1938
1939         // Put our Instruction in a list of Instructions
1940         InstructionsBuilder isb = new InstructionsBuilder();
1941         List<Instruction> instructions = new ArrayList<Instruction>();
1942         instructions.add(ib.build());
1943         isb.setInstruction(instructions);
1944         return isb;
1945     }
1946
1947     private static InstructionsBuilder createAppyActionInstruction37() {
1948
1949         List<Action> actionList = new ArrayList<Action>();
1950         ActionBuilder ab = new ActionBuilder();
1951         ActionBuilder ab1 = new ActionBuilder();
1952         ActionBuilder ab2 = new ActionBuilder();
1953
1954         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
1955         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
1956         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
1957         // Ip
1958         IpMatchBuilder ipmatch = new IpMatchBuilder();
1959         IpMatchBuilder ipmatch1 = new IpMatchBuilder();
1960         IpMatchBuilder ipmatch2 = new IpMatchBuilder();
1961         Dscp dscp = new Dscp((short) 3);
1962         ipmatch.setIpDscp(dscp);
1963         ipmatch1.setIpEcn((short) 2);
1964         ipmatch2.setIpProtocol((short) 120);
1965         setFieldBuilder.setIpMatch(ipmatch.build());
1966         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
1967         ab.setKey(new ActionKey(0));
1968         actionList.add(ab.build());
1969
1970         setFieldBuilder1.setIpMatch(ipmatch1.build());
1971         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
1972         ab1.setKey(new ActionKey(1));
1973         actionList.add(ab1.build());
1974
1975         setFieldBuilder2.setIpMatch(ipmatch2.build());
1976         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
1977         ab2.setKey(new ActionKey(2));
1978         actionList.add(ab2.build());
1979
1980         ApplyActionsBuilder aab = new ApplyActionsBuilder();
1981         aab.setAction(actionList);
1982
1983         InstructionBuilder ib = new InstructionBuilder();
1984         ib.setKey(new InstructionKey(0));
1985         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
1986
1987         // Put our Instruction in a list of Instructions
1988         InstructionsBuilder isb = new InstructionsBuilder();
1989         List<Instruction> instructions = new ArrayList<Instruction>();
1990         instructions.add(ib.build());
1991         isb.setInstruction(instructions);
1992         return isb;
1993     }
1994
1995     private static InstructionsBuilder createAppyActionInstruction38() {
1996
1997         List<Action> actionList = new ArrayList<Action>();
1998         ActionBuilder ab = new ActionBuilder();
1999         ActionBuilder ab1 = new ActionBuilder();
2000
2001         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2002         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2003         // IPv4
2004         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2005         Ipv4MatchBuilder ipv4Match1 = new Ipv4MatchBuilder();
2006         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.5210");
2007         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1");
2008         ipv4Match1.setIpv4Destination(dstip);
2009         ipv4Match.setIpv4Source(srcip);
2010         setFieldBuilder.setLayer3Match(ipv4Match.build());
2011         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2012         ab.setKey(new ActionKey(0));
2013         actionList.add(ab.build());
2014
2015         setFieldBuilder1.setLayer3Match(ipv4Match1.build());
2016         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2017         ab1.setKey(new ActionKey(1));
2018         actionList.add(ab1.build());
2019
2020         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2021         aab.setAction(actionList);
2022
2023         InstructionBuilder ib = new InstructionBuilder();
2024         ib.setKey(new InstructionKey(0));
2025         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2026
2027         // Put our Instruction in a list of Instructions
2028         InstructionsBuilder isb = new InstructionsBuilder();
2029         List<Instruction> instructions = new ArrayList<Instruction>();
2030         instructions.add(ib.build());
2031         isb.setInstruction(instructions);
2032         return isb;
2033     }
2034
2035     private static InstructionsBuilder createAppyActionInstruction39() {
2036
2037         List<Action> actionList = new ArrayList<Action>();
2038         ActionBuilder ab = new ActionBuilder();
2039         ActionBuilder ab1 = new ActionBuilder();
2040
2041         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2042         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2043
2044         // Tcp
2045         PortNumber tcpsrcport = new PortNumber(1213);
2046         PortNumber tcpdstport = new PortNumber(646);
2047         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
2048         TcpMatchBuilder tcpmatch1 = new TcpMatchBuilder();
2049         tcpmatch.setTcpSourcePort(tcpsrcport);
2050         tcpmatch1.setTcpDestinationPort(tcpdstport);
2051         setFieldBuilder.setLayer4Match(tcpmatch.build());
2052         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2053         ab.setKey(new ActionKey(0));
2054         actionList.add(ab.build());
2055
2056         setFieldBuilder1.setLayer4Match(tcpmatch1.build());
2057         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2058         ab1.setKey(new ActionKey(1));
2059         actionList.add(ab.build());
2060
2061         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2062         aab.setAction(actionList);
2063
2064         InstructionBuilder ib = new InstructionBuilder();
2065         ib.setKey(new InstructionKey(0));
2066         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2067
2068         // Put our Instruction in a list of Instructions
2069         InstructionsBuilder isb = new InstructionsBuilder();
2070         List<Instruction> instructions = new ArrayList<Instruction>();
2071         instructions.add(ib.build());
2072         isb.setInstruction(instructions);
2073         return isb;
2074     }
2075
2076     private static InstructionsBuilder createAppyActionInstruction40() {
2077
2078         List<Action> actionList = new ArrayList<Action>();
2079         ActionBuilder ab = new ActionBuilder();
2080         ActionBuilder ab1 = new ActionBuilder();
2081
2082         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2083         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2084
2085         // Udp
2086         PortNumber udpsrcport = new PortNumber(1325);
2087         PortNumber udpdstport = new PortNumber(42);
2088         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
2089         UdpMatchBuilder udpmatch1 = new UdpMatchBuilder();
2090         udpmatch.setUdpDestinationPort(udpdstport);
2091         udpmatch1.setUdpSourcePort(udpsrcport);
2092         setFieldBuilder.setLayer4Match(udpmatch.build());
2093         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2094         ab.setKey(new ActionKey(0));
2095         actionList.add(ab.build());
2096
2097         setFieldBuilder1.setLayer4Match(udpmatch1.build());
2098         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2099         ab1.setKey(new ActionKey(1));
2100         actionList.add(ab1.build());
2101
2102         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2103         aab.setAction(actionList);
2104
2105         InstructionBuilder ib = new InstructionBuilder();
2106         ib.setKey(new InstructionKey(0));
2107         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2108
2109         // Put our Instruction in a list of Instructions
2110         InstructionsBuilder isb = new InstructionsBuilder();
2111         List<Instruction> instructions = new ArrayList<Instruction>();
2112         instructions.add(ib.build());
2113         isb.setInstruction(instructions);
2114         return isb;
2115     }
2116
2117     private static InstructionsBuilder createAppyActionInstruction41() {
2118
2119         List<Action> actionList = new ArrayList<Action>();
2120         ActionBuilder ab = new ActionBuilder();
2121         ActionBuilder ab1 = new ActionBuilder();
2122
2123         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2124         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2125
2126         // Sctp
2127         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2128         SctpMatchBuilder sctpmatch1 = new SctpMatchBuilder();
2129         PortNumber srcport = new PortNumber(1435);
2130         PortNumber dstport = new PortNumber(22);
2131         sctpmatch.setSctpSourcePort(srcport);
2132         sctpmatch1.setSctpDestinationPort(dstport);
2133         setFieldBuilder.setLayer4Match(sctpmatch.build());
2134         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2135         ab.setKey(new ActionKey(0));
2136         actionList.add(ab.build());
2137
2138         setFieldBuilder1.setLayer4Match(sctpmatch1.build());
2139         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2140         ab1.setKey(new ActionKey(1));
2141         actionList.add(ab1.build());
2142
2143         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2144         aab.setAction(actionList);
2145
2146         InstructionBuilder ib = new InstructionBuilder();
2147         ib.setKey(new InstructionKey(0));
2148         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2149
2150         // Put our Instruction in a list of Instructions
2151         InstructionsBuilder isb = new InstructionsBuilder();
2152         List<Instruction> instructions = new ArrayList<Instruction>();
2153         instructions.add(ib.build());
2154         isb.setInstruction(instructions);
2155         return isb;
2156     }
2157
2158     private static InstructionsBuilder createAppyActionInstruction42() {
2159
2160         List<Action> actionList = new ArrayList<Action>();
2161         ActionBuilder ab = new ActionBuilder();
2162         ActionBuilder ab1 = new ActionBuilder();
2163         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2164         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2165
2166         // Icmpv4
2167         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
2168         Icmpv4MatchBuilder icmpv4match1 = new Icmpv4MatchBuilder();
2169         icmpv4match.setIcmpv4Type((short) 8);
2170         icmpv4match1.setIcmpv4Code((short) 0);
2171         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
2172         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2173         ab.setKey(new ActionKey(0));
2174         actionList.add(ab.build());
2175
2176         setFieldBuilder1.setIcmpv4Match(icmpv4match1.build());
2177         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2178         ab1.setKey(new ActionKey(1));
2179         actionList.add(ab1.build());
2180
2181         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2182         aab.setAction(actionList);
2183
2184         InstructionBuilder ib = new InstructionBuilder();
2185         ib.setKey(new InstructionKey(0));
2186         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2187
2188         // Put our Instruction in a list of Instructions
2189         InstructionsBuilder isb = new InstructionsBuilder();
2190         List<Instruction> instructions = new ArrayList<Instruction>();
2191         instructions.add(ib.build());
2192         isb.setInstruction(instructions);
2193         return isb;
2194     }
2195
2196     private static InstructionsBuilder createAppyActionInstruction43() {
2197
2198         List<Action> actionList = new ArrayList<Action>();
2199         ActionBuilder ab = new ActionBuilder();
2200         ActionBuilder ab1 = new ActionBuilder();
2201         ActionBuilder ab2 = new ActionBuilder();
2202         ActionBuilder ab3 = new ActionBuilder();
2203         ActionBuilder ab4 = new ActionBuilder();
2204
2205         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2206         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2207         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2208         SetFieldBuilder setFieldBuilder3 = new SetFieldBuilder();
2209         SetFieldBuilder setFieldBuilder4 = new SetFieldBuilder();
2210
2211         // setting the values of ARP
2212         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2213         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2214         Ipv4Prefix dstiparp = new Ipv4Prefix("200.71.9.52/10");
2215         Ipv4Prefix srciparp = new Ipv4Prefix("100.1.1.1/8");
2216         // create ARP match action
2217         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
2218         ArpMatchBuilder arpmatch1 = new ArpMatchBuilder();
2219         ArpMatchBuilder arpmatch2 = new ArpMatchBuilder();
2220         ArpMatchBuilder arpmatch3 = new ArpMatchBuilder();
2221         ArpMatchBuilder arpmatch4 = new ArpMatchBuilder();
2222         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2223         arpsrc.setAddress(macsrc);
2224         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2225         arpdst.setAddress(macdest);
2226         arpmatch.setArpOp(2);
2227         arpmatch1.setArpSourceHardwareAddress(arpsrc.build());
2228         arpmatch2.setArpTargetHardwareAddress(arpdst.build());
2229         arpmatch3.setArpSourceTransportAddress(srciparp);
2230         arpmatch4.setArpTargetTransportAddress(dstiparp);
2231         setFieldBuilder.setLayer3Match(arpmatch.build());
2232         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2233         ab.setKey(new ActionKey(0));
2234         actionList.add(ab.build());
2235
2236         setFieldBuilder1.setLayer3Match(arpmatch1.build());
2237         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2238         ab1.setKey(new ActionKey(1));
2239         actionList.add(ab1.build());
2240
2241         setFieldBuilder2.setLayer3Match(arpmatch2.build());
2242         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2243         ab2.setKey(new ActionKey(2));
2244         actionList.add(ab2.build());
2245
2246         setFieldBuilder3.setLayer3Match(arpmatch3.build());
2247         ab3.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder3.build()).build());
2248         ab3.setKey(new ActionKey(3));
2249         actionList.add(ab3.build());
2250
2251         setFieldBuilder4.setLayer3Match(arpmatch4.build());
2252         ab4.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder4.build()).build());
2253         ab4.setKey(new ActionKey(4));
2254         actionList.add(ab4.build());
2255
2256         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2257         aab.setAction(actionList);
2258
2259         InstructionBuilder ib = new InstructionBuilder();
2260         ib.setKey(new InstructionKey(0));
2261         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2262
2263         // Put our Instruction in a list of Instructions
2264         InstructionsBuilder isb = new InstructionsBuilder();
2265         List<Instruction> instructions = new ArrayList<Instruction>();
2266         instructions.add(ib.build());
2267         isb.setInstruction(instructions);
2268         return isb;
2269     }
2270
2271     private static InstructionsBuilder createAppyActionInstruction44() {
2272
2273         List<Action> actionList = new ArrayList<Action>();
2274         ActionBuilder ab = new ActionBuilder();
2275         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2276         ActionBuilder ab1 = new ActionBuilder();
2277         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2278
2279         // IPv6
2280         Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
2281         Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
2282         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2");
2283         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1");
2284         ipv6Builder1.setIpv6Destination(dstip6);
2285         ipv6Builder.setIpv6Source(srcip6);
2286         setFieldBuilder.setLayer3Match(ipv6Builder.build());
2287         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2288         ab.setKey(new ActionKey(0));
2289         actionList.add(ab.build());
2290
2291         setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
2292         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2293         ab1.setKey(new ActionKey(1));
2294         actionList.add(ab1.build());
2295
2296         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2297         aab.setAction(actionList);
2298
2299         InstructionBuilder ib = new InstructionBuilder();
2300         ib.setKey(new InstructionKey(0));
2301         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2302
2303         // Put our Instruction in a list of Instructions
2304         InstructionsBuilder isb = new InstructionsBuilder();
2305         List<Instruction> instructions = new ArrayList<Instruction>();
2306         instructions.add(ib.build());
2307         isb.setInstruction(instructions);
2308         return isb;
2309     }
2310
2311     private static InstructionsBuilder createAppyActionInstruction45() {
2312
2313         List<Action> actionList = new ArrayList<Action>();
2314         ActionBuilder ab = new ActionBuilder();
2315         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2316         ActionBuilder ab1 = new ActionBuilder();
2317         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2318
2319         // Icmpv6
2320         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder();
2321         Icmpv6MatchBuilder icmpv6match1 = new Icmpv6MatchBuilder();
2322         icmpv6match.setIcmpv6Type((short) 135);
2323         icmpv6match1.setIcmpv6Code((short) 0);
2324         setFieldBuilder.setIcmpv6Match(icmpv6match.build());
2325         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2326         ab.setKey(new ActionKey(0));
2327         actionList.add(ab.build());
2328
2329         setFieldBuilder1.setIcmpv6Match(icmpv6match1.build());
2330         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2331         ab1.setKey(new ActionKey(1));
2332         actionList.add(ab1.build());
2333
2334         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2335         aab.setAction(actionList);
2336
2337         InstructionBuilder ib = new InstructionBuilder();
2338         ib.setKey(new InstructionKey(0));
2339         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2340
2341         // Put our Instruction in a list of Instructions
2342         InstructionsBuilder isb = new InstructionsBuilder();
2343         List<Instruction> instructions = new ArrayList<Instruction>();
2344         instructions.add(ib.build());
2345         isb.setInstruction(instructions);
2346         return isb;
2347     }
2348
2349     private static InstructionsBuilder createAppyActionInstruction46() {
2350
2351         List<Action> actionList = new ArrayList<Action>();
2352         ActionBuilder ab = new ActionBuilder();
2353         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2354         ActionBuilder ab1 = new ActionBuilder();
2355         SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
2356         ActionBuilder ab2 = new ActionBuilder();
2357         SetFieldBuilder setFieldBuilder2 = new SetFieldBuilder();
2358
2359         // MPLS
2360         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2361         ProtocolMatchFieldsBuilder protomatch1 = new ProtocolMatchFieldsBuilder();
2362         ProtocolMatchFieldsBuilder protomatch2 = new ProtocolMatchFieldsBuilder();
2363         protomatch.setMplsLabel((long) 36008);
2364         protomatch1.setMplsTc((short) 4);
2365         protomatch2.setMplsBos((short) 1);
2366         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2367         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2368         ab.setKey(new ActionKey(0));
2369         actionList.add(ab.build());
2370
2371         setFieldBuilder1.setProtocolMatchFields(protomatch1.build());
2372         ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
2373         ab1.setKey(new ActionKey(1));
2374         actionList.add(ab1.build());
2375
2376         setFieldBuilder2.setProtocolMatchFields(protomatch2.build());
2377         ab2.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder2.build()).build());
2378         ab2.setKey(new ActionKey(2));
2379         actionList.add(ab2.build());
2380
2381         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2382         aab.setAction(actionList);
2383
2384         InstructionBuilder ib = new InstructionBuilder();
2385         ib.setKey(new InstructionKey(0));
2386         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2387
2388         // Put our Instruction in a list of Instructions
2389         InstructionsBuilder isb = new InstructionsBuilder();
2390         List<Instruction> instructions = new ArrayList<Instruction>();
2391         instructions.add(ib.build());
2392         isb.setInstruction(instructions);
2393         return isb;
2394     }
2395
2396     private static InstructionsBuilder createAppyActionInstruction47() {
2397
2398         List<Action> actionList = new ArrayList<Action>();
2399         ActionBuilder ab = new ActionBuilder();
2400         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2401         // PBB
2402         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder();
2403         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
2404         setFieldBuilder.setProtocolMatchFields(protomatch.build());
2405         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2406         actionList.add(ab.build());
2407
2408         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2409         aab.setAction(actionList);
2410
2411         InstructionBuilder ib = new InstructionBuilder();
2412         ib.setKey(new InstructionKey(0));
2413         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2414
2415         // Put our Instruction in a list of Instructions
2416         InstructionsBuilder isb = new InstructionsBuilder();
2417         List<Instruction> instructions = new ArrayList<Instruction>();
2418         instructions.add(ib.build());
2419         isb.setInstruction(instructions);
2420         return isb;
2421     }
2422
2423     private static InstructionsBuilder createAppyActionInstruction48() {
2424
2425         List<Action> actionList = new ArrayList<Action>();
2426         ActionBuilder ab = new ActionBuilder();
2427         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
2428         // Tunnel
2429         TunnelBuilder tunnel = new TunnelBuilder();
2430         tunnel.setTunnelId(BigInteger.valueOf(10668));
2431         setFieldBuilder.setTunnel(tunnel.build());
2432         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
2433         actionList.add(ab.build());
2434
2435         ApplyActionsBuilder aab = new ApplyActionsBuilder();
2436         aab.setAction(actionList);
2437
2438         InstructionBuilder ib = new InstructionBuilder();
2439         ib.setKey(new InstructionKey(0));
2440         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
2441
2442         // Put our Instruction in a list of Instructions
2443         InstructionsBuilder isb = new InstructionsBuilder();
2444         List<Instruction> instructions = new ArrayList<Instruction>();
2445         instructions.add(ib.build());
2446         isb.setInstruction(instructions);
2447         return isb;
2448     }
2449
2450     /**
2451      * @return
2452      */
2453     private static MatchBuilder createMatch1() {
2454         MatchBuilder match = new MatchBuilder();
2455         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2456         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2457         ipv4Match.setIpv4Destination(prefix);
2458         Ipv4Match i4m = ipv4Match.build();
2459         match.setLayer3Match(i4m);
2460
2461         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2462         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2463         ethTypeBuilder.setType(new EtherType(0x0800L));
2464         eth.setEthernetType(ethTypeBuilder.build());
2465         match.setEthernetMatch(eth.build());
2466         return match;
2467     }
2468
2469     /**
2470      * @return
2471      */
2472     private static MatchBuilder createIPv4DstMatch() {
2473         MatchBuilder match = new MatchBuilder();
2474         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2475         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
2476         ipv4Match.setIpv4Destination(prefix);
2477         Ipv4Match i4m = ipv4Match.build();
2478         match.setLayer3Match(i4m);
2479
2480         return match;
2481     }
2482
2483     /**
2484      * @return
2485      */
2486     private static MatchBuilder createIPv4SrcMatch() {
2487         MatchBuilder match = new MatchBuilder();
2488         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2489         Ipv4Prefix prefix = new Ipv4Prefix("10.20.30.40/24");
2490         ipv4Match.setIpv4Source(prefix);
2491         Ipv4Match i4m = ipv4Match.build();
2492         match.setLayer3Match(i4m);
2493
2494         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2495         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2496         ethTypeBuilder.setType(new EtherType(0x0800L));
2497         eth.setEthernetType(ethTypeBuilder.build());
2498         match.setEthernetMatch(eth.build());
2499         return match;
2500     }
2501
2502     /**
2503      * @return
2504      */
2505     private static MatchBuilder createMatch2() {
2506         MatchBuilder match = new MatchBuilder();
2507         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2508         Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1");
2509         ipv4Match.setIpv4Source(prefix);
2510         Ipv4Match i4m = ipv4Match.build();
2511         match.setLayer3Match(i4m);
2512
2513         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2514         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2515         ethTypeBuilder.setType(new EtherType(0x0800L));
2516         eth.setEthernetType(ethTypeBuilder.build());
2517         match.setEthernetMatch(eth.build());
2518         return match;
2519     }
2520
2521     /**
2522      * @return
2523      */
2524     private static MatchBuilder createMatch3() {
2525         MatchBuilder match = new MatchBuilder();
2526         EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
2527         EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
2528         ethSourceBuilder.setAddress(new MacAddress("00:00:00:00:00:01"));
2529         ethernetMatch.setEthernetSource(ethSourceBuilder.build());
2530         match.setEthernetMatch(ethernetMatch.build());
2531
2532         return match;
2533     }
2534
2535     private static MatchBuilder createInphyportMatch() {
2536         MatchBuilder match = new MatchBuilder();
2537         match.setInPort(202L);
2538         match.setInPhyPort(10122L);
2539         return match;
2540     }
2541
2542     private static MatchBuilder createEthernetMatch() {
2543         MatchBuilder match = new MatchBuilder();
2544
2545         byte[] mask1 = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2546         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2547
2548         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); // ethernettype
2549                                                                     // match
2550         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2551         EtherType type = new EtherType(0x0800L);
2552         ethmatch.setEthernetType(ethtype.setType(type).build());
2553
2554         EthernetDestinationBuilder ethdest = new EthernetDestinationBuilder(); // ethernet
2555                                                                                // macaddress
2556                                                                                // match
2557         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2558         ethdest.setAddress(macdest);
2559         ethdest.setMask(mask1);
2560
2561         ethmatch.setEthernetDestination(ethdest.build());
2562
2563         EthernetSourceBuilder ethsrc = new EthernetSourceBuilder();
2564         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2565         ethsrc.setAddress(macsrc);
2566         ethsrc.setMask(mask2);
2567
2568         ethmatch.setEthernetSource(ethsrc.build());
2569         match.setEthernetMatch(ethmatch.build());
2570         return match;
2571
2572     }
2573
2574     /**
2575      * @return
2576      */
2577
2578     private static MatchBuilder createVlanMatch() {
2579         MatchBuilder match = new MatchBuilder();
2580         VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); // vlan match
2581         VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
2582         VlanId vlanId = new VlanId(10);
2583         VlanPcp vpcp = new VlanPcp((short) 3);
2584         vlanBuilder.setVlanPcp(vpcp);
2585         vlanIdBuilder.setVlanId(vlanId);
2586         vlanIdBuilder.setVlanIdPresent(true);
2587         vlanBuilder.setVlanId(vlanIdBuilder.build());
2588         match.setVlanMatch(vlanBuilder.build());
2589         return match;
2590     }
2591
2592     /**
2593      * @return
2594      */
2595     private static MatchBuilder createArpMatch() {
2596         MatchBuilder match = new MatchBuilder();
2597
2598         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2599         MacAddress macdest = new MacAddress("ff:ff:ff:ff:ff:ff");
2600         MacAddress macsrc = new MacAddress("00:00:00:00:23:ae");
2601
2602         byte[] mask = new byte[] { (byte) -1, (byte) -1, 0, 0, 0, 0 };
2603         byte[] mask2 = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0 };
2604
2605         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2606         EtherType type = new EtherType(0x0806L);
2607         ethmatch.setEthernetType(ethtype.setType(type).build());
2608
2609         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2610         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2611
2612         ArpMatchBuilder arpmatch = new ArpMatchBuilder(); // arp match
2613         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
2614         arpsrc.setAddress(macsrc);
2615         arpsrc.setMask(mask);
2616         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
2617         arpdst.setAddress(macdest);
2618         arpdst.setMask(mask2);
2619         arpmatch.setArpOp(2);
2620         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
2621         arpmatch.setArpTargetHardwareAddress(arpdst.build());
2622         arpmatch.setArpSourceTransportAddress(srcip);
2623         arpmatch.setArpTargetTransportAddress(dstip);
2624
2625         match.setEthernetMatch(ethmatch.build());
2626         match.setLayer3Match(arpmatch.build());
2627
2628         return match;
2629     }
2630
2631     /**
2632      * @return
2633      */
2634     private static MatchBuilder createIPMatch() {
2635         MatchBuilder match = new MatchBuilder();
2636         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2637         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2638         EtherType type = new EtherType(0x0800L);
2639         ethmatch.setEthernetType(ethtype.setType(type).build());
2640         match.setEthernetMatch(ethmatch.build());
2641
2642         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2643         ipmatch.setIpProtocol((short) 1);
2644         Dscp dscp = new Dscp((short) 3);
2645         ipmatch.setIpDscp(dscp);
2646         ipmatch.setIpEcn((short) 2);
2647         match.setIpMatch(ipmatch.build());
2648         return match;
2649     }
2650
2651     /**
2652      * @return
2653      */
2654     private static MatchBuilder createL3IPv4Match() {
2655         MatchBuilder match = new MatchBuilder();
2656
2657         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2658         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2659         ethTypeBuilder.setType(new EtherType(0x0800L));
2660         eth.setEthernetType(ethTypeBuilder.build());
2661         match.setEthernetMatch(eth.build());
2662
2663         Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
2664         Ipv4Prefix dstip = new Ipv4Prefix("200.71.9.52/10"); // ipv4 match
2665         Ipv4Prefix srcip = new Ipv4Prefix("100.1.1.1/8");
2666         Ipv4MatchBuilder ipv4match = new Ipv4MatchBuilder();
2667         ipv4match.setIpv4Destination(dstip);
2668         ipv4match.setIpv4Source(srcip);
2669         match.setLayer3Match(ipv4match.build());
2670
2671         return match;
2672
2673     }
2674
2675     /**
2676      * @return
2677      */
2678     private static MatchBuilder createL3IPv6Match() {
2679         MatchBuilder match = new MatchBuilder();
2680
2681         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2682         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2683         ethTypeBuilder.setType(new EtherType(0x86ddL));
2684         eth.setEthernetType(ethTypeBuilder.build());
2685         match.setEthernetMatch(eth.build());
2686
2687         Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/64");
2688         Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/56");
2689         Ipv6Address ndtarget = new Ipv6Address("2001:db8:0:1:fd97:f9f0:a810:782e");
2690         MacAddress ndsll = new MacAddress("c2:00:54:f5:00:00");
2691         MacAddress ndtll = new MacAddress("00:0c:29:0e:4c:67");
2692         Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
2693         nextheader.setIpv6Exthdr(58);
2694         Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
2695         Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
2696         ipv6label.setIpv6Flabel(label);
2697         ipv6label.setFlabelMask(new byte[] { 0, 1, -1, -1 });
2698
2699         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2700                                                                    // match
2701         icmpv6match.setIcmpv6Type((short) 135);
2702         icmpv6match.setIcmpv6Code((short) 0);
2703         match.setIcmpv6Match(icmpv6match.build());
2704
2705         Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder();
2706         // ipv6match.setIpv6Source(srcip6);
2707         // ipv6match.setIpv6Destination(dstip6);
2708         // ipv6match.setIpv6ExtHeader(nextheader.build());
2709         ipv6match.setIpv6NdSll(ndsll);
2710         ipv6match.setIpv6NdTll(ndtll);
2711         // ipv6match.setIpv6NdTarget(ndtarget);
2712         ipv6match.setIpv6Label(ipv6label.build());
2713
2714         match.setLayer3Match(ipv6match.build());
2715
2716         return match;
2717     }
2718
2719     /**
2720      * @return
2721      */
2722
2723     private static MatchBuilder createICMPv4Match() {
2724         MatchBuilder match = new MatchBuilder();
2725         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2726         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2727         ethTypeBuilder.setType(new EtherType(0x0800L));
2728         eth.setEthernetType(ethTypeBuilder.build());
2729         match.setEthernetMatch(eth.build());
2730
2731         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2732         ipmatch.setIpProtocol((short) 1);
2733         match.setIpMatch(ipmatch.build());
2734
2735         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4
2736                                                                    // match
2737         icmpv4match.setIcmpv4Type((short) 8);
2738         icmpv4match.setIcmpv4Code((short) 0);
2739         match.setIcmpv4Match(icmpv4match.build());
2740         return match;
2741     }
2742
2743     /**
2744      * @return
2745      */
2746     private static MatchBuilder createICMPv6Match() {
2747
2748         MatchBuilder match = new MatchBuilder();
2749         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2750         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2751         ethTypeBuilder.setType(new EtherType(0x86ddL));
2752         eth.setEthernetType(ethTypeBuilder.build());
2753         match.setEthernetMatch(eth.build());
2754
2755         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2756         ipmatch.setIpProtocol((short) 58);
2757         match.setIpMatch(ipmatch.build());
2758
2759         Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6
2760                                                                    // match
2761         icmpv6match.setIcmpv6Type((short) 135);
2762         icmpv6match.setIcmpv6Code((short) 1);
2763         match.setIcmpv6Match(icmpv6match.build());
2764
2765         return match;
2766     }
2767
2768     /**
2769      * @return
2770      */
2771     private static MatchBuilder createToSMatch() {
2772         MatchBuilder match = new MatchBuilder();
2773         EthernetMatchBuilder ethmatch = new EthernetMatchBuilder();
2774         EthernetTypeBuilder ethtype = new EthernetTypeBuilder();
2775         EtherType type = new EtherType(0x0800L);
2776         ethmatch.setEthernetType(ethtype.setType(type).build());
2777         match.setEthernetMatch(ethmatch.build());
2778
2779         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2780         ipmatch.setIpProtocol((short) 6);
2781         Dscp dscp = new Dscp((short) 8);
2782         ipmatch.setIpDscp(dscp);
2783         match.setIpMatch(ipmatch.build());
2784         return match;
2785     }
2786
2787     /**
2788      * @return
2789      */
2790
2791     private static MatchBuilder createL4TCPMatch() {
2792         MatchBuilder match = new MatchBuilder();
2793
2794         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2795         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2796         ethTypeBuilder.setType(new EtherType(0x0800L));
2797         eth.setEthernetType(ethTypeBuilder.build());
2798         match.setEthernetMatch(eth.build());
2799
2800         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2801         ipmatch.setIpProtocol((short) 6);
2802         match.setIpMatch(ipmatch.build());
2803
2804         PortNumber srcport = new PortNumber(1213);
2805         PortNumber dstport = new PortNumber(646);
2806         TcpMatchBuilder tcpmatch = new TcpMatchBuilder(); // tcp match
2807         tcpmatch.setTcpSourcePort(srcport);
2808         tcpmatch.setTcpDestinationPort(dstport);
2809         match.setLayer4Match(tcpmatch.build());
2810
2811         return match;
2812     }
2813
2814     /**
2815      * @return
2816      */
2817     private static MatchBuilder createL4UDPMatch() {
2818         MatchBuilder match = new MatchBuilder();
2819
2820         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2821         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2822         ethTypeBuilder.setType(new EtherType(0x0800L));
2823         eth.setEthernetType(ethTypeBuilder.build());
2824         match.setEthernetMatch(eth.build());
2825
2826         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2827         ipmatch.setIpProtocol((short) 17);
2828         match.setIpMatch(ipmatch.build());
2829
2830         PortNumber srcport = new PortNumber(1325);
2831         PortNumber dstport = new PortNumber(42);
2832         UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match
2833         udpmatch.setUdpDestinationPort(dstport);
2834         udpmatch.setUdpSourcePort(srcport);
2835         match.setLayer4Match(udpmatch.build());
2836
2837         return match;
2838     }
2839
2840     /**
2841      * @return
2842      */
2843     private static MatchBuilder createL4SCTPMatch() {
2844         MatchBuilder match = new MatchBuilder();
2845
2846         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2847         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2848         ethTypeBuilder.setType(new EtherType(0x0800L));
2849         eth.setEthernetType(ethTypeBuilder.build());
2850         match.setEthernetMatch(eth.build());
2851
2852         IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version
2853         ipmatch.setIpProtocol((short) 132);
2854         match.setIpMatch(ipmatch.build());
2855
2856         SctpMatchBuilder sctpmatch = new SctpMatchBuilder();
2857         PortNumber srcport = new PortNumber(1435);
2858         PortNumber dstport = new PortNumber(22);
2859         sctpmatch.setSctpSourcePort(srcport);
2860         sctpmatch.setSctpDestinationPort(dstport);
2861         match.setLayer4Match(sctpmatch.build());
2862
2863         return match;
2864     }
2865
2866     /**
2867      * @return
2868      */
2869     private static MatchBuilder createMetadataMatch() {
2870         MatchBuilder match = new MatchBuilder();
2871         byte[] metamask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
2872         MetadataBuilder metadata = new MetadataBuilder(); // metadata match
2873         metadata.setMetadata(BigInteger.valueOf(500L));
2874         metadata.setMetadataMask(metamask);
2875         match.setMetadata(metadata.build());
2876
2877         return match;
2878     }
2879
2880     /**
2881      * @return
2882      */
2883     private static MatchBuilder createMplsMatch() {
2884         MatchBuilder match = new MatchBuilder();
2885
2886         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2887         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2888         ethTypeBuilder.setType(new EtherType(0x8847L));
2889         eth.setEthernetType(ethTypeBuilder.build());
2890         match.setEthernetMatch(eth.build());
2891
2892         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2893         // match
2894         protomatch.setMplsLabel((long) 36008);
2895         protomatch.setMplsTc((short) 4);
2896         protomatch.setMplsBos((short) 1);
2897         match.setProtocolMatchFields(protomatch.build());
2898
2899         return match;
2900
2901     }
2902
2903     /**
2904      * @return
2905      */
2906     private static MatchBuilder createPbbMatch() {
2907         MatchBuilder match = new MatchBuilder();
2908
2909         EthernetMatchBuilder eth = new EthernetMatchBuilder();
2910         EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
2911         ethTypeBuilder.setType(new EtherType(0x88E7L));
2912         eth.setEthernetType(ethTypeBuilder.build());
2913         match.setEthernetMatch(eth.build());
2914
2915         ProtocolMatchFieldsBuilder protomatch = new ProtocolMatchFieldsBuilder(); // mpls
2916         // match
2917         protomatch.setPbb(new PbbBuilder().setPbbIsid(4L).setPbbMask(new byte[] { 0, 1, 0, 0 }).build());
2918         match.setProtocolMatchFields(protomatch.build());
2919
2920         return match;
2921
2922     }
2923
2924     /**
2925      * @return
2926      */
2927     private static MatchBuilder createTunnelIDMatch() {
2928         MatchBuilder match = new MatchBuilder();
2929         TunnelBuilder tunnel = new TunnelBuilder(); // tunnel id match
2930         tunnel.setTunnelId(BigInteger.valueOf(10668));
2931         byte[] mask = new byte[] { (byte) -1, (byte) -1, (byte) -1, 0, 0, 0, (byte) 1, (byte) 1 };
2932         tunnel.setTunnelMask(mask);
2933         match.setTunnel(tunnel.build());
2934
2935         return match;
2936     }
2937
2938     public void _removeMDFlow(CommandInterpreter ci) {
2939         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
2940         NodeBuilder tn = createTestNode(ci.nextArgument());
2941         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2942         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class).child(Node.class, tn.getKey())
2943                 .augmentation(FlowCapableNode.class).child(Table.class, new TableKey(tf.getTableId()))
2944                 .child(Flow.class, tf.getKey()).build();
2945         modification.removeOperationalData(nodeBuilderToInstanceId(tn));
2946         modification.removeOperationalData(path1);
2947         modification.removeConfigurationData(nodeBuilderToInstanceId(tn));
2948         modification.removeConfigurationData(path1);
2949         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
2950         try {
2951             RpcResult<TransactionStatus> result = commitFuture.get();
2952             TransactionStatus status = result.getResult();
2953             ci.println("Status of Flow Data Loaded Transaction: " + status);
2954
2955         } catch (InterruptedException e) {
2956             LOG.error(e.getMessage(), e);
2957         } catch (ExecutionException e) {
2958             LOG.error(e.getMessage(), e);
2959         }
2960     }
2961
2962     public void _addMDFlow(CommandInterpreter ci) {
2963         NodeBuilder tn = createTestNode(ci.nextArgument());
2964         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2965         writeFlow(ci, tf, tn);
2966     }
2967
2968     private void writeFlow(CommandInterpreter ci, FlowBuilder flow, NodeBuilder nodeBuilder) {
2969         DataModification<InstanceIdentifier<?>, DataObject> modification = dataBrokerService.beginTransaction();
2970         InstanceIdentifier<Flow> path1 = InstanceIdentifier.builder(Nodes.class)
2971                 .child(Node.class, nodeBuilder.getKey()).augmentation(FlowCapableNode.class)
2972                 .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
2973         modification.putOperationalData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2974         modification.putOperationalData(path1, flow.build());
2975         modification.putConfigurationData(nodeBuilderToInstanceId(nodeBuilder), nodeBuilder.build());
2976         modification.putConfigurationData(path1, flow.build());
2977         Future<RpcResult<TransactionStatus>> commitFuture = modification.commit();
2978         try {
2979             RpcResult<TransactionStatus> result = commitFuture.get();
2980             TransactionStatus status = result.getResult();
2981             ci.println("Status of Flow Data Loaded Transaction: " + status);
2982
2983         } catch (InterruptedException e) {
2984             LOG.error(e.getMessage(), e);
2985         } catch (ExecutionException e) {
2986             LOG.error(e.getMessage(), e);
2987         }
2988     }
2989
2990     public void _modifyMDFlow(CommandInterpreter ci) {
2991         NodeBuilder tn = createTestNode(ci.nextArgument());
2992         FlowBuilder tf = createTestFlow(tn, ci.nextArgument(), ci.nextArgument());
2993         tf.setFlowName(updatedFlowName);
2994         writeFlow(ci, tf, tn);
2995         tf.setFlowName(originalFlowName);
2996         writeFlow(ci, tf, tn);
2997     }
2998
2999     private static NodeRef createNodeRef(String string) {
3000         NodeKey key = new NodeKey(new NodeId(string));
3001         InstanceIdentifier<Node> path = InstanceIdentifier.builder().node(Nodes.class).node(Node.class, key)
3002                 .toInstance();
3003
3004         return new NodeRef(path);
3005     }
3006
3007     @Override
3008     public String getHelp() {
3009         return "No help";
3010     }
3011 }