Add Enqueue validation check in FlowConfig 98/5798/3
authorAndrew Kim <andrekim@cisco.com>
Fri, 28 Mar 2014 02:44:47 +0000 (21:44 -0500)
committerAndrew Kim <andrekim@cisco.com>
Fri, 28 Mar 2014 17:04:06 +0000 (12:04 -0500)
Backend validation to check enqueue queue is within range 0 - 2147483647

Change-Id: Ib17f3259a75fe3553455775bf7f26649ced40612
Signed-off-by: Andrew Kim <andrekim@cisco.com>
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java

index 0841485cb179d0a1517658d9ade15ab7fd668f5f..c89cfc1b9e8914148bc58fc6f3a375baca026e53 100644 (file)
@@ -792,6 +792,27 @@ public class FlowConfig extends ConfigurationObject implements Serializable {
                     continue;
                 }
 
+                sstr = Pattern.compile(ActionType.ENQUEUE + "=(.*)").matcher(actiongrp);
+                if (sstr.matches()) {
+                    for (String t : sstr.group(1).split(",")) {
+                        if (t != null) {
+                            String parts[] = t.split(":");
+                            String nc = String.format("%s|%s@%s", node.getType(), parts[0], node.toString());
+                            if (NodeConnector.fromString(nc) == null) {
+                                return new Status(StatusCode.BADREQUEST, String.format("Enqueue port is not valid"));
+                            }
+                            if (parts.length > 1) {
+                                try {
+                                    Integer.parseInt(parts[1]);
+                                } catch (NumberFormatException e) {
+                                    return new Status(StatusCode.BADREQUEST, String.format("Enqueue %s is not in the range 0 - 2147483647", parts[1]));
+                                }
+                            }
+                        }
+                    }
+                    continue;
+                }
+
                 sstr = Pattern.compile(ActionType.SET_VLAN_PCP.toString() + "=(.*)").matcher(actiongrp);
                 if (sstr.matches()) {
                     if ((sstr.group(1) != null) && !isVlanPriorityValid(sstr.group(1))) {