Fix javadoc JDK8 compatibility
[netvirt.git] / utils / mdsal-openflow / src / main / java / org / opendaylight / ovsdb / utils / mdsal / openflow / InstructionUtils.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
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
10 package org.opendaylight.ovsdb.utils.mdsal.openflow;
11
12 import static org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils.dropAction;
13
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4MatchBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
71
72 import com.google.common.collect.Lists;
73
74 import org.slf4j.Logger;
75 import org.slf4j.LoggerFactory;
76
77 import java.math.BigInteger;
78 import java.util.ArrayList;
79 import java.util.List;
80
81 public class InstructionUtils {
82     private static final Logger logger = LoggerFactory.getLogger(InstructionUtils.class);
83     private static final int IPV4 = 0x8100;
84     private static final int MAX_LENGTH = 0xffff;
85
86     /**
87      * Create Send to Controller Reserved Port Instruction (packet_in)
88      *
89      * @param nodeName Uri Prefix, containing nodeConnectorType and dpId (aka NodeId)
90      * @param ib Map InstructionBuilder without any instructions
91      * @return ib Map InstructionBuilder with instructions
92      */
93     public static InstructionBuilder createSendToControllerInstructions(String nodeName, InstructionBuilder ib) {
94
95         List<Action> actionList = Lists.newArrayList();
96         ActionBuilder ab = new ActionBuilder();
97
98         OutputActionBuilder output = new OutputActionBuilder();
99         output.setMaxLength(MAX_LENGTH);
100         NodeId nodeId = new NodeId(nodeName);
101         output.setOutputNodeConnector(new NodeConnectorId(nodeId.getValue() + ":"
102                 + OutputPortValues.CONTROLLER.toString()));
103         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
104         ab.setOrder(0);
105         ab.setKey(new ActionKey(0));
106         actionList.add(ab.build());
107
108         // Create an Apply Action
109         ApplyActionsBuilder aab = new ApplyActionsBuilder();
110         aab.setAction(actionList);
111
112         // Wrap our Apply Action in an Instruction
113         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
114
115         return ib;
116     }
117
118     /**
119      * Create NORMAL Reserved Port Instruction (packet_in)
120      *
121      * @param nodeName Uri Prefix, containing nodeConnectorType and dpId (aka NodeId)
122      * @param ib Map InstructionBuilder without any instructions
123      * @return ib Map InstructionBuilder with instructions
124      */
125
126     public static InstructionBuilder createNormalInstructions(String nodeName, InstructionBuilder ib) {
127
128         List<Action> actionList = Lists.newArrayList();
129         ActionBuilder ab = new ActionBuilder();
130
131         OutputActionBuilder output = new OutputActionBuilder();
132         NodeId nodeId = new NodeId(nodeName);
133         output.setOutputNodeConnector(new NodeConnectorId(nodeId.getValue() + ":"
134                 + OutputPortValues.NORMAL.toString()));
135         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
136         ab.setOrder(0);
137         ab.setKey(new ActionKey(0));
138         actionList.add(ab.build());
139
140         // Create an Apply Action
141         ApplyActionsBuilder aab = new ApplyActionsBuilder();
142         aab.setAction(actionList);
143
144         // Wrap our Apply Action in an Instruction
145         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
146
147         return ib;
148     }
149
150     /**
151      * Create Output Port Instruction
152      *
153      * @param ib       Map InstructionBuilder without any instructions
154      * @param dpidLong Long the datapath ID of a switch/node
155      * @param port     Long representing a port on a switch/node
156      * @return ib InstructionBuilder Map with instructions
157      */
158     public static InstructionBuilder createOutputPortInstructions(InstructionBuilder ib, Long dpidLong, Long port) {
159
160         NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
161         logger.debug("createOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} inPort={} ",
162                 dpidLong, port);
163
164         List<Action> actionList = Lists.newArrayList();
165         ActionBuilder ab = new ActionBuilder();
166         OutputActionBuilder oab = new OutputActionBuilder();
167         oab.setOutputNodeConnector(ncid);
168
169         ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
170         ab.setOrder(0);
171         ab.setKey(new ActionKey(0));
172         actionList.add(ab.build());
173
174         // Create an Apply Action
175         ApplyActionsBuilder aab = new ApplyActionsBuilder();
176         aab.setAction(actionList);
177         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
178
179         return ib;
180     }
181
182     /**
183      * add Output Port action to Instruction action list.
184      * This is use for flow with single output port actions.
185      * Flow with mutiple output port actions should use createOutputPortInstructions() method.
186      *
187      * @param ib       Map InstructionBuilder without any instructions
188      * @param dpidLong Long the datapath ID of a switch/node
189      * @param port     Long representing a port on a switch/node
190      * @return ib InstructionBuilder Map with instructions
191      */
192     public static InstructionBuilder addOutputPortInstructions(InstructionBuilder ib,
193             Long dpidLong, Long port,
194             List<Instruction> instructions) {
195         NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
196         logger.debug(
197                 "addOutputPortInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
198                 dpidLong, port, instructions);
199
200         List<Action> actionList = Lists.newArrayList();
201         ActionBuilder ab = new ActionBuilder();
202
203         List<Action> existingActions;
204         if (instructions != null) {
205             for (Instruction in : instructions) {
206                 if (in.getInstruction() instanceof ApplyActionsCase) {
207                     existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
208                     actionList.addAll(existingActions);
209                 }
210             }
211         }
212
213         /* Create output action for this port*/
214         OutputActionBuilder oab = new OutputActionBuilder();
215         oab.setOutputNodeConnector(ncid);
216         ab.setAction(new OutputActionCaseBuilder().setOutputAction(oab.build()).build());
217         ab.setOrder(actionList.size());
218         ab.setKey(new ActionKey(actionList.size()));
219         actionList.add(ab.build());
220
221         // Create an Apply Action
222         ApplyActionsBuilder aab = new ApplyActionsBuilder();
223         aab.setAction(actionList);
224         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
225
226         return ib;
227     }
228
229     /**
230      * Remove Output Port from Instruction
231      *
232      * @param ib       Map InstructionBuilder without any instructions
233      * @param dpidLong Long the datapath ID of a switch/node
234      * @param port     Long representing a port on a switch/node
235      * @return ib InstructionBuilder Map with instructions
236      */
237     public static boolean removeOutputPortFromInstructions(InstructionBuilder ib,
238             Long dpidLong, Long port, List<Instruction> instructions) {
239
240         NodeConnectorId ncid = new NodeConnectorId("openflow:" + dpidLong + ":" + port);
241         logger.debug(
242                 "removeOutputPortFromInstructions() Node Connector ID is - Type=openflow: DPID={} port={} existingInstructions={}",
243                 dpidLong, port, instructions);
244
245         List<Action> actionList = Lists.newArrayList();
246         ActionBuilder ab;
247
248         List<Action> existingActions;
249         if (instructions != null) {
250             for (Instruction in : instructions) {
251                 if (in.getInstruction() instanceof ApplyActionsCase) {
252                     existingActions = (((ApplyActionsCase) in.getInstruction()).getApplyActions().getAction());
253                     actionList.addAll(existingActions);
254                     break;
255                 }
256             }
257         }
258
259         int index = 0;
260         boolean isPortDeleted = false;
261         boolean removeFlow = true;
262         for (Action action : actionList) {
263             if (action.getAction() instanceof OutputActionCase) {
264                 OutputActionCase opAction = (OutputActionCase) action.getAction();
265                 if (opAction.getOutputAction().getOutputNodeConnector().equals(new Uri(ncid))) {
266                     /* Find the output port in action list and remove */
267                     index = actionList.indexOf(action);
268                     actionList.remove(action);
269                     isPortDeleted = true;
270                     break;
271                 }
272                 removeFlow = false;
273             }
274         }
275
276         if (isPortDeleted) {
277             for (int i = index; i < actionList.size(); i++) {
278                 Action action = actionList.get(i);
279                 if (action.getOrder() != i) {
280                     /* Shift the action order */
281                     ab = new ActionBuilder();
282                     ab.setAction(action.getAction());
283                     ab.setOrder(i);
284                     ab.setKey(new ActionKey(i));
285                     Action actionNewOrder = ab.build();
286                     actionList.remove(action);
287                     actionList.add(i, actionNewOrder);
288                 }
289                 if (action.getAction() instanceof OutputActionCase) {
290                     removeFlow = false;
291                 }
292             }
293         }
294
295         /* Put new action list in Apply Action instruction */
296         if (!removeFlow) {
297             ApplyActionsBuilder aab = new ApplyActionsBuilder();
298             aab.setAction(actionList);
299             ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
300             logger.debug("removeOutputPortFromInstructions() : applyAction {}", aab.build());
301             return false;
302         } else {
303             /* if all output port are removed. Return true to indicate flow remove */
304             return true;
305         }
306     }
307
308     /**
309      * Create Set Vlan ID Instruction - This includes push vlan action, and set field -&gt; vlan vid action
310      *
311      * @param ib     Map InstructionBuilder without any instructions
312      * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID
313      * @return ib Map InstructionBuilder with instructions
314      */
315     public static InstructionBuilder createSetVlanInstructions(InstructionBuilder ib, VlanId vlanId) {
316
317         List<Action> actionList = Lists.newArrayList();
318         ActionBuilder ab = new ActionBuilder();
319
320         /* First we push vlan header */
321         PushVlanActionBuilder vlan = new PushVlanActionBuilder();
322         vlan.setEthernetType(IPV4);
323         ab.setAction(new PushVlanActionCaseBuilder().setPushVlanAction(vlan.build()).build());
324         ab.setOrder(0);
325         actionList.add(ab.build());
326
327         /* Then we set vlan id value as vlanId */
328         SetVlanIdActionBuilder vl = new SetVlanIdActionBuilder();
329         vl.setVlanId(vlanId);
330         ab = new ActionBuilder();
331         ab.setAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(vl.build()).build());
332         ab.setOrder(1);
333         actionList.add(ab.build());
334         // Create an Apply Action
335         ApplyActionsBuilder aab = new ApplyActionsBuilder();
336         aab.setAction(actionList);
337
338         // Wrap our Apply Action in an Instruction
339         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
340
341         return ib;
342     }
343
344     /**
345      * Create Pop Vlan Instruction - this remove vlan header
346      *
347      * @param ib Map InstructionBuilder without any instructions
348      * @return ib Map InstructionBuilder with instructions
349      */
350     public static InstructionBuilder createPopVlanInstructions(InstructionBuilder ib) {
351
352         List<Action> actionList = Lists.newArrayList();
353         ActionBuilder ab = new ActionBuilder();
354
355         PopVlanActionBuilder popVlanActionBuilder = new PopVlanActionBuilder();
356         ab.setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVlanActionBuilder.build()).build());
357         ab.setOrder(0);
358         actionList.add(ab.build());
359
360         // Create an Apply Action
361         ApplyActionsBuilder aab = new ApplyActionsBuilder();
362         aab.setAction(actionList);
363
364         // Wrap our Apply Action in an Instruction
365         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
366
367         return ib;
368     }
369
370     /**
371      * Create Set IPv4 Source Instruction
372      *
373      * @param ib        Map InstructionBuilder without any instructions
374      * @param prefixsrc String containing an IPv4 prefix
375      * @return ib Map InstructionBuilder with instructions
376      */
377     public static InstructionBuilder createNwSrcInstructions(InstructionBuilder ib, Ipv4Prefix prefixsrc) {
378
379         List<Action> actionList = Lists.newArrayList();
380         ActionBuilder ab = new ActionBuilder();
381
382         SetNwSrcActionBuilder setNwsrcActionBuilder = new SetNwSrcActionBuilder();
383         Ipv4Builder ipsrc = new Ipv4Builder();
384         ipsrc.setIpv4Address(prefixsrc);
385         setNwsrcActionBuilder.setAddress(ipsrc.build());
386         ab.setAction(new SetNwSrcActionCaseBuilder().setSetNwSrcAction(setNwsrcActionBuilder.build()).build());
387         ab.setOrder(0);
388         ab.setKey(new ActionKey(0));
389         actionList.add(ab.build());
390
391         // Create an Apply Action
392         ApplyActionsBuilder aab = new ApplyActionsBuilder();
393         aab.setAction(actionList);
394
395         // Wrap our Apply Action in an Instruction
396         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
397
398         return ib;
399     }
400
401     /**
402      * Create Set IPv4 Destination Instruction
403      *
404      * @param ib        Map InstructionBuilder without any instructions
405      * @param prefixdst String containing an IPv4 prefix
406      * @return ib Map InstructionBuilder with instructions
407      */
408     public static InstructionBuilder createNwDstInstructions(InstructionBuilder ib, Ipv4Prefix prefixdst) {
409
410         List<Action> actionList = Lists.newArrayList();
411         ActionBuilder ab = new ActionBuilder();
412
413         SetNwDstActionBuilder setNwDstActionBuilder = new SetNwDstActionBuilder();
414         Ipv4Builder ipdst = new Ipv4Builder();
415         ipdst.setIpv4Address(prefixdst);
416         setNwDstActionBuilder.setAddress(ipdst.build());
417         ab.setAction(new SetNwDstActionCaseBuilder().setSetNwDstAction(setNwDstActionBuilder.build()).build());
418         ab.setOrder(0);
419         ab.setKey(new ActionKey(0));
420         actionList.add(ab.build());
421
422         // Create an Apply Action
423         ApplyActionsBuilder aab = new ApplyActionsBuilder();
424         aab.setAction(actionList);
425
426         // Wrap our Apply Action in an Instruction
427         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
428
429         return ib;
430     }
431
432     /**
433      * Create Drop Instruction
434      *
435      * @param ib Map InstructionBuilder without any instructions
436      * @return ib Map InstructionBuilder with instructions
437      */
438     public static InstructionBuilder createDropInstructions(InstructionBuilder ib) {
439
440         DropActionBuilder dab = new DropActionBuilder();
441         DropAction dropAction = dab.build();
442         ActionBuilder ab = new ActionBuilder();
443         ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
444         ab.setOrder(0);
445         ab.setKey(new ActionKey(0));
446
447         // Add our drop action to a list
448         List<Action> actionList = Lists.newArrayList();
449         actionList.add(ab.build());
450
451         // Create an Apply Action
452         ApplyActionsBuilder aab = new ApplyActionsBuilder();
453         aab.setAction(actionList);
454
455         // Wrap our Apply Action in an Instruction
456         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
457
458         return ib;
459     }
460
461     /**
462      * Create GOTO Table Instruction Builder
463      *
464      * @param ib      Map InstructionBuilder without any instructions
465      * @param tableId short representing a flow table ID short representing a flow table ID
466      * @return ib Map InstructionBuilder with instructions
467      */
468     public static InstructionBuilder createGotoTableInstructions(InstructionBuilder ib, short tableId) {
469
470         GoToTableBuilder gttb = new GoToTableBuilder();
471         gttb.setTableId(tableId);
472
473         // Wrap our Apply Action in an InstructionBuilder
474         ib.setInstruction(new GoToTableCaseBuilder().setGoToTable(gttb.build()).build());
475
476         return ib;
477     }
478
479     /**
480      * Create Set Tunnel ID Instruction Builder
481      *
482      * @param ib       Map InstructionBuilder without any instructions
483      * @param tunnelId BigInteger representing a tunnel ID
484      * @return ib Map InstructionBuilder with instructions
485      */
486     public static InstructionBuilder createSetTunnelIdInstructions(InstructionBuilder ib, BigInteger tunnelId) {
487
488         List<Action> actionList = Lists.newArrayList();
489         ActionBuilder ab = new ActionBuilder();
490         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
491
492         // Build the Set Tunnel Field Action
493         TunnelBuilder tunnel = new TunnelBuilder();
494         tunnel.setTunnelId(tunnelId);
495         setFieldBuilder.setTunnel(tunnel.build());
496         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
497         ab.setOrder(0);
498         ab.setKey(new ActionKey(0));
499         actionList.add(ab.build());
500
501         ApplyActionsBuilder aab = new ApplyActionsBuilder();
502         aab.setAction(actionList);
503
504         // Wrap the Apply Action in an InstructionBuilder and return
505         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
506
507         return ib;
508     }
509
510     /**
511      * Create Set Source TCP Port Instruction
512      *
513      * @param ib      Map InstructionBuilder without any instructions
514      * @param tcpport Integer representing a source TCP port
515      * @return ib Map InstructionBuilder with instructions
516      */
517     public static InstructionBuilder createSetSrcTCPPort(InstructionBuilder ib, PortNumber tcpport) {
518
519         List<Action> actionList = Lists.newArrayList();
520         ActionBuilder ab = new ActionBuilder();
521         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
522
523         // Build the Destination TCP Port
524         PortNumber tcpsrcport = new PortNumber(tcpport);
525         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
526         tcpmatch.setTcpSourcePort(tcpsrcport);
527
528         setFieldBuilder.setLayer4Match(tcpmatch.build());
529         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
530         ab.setOrder(0);
531         ab.setKey(new ActionKey(0));
532         actionList.add(ab.build());
533
534         ApplyActionsBuilder aab = new ApplyActionsBuilder();
535         aab.setAction(actionList);
536         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
537
538         return ib;
539     }
540
541     /**
542      * Create Set Destination TCP Port Instruction
543      *
544      * @param ib      Map InstructionBuilder without any instructions
545      * @param tcpport Integer representing a source TCP port
546      * @return ib Map InstructionBuilder with instructions
547      */
548     public static InstructionBuilder createSetDstTCPPort(InstructionBuilder ib, PortNumber tcpport) {
549
550         List<Action> actionList = Lists.newArrayList();
551         ActionBuilder ab = new ActionBuilder();
552         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
553
554         // Build the Destination TCP Port
555         PortNumber tcpdstport = new PortNumber(tcpport);
556         TcpMatchBuilder tcpmatch = new TcpMatchBuilder();
557         tcpmatch.setTcpDestinationPort(tcpdstport);
558
559         setFieldBuilder.setLayer4Match(tcpmatch.build());
560         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
561         ab.setOrder(0);
562         ab.setKey(new ActionKey(0));
563         actionList.add(ab.build());
564
565         ApplyActionsBuilder aab = new ApplyActionsBuilder();
566         aab.setAction(actionList);
567         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
568
569         return ib;
570     }
571
572     /**
573      * Create Set Source UDP Port Instruction
574      *
575      * @param ib      Map InstructionBuilder without any instructions
576      * @param udpport Integer representing a source UDP port
577      * @return ib Map InstructionBuilder with instructions
578      */
579     public static InstructionBuilder createSetSrcUDPPort(InstructionBuilder ib, PortNumber udpport) {
580
581         List<Action> actionList = Lists.newArrayList();
582         ActionBuilder ab = new ActionBuilder();
583         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
584
585         // Build the Destination TCP Port
586         PortNumber udpsrcport = new PortNumber(udpport);
587         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
588         udpmatch.setUdpSourcePort(udpsrcport);
589
590         setFieldBuilder.setLayer4Match(udpmatch.build());
591         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
592         ab.setOrder(0);
593         ab.setKey(new ActionKey(0));
594         actionList.add(ab.build());
595
596         ApplyActionsBuilder aab = new ApplyActionsBuilder();
597         aab.setAction(actionList);
598         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
599
600         return ib;
601     }
602
603     /**
604      * Create Set Destination UDP Port Instruction
605      *
606      * @param ib      Map InstructionBuilder without any instructions
607      * @param udpport Integer representing a destination UDP port
608      * @return ib Map InstructionBuilder with instructions
609      */
610     public static InstructionBuilder createSetDstUDPPort(InstructionBuilder ib, PortNumber udpport) {
611
612         List<Action> actionList = Lists.newArrayList();
613         ActionBuilder ab = new ActionBuilder();
614         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
615
616         // Build the Destination TCP Port
617         PortNumber udpdstport = new PortNumber(udpport);
618         UdpMatchBuilder udpmatch = new UdpMatchBuilder();
619         udpmatch.setUdpDestinationPort(udpdstport);
620
621         setFieldBuilder.setLayer4Match(udpmatch.build());
622         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
623         ab.setOrder(0);
624         ab.setKey(new ActionKey(0));
625         actionList.add(ab.build());
626
627         ApplyActionsBuilder aab = new ApplyActionsBuilder();
628         aab.setAction(actionList);
629         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
630
631         return ib;
632     }
633
634     /**
635      * Create Set ICMP Code Instruction
636      *
637      * @param ib   Map InstructionBuilder without any instructions
638      * @param code short repesenting an ICMP code
639      * @return ib Map InstructionBuilder with instructions
640      */
641
642     public static InstructionBuilder createSetIcmpCodeInstruction(InstructionBuilder ib, short code) {
643
644         List<Action> actionList = Lists.newArrayList();
645         ActionBuilder ab = new ActionBuilder();
646         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
647         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
648
649         // Build the ICMPv4 Code Match
650         icmpv4match.setIcmpv4Code(code);
651         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
652
653         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
654         ab.setOrder(0);
655         ab.setKey(new ActionKey(0));
656         actionList.add(ab.build());
657         ApplyActionsBuilder aab = new ApplyActionsBuilder();
658         aab.setAction(actionList);
659
660         // Wrap our Apply Action in an Instruction
661         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
662
663         return ib;
664     }
665
666     /**
667      * Create Set ICMP Code Instruction
668      *
669      * @param ib Map InstructionBuilder without any instructions
670      * @return ib Map InstructionBuilder with instructions
671      */
672     public static InstructionBuilder createSetIcmpTypeInstruction(InstructionBuilder ib, short type) {
673
674         List<Action> actionList = Lists.newArrayList();
675         ActionBuilder ab = new ActionBuilder();
676         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
677         Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder();
678
679         // Build the ICMPv4 Code Match
680         icmpv4match.setIcmpv4Code(type);
681         setFieldBuilder.setIcmpv4Match(icmpv4match.build());
682
683         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
684         ab.setOrder(0);
685         ab.setKey(new ActionKey(0));
686         actionList.add(ab.build());
687         ApplyActionsBuilder aab = new ApplyActionsBuilder();
688         aab.setAction(actionList);
689
690         // Wrap our Apply Action in an Instruction
691         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
692
693         return ib;
694     }
695
696     /**
697      * Create Decrement TTL Instruction
698      *
699      * @param ib Map InstructionBuilder without any instructions
700      * @return ib Map InstructionBuilder with instructions
701      */
702     public static InstructionBuilder createDecNwTtlInstructions(InstructionBuilder ib) {
703         DecNwTtlBuilder decNwTtlBuilder = new DecNwTtlBuilder();
704         DecNwTtl decNwTtl = decNwTtlBuilder.build();
705         ActionBuilder ab = new ActionBuilder();
706         ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
707         ab.setOrder(0);
708         ab.setKey(new ActionKey(0));
709
710         // Add our drop action to a list
711         List<Action> actionList = Lists.newArrayList();
712         actionList.add(ab.build());
713
714         // Create an Apply Action
715         ApplyActionsBuilder aab = new ApplyActionsBuilder();
716         aab.setAction(actionList);
717
718         // Wrap our Apply Action in an Instruction
719         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
720
721         return ib;
722     }
723
724     /**
725      * Set ARP_SHA Instructions
726      * @param ib Map InstructionBuilder
727      * @param macsrc the macsrc
728      * @return instructionbuilder with new instructions
729      */
730     public static InstructionBuilder createSrcArpMacInstructions(InstructionBuilder ib, MacAddress macsrc) {
731
732         List<Action> actionList = Lists.newArrayList();
733         ActionBuilder ab = new ActionBuilder();
734
735         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
736         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
737         ArpSourceHardwareAddressBuilder arpsrc = new ArpSourceHardwareAddressBuilder();
738         arpsrc.setAddress(macsrc);
739         arpmatch.setArpSourceHardwareAddress(arpsrc.build());
740         setFieldBuilder.setLayer3Match(arpmatch.build());
741         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
742         ab.setOrder(0);
743         ab.setKey(new ActionKey(0));
744         actionList.add(ab.build());
745
746         ApplyActionsBuilder aab = new ApplyActionsBuilder();
747         aab.setAction(actionList);
748         // Wrap our Apply Action in an Instruction
749         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
750
751         return ib;
752     }
753
754     /**
755      * Set ARP_THA Instructions
756      * @param ib Map InstructionBuilder
757      * @param macdst the macdst
758      * @return instructionbuilder with new attributes
759      */
760     public static InstructionBuilder createDstArpMacInstructions(InstructionBuilder ib, MacAddress macdst) {
761
762         List<Action> actionList = Lists.newArrayList();
763         ActionBuilder ab = new ActionBuilder();
764         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
765
766         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
767         ArpTargetHardwareAddressBuilder arpdst = new ArpTargetHardwareAddressBuilder();
768         arpdst.setAddress(macdst);
769         setFieldBuilder.setLayer3Match(arpmatch.build());
770         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
771         ab.setOrder(0);
772         ab.setKey(new ActionKey(0));
773         actionList.add(ab.build());
774
775         ApplyActionsBuilder aab = new ApplyActionsBuilder();
776         aab.setAction(actionList);
777         // Wrap our Apply Action in an Instruction
778         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
779
780         return ib;
781     }
782
783     /**
784      * Set ARP_TPA Instructions
785      * @param ib Map InstructionBuilder
786      * @param dstiparp the dstiparp
787      * @return instructionbuilder with new attributes
788      */
789     public static InstructionBuilder createDstArpIpInstructions(InstructionBuilder ib, Ipv4Prefix dstiparp) {
790
791         List<Action> actionList = Lists.newArrayList();
792         ActionBuilder ab = new ActionBuilder();
793         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
794
795         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
796         arpmatch.setArpTargetTransportAddress(dstiparp);
797         setFieldBuilder.setLayer3Match(arpmatch.build());
798         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
799         ab.setOrder(0);
800         ab.setKey(new ActionKey(0));
801         actionList.add(ab.build());
802
803         ApplyActionsBuilder aab = new ApplyActionsBuilder();
804         aab.setAction(actionList);
805         // Wrap our Apply Action in an Instruction
806         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
807
808         return ib;
809     }
810
811     /**
812      * Set ARP_SPA Instructions
813      * @param ib Map InstructionBuilder
814      * @param srciparp the srciparp
815      * @return instructionbuilder with new attributes
816      */
817     public static InstructionBuilder createSrcArpIpInstructions(InstructionBuilder ib, Ipv4Prefix srciparp) {
818
819         List<Action> actionList = Lists.newArrayList();
820         ActionBuilder ab = new ActionBuilder();
821         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
822
823         ArpMatchBuilder arpmatch = new ArpMatchBuilder();
824         arpmatch.setArpSourceTransportAddress(srciparp);
825         setFieldBuilder.setLayer3Match(arpmatch.build());
826         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
827         ab.setOrder(0);
828         ab.setKey(new ActionKey(0));
829         actionList.add(ab.build());
830
831         ApplyActionsBuilder aab = new ApplyActionsBuilder();
832         aab.setAction(actionList);
833         // Wrap our Apply Action in an Instruction
834         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
835
836         return ib;
837     }
838
839     /**
840      * Set the Tunnel EndpointIPv4 Source Address
841      * @param ib Map InstructionBuilder
842      * @param srcIp Ipv4Prefix source IP for the tunnel endpoint (TEP)
843      * @return instructionbuilder with new attributes
844      */
845     public static InstructionBuilder createTunnelIpv4SrcInstructions(InstructionBuilder ib, Ipv4Prefix srcIp) {
846
847         List<Action> actionList = new ArrayList<Action>();
848         ActionBuilder ab = new ActionBuilder();
849
850         // Build the tunnel endpoint source IPv4 address
851         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
852
853         // Add the new IPv4 object as the tunnel destination
854         TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
855         tunnelIpv4MatchBuilder.setTunnelIpv4Source(srcIp);
856         setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
857
858         // Add the IPv4 tunnel src to the set_field value
859         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
860         ab.setOrder(0);
861         ab.setKey(new ActionKey(0));
862         actionList.add(ab.build());
863
864         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
865         ApplyActionsBuilder aab = new ApplyActionsBuilder();
866         aab.setAction(actionList);
867         // Wrap our Apply Action in an Instruction
868         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
869
870         return ib;
871     }
872
873     /**
874      * Set the Tunnel EndpointIPv4 Destination Address
875      * @param ib Map InstructionBuilder
876      * @param dstIp Ipv4Prefix destination IP for the tunnel endpoint (TEP)
877      * @return instructionbuilder with new attributes
878      */
879     public static InstructionBuilder createTunnelIpv4DstInstructions(InstructionBuilder ib, Ipv4Prefix dstIp) {
880
881         List<Action> actionList = new ArrayList<Action>();
882         ActionBuilder ab = new ActionBuilder();
883
884         // Build the tunnel endpoint dst IPv4 address
885         SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
886
887         // Add the new IPv4 object as the tunnel destination
888         TunnelIpv4MatchBuilder tunnelIpv4MatchBuilder = new TunnelIpv4MatchBuilder();
889         tunnelIpv4MatchBuilder.setTunnelIpv4Destination(dstIp);
890         setFieldBuilder.setLayer3Match(tunnelIpv4MatchBuilder.build());
891
892         // Add the IPv4 tunnel src to the set_field value
893         ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
894         ab.setOrder(0);
895         ab.setKey(new ActionKey(0));
896         actionList.add(ab.build());
897
898         // Resulting action is a per/flow src TEP (set_field:172.16.100.100->tun_src)
899         ApplyActionsBuilder aab = new ApplyActionsBuilder();
900         aab.setAction(actionList);
901         // Wrap our Apply Action in an Instruction
902         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
903
904         return ib;
905     }
906
907     /**
908      * Set IPv4 Source Address Instructions
909      * @param ib Map InstructionBuilder
910      * @param metaData BigInteger representing the OpenFlow metadata
911      * @param metaDataMask  BigInteger representing the OpenFlow metadata mask
912      * @return instructionbuilder with new attributes
913      */
914     public static InstructionBuilder createMetadataInstructions(InstructionBuilder ib, BigInteger metaData, BigInteger metaDataMask) {
915
916         WriteMetadataBuilder aab = new WriteMetadataBuilder();
917         aab.setMetadata(metaData);
918         aab.setMetadataMask(metaDataMask);
919         ib.setInstruction(new WriteMetadataCaseBuilder().setWriteMetadata(aab.build()).build());
920
921         /**
922         *
923         * TODO Determine why the following fails serialization
924         * with a null value. Per the spec it is optional.
925         * The metadata match, the Flowmod works w/o an accompanying mask.
926         *
927         * if (metaDataMask != null) {
928         *    aab.setMetadataMask(metaDataMask);
929         * }
930         *
931         */
932
933         return ib;
934     }
935
936     public static InstructionBuilder createDlSrcInstructions(InstructionBuilder ib, MacAddress macAddress) {
937
938         List<Action> actionList = Lists.newArrayList();
939         ActionBuilder ab = new ActionBuilder();
940
941         SetDlSrcActionBuilder dlSrcActionBuilder= new SetDlSrcActionBuilder();
942
943         dlSrcActionBuilder.setAddress(macAddress);
944
945         ab.setAction(new SetDlSrcActionCaseBuilder().setSetDlSrcAction(dlSrcActionBuilder.build()).build());
946         ab.setOrder(0);
947         ab.setKey(new ActionKey(0));
948         actionList.add(ab.build());
949
950
951         // Create an Apply Action
952         ApplyActionsBuilder aab = new ApplyActionsBuilder();
953         aab.setAction(actionList);
954
955         // Wrap our Apply Action in an Instruction
956         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
957
958         return ib;
959     }
960
961     public static InstructionBuilder createDlDstInstructions(InstructionBuilder ib, MacAddress macAddress) {
962
963         List<Action> actionList = Lists.newArrayList();
964         ActionBuilder ab = new ActionBuilder();
965
966         SetDlDstActionBuilder dlDstActionBuilder= new SetDlDstActionBuilder();
967
968         dlDstActionBuilder.setAddress(macAddress);
969
970         ab.setAction(new SetDlDstActionCaseBuilder().setSetDlDstAction(dlDstActionBuilder.build()).build());
971         ab.setOrder(0);
972         ab.setKey(new ActionKey(0));
973         actionList.add(ab.build());
974
975         // Create an Apply Action
976         ApplyActionsBuilder aab = new ApplyActionsBuilder();
977         aab.setAction(actionList);
978
979         // Wrap our Apply Action in an Instruction
980         ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
981
982         return ib;
983     }
984
985     public static ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
986                   actionList (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action... actions) {
987
988         ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> alist
989             = new ArrayList<>();
990         int count = 0;
991         for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action : actions) {
992             alist.add(new ActionBuilder()
993                 .setOrder(count)
994                 .setKey(new ActionKey(count))
995                 .setAction(action)
996                 .build());
997             count++;
998         }
999         return alist;
1000     }
1001
1002     public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction
1003         applyActionIns(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action... actions) {
1004
1005         return new ApplyActionsCaseBuilder()
1006             .setApplyActions(new ApplyActionsBuilder()
1007                 .setAction(actionList(actions))
1008                 .build())
1009             .build();
1010     }
1011
1012     public static Instructions getInstructions(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction... instructions) {
1013         ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins
1014             = new ArrayList<>();
1015         int order = 0;
1016         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction i : instructions) {
1017             ins.add(new InstructionBuilder()
1018                 .setOrder(order)
1019                 .setKey(new InstructionKey(order))
1020                 .setInstruction(i)
1021                 .build());
1022             order++;
1023         }
1024         return new InstructionsBuilder().setInstruction(ins).build();
1025     }
1026
1027     public static Instructions dropInstructions() {
1028         return getInstructions(applyActionIns(dropAction()));
1029     }
1030
1031     /**
1032      * Get a list of Instructions containing Nicira extensions that can have
1033      * additional OF/OXM instructions added to the returned Instruction list
1034      *
1035      * @param instructions org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instructions
1036      * @return instruction list that additional
1037      */
1038     public static List<Instruction> getInstructionList(
1039             org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction... instructions) {
1040         ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> ins
1041                 = new ArrayList<>();
1042         int order = 0;
1043         for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction i : instructions) {
1044             ins.add(new InstructionBuilder()
1045                     .setOrder(order++)
1046                     .setInstruction(i)
1047                     .build());
1048         }
1049         return ins;
1050     }
1051 }