BUG-625: migrate MDFlowMapping 63/7463/1
authorRobert Varga <rovarga@cisco.com>
Wed, 28 May 2014 12:57:06 +0000 (14:57 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 28 May 2014 15:00:33 +0000 (17:00 +0200)
This patch migrates MDFlowMapping from xtend to pure Java, optimizing it
at the same time.

Change-Id: Ibc92760b2d250b190ca9aa25c818b9cc40ad39b2
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java [new file with mode: 0644]
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend [deleted file]

diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.java
new file mode 100644 (file)
index 0000000..e989db4
--- /dev/null
@@ -0,0 +1,445 @@
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.compatibility;
+
+import java.math.BigInteger;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.sal.action.Action;
+import org.opendaylight.controller.sal.action.Controller;
+import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.action.Flood;
+import org.opendaylight.controller.sal.action.FloodAll;
+import org.opendaylight.controller.sal.action.HwPath;
+import org.opendaylight.controller.sal.action.Loopback;
+import org.opendaylight.controller.sal.action.Output;
+import org.opendaylight.controller.sal.action.PopVlan;
+import org.opendaylight.controller.sal.action.PushVlan;
+import org.opendaylight.controller.sal.action.SetDlDst;
+import org.opendaylight.controller.sal.action.SetDlSrc;
+import org.opendaylight.controller.sal.action.SetDlType;
+import org.opendaylight.controller.sal.action.SetNextHop;
+import org.opendaylight.controller.sal.action.SetNwDst;
+import org.opendaylight.controller.sal.action.SetNwSrc;
+import org.opendaylight.controller.sal.action.SetNwTos;
+import org.opendaylight.controller.sal.action.SetTpDst;
+import org.opendaylight.controller.sal.action.SetTpSrc;
+import org.opendaylight.controller.sal.action.SetVlanCfi;
+import org.opendaylight.controller.sal.action.SetVlanId;
+import org.opendaylight.controller.sal.action.SetVlanPcp;
+import org.opendaylight.controller.sal.action.SwPath;
+import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.flowprogrammer.Flow;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp;
+
+import com.google.common.base.Preconditions;
+import com.google.common.net.InetAddresses;
+
+public final class MDFlowMapping {
+    private MDFlowMapping() {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    private static List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> toMDActions(final List<Action> actions) {
+        final ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ret =
+                new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>(actions.size());
+        int action = 0;
+        for (final Action sourceAction : actions) {
+            ret.add(toAction(sourceAction, action));
+            action++;
+        }
+
+        return ret;
+    }
+
+    public static FlowAdded flowAdded(final Flow sourceFlow) {
+        Preconditions.checkArgument(sourceFlow != null);
+
+        return new FlowAddedBuilder()
+        .setHardTimeout(Integer.valueOf(sourceFlow.getHardTimeout()))
+        .setIdleTimeout(Integer.valueOf(sourceFlow.getIdleTimeout()))
+        .setCookie(new FlowCookie(BigInteger.valueOf(sourceFlow.getId())))
+        .setPriority(Integer.valueOf(sourceFlow.getPriority()))
+        .setInstructions(MDFlowMapping.toApplyInstruction(toMDActions(sourceFlow.getActions())))
+        .setMatch(FromSalConversionsUtils.toMatch(sourceFlow.getMatch()))
+        .setTableId((short)0)
+        .build();
+    }
+
+    private static FlowBuilder internalToMDFlow(final Flow sourceFlow) {
+        Preconditions.checkArgument(sourceFlow != null);
+
+        return new FlowBuilder()
+        .setHardTimeout(Integer.valueOf(sourceFlow.getHardTimeout()))
+        .setIdleTimeout(Integer.valueOf(sourceFlow.getIdleTimeout()))
+        .setCookie(new FlowCookie(BigInteger.valueOf(sourceFlow.getId())))
+        .setPriority(Integer.valueOf((sourceFlow.getPriority())))
+        .setInstructions(MDFlowMapping.toApplyInstruction(toMDActions(sourceFlow.getActions())))
+        .setMatch(FromSalConversionsUtils.toMatch(sourceFlow.getMatch()));
+    }
+
+    public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow toMDFlow(final Flow sourceFlow, final String flowId) {
+        return internalToMDFlow(sourceFlow)
+                .setTableId((short)0)
+                .setId(new FlowId(flowId))
+                .build();
+    }
+
+    public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow toMDSalflow(final Flow sourceFlow) {
+        return internalToMDFlow(sourceFlow).build();
+    }
+
+    public static Instructions toApplyInstruction(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
+        return new InstructionsBuilder()
+        .setInstruction(
+                Collections.singletonList(
+                        new InstructionBuilder()
+                        .setOrder(0)
+                        .setInstruction(
+                                new ApplyActionsCaseBuilder()
+                                .setApplyActions(new ApplyActionsBuilder().setAction(actions).build())
+                                .build()
+                                ).build())
+                ).build();
+    }
+
+    public static RemoveFlowInput removeFlowInput(final Node sourceNode, final Flow sourceFlow) {
+        final FlowAdded source = MDFlowMapping.flowAdded(sourceFlow);
+        return new RemoveFlowInputBuilder((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) source)
+        .setNode(NodeMapping.toNodeRef(sourceNode))
+        .build();
+    }
+
+    public static AddFlowInput addFlowInput(final Node sourceNode, final Flow sourceFlow) {
+        final FlowAdded source = MDFlowMapping.flowAdded(sourceFlow);
+        return new AddFlowInputBuilder(((org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) source))
+        .setNode(NodeMapping.toNodeRef(sourceNode))
+        .build();
+    }
+
+    public static UpdateFlowInput updateFlowInput(final Node sourceNode, final Flow oldFlow, final Flow newFlow) {
+        return new UpdateFlowInputBuilder()
+        .setOriginalFlow(new OriginalFlowBuilder(MDFlowMapping.flowAdded(newFlow)).build())
+        .setUpdatedFlow(new UpdatedFlowBuilder(MDFlowMapping.flowAdded(newFlow)).build())
+        .setNode(NodeMapping.toNodeRef(sourceNode))
+        .build();
+    }
+
+    private static ControllerActionCase _toAction(final Controller sourceAction) {
+        return new ControllerActionCaseBuilder().setControllerAction(new ControllerActionBuilder().build()).build();
+    }
+
+    private static DropActionCase _toAction(final Drop sourceAction) {
+        return new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
+    }
+
+    private static FloodActionCase _toAction(final Flood sourceAction) {
+        return new FloodActionCaseBuilder().setFloodAction(new FloodActionBuilder().build()).build();
+    }
+
+    private static FloodAllActionCase _toAction(final FloodAll sourceAction) {
+        return new FloodAllActionCaseBuilder().setFloodAllAction(new FloodAllActionBuilder().build()).build();
+    }
+
+    private static HwPathActionCase _toAction(final HwPath sourceAction) {
+        return new HwPathActionCaseBuilder().setHwPathAction(new HwPathActionBuilder().build()).build();
+    }
+
+    private static LoopbackActionCase _toAction(final Loopback sourceAction) {
+        return new LoopbackActionCaseBuilder().setLoopbackAction( new LoopbackActionBuilder().build()).build();
+    }
+
+    private static OutputActionCase _toAction(final Output sourceAction) {
+        return new OutputActionCaseBuilder()
+        .setOutputAction(
+                new OutputActionBuilder().setOutputNodeConnector(MDFlowMapping.toUri(sourceAction.getPort())).build()
+                ).build();
+    }
+
+    private static PopVlanActionCase _toAction(final PopVlan sourceAction) {
+        return new PopVlanActionCaseBuilder().build();
+    }
+
+    private static PushVlanActionCase _toAction(final PushVlan sourceAction) {
+        return new PushVlanActionCaseBuilder()
+        .setPushVlanAction(
+                new PushVlanActionBuilder()
+                .setCfi(new VlanCfi(sourceAction.getCfi()))
+                .setPcp(sourceAction.getPcp())
+                .setTag(sourceAction.getTag())
+                .setVlanId(new VlanId(sourceAction.getVlanId()))
+                .build()
+                ).build();
+    }
+
+    private static SetDlDstActionCase _toAction(final SetDlDst sourceAction) {
+        return new SetDlDstActionCaseBuilder()
+        .setSetDlDstAction(new SetDlDstActionBuilder().setAddress(MDFlowMapping.toMacAddress(sourceAction.getDlAddress())).build())
+        .build();
+    }
+
+    private static SetDlSrcActionCase _toAction(final SetDlSrc sourceAction) {
+        return new SetDlSrcActionCaseBuilder()
+        .setSetDlSrcAction(new SetDlSrcActionBuilder().setAddress(MDFlowMapping.toMacAddress(sourceAction.getDlAddress())).build())
+        .build();
+    }
+
+    private static SetDlTypeActionCase _toAction(final SetDlType sourceAction) {
+        return new SetDlTypeActionCaseBuilder()
+        .setSetDlTypeAction(new SetDlTypeActionBuilder().setDlType(new EtherType(Long.valueOf(sourceAction.getDlType()))).build())
+        .build();
+    }
+
+    private static SetNextHopActionCase _toAction(final SetNextHop sourceAction) {
+        return new SetNextHopActionCaseBuilder()
+        .setSetNextHopAction(new SetNextHopActionBuilder().setAddress(MDFlowMapping.toInetAddress(sourceAction.getAddress())).build())
+        .build();
+    }
+
+    private static SetNwDstActionCase _toAction(final SetNwDst sourceAction) {
+        return new SetNwDstActionCaseBuilder()
+        .setSetNwDstAction(new SetNwDstActionBuilder().setAddress(MDFlowMapping.toInetAddress(sourceAction.getAddress())).build())
+        .build();
+    }
+
+    private static SetNwSrcActionCase _toAction(final SetNwSrc sourceAction) {
+        return new SetNwSrcActionCaseBuilder()
+        .setSetNwSrcAction(new SetNwSrcActionBuilder().setAddress(MDFlowMapping.toInetAddress(sourceAction.getAddress())).build())
+        .build();
+    }
+
+    private static SetNwTosActionCase _toAction(final SetNwTos sourceAction) {
+        return new SetNwTosActionCaseBuilder()
+        .setSetNwTosAction(new SetNwTosActionBuilder().setTos(sourceAction.getNwTos()).build())
+        .build();
+    }
+
+    private static SetTpDstActionCase _toAction(final SetTpDst sourceAction) {
+        return new SetTpDstActionCaseBuilder()
+        .setSetTpDstAction(new SetTpDstActionBuilder().setPort(new PortNumber(sourceAction.getPort())).build())
+        .build();
+    }
+
+    private static SetTpSrcActionCase _toAction(final SetTpSrc sourceAction) {
+        return new SetTpSrcActionCaseBuilder()
+        .setSetTpSrcAction(new SetTpSrcActionBuilder().setPort(new PortNumber(sourceAction.getPort())).build())
+        .build();
+    }
+
+    private static SetVlanCfiActionCase _toAction(final SetVlanCfi sourceAction) {
+        return new SetVlanCfiActionCaseBuilder()
+        .setSetVlanCfiAction(new SetVlanCfiActionBuilder().setVlanCfi(new VlanCfi(sourceAction.getCfi())).build())
+        .build();
+    }
+
+    private static SetVlanIdActionCase _toAction(final SetVlanId sourceAction) {
+        return new SetVlanIdActionCaseBuilder()
+        .setSetVlanIdAction(new SetVlanIdActionBuilder().setVlanId(new VlanId(sourceAction.getVlanId())).build())
+        .build();
+    }
+
+    private static SetVlanPcpActionCase _toAction(final SetVlanPcp sourceAction) {
+        return new SetVlanPcpActionCaseBuilder()
+        .setSetVlanPcpAction(new SetVlanPcpActionBuilder().setVlanPcp(new VlanPcp((short) sourceAction.getPcp())).build())
+        .build();
+    }
+
+    private static SwPathActionCase _toAction(final SwPath sourceAction) {
+        return new SwPathActionCaseBuilder().setSwPathAction(new SwPathActionBuilder().build()).build();
+    }
+
+    public static Uri toUri(final NodeConnector connector) {
+        return new NodeConnectorId(((String) connector.getID()));
+    }
+
+    public static MacAddress toMacAddress(final byte[] bytes) {
+        final StringBuilder sb = new StringBuilder(18);
+        boolean first = true;
+
+        for (final byte b : bytes) {
+            if (first) {
+                first = false;
+            } else {
+                sb.append(':');
+            }
+            sb.append(String.format("%02x", Byte.valueOf(b)));
+        }
+        return new MacAddress(sb.toString());
+    }
+
+    public static org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action toAction(final Action sourceAction, final int order) {
+        final ActionBuilder ret = new ActionBuilder().setOrder(order);
+
+        if (sourceAction instanceof Controller) {
+            ret.setAction(_toAction((Controller)sourceAction));
+        } else if (sourceAction instanceof Drop) {
+            ret.setAction(_toAction((Drop)sourceAction));
+        } else if (sourceAction instanceof Flood) {
+            ret.setAction(_toAction((Flood)sourceAction));
+        } else if (sourceAction instanceof FloodAll) {
+            ret.setAction(_toAction((FloodAll)sourceAction));
+        } else if (sourceAction instanceof HwPath) {
+            ret.setAction(_toAction((HwPath)sourceAction));
+        } else if (sourceAction instanceof Loopback) {
+            ret.setAction(_toAction((Loopback)sourceAction));
+        } else if (sourceAction instanceof Output) {
+            ret.setAction(_toAction((Output)sourceAction));
+        } else if (sourceAction instanceof PopVlan) {
+            ret.setAction(_toAction((PopVlan)sourceAction));
+        } else if (sourceAction instanceof PushVlan) {
+            ret.setAction(_toAction((PushVlan)sourceAction));
+        } else if (sourceAction instanceof SetDlDst) {
+            ret.setAction(_toAction((SetDlDst)sourceAction));
+        } else if (sourceAction instanceof SetDlSrc) {
+            ret.setAction(_toAction((SetDlSrc)sourceAction));
+        } else if (sourceAction instanceof SetDlType) {
+            ret.setAction(_toAction((SetDlType)sourceAction));
+        } else if (sourceAction instanceof SetNextHop) {
+            ret.setAction(_toAction((SetNextHop)sourceAction));
+        } else if (sourceAction instanceof SetNwDst) {
+            ret.setAction(_toAction((SetNwDst)sourceAction));
+        } else if (sourceAction instanceof SetNwSrc) {
+            ret.setAction(_toAction((SetNwSrc)sourceAction));
+        } else if (sourceAction instanceof SetNwTos) {
+            ret.setAction(_toAction((SetNwTos)sourceAction));
+        } else if (sourceAction instanceof SetTpDst) {
+            ret.setAction(_toAction((SetTpDst)sourceAction));
+        } else if (sourceAction instanceof SetTpSrc) {
+            ret.setAction(_toAction((SetTpSrc)sourceAction));
+        } else if (sourceAction instanceof SetVlanCfi) {
+            ret.setAction(_toAction((SetVlanCfi)sourceAction));
+        } else if (sourceAction instanceof SetVlanId) {
+            ret.setAction(_toAction((SetVlanId)sourceAction));
+        } else if (sourceAction instanceof SetVlanPcp) {
+            ret.setAction(_toAction((SetVlanPcp)sourceAction));
+        } else if (sourceAction instanceof SwPath) {
+            ret.setAction(_toAction((SwPath)sourceAction));
+        } else {
+            throw new IllegalArgumentException(String.format("Unhandled action class %s", sourceAction.getClass()));
+        }
+
+        return ret.build();
+    }
+
+    public static Address toInetAddress(final InetAddress address) {
+        if (address instanceof Inet4Address) {
+            return new Ipv4Builder()
+            .setIpv4Address(new Ipv4Prefix(InetAddresses.toAddrString(address)))
+            .build();
+        }
+        if (address instanceof Inet6Address) {
+            return new Ipv6Builder()
+            .setIpv6Address(new Ipv6Prefix(InetAddresses.toAddrString(address)))
+            .build();
+        }
+
+        throw new IllegalArgumentException(String.format("Unhandled address class %s", address.getClass()));
+    }
+}
diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/MDFlowMapping.xtend
deleted file mode 100644 (file)
index 75cbf49..0000000
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.sal.compatibility;
-
-import com.google.common.net.InetAddresses
-import java.math.BigInteger
-import java.net.Inet4Address
-import java.net.Inet6Address
-import java.util.ArrayList
-import org.opendaylight.controller.sal.action.Controller
-import org.opendaylight.controller.sal.action.Drop
-import org.opendaylight.controller.sal.action.Flood
-import org.opendaylight.controller.sal.action.FloodAll
-import org.opendaylight.controller.sal.action.HwPath
-import org.opendaylight.controller.sal.action.Loopback
-import org.opendaylight.controller.sal.action.Output
-import org.opendaylight.controller.sal.action.PopVlan
-import org.opendaylight.controller.sal.action.PushVlan
-import org.opendaylight.controller.sal.action.SetDlDst
-import org.opendaylight.controller.sal.action.SetDlSrc
-import org.opendaylight.controller.sal.action.SetDlType
-import org.opendaylight.controller.sal.action.SetNextHop
-import org.opendaylight.controller.sal.action.SetNwDst
-import org.opendaylight.controller.sal.action.SetNwSrc
-import org.opendaylight.controller.sal.action.SetNwTos
-import org.opendaylight.controller.sal.action.SetTpDst
-import org.opendaylight.controller.sal.action.SetTpSrc
-import org.opendaylight.controller.sal.action.SetVlanCfi
-import org.opendaylight.controller.sal.action.SetVlanId
-import org.opendaylight.controller.sal.action.SetVlanPcp
-import org.opendaylight.controller.sal.action.SwPath
-import org.opendaylight.controller.sal.core.Node
-import org.opendaylight.controller.sal.core.NodeConnector
-import org.opendaylight.controller.sal.flowprogrammer.Flow
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.VlanCfi
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4Builder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6Builder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp
-
-import static extension org.opendaylight.controller.sal.compatibility.FromSalConversionsUtils.*
-import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder
-import java.util.Collections
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.controller.action._case.ControllerActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.action._case.FloodActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.flood.all.action._case.FloodAllActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.hw.path.action._case.HwPathActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.loopback.action._case.LoopbackActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.dst.action._case.SetDlDstActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.src.action._case.SetDlSrcActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.dl.type.action._case.SetDlTypeActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.next.hop.action._case.SetNextHopActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.dst.action._case.SetNwDstActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.src.action._case.SetNwSrcActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.nw.tos.action._case.SetNwTosActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.dst.action._case.SetTpDstActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.tp.src.action._case.SetTpSrcActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.cfi.action._case.SetVlanCfiActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.pcp.action._case.SetVlanPcpActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.sw.path.action._case.SwPathActionBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpSrcActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetTpDstActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwTosActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwDstActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNextHopActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlTypeActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlDstActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.ControllerActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.FloodAllActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.HwPathActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.LoopbackActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetDlSrcActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanCfiActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanPcpActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SwPathActionCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie
-
-public class MDFlowMapping {
-
-    private new() {
-        throw new UnsupportedOperationException()
-    }
-
-    public static def flowAdded(Flow sourceFlow) {
-        if (sourceFlow == null)
-            throw new IllegalArgumentException();
-        val it = new FlowAddedBuilder();
-
-        hardTimeout = sourceFlow.hardTimeout as int
-        idleTimeout = sourceFlow.idleTimeout as int
-        cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
-        priority = sourceFlow.priority as int
-
-        val sourceActions = sourceFlow.actions;
-        val targetActions = new ArrayList<Action>();
-        var int action = 0;
-        for (sourceAction : sourceActions) {
-            targetActions.add(sourceAction.toAction(action));
-            action = action + 1;
-        }
-        instructions = targetActions.toApplyInstruction();
-        match = sourceFlow.match.toMatch();
-        tableId = new Integer(0).shortValue
-        return it.build();
-
-    }
-    
-    public static def toMDFlow(Flow sourceFlow, String flowId) {
-       if (sourceFlow == null)
-            throw new IllegalArgumentException();
-       val it = new FlowBuilder();
-       hardTimeout = sourceFlow.hardTimeout as int
-       idleTimeout = sourceFlow.idleTimeout as int
-       cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
-       priority = sourceFlow.priority as int
-       id = new FlowId(flowId)
-    
-       val sourceActions = sourceFlow.actions;
-       val targetActions = new ArrayList<Action>();
-       var int action = 0;
-       for (sourceAction : sourceActions) {
-           targetActions.add(sourceAction.toAction(action));
-           action = action+ 1;
-       }
-       instructions = targetActions.toApplyInstruction();
-       match = sourceFlow.match.toMatch();
-       tableId = new Integer(0).shortValue
-       return it.build();
-    }
-    
-    public static def Instructions toApplyInstruction(ArrayList<Action> actions) {
-        val it = new InstructionsBuilder;
-        val applyActions = new InstructionBuilder;
-        applyActions.instruction = new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build()
-        applyActions.setOrder(new Integer(0))
-        instruction = Collections.<Instruction>singletonList(applyActions.build)
-        return it.build;
-    }
-
-    public static def removeFlowInput(Node sourceNode, Flow sourceFlow) {
-        val source = flowAdded(sourceFlow);
-        val it = new RemoveFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
-        node = sourceNode.toNodeRef()
-        return it.build();
-    }
-
-    public static def addFlowInput(Node sourceNode, Flow sourceFlow) {
-        val source = flowAdded(sourceFlow);
-        val it = new AddFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
-        it.setNode(sourceNode.toNodeRef)
-        return it.build();
-    }
-
-    public static def updateFlowInput(Node sourceNode, Flow oldFlow, Flow newFlow) {
-        val it = new UpdateFlowInputBuilder();
-        val sourceOld = flowAdded(newFlow);
-
-        val original = new OriginalFlowBuilder(sourceOld as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
-        val sourceNew = flowAdded(newFlow);
-        val updated = new UpdatedFlowBuilder(sourceNew as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow);
-        originalFlow = original.build()
-        updatedFlow = updated.build();
-        node = sourceNode.toNodeRef()
-        return it.build();
-    }
-
-    public static dispatch def toAction(Controller sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new ControllerActionCaseBuilder().setControllerAction(new ControllerActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(Drop sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new DropActionCaseBuilder().setDropAction(new DropActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(Flood sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new FloodActionCaseBuilder().setFloodAction(new FloodActionBuilder().build).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(FloodAll sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new FloodAllActionCaseBuilder().setFloodAllAction(new FloodAllActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(HwPath sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new HwPathActionCaseBuilder().setHwPathAction(new HwPathActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(Loopback sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new LoopbackActionCaseBuilder().setLoopbackAction(new LoopbackActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(Output sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new OutputActionBuilder();
-        outputNodeConnector = sourceAction.port.toUri;
-        actionBuilder.action = new OutputActionCaseBuilder().setOutputAction(it.build()).build();
-        return actionBuilder.build();
-
-    }
-
-    public static dispatch def toAction(PopVlan sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new PopVlanActionCaseBuilder().build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(PushVlan sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new PushVlanActionBuilder();
-        cfi = new VlanCfi(sourceAction.cfi);
-        vlanId = new VlanId(sourceAction.vlanId);
-        pcp = sourceAction.pcp;
-        tag = sourceAction.tag;
-        actionBuilder.action = new PushVlanActionCaseBuilder().setPushVlanAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetDlDst sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetDlDstActionBuilder();
-        address = sourceAction.dlAddress.toMacAddress();
-        actionBuilder.action = new SetDlDstActionCaseBuilder().setSetDlDstAction(it.build()).build;
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetDlSrc sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetDlSrcActionBuilder();
-        address = sourceAction.dlAddress.toMacAddress;
-        actionBuilder.action = new SetDlSrcActionCaseBuilder().setSetDlSrcAction(it.build()).build;
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetDlType sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetDlTypeActionBuilder();
-        dlType = new EtherType(sourceAction.dlType as long);
-        actionBuilder.action = new SetDlTypeActionCaseBuilder().setSetDlTypeAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetNextHop sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetNextHopActionBuilder();
-        val inetAddress = sourceAction.address;
-        address = inetAddress.toInetAddress;
-        actionBuilder.action = new SetNextHopActionCaseBuilder().setSetNextHopAction(it.build).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetNwDst sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetNwDstActionBuilder();
-        val inetAddress = sourceAction.address;
-        address = inetAddress.toInetAddress;
-        actionBuilder.action = new SetNwDstActionCaseBuilder().setSetNwDstAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetNwSrc sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetNwSrcActionBuilder();
-        val inetAddress = sourceAction.address;
-        address = inetAddress.toInetAddress;
-        actionBuilder.action = new SetNwSrcActionCaseBuilder().setSetNwSrcAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetNwTos sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetNwTosActionBuilder();
-        tos = sourceAction.nwTos;
-        actionBuilder.action = new SetNwTosActionCaseBuilder().setSetNwTosAction(it.build).build;
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetTpDst sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetTpDstActionBuilder();
-        port = new PortNumber(sourceAction.port);
-        actionBuilder.action = new SetTpDstActionCaseBuilder().setSetTpDstAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetTpSrc sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetTpSrcActionBuilder();
-        port = new PortNumber(sourceAction.port);
-        actionBuilder.action = new SetTpSrcActionCaseBuilder().setSetTpSrcAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetVlanCfi sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetVlanCfiActionBuilder();
-        vlanCfi = new VlanCfi(sourceAction.cfi);
-        actionBuilder.action = new SetVlanCfiActionCaseBuilder().setSetVlanCfiAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetVlanId sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-
-        val it = new SetVlanIdActionBuilder();
-        vlanId = new VlanId(sourceAction.vlanId);
-        actionBuilder.action = new SetVlanIdActionCaseBuilder().setSetVlanIdAction(it.build()).build();
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SetVlanPcp sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        val it = new SetVlanPcpActionBuilder();
-        vlanPcp = new VlanPcp(sourceAction.pcp as short);
-        actionBuilder.action = new SetVlanPcpActionCaseBuilder().setSetVlanPcpAction(it.build).build;
-        return actionBuilder.build();
-    }
-
-    public static dispatch def toAction(SwPath sourceAction, int order) {
-        val actionBuilder = new ActionBuilder().setOrder(order);
-        actionBuilder.action = new SwPathActionCaseBuilder().setSwPathAction(new SwPathActionBuilder().build()).build();
-        return actionBuilder.build();
-    }
-
-    public static def dispatch Address toInetAddress(Inet4Address address) {
-        val it = new Ipv4Builder
-        ipv4Address = new Ipv4Prefix(InetAddresses.toAddrString(address))
-        return it.build()
-    }
-
-    public static def dispatch Address toInetAddress(Inet6Address address) {
-        val it = new Ipv6Builder
-        ipv6Address = new Ipv6Prefix(InetAddresses.toAddrString(address))
-        return it.build()
-    }
-
-    public static def Uri toUri(NodeConnector connector) {
-        return new NodeConnectorId(connector.ID as String);
-    }
-
-    public static def MacAddress toMacAddress(byte[] bytes) {
-        val sb = new StringBuilder(18);
-        for (byte b : bytes) {
-            if (sb.length() > 0)
-                sb.append(':');
-            sb.append(String.format("%02x", b));
-        }
-        return new MacAddress(sb.toString());
-    }
-       
-       public static def toMDSalflow(Flow sourceFlow) {
-        if (sourceFlow == null)
-            throw new IllegalArgumentException();
-        val it = new FlowBuilder();
-
-        hardTimeout = sourceFlow.hardTimeout as int
-        idleTimeout = sourceFlow.idleTimeout as int
-        cookie = new FlowCookie(BigInteger.valueOf(sourceFlow.id))
-        priority = sourceFlow.priority as int
-
-        val sourceActions = sourceFlow.actions;
-        val targetActions = new ArrayList<Action>();
-        var int action = 0;
-        for (sourceAction : sourceActions) {
-            targetActions.add(sourceAction.toAction(action));
-            action = action + 1;
-        }
-        instructions = targetActions.toApplyInstruction();
-        match = sourceFlow.match.toMatch();
-        return it.build();
-       }
-       
-}

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