From 9a06086ce358a452e4de62b5f05dd849c770769b Mon Sep 17 00:00:00 2001 From: Anilkumar Vishnoi Date: Thu, 19 Jun 2014 00:55:46 +0530 Subject: [PATCH] Bug 1186 - of-flow: pop-mpls-action different in config and operational data store Change-Id: I9b13cd917200504c24b2892590661a85824899cb Signed-off-by: Anilkumar Vishnoi --- .../core/sal/convertor/ActionConvertor.java | 21 ++++++++++++++++--- .../sal/convertor/ActionConvertorTest.java | 18 ++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java index efd14bd7fd..a5d6a69c9b 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertor.java @@ -735,12 +735,11 @@ public final class ActionConvertor { } else if (action.getType().equals( org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls.class)) { - bucketActions.add(ofToSALPushVlanAction(action)); + bucketActions.add(ofToSALPushMplsAction(action)); } else if (action.getType().equals( org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls.class)) { - PopMplsActionBuilder popMpls = new PopMplsActionBuilder(); - bucketActions.add(new PopMplsActionCaseBuilder().setPopMplsAction(popMpls.build()).build()); + bucketActions.add(ofToSALPopMplsAction(action)); } else if (action.getType().equals( org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue.class)) { @@ -870,6 +869,22 @@ public final class ActionConvertor { return new PushMplsActionCaseBuilder().setPushMplsAction(pushMplsAction.build()).build(); } + /** + * Method converts OF PopMpls action to SAL PopMpls action. + * + * @param action + * @return PopMplsActionCase + */ + public static PopMplsActionCase ofToSALPopMplsAction(Action action) { + + PopMplsActionBuilder popMplsAction = new PopMplsActionBuilder(); + + EthertypeAction etherType = action.getAugmentation(EthertypeAction.class); + popMplsAction.setEthernetType(etherType.getEthertype().getValue()); + + return new PopMplsActionCaseBuilder().setPopMplsAction(popMplsAction.build()).build(); + } + /** * Method converts OF SetQueue action to SAL SetQueue action. * diff --git a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java index 5adba4d7b2..8f0571c89b 100644 --- a/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java +++ b/openflowplugin/src/test/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/ActionConvertorTest.java @@ -587,6 +587,24 @@ public class ActionConvertorTest { Assert.assertEquals("2001:0db8:85a3:0042:1000:8a2e:0370:7334", matchEntry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue()); } + /** + * testing {@link ActionConvertor#ofToSALPopMplsAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action)} + * with OF-1.3, IPv6 + */ + @Test + public void testOFtoSALPopMplsAction() { + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder actionBuilder + = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder(); + + actionBuilder.setType(PopMpls.class); + EthertypeActionBuilder ethertypeActionBuilder = new EthertypeActionBuilder(); + ethertypeActionBuilder.setEthertype(new EtherType(new Integer(34888))); + actionBuilder.addAugmentation(EthertypeAction.class, ethertypeActionBuilder.build()); + org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action action = actionBuilder.build(); + + Assert.assertEquals(34888, ActionConvertor.ofToSALPopMplsAction(action).getPopMplsAction().getEthernetType().intValue()); + } + private static SetNwDstActionCase provisionNwDstActionBuilder(Address address) { SetNwDstAction nwDstAction = new SetNwDstActionBuilder().setAddress(address).build(); SetNwDstActionCase action = new SetNwDstActionCaseBuilder() -- 2.36.6