Fixed missing keys in sal-compatibility flows.
[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         var int action = 0;
136         for (sourceAction : sourceActions) {
137             targetActions.add(sourceAction.toAction(action));
138             action = action + 1;
139         }
140         instructions = targetActions.toApplyInstruction();
141         match = sourceFlow.match.toMatch();
142         tableId = new Integer(0).shortValue
143         return it.build();
144
145     }
146     
147     public static def toMDFlow(Flow sourceFlow, String flowId) {
148        if (sourceFlow == null)
149             throw new IllegalArgumentException();
150        val it = new FlowBuilder();
151        hardTimeout = sourceFlow.hardTimeout as int
152        idleTimeout = sourceFlow.idleTimeout as int
153        cookie = BigInteger.valueOf(sourceFlow.id)
154        priority = sourceFlow.priority as int
155        id = new FlowId(flowId)
156     
157        val sourceActions = sourceFlow.actions;
158        val targetActions = new ArrayList<Action>();
159        var int action = 0;
160        for (sourceAction : sourceActions) {
161            targetActions.add(sourceAction.toAction(action));
162            action = action+ 1;
163        }
164        instructions = targetActions.toApplyInstruction();
165        match = sourceFlow.match.toMatch();
166        tableId = new Integer(0).shortValue
167        return it.build();
168     }
169     
170     public static def Instructions toApplyInstruction(ArrayList<Action> actions) {
171         val it = new InstructionsBuilder;
172         val applyActions = new InstructionBuilder;
173         applyActions.instruction = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build()
174         applyActions.setOrder(new Integer(0))
175         instruction = Collections.<Instruction>singletonList(applyActions.build)
176         return it.build;
177     }
178
179     public static def removeFlowInput(Node sourceNode, Flow sourceFlow) {
180         val source = flowAdded(sourceFlow);
181         val it = new RemoveFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
182         node = sourceNode.toNodeRef()
183         return it.build();
184     }
185
186     public static def addFlowInput(Node sourceNode, Flow sourceFlow) {
187         val source = flowAdded(sourceFlow);
188         val it = new AddFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
189         it.setNode(sourceNode.toNodeRef)
190         return it.build();
191     }
192
193     public static def updateFlowInput(Node sourceNode, Flow oldFlow, Flow newFlow) {
194         val it = new UpdateFlowInputBuilder();
195         val sourceOld = flowAdded(newFlow);
196
197         val original = new OriginalFlowBuilder(sourceOld as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
198         val sourceNew = flowAdded(newFlow);
199         val updated = new UpdatedFlowBuilder(sourceNew as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
200         originalFlow = original.build()
201         updatedFlow = updated.build();
202         node = sourceNode.toNodeRef()
203         return it.build();
204     }
205
206     public static dispatch def toAction(Controller sourceAction, int order) {
207         val actionBuilder = new ActionBuilder().setOrder(order);
208         actionBuilder.action = new ControllerActionCaseBuilder().setControllerAction(new ControllerActionBuilder().build()).build();
209         return actionBuilder.build();
210     }
211
212     public static dispatch def toAction(Drop sourceAction, int order) {
213         val actionBuilder = new ActionBuilder().setOrder(order);
214         actionBuilder.action = new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
215         return actionBuilder.build();
216     }
217
218     public static dispatch def toAction(Flood sourceAction, int order) {
219         val actionBuilder = new ActionBuilder().setOrder(order);
220         actionBuilder.action = new FloodActionCaseBuilder().setFloodAction(new FloodActionBuilder().build).build();
221         return actionBuilder.build();
222     }
223
224     public static dispatch def toAction(FloodAll sourceAction, int order) {
225         val actionBuilder = new ActionBuilder().setOrder(order);
226         actionBuilder.action = new FloodAllActionCaseBuilder().setFloodAllAction(new FloodAllActionBuilder().build()).build();
227         return actionBuilder.build();
228     }
229
230     public static dispatch def toAction(HwPath sourceAction, int order) {
231         val actionBuilder = new ActionBuilder().setOrder(order);
232         actionBuilder.action = new HwPathActionCaseBuilder().setHwPathAction(new HwPathActionBuilder().build()).build();
233         return actionBuilder.build();
234     }
235
236     public static dispatch def toAction(Loopback sourceAction, int order) {
237         val actionBuilder = new ActionBuilder().setOrder(order);
238         actionBuilder.action = new LoopbackActionCaseBuilder().setLoopbackAction(new LoopbackActionBuilder().build()).build();
239         return actionBuilder.build();
240     }
241
242     public static dispatch def toAction(Output sourceAction, int order) {
243         val actionBuilder = new ActionBuilder().setOrder(order);
244         val it = new OutputActionBuilder();
245         outputNodeConnector = sourceAction.port.toUri;
246         actionBuilder.action = new OutputActionCaseBuilder().setOutputAction(it.build()).build();
247         return actionBuilder.build();
248
249     }
250
251     public static dispatch def toAction(PopVlan sourceAction, int order) {
252         val actionBuilder = new ActionBuilder().setOrder(order);
253         actionBuilder.action = new PopVlanActionCaseBuilder().build();
254         return actionBuilder.build();
255     }
256
257     public static dispatch def toAction(PushVlan sourceAction, int order) {
258         val actionBuilder = new ActionBuilder().setOrder(order);
259         val it = new PushVlanActionBuilder();
260         cfi = new VlanCfi(sourceAction.cfi);
261         vlanId = new VlanId(sourceAction.vlanId);
262         pcp = sourceAction.pcp;
263         tag = sourceAction.tag;
264         actionBuilder.action = new PushVlanActionCaseBuilder().setPushVlanAction(it.build()).build();
265         return actionBuilder.build();
266     }
267
268     public static dispatch def toAction(SetDlDst sourceAction, int order) {
269         val actionBuilder = new ActionBuilder().setOrder(order);
270         val it = new SetDlDstActionBuilder();
271         address = sourceAction.dlAddress.toMacAddress();
272         actionBuilder.action = new SetDlDstActionCaseBuilder().setSetDlDstAction(it.build()).build;
273         return actionBuilder.build();
274     }
275
276     public static dispatch def toAction(SetDlSrc sourceAction, int order) {
277         val actionBuilder = new ActionBuilder().setOrder(order);
278         val it = new SetDlSrcActionBuilder();
279         address = sourceAction.dlAddress.toMacAddress;
280         actionBuilder.action = new SetDlSrcActionCaseBuilder().setSetDlSrcAction(it.build()).build;
281         return actionBuilder.build();
282     }
283
284     public static dispatch def toAction(SetDlType sourceAction, int order) {
285         val actionBuilder = new ActionBuilder().setOrder(order);
286         val it = new SetDlTypeActionBuilder();
287         dlType = new EtherType(sourceAction.dlType as long);
288         actionBuilder.action = new SetDlTypeActionCaseBuilder().setSetDlTypeAction(it.build()).build();
289         return actionBuilder.build();
290     }
291
292     public static dispatch def toAction(SetNextHop sourceAction, int order) {
293         val actionBuilder = new ActionBuilder().setOrder(order);
294         val it = new SetNextHopActionBuilder();
295         val inetAddress = sourceAction.address;
296         address = inetAddress.toInetAddress;
297         actionBuilder.action = new SetNextHopActionCaseBuilder().setSetNextHopAction(it.build).build();
298         return actionBuilder.build();
299     }
300
301     public static dispatch def toAction(SetNwDst sourceAction, int order) {
302         val actionBuilder = new ActionBuilder().setOrder(order);
303         val it = new SetNwDstActionBuilder();
304         val inetAddress = sourceAction.address;
305         address = inetAddress.toInetAddress;
306         actionBuilder.action = new SetNwDstActionCaseBuilder().setSetNwDstAction(it.build()).build();
307         return actionBuilder.build();
308     }
309
310     public static dispatch def toAction(SetNwSrc sourceAction, int order) {
311         val actionBuilder = new ActionBuilder().setOrder(order);
312         val it = new SetNwSrcActionBuilder();
313         val inetAddress = sourceAction.address;
314         address = inetAddress.toInetAddress;
315         actionBuilder.action = new SetNwSrcActionCaseBuilder().setSetNwSrcAction(it.build()).build();
316         return actionBuilder.build();
317     }
318
319     public static dispatch def toAction(SetNwTos sourceAction, int order) {
320         val actionBuilder = new ActionBuilder().setOrder(order);
321         val it = new SetNwTosActionBuilder();
322         tos = sourceAction.nwTos;
323         actionBuilder.action = new SetNwTosActionCaseBuilder().setSetNwTosAction(it.build).build;
324         return actionBuilder.build();
325     }
326
327     public static dispatch def toAction(SetTpDst sourceAction, int order) {
328         val actionBuilder = new ActionBuilder().setOrder(order);
329         val it = new SetTpDstActionBuilder();
330         port = new PortNumber(sourceAction.port);
331         actionBuilder.action = new SetTpDstActionCaseBuilder().setSetTpDstAction(it.build()).build();
332         return actionBuilder.build();
333     }
334
335     public static dispatch def toAction(SetTpSrc sourceAction, int order) {
336         val actionBuilder = new ActionBuilder().setOrder(order);
337         val it = new SetTpSrcActionBuilder();
338         port = new PortNumber(sourceAction.port);
339         actionBuilder.action = new SetTpSrcActionCaseBuilder().setSetTpSrcAction(it.build()).build();
340         return actionBuilder.build();
341     }
342
343     public static dispatch def toAction(SetVlanCfi sourceAction, int order) {
344         val actionBuilder = new ActionBuilder().setOrder(order);
345         val it = new SetVlanCfiActionBuilder();
346         vlanCfi = new VlanCfi(sourceAction.cfi);
347         actionBuilder.action = new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(it.build()).build();
348         return actionBuilder.build();
349     }
350
351     public static dispatch def toAction(SetVlanId sourceAction, int order) {
352         val actionBuilder = new ActionBuilder().setOrder(order);
353
354         val it = new SetVlanIdActionBuilder();
355         vlanId = new VlanId(sourceAction.vlanId);
356         actionBuilder.action = new SetVlanIdActionCaseBuilder().setSetVlanIdAction(it.build()).build();
357         return actionBuilder.build();
358     }
359
360     public static dispatch def toAction(SetVlanPcp sourceAction, int order) {
361         val actionBuilder = new ActionBuilder().setOrder(order);
362         val it = new SetVlanPcpActionBuilder();
363         vlanPcp = new VlanPcp(sourceAction.pcp as short);
364         actionBuilder.action = new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(it.build).build;
365         return actionBuilder.build();
366     }
367
368     public static dispatch def toAction(SwPath sourceAction, int order) {
369         val actionBuilder = new ActionBuilder().setOrder(order);
370         actionBuilder.action = new SwPathActionCaseBuilder().setSwPathAction(new SwPathActionBuilder().build()).build();
371         return actionBuilder.build();
372     }
373
374     public static def dispatch Address toInetAddress(Inet4Address address) {
375         val it = new Ipv4Builder
376         ipv4Address = new Ipv4Prefix(InetAddresses.toAddrString(address))
377         return it.build()
378     }
379
380     public static def dispatch Address toInetAddress(Inet6Address address) {
381         val it = new Ipv6Builder
382         ipv6Address = new Ipv6Prefix(InetAddresses.toAddrString(address))
383         return it.build()
384     }
385
386     public static def Uri toUri(NodeConnector connector) {
387         return new NodeConnectorId(connector.ID as String);
388     }
389
390     public static def MacAddress toMacAddress(byte[] bytes) {
391         val sb = new StringBuilder(18);
392         for (byte b : bytes) {
393             if (sb.length() > 0)
394                 sb.append(':');
395             sb.append(String.format("%02x", b));
396         }
397         return new MacAddress(sb.toString());
398     }
399         
400         public static def toMDSalflow(Flow sourceFlow) {
401         if (sourceFlow == null)
402             throw new IllegalArgumentException();
403         val it = new FlowBuilder();
404
405         hardTimeout = sourceFlow.hardTimeout as int
406         idleTimeout = sourceFlow.idleTimeout as int
407         cookie = BigInteger.valueOf(sourceFlow.id)
408         priority = sourceFlow.priority as int
409
410         val sourceActions = sourceFlow.actions;
411         val targetActions = new ArrayList<Action>();
412         var int action = 0;
413         for (sourceAction : sourceActions) {
414             targetActions.add(sourceAction.toAction(action));
415             action = action + 1;
416         }
417         instructions = targetActions.toApplyInstruction();
418         match = sourceFlow.match.toMatch();
419         return it.build();
420         }
421         
422 }

©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.