Bug 2021 - Continuous WARN log nodeConnector creation failed at node: OF|00:00:xx... 68/12568/8
authorFlavio Fernandes <ffernand@redhat.com>
Thu, 6 Nov 2014 13:22:04 +0000 (08:22 -0500)
committerFlavio Fernandes <ffernand@redhat.com>
Wed, 12 Nov 2014 03:15:12 +0000 (22:15 -0500)
This fixes the bug in ToSalConversionsUtils.actionFrom() that mistakenly
passed an AD-SAL-style NodeID to a conversion utility (fromNodeConnectorRef)
that was expecting a MD-SAL-style NodeID.

Patch 8: Add unit test to exercise code path that exposes the issue

Change-Id: Icc107bd785d6558a3351f139c1b13b8737b56ae7
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
Signed-off-by: Colin Dixon <colin@colindixon.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java
opendaylight/md-sal/compatibility/sal-compatibility/src/test/java/org/opendaylight/controller/sal/compatibility/test/TestToSalConversionsUtils.java

index dcc1a46..99e5a80 100644 (file)
@@ -52,6 +52,7 @@ import org.opendaylight.controller.sal.action.SetVlanPcp;
 import org.opendaylight.controller.sal.action.SwPath;
 import org.opendaylight.controller.sal.core.ConstructionException;
 import org.opendaylight.controller.sal.core.Node;
+import org.opendaylight.controller.sal.core.Node.NodeIDType;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
 import org.opendaylight.controller.sal.match.Match;
@@ -207,10 +208,16 @@ public class ToSalConversionsUtils {
 
                 Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector();
                 if (nodeConnector != null) {
-                    //for (Uri uri : nodeConnectors) {
-                    Uri fullNodeConnector = new Uri(node.getType()+":"+node.getID()+":"+nodeConnector.getValue());
+                    // TODO: We should really have a bi-directional map from AD-SAL node types to
+                    //       MD-SAL node types, but lets fix that later.
+                    String type = node.getType();
+                    if( type.equals(NodeIDType.OPENFLOW) ){
+                        type = NodeMapping.OPENFLOW_ID_PREFIX;
+                    }else{
+                        type = type + ":";
+                    }
+                    Uri fullNodeConnector = new Uri(type+node.getID()+":"+nodeConnector.getValue());
                         targetAction.add(new Output(fromNodeConnectorRef(fullNodeConnector, node)));
-                    //}
                 }
             } else if (sourceAction instanceof PopMplsActionCase) {
                 // TODO: define maping
index 54ffddb..7c20c24 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.sal.compatibility.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
 import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.ETHERNET_ARP;
@@ -199,6 +200,29 @@ public class TestToSalConversionsUtils {
         assertEquals("OF|1@OF|00:00:00:00:00:00:00:2a", nodeConnector.toString());
     }
 
+    @Test
+    public void testActionFrom() throws ConstructionException {
+        // Bug 2021: Convert AD-SAL notation into MD-SAL notation before calling NodeConnector
+        Node node = new Node(NodeIDType.OPENFLOW, 42L);
+        List<Action> odActions = new ArrayList<>();
+
+        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
+        outputActionBuilder.setOutputNodeConnector(new Uri("CONTROLLER"));
+        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
+        outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
+        odActions.add(new ActionBuilder().setAction(outputActionCaseBuilder.build()).build());
+
+        List<org.opendaylight.controller.sal.action.Action> targetAction =
+                ToSalConversionsUtils.actionFrom(odActions, node);
+        assertNotNull(targetAction);
+        assertTrue( Output.class.isInstance(targetAction.get(0)) );
+        Output targetActionOutput = (Output) targetAction.get(0);
+        NodeConnector port = targetActionOutput.getPort();
+        assertNotNull(port);
+        assertEquals(port.getType(), NodeConnectorIDType.CONTROLLER);
+        assertEquals(port.getID(), org.opendaylight.controller.sal.core.NodeConnector.SPECIALNODECONNECTORID);
+    }
+
     private void checkSalMatch(org.opendaylight.controller.sal.match.Match match, MtchType mt) throws ConstructionException {
         switch (mt) {
         case other:

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