Fixed discard-changes for mdsal netconf, mapping code cleanup.
[controller.git] / opendaylight / md-sal / compatibility / sal-compatibility / src / main / java / org / opendaylight / controller / sal / compatibility / ToSalConversionsUtils.java
index 28dd57c3b7986fecabae2c2fa9749e8d58fbd36e..99e5a80a82294c7a2462f260df87917e09d9079d 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;
@@ -128,7 +129,7 @@ public class ToSalConversionsUtils {
     private static final Logger LOG = LoggerFactory.getLogger(ToSalConversionsUtils.class);
 
     private ToSalConversionsUtils() {
-
+        throw new IllegalAccessError("forcing no instance for factory");
     }
 
     public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source, Node node) {
@@ -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
@@ -287,7 +294,7 @@ public class ToSalConversionsUtils {
             } else if (sourceAction instanceof SetNwTosActionCase) {
                 Integer tos = ((SetNwTosActionCase) sourceAction).getSetNwTosAction().getTos();
                 if (tos != null) {
-                    targetAction.add(new SetNwTos(tos));
+                    targetAction.add(new SetNwTos(ToSalConversionsUtils.tosToNwDscp(tos)));
                 }
             } else if (sourceAction instanceof SetTpDstActionCase) {
                 PortNumber port = ((SetTpDstActionCase) sourceAction).getSetTpDstAction().getPort();
@@ -643,4 +650,12 @@ public class ToSalConversionsUtils {
 
         return mac;
     }
+
+    /**
+     * @param nwTos NW-TOS
+     * @return shifted to NW-DSCP
+     */
+    public static int tosToNwDscp(int nwTos) {
+        return (short) (nwTos >>> FromSalConversionsUtils.ENC_FIELD_BIT_SIZE);
+    }
 }