X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-compability%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompability%2FMDFlowMapping.xtend;h=cd03df83987ecb43669e8b1abab7f17db272d7fe;hb=18fa9cb41678400d1decd007a66fc1f7be894f66;hp=8490ad950148899b9e1f3076fd878070a2a27bb7;hpb=4f5a4b3e71e81c6149a1ca78ca418866e152c45b;p=controller.git diff --git a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend index 8490ad9501..cd03df8398 100644 --- a/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend +++ b/opendaylight/md-sal/sal-compability/src/main/java/org/opendaylight/controller/sal/compability/MDFlowMapping.xtend @@ -41,40 +41,48 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.Flow 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.flow.statistics.rev130819.GetFlowStatisticsInputBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.VlanCfi -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.ControllerActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.DropActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.FloodActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.FloodAllActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.HwPathActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.LoopbackActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.OutputActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PopVlanActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.PushVlanActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetDlDstActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetDlSrcActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetDlTypeActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNextHopActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNwDstActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNwSrcActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetNwTosActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetTpDstActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetTpSrcActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetVlanCfiActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetVlanIdActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SetVlanPcpActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.action.action.SwPathActionBuilder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.Address -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv4Builder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.address.address.Ipv6Builder -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.Action -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev130819.flow.ActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.VlanCfi +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.ControllerActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.DropActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.FloodAllActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.HwPathActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.LoopbackActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.OutputActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PopVlanActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.PushVlanActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlDstActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlSrcActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetDlTypeActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNextHopActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwDstActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwSrcActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetNwTosActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpDstActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetTpSrcActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanCfiActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanIdActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SetVlanPcpActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.action.SwPathActionBuilder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.Address +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv4Builder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.address.address.Ipv6Builder +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.action.list.Action +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.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.compability.FromSalConversionsUtils.* import static extension org.opendaylight.controller.sal.compability.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.instruction.ApplyActionsBuilder +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 public class MDFlowMapping { @@ -97,64 +105,48 @@ public class MDFlowMapping { for (sourceAction : sourceActions) { targetActions.add(sourceAction.toAction()); } - action = targetActions; + instructions = targetActions.toApplyInstruction(); match = sourceFlow.match.toMatch(); return it.build(); } + + public static def Instructions toApplyInstruction(ArrayList actions) { + val it = new InstructionsBuilder; + val applyActions = new InstructionBuilder; + applyActions.instruction = new ApplyActionsBuilder().setAction(actions).build() + instruction = Collections.singletonList(applyActions.build) + return it.build; + } public static def flowStatisticsInput(Node sourceNode, Flow sourceFlow) { - val it = new GetFlowStatisticsInputBuilder(); val source = flowAdded(sourceFlow); - cookie = (source.getCookie()); - action = (source.getAction()); - action = (source.getAction()); - cookie = (source.getCookie()); - hardTimeout = (source.getHardTimeout()); - match = (source.getMatch()); - priority = (source.getPriority()); + val it = new GetFlowStatisticsInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow); node = sourceNode.toNodeRef(); return it.build(); } public static def removeFlowInput(Node sourceNode, Flow sourceFlow) { - val it = new RemoveFlowInputBuilder(); val source = flowAdded(sourceFlow); - action = (source.getAction()); - cookie = (source.getCookie()); - action = (source.getAction()); - cookie = (source.getCookie()); - hardTimeout = (source.getHardTimeout()); - match = (source.getMatch()); - priority = (source.getPriority()); - node = sourceNode.toNodeRef(); + val it = new RemoveFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow); return it.build(); } public static def addFlowInput(Node sourceNode, Flow sourceFlow) { - val it = new AddFlowInputBuilder(); val source = flowAdded(sourceFlow); - action = (source.getAction()); - cookie = (source.getCookie()); - action = (source.getAction()); - cookie = (source.getCookie()); - hardTimeout = (source.getHardTimeout()); - match = (source.getMatch()); - priority = (source.getPriority()); - node = sourceNode.toNodeRef() + val it = new AddFlowInputBuilder(source as org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow); return it.build(); } public static def updateFlowInput(Node sourceNode, Flow oldFlow, Flow newFlow) { val it = new UpdateFlowInputBuilder(); - val source = flowAdded(newFlow); - action = (source.getAction()); - cookie = (source.getCookie()); - action = (source.getAction()); - cookie = (source.getCookie()); - hardTimeout = (source.getHardTimeout()); - match = (source.getMatch()); - priority = (source.getPriority()); + 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(); } @@ -203,8 +195,6 @@ public class MDFlowMapping { return actionBuilder.build(); } - - public static dispatch def toAction(PopVlan sourceAction) { val actionBuilder = new ActionBuilder(); @@ -328,13 +318,13 @@ public class MDFlowMapping { actionBuilder.action = new SwPathActionBuilder().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)) @@ -344,7 +334,7 @@ public class MDFlowMapping { public static def List toUriList(NodeConnector connector) { throw new UnsupportedOperationException("TODO: auto-generated method stub") } - + public static def MacAddress toMacAddress(byte[] bytes) { val sb = new StringBuilder(18); for (byte b : bytes) {