fe545b09888c6153b225f8467bab4456134f4cfe
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / MDFlowMapping.xtend
1 /*
2  * Copyright (c) 2014 Cisco Systems, 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 package org.opendaylight.controller.sal.compatibility;
9
10 import com.google.common.net.InetAddresses
11 import java.math.BigInteger
12 import java.net.Inet4Address
13 import java.net.Inet6Address
14 import java.util.ArrayList
15 import org.opendaylight.controller.sal.action.Controller
16 import org.opendaylight.controller.sal.action.Drop
17 import org.opendaylight.controller.sal.action.Flood
18 import org.opendaylight.controller.sal.action.FloodAll
19 import org.opendaylight.controller.sal.action.HwPath
20 import org.opendaylight.controller.sal.action.Loopback
21 import org.opendaylight.controller.sal.action.Output
22 import org.opendaylight.controller.sal.action.PopVlan
23 import org.opendaylight.controller.sal.action.PushVlan
24 import org.opendaylight.controller.sal.action.SetDlDst
25 import org.opendaylight.controller.sal.action.SetDlSrc
26 import org.opendaylight.controller.sal.action.SetDlType
27 import org.opendaylight.controller.sal.action.SetNextHop
28 import org.opendaylight.controller.sal.action.SetNwDst
29 import org.opendaylight.controller.sal.action.SetNwSrc
30 import org.opendaylight.controller.sal.action.SetNwTos
31 import org.opendaylight.controller.sal.action.SetTpDst
32 import org.opendaylight.controller.sal.action.SetTpSrc
33 import org.opendaylight.controller.sal.action.SetVlanCfi
34 import org.opendaylight.controller.sal.action.SetVlanId
35 import org.opendaylight.controller.sal.action.SetVlanPcp
36 import org.opendaylight.controller.sal.action.SwPath
37 import org.opendaylight.controller.sal.core.Node
38 import org.opendaylight.controller.sal.core.NodeConnector
39 import org.opendaylight.controller.sal.flowprogrammer.Flow
40 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix
41 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber
43 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
44 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp
58
59 import static extension org.opendaylight.controller.sal.compatibility.FromSalConversionsUtils.*
60 import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
65 import java.util.Collections
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
116
117 public class MDFlowMapping {
118
119     private new() {
120         throw new UnsupportedOperationException()
121     }
122
123     public static def flowAdded(Flow sourceFlow) {
124         if (sourceFlow == null)
125             throw new IllegalArgumentException();
126         val it = new FlowAddedBuilder();
127
128         hardTimeout = sourceFlow.hardTimeout as int
129         idleTimeout = sourceFlow.idleTimeout as int
130         cookie = BigInteger.valueOf(sourceFlow.id)
131         priority = sourceFlow.priority as int
132
133         val sourceActions = sourceFlow.actions;
134         val targetActions = new ArrayList<Action>();
135         for (sourceAction : sourceActions) {
136             targetActions.add(sourceAction.toAction());
137         }
138         instructions = targetActions.toApplyInstruction();
139         match = sourceFlow.match.toMatch();
140         tableId = new Integer(0).shortValue
141         return it.build();
142
143     }
144     
145     public static def toMDFlow(Flow sourceFlow, String flowId) {
146        if (sourceFlow == null)
147             throw new IllegalArgumentException();
148        val it = new FlowBuilder();
149        hardTimeout = sourceFlow.hardTimeout as int
150        idleTimeout = sourceFlow.idleTimeout as int
151        cookie = BigInteger.valueOf(sourceFlow.id)
152        priority = sourceFlow.priority as int
153        id = new FlowId(flowId)
154     
155        val sourceActions = sourceFlow.actions;
156        val targetActions = new ArrayList<Action>();
157        for (sourceAction : sourceActions) {
158            targetActions.add(sourceAction.toAction());
159        }
160        instructions = targetActions.toApplyInstruction();
161        match = sourceFlow.match.toMatch();
162        tableId = new Integer(0).shortValue
163        return it.build();
164     }
165     
166     public static def Instructions toApplyInstruction(ArrayList<Action> actions) {
167         val it = new InstructionsBuilder;
168         val applyActions = new InstructionBuilder;
169         applyActions.instruction = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build()
170         applyActions.setOrder(new Integer(0))
171         instruction = Collections.<Instruction>singletonList(applyActions.build)
172         return it.build;
173     }
174
175     public static def removeFlowInput(Node sourceNode, Flow sourceFlow) {
176         val source = flowAdded(sourceFlow);
177         val it = new RemoveFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
178         node = sourceNode.toNodeRef()
179         return it.build();
180     }
181
182     public static def addFlowInput(Node sourceNode, Flow sourceFlow) {
183         val source = flowAdded(sourceFlow);
184         val it = new AddFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
185         it.setNode(sourceNode.toNodeRef)
186         return it.build();
187     }
188
189     public static def updateFlowInput(Node sourceNode, Flow oldFlow, Flow newFlow) {
190         val it = new UpdateFlowInputBuilder();
191         val sourceOld = flowAdded(newFlow);
192
193         val original = new OriginalFlowBuilder(sourceOld as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
194         val sourceNew = flowAdded(newFlow);
195         val updated = new UpdatedFlowBuilder(sourceNew as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
196         originalFlow = original.build()
197         updatedFlow = updated.build();
198         node = sourceNode.toNodeRef()
199         return it.build();
200     }
201
202     public static dispatch def toAction(Controller sourceAction) {
203         val actionBuilder = new ActionBuilder();
204         actionBuilder.action = new ControllerActionCaseBuilder().setControllerAction(new ControllerActionBuilder().build()).build();
205         return actionBuilder.build();
206     }
207
208     public static dispatch def toAction(Drop sourceAction) {
209         val actionBuilder = new ActionBuilder();
210         actionBuilder.action = new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
211         return actionBuilder.build();
212     }
213
214     public static dispatch def toAction(Flood sourceAction) {
215         val actionBuilder = new ActionBuilder();
216         actionBuilder.action = new FloodActionCaseBuilder().setFloodAction(new FloodActionBuilder().build).build();
217         return actionBuilder.build();
218     }
219
220     public static dispatch def toAction(FloodAll sourceAction) {
221         val actionBuilder = new ActionBuilder();
222         actionBuilder.action = new FloodAllActionCaseBuilder().setFloodAllAction(new FloodAllActionBuilder().build()).build();
223         return actionBuilder.build();
224     }
225
226     public static dispatch def toAction(HwPath sourceAction) {
227         val actionBuilder = new ActionBuilder();
228         actionBuilder.action = new HwPathActionCaseBuilder().setHwPathAction(new HwPathActionBuilder().build()).build();
229         return actionBuilder.build();
230     }
231
232     public static dispatch def toAction(Loopback sourceAction) {
233         val actionBuilder = new ActionBuilder();
234         actionBuilder.action = new LoopbackActionCaseBuilder().setLoopbackAction(new LoopbackActionBuilder().build()).build();
235         return actionBuilder.build();
236     }
237
238     public static dispatch def toAction(Output sourceAction) {
239         val actionBuilder = new ActionBuilder();
240         val it = new OutputActionBuilder();
241         outputNodeConnector = sourceAction.port.toUri;
242         actionBuilder.action = new OutputActionCaseBuilder().setOutputAction(it.build()).build();
243         return actionBuilder.build();
244
245     }
246
247     public static dispatch def toAction(PopVlan sourceAction) {
248         val actionBuilder = new ActionBuilder();
249         actionBuilder.action = new PopVlanActionCaseBuilder().build();
250         return actionBuilder.build();
251     }
252
253     public static dispatch def toAction(PushVlan sourceAction) {
254         val actionBuilder = new ActionBuilder();
255         val it = new PushVlanActionBuilder();
256         cfi = new VlanCfi(sourceAction.cfi);
257         vlanId = new VlanId(sourceAction.vlanId);
258         pcp = sourceAction.pcp;
259         tag = sourceAction.tag;
260         actionBuilder.action = new PushVlanActionCaseBuilder().setPushVlanAction(it.build()).build();
261         return actionBuilder.build();
262     }
263
264     public static dispatch def toAction(SetDlDst sourceAction) {
265         val actionBuilder = new ActionBuilder();
266         val it = new SetDlDstActionBuilder();
267         address = sourceAction.dlAddress.toMacAddress();
268         actionBuilder.action = new SetDlDstActionCaseBuilder().setSetDlDstAction(it.build()).build;
269         return actionBuilder.build();
270     }
271
272     public static dispatch def toAction(SetDlSrc sourceAction) {
273         val actionBuilder = new ActionBuilder();
274         val it = new SetDlSrcActionBuilder();
275         address = sourceAction.dlAddress.toMacAddress;
276         actionBuilder.action = new SetDlSrcActionCaseBuilder().setSetDlSrcAction(it.build()).build;
277         return actionBuilder.build();
278     }
279
280     public static dispatch def toAction(SetDlType sourceAction) {
281         val actionBuilder = new ActionBuilder();
282         val it = new SetDlTypeActionBuilder();
283         dlType = new EtherType(sourceAction.dlType as long);
284         actionBuilder.action = new SetDlTypeActionCaseBuilder().setSetDlTypeAction(it.build()).build();
285         return actionBuilder.build();
286     }
287
288     public static dispatch def toAction(SetNextHop sourceAction) {
289         val actionBuilder = new ActionBuilder();
290         val it = new SetNextHopActionBuilder();
291         val inetAddress = sourceAction.address;
292         address = inetAddress.toInetAddress;
293         actionBuilder.action = new SetNextHopActionCaseBuilder().setSetNextHopAction(it.build).build();
294         return actionBuilder.build();
295     }
296
297     public static dispatch def toAction(SetNwDst sourceAction) {
298         val actionBuilder = new ActionBuilder();
299         val it = new SetNwDstActionBuilder();
300         val inetAddress = sourceAction.address;
301         address = inetAddress.toInetAddress;
302         actionBuilder.action = new SetNwDstActionCaseBuilder().setSetNwDstAction(it.build()).build();
303         return actionBuilder.build();
304     }
305
306     public static dispatch def toAction(SetNwSrc sourceAction) {
307         val actionBuilder = new ActionBuilder();
308         val it = new SetNwSrcActionBuilder();
309         val inetAddress = sourceAction.address;
310         address = inetAddress.toInetAddress;
311         actionBuilder.action = new SetNwSrcActionCaseBuilder().setSetNwSrcAction(it.build()).build();
312         return actionBuilder.build();
313     }
314
315     public static dispatch def toAction(SetNwTos sourceAction) {
316         val actionBuilder = new ActionBuilder();
317         val it = new SetNwTosActionBuilder();
318         tos = sourceAction.nwTos;
319         actionBuilder.action = new SetNwTosActionCaseBuilder().setSetNwTosAction(it.build).build;
320         return actionBuilder.build();
321     }
322
323     public static dispatch def toAction(SetTpDst sourceAction) {
324         val actionBuilder = new ActionBuilder();
325         val it = new SetTpDstActionBuilder();
326         port = new PortNumber(sourceAction.port);
327         actionBuilder.action = new SetTpDstActionCaseBuilder().setSetTpDstAction(it.build()).build();
328         return actionBuilder.build();
329     }
330
331     public static dispatch def toAction(SetTpSrc sourceAction) {
332         val actionBuilder = new ActionBuilder();
333         val it = new SetTpSrcActionBuilder();
334         port = new PortNumber(sourceAction.port);
335         actionBuilder.action = new SetTpSrcActionCaseBuilder().setSetTpSrcAction(it.build()).build();
336         return actionBuilder.build();
337     }
338
339     public static dispatch def toAction(SetVlanCfi sourceAction) {
340         val actionBuilder = new ActionBuilder();
341         val it = new SetVlanCfiActionBuilder();
342         vlanCfi = new VlanCfi(sourceAction.cfi);
343         actionBuilder.action = new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(it.build()).build();
344         return actionBuilder.build();
345     }
346
347     public static dispatch def toAction(SetVlanId sourceAction) {
348         val actionBuilder = new ActionBuilder();
349
350         val it = new SetVlanIdActionBuilder();
351         vlanId = new VlanId(sourceAction.vlanId);
352         actionBuilder.action = new SetVlanIdActionCaseBuilder().setSetVlanIdAction(it.build()).build();
353         return actionBuilder.build();
354     }
355
356     public static dispatch def toAction(SetVlanPcp sourceAction) {
357         val actionBuilder = new ActionBuilder();
358         val it = new SetVlanPcpActionBuilder();
359         vlanPcp = new VlanPcp(sourceAction.pcp as short);
360         actionBuilder.action = new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(it.build).build;
361         return actionBuilder.build();
362     }
363
364     public static dispatch def toAction(SwPath sourceAction) {
365         val actionBuilder = new ActionBuilder();
366         actionBuilder.action = new SwPathActionCaseBuilder().setSwPathAction(new SwPathActionBuilder().build()).build();
367         return actionBuilder.build();
368     }
369
370     public static def dispatch Address toInetAddress(Inet4Address address) {
371         val it = new Ipv4Builder
372         ipv4Address = new Ipv4Prefix(InetAddresses.toAddrString(address))
373         return it.build()
374     }
375
376     public static def dispatch Address toInetAddress(Inet6Address address) {
377         val it = new Ipv6Builder
378         ipv6Address = new Ipv6Prefix(InetAddresses.toAddrString(address))
379         return it.build()
380     }
381
382     public static def Uri toUri(NodeConnector connector) {
383         return new NodeConnectorId(connector.ID as String);
384     }
385
386     public static def MacAddress toMacAddress(byte[] bytes) {
387         val sb = new StringBuilder(18);
388         for (byte b : bytes) {
389             if (sb.length() > 0)
390                 sb.append(':');
391             sb.append(String.format("%02x", b));
392         }
393         return new MacAddress(sb.toString());
394     }
395         
396         public static def toMDSalflow(Flow sourceFlow) {
397         if (sourceFlow == null)
398             throw new IllegalArgumentException();
399         val it = new FlowBuilder();
400
401         hardTimeout = sourceFlow.hardTimeout as int
402         idleTimeout = sourceFlow.idleTimeout as int
403         cookie = BigInteger.valueOf(sourceFlow.id)
404         priority = sourceFlow.priority as int
405
406         val sourceActions = sourceFlow.actions;
407         val targetActions = new ArrayList<Action>();
408         for (sourceAction : sourceActions) {
409             targetActions.add(sourceAction.toAction());
410         }
411         instructions = targetActions.toApplyInstruction();
412         match = sourceFlow.match.toMatch();
413         return it.build();
414         }
415         
416 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.