Fix for bug ONOS-897:

Add support for specifying flow entry priority.
Now the default priority is 32768 (same as NOX)

The priority can be specified by add_flow.py script with the
"priority <flowPriority>" keyword.

Conflicts:

	src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
	src/main/java/net/onrc/onos/ofcontroller/flowprogrammer/FlowPusher.java
	src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowEntryTest.java
	src/test/java/net/onrc/onos/ofcontroller/core/INetMapTopologyObjectsIFlowPathTest.java
	src/test/java/net/onrc/onos/ofcontroller/core/internal/TestableGraphDBOperation.java
	src/test/java/net/onrc/onos/ofcontroller/util/FlowPathTest.java

NOTE: The conflicts in file FlowDatabaseOperation.java and FlowPusher.java
have been resolved by hand.
The rest of the conflicts are because of missing test files and have been
ignored.

Change-Id: Ia8291fa321d250675850942ea6763f3770af711f

Fix the formatting of the help string.

Change-Id: I95f4c64d6960f7d66db3821210277fc91c2239e1
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
index cedfdfd..ec3064e 100755
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowDatabaseOperation.java
@@ -5,6 +5,7 @@
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.LinkedList;
 import java.util.Map;
 
 import net.floodlightcontroller.core.IOFSwitch;
@@ -100,6 +101,9 @@
         flowPathEntity.setProperty("hard_timeout", flowPath.hardTimeout());
 	flowProp.setHardTimeout(flowPath.hardTimeout());
 
+        flowPathEntity.setProperty("priority", flowPath.priority());
+	flowProp.setPriority(flowPath.priority());
+
         flowPathEntity.setProperty("src_switch", flowPath.dataPath().srcPort().dpid().toString());
 	flowProp.setSrcSwitch(flowPath.dataPath().srcPort().dpid().toString());
 
@@ -208,6 +212,8 @@
 
             flowEntryEntity.setProperty("hard_timeout", flowEntry.hardTimeout());
 
+            flowEntryEntity.setProperty("priority", flowEntry.priority());
+
             flowEntryEntity.setProperty("switch_dpid", flowEntry.dpid().toString());
 
             flowEntryEntity.addEdge(sw, Direction.OUT, "switch");
@@ -400,6 +406,7 @@
 	//
 	// - flowEntry.idleTimeout()
 	// - flowEntry.hardTimeout()
+	// - flowEntry.priority()
 	// - flowEntry.dpid()
 	// - flowEntry.flowEntryUserState()
 	// - flowEntry.flowEntrySwitchState()
@@ -429,6 +436,7 @@
 
 	flowProp.setIdleTimeout(flowEntry.idleTimeout());
 	flowProp.setHardTimeout(flowEntry.hardTimeout());
+	flowProp.setPriority(flowEntry.priority());
 	flowProp.setSwitchDpid(flowEntry.dpid().toString());
 	if (measureONOSFlowEntryTimeProp) {
 	    numProperties += 3;
@@ -961,6 +969,7 @@
 	Long flowPathFlags;
 	Integer idleTimeout;
 	Integer hardTimeout;
+	Integer priority;
 	String srcSwitchStr;
 	Short srcPortShort;
 	String dstSwitchStr;
@@ -977,6 +986,7 @@
 	    flowPathFlags = (Long)propMap.get("flow_path_flags");
 	    idleTimeout = (Integer) propMap.get("idle_timeout");
 	    hardTimeout = (Integer) propMap.get("hard_timeout");
+	    priority = (Integer) propMap.get("priority");
 	    srcSwitchStr = (String) propMap.get("src_switch");
 	    srcPortShort = (Short)propMap.get("src_port");
 	    dstSwitchStr = (String) propMap.get("dst_switch");
@@ -989,6 +999,7 @@
 	    flowPathFlags = flowObj.getFlowPathFlags();
 	    idleTimeout = flowObj.getIdleTimeout();
 	    hardTimeout = flowObj.getHardTimeout();
+	    priority = flowObj.getPriority();
 	    srcSwitchStr = flowObj.getSrcSwitch();
 	    srcPortShort = flowObj.getSrcPort();
 	    dstSwitchStr = flowObj.getDstSwitch();
@@ -1002,6 +1013,7 @@
 	    (flowPathFlags == null) ||
 	    (idleTimeout == null) ||
 	    (hardTimeout == null) ||
+	    (priority == null) ||
 	    (srcSwitchStr == null) ||
 	    (srcPortShort == null) ||
 	    (dstSwitchStr == null) ||
@@ -1019,6 +1031,7 @@
 	flowPath.setFlowPathFlags(new FlowPathFlags(flowPathFlags));
 	flowPath.setIdleTimeout(idleTimeout);
 	flowPath.setHardTimeout(hardTimeout);
+	flowPath.setPriority(priority);
 	flowPath.dataPath().srcPort().setDpid(new Dpid(srcSwitchStr));
 	flowPath.dataPath().srcPort().setPort(new Port(srcPortShort));
 	flowPath.dataPath().dstPort().setDpid(new Dpid(dstSwitchStr));
@@ -1076,6 +1089,7 @@
 	String flowEntryIdStr;
 	Integer idleTimeout;
 	Integer hardTimeout;
+	Integer priority;
 	String switchDpidStr;
 	String userState;
 	String switchState;
@@ -1086,6 +1100,7 @@
 	    flowEntryIdStr = (String) propMap.get("flow_entry_id");
 	    idleTimeout = (Integer) propMap.get("idle_timeout");
 	    hardTimeout = (Integer) propMap.get("hard_timeout");
+	    priority = (Integer) propMap.get("priority");
 	    switchDpidStr = (String) propMap.get("switch_dpid");
 	    userState = (String) propMap.get("user_state");
 	    switchState = (String) propMap.get("switch_state");
@@ -1093,6 +1108,7 @@
 	    flowEntryIdStr = flowEntryObj.getFlowEntryId();
 	    idleTimeout = flowEntryObj.getIdleTimeout();
 	    hardTimeout = flowEntryObj.getHardTimeout();
+	    priority = flowEntryObj.getPriority();
 	    switchDpidStr = flowEntryObj.getSwitchDpid();
 	    userState = flowEntryObj.getUserState();
 	    switchState = flowEntryObj.getSwitchState();
@@ -1102,6 +1118,7 @@
 	    (flowEntryIdStr == null) ||
 	    (idleTimeout == null) ||
 	    (hardTimeout == null) ||
+	    (priority == null) ||
 	    (switchDpidStr == null) ||
 	    (userState == null) ||
 	    (switchState == null)) {
@@ -1116,6 +1133,7 @@
 	flowEntry.setDpid(new Dpid(switchDpidStr));
 	flowEntry.setIdleTimeout(idleTimeout);
 	flowEntry.setHardTimeout(hardTimeout);
+	flowEntry.setPriority(priority);
 
 	//
 	// Extract the match conditions
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEntryProperty.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEntryProperty.java
index b45f8ff..f893ac1 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEntryProperty.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEntryProperty.java
@@ -48,6 +48,10 @@
     public void setHardTimeout(Integer value) {
         map.put("hard_timeout", value);
     }
+
+    public void setPriority(Integer value) {
+        map.put("priority", value);
+    }
     
     public void setSwitchDpid(String value) {
         map.put("switch_dpid", value);
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
index 5ff1dc5..1a2563d 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowEventHandler.java
@@ -1318,6 +1318,7 @@
 	    //
 	    newFlowEntry.setIdleTimeout(flowPath.idleTimeout());
 	    newFlowEntry.setHardTimeout(flowPath.hardTimeout());
+	    newFlowEntry.setPriority(flowPath.priority());
 
 	    //
 	    // Allocate the FlowEntryMatch by copying the default one
diff --git a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowPathProperty.java b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowPathProperty.java
index 21db7bc..50bbcc8 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowPathProperty.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/flowmanager/FlowPathProperty.java
@@ -41,6 +41,10 @@
 		map.put("hard_timeout", hardTimeout);
 	}
 
+	public void setPriority(Integer priority) {
+		map.put("priority", priority);
+	}
+
 	public void setSrcSwitch(String srcSwitch) {
 		map.put("src_switch", srcSwitch);
 	}