Bug 2021 - NORMAL and CONTROLLER flows should not use hard coded strings 60/12560/4
authorFlavio Fernandes <ffernand@redhat.com>
Thu, 6 Nov 2014 11:46:18 +0000 (06:46 -0500)
committerFlavio Fernandes <ffernand@redhat.com>
Fri, 7 Nov 2014 00:10:43 +0000 (00:10 +0000)
The output port value should be using the node connector id assembled
from the sal-compatibility library, which is provided by the controller.

Patch 3: Add feedback from code review

Change-Id: I3aa503bfd54e3cfcd7fa6dd730849b88f90a38c1
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/ClassifierService.java
ovs-sfc/src/main/java/org/opendaylight/ovsdb/ovssfc/Flows.java
utils/mdsal-openflow/pom.xml
utils/mdsal-openflow/src/main/java/org/opendaylight/ovsdb/utils/mdsal/openflow/InstructionUtils.java

index 27dec7aa4c11c37f6ce060f08b7c10bade312b29..e24653a6c3fa6248a2b61ee9617efb6a6590a791 100644 (file)
@@ -1398,7 +1398,7 @@ public class OF13Provider implements NetworkingProvider {
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        InstructionUtils.createNormalInstructions(ib);
+        InstructionUtils.createNormalInstructions(nodeName, ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
index 95713134df6d93beeb4f719b2c525bda3e7c6d95..40461f74613379ee4022c66fbad31613620b3a18 100644 (file)
@@ -425,7 +425,7 @@ public class ClassifierService extends AbstractServiceInstance implements Classi
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        InstructionUtils.createSendToControllerInstructions(ib);
+        InstructionUtils.createSendToControllerInstructions(nodeName, ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
index b871a2023788f4535bd087db73f0d2a6423f619c..01b8805af40d8210b122a6516baf02c084750cc4 100644 (file)
@@ -142,7 +142,7 @@ public class Flows {
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        InstructionUtils.createSendToControllerInstructions(ib);
+        InstructionUtils.createSendToControllerInstructions(nodeName, ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
@@ -188,7 +188,7 @@ public class Flows {
         List<Instruction> instructions = Lists.newArrayList();
 
         // Call the InstructionBuilder Methods Containing Actions
-        InstructionUtils.createNormalInstructions(ib);
+        InstructionUtils.createNormalInstructions(nodeName, ib);
         ib.setOrder(0);
         ib.setKey(new InstructionKey(0));
         instructions.add(ib.build());
index 99e6ec75796440f8fed6bef06e9c0b521a240f58..65d03c888831d2030c14393b89ee1fc9334ac2d5 100644 (file)
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-compatibility</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.ovsdb</groupId>
       <artifactId>library</artifactId>
index 213123be2246704147ccd15ddb71298f04d674b3..0f333cefa79de3abb5ff1735b7b4534c5926c73c 100644 (file)
@@ -10,6 +10,7 @@
 package org.opendaylight.ovsdb.utils.mdsal.openflow;
 
 import static org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils.dropAction;
+import org.opendaylight.controller.sal.compatibility.NodeMapping;
 
 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.PortNumber;
@@ -57,6 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpSourceHardwareAddressBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
@@ -84,18 +86,18 @@ public class InstructionUtils {
     /**
      * Create Send to Controller Reserved Port Instruction (packet_in)
      *
+     * @param nodeName Uri Prefix, containing nodeConnectorType and dpId (aka NodeId)
      * @param ib Map InstructionBuilder without any instructions
      * @return ib Map InstructionBuilder with instructions
      */
-    public static InstructionBuilder createSendToControllerInstructions(InstructionBuilder ib) {
+    public static InstructionBuilder createSendToControllerInstructions(String nodeName, InstructionBuilder ib) {
 
         List<Action> actionList = Lists.newArrayList();
         ActionBuilder ab = new ActionBuilder();
 
         OutputActionBuilder output = new OutputActionBuilder();
         output.setMaxLength(MAX_LENGTH);
-        Uri value = new Uri("CONTROLLER");
-        output.setOutputNodeConnector(value);
+        output.setOutputNodeConnector(NodeMapping.toControllerNodeConnectorId(new NodeId(nodeName)));
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));
@@ -114,18 +116,18 @@ public class InstructionUtils {
     /**
      * Create NORMAL Reserved Port Instruction (packet_in)
      *
+     * @param nodeId Uri Prefix, containing nodeConnectorType and dpId (aka NodeId)
      * @param ib Map InstructionBuilder without any instructions
      * @return ib Map InstructionBuilder with instructions
      */
 
-    public static InstructionBuilder createNormalInstructions(InstructionBuilder ib) {
+    public static InstructionBuilder createNormalInstructions(String nodeId, InstructionBuilder ib) {
 
         List<Action> actionList = Lists.newArrayList();
         ActionBuilder ab = new ActionBuilder();
 
         OutputActionBuilder output = new OutputActionBuilder();
-        Uri value = new Uri("NORMAL");
-        output.setOutputNodeConnector(value);
+        output.setOutputNodeConnector(NodeMapping.toNormalNodeConnectorId(new NodeId(nodeId)));
         ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
         ab.setOrder(0);
         ab.setKey(new ActionKey(0));