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/web/add_flow.py b/web/add_flow.py
index 6ff250a..3066936 100755
--- a/web/add_flow.py
+++ b/web/add_flow.py
@@ -129,12 +129,13 @@
my_dst_port = my_args[5]
#
- # Extract the "flowPathFlags", "idleTimeout", "hardTimeout",
+ # Extract the "flowPathFlags", "idleTimeout", "hardTimeout", "priority",
# "match" and "action" arguments.
#
flowPathFlags = 0L
idleTimeout = 0
hardTimeout = 0
+ priority = 32768
match = {}
matchInPortEnabled = True # NOTE: Enabled by default
actions = []
@@ -162,6 +163,8 @@
idleTimeout = arg2
elif arg1 == "hardTimeout":
hardTimeout = arg2
+ elif arg1 == "priority":
+ priority = arg2
elif arg1 == "matchInPort":
# Just mark whether inPort matching is enabled
matchInPortEnabled = arg2 in ['True', 'true']
@@ -319,6 +322,7 @@
'flowPathFlags' : flowPathFlags,
'idleTimeout' : idleTimeout,
'hardTimeout' : hardTimeout,
+ 'priority' : priority,
'match' : match,
'matchInPortEnabled' : matchInPortEnabled,
'actions' : actions,
@@ -345,6 +349,7 @@
myFlowPathFlags = parsed_args['flowPathFlags']
myIdleTimeout = parsed_args['idleTimeout']
myHardTimeout = parsed_args['hardTimeout']
+ myPriority = parsed_args['priority']
match = parsed_args['match']
matchInPortEnabled = parsed_args['matchInPortEnabled']
actions = parsed_args['actions']
@@ -369,6 +374,7 @@
flow_path['flowPathFlags'] = flowPathFlags
flow_path['idleTimeout'] = myIdleTimeout
flow_path['hardTimeout'] = myHardTimeout
+ flow_path['priority'] = myPriority
if (len(match) > 0):
flow_path['flowEntryMatch'] = copy.deepcopy(match)
@@ -499,7 +505,7 @@
if __name__ == "__main__":
- usage_msg = "Usage: %s [Flags] <flow-id> <installer-id> <src-dpid> <src-port> <dest-dpid> <dest-port> [Flow Path Flags] [Match Conditions] [Actions]\n" % (sys.argv[0])
+ usage_msg = "Usage: %s [Flags] <flow-id> <installer-id> <src-dpid> <src-port> <dest-dpid> <dest-port> [Flow Attributes] [Match Conditions] [Actions]\n" % (sys.argv[0])
usage_msg = usage_msg + "\n"
usage_msg = usage_msg + " <flow-id> The Flow ID, or -1 if it should be assigned by ONOS\n"
usage_msg = usage_msg + "\n"
@@ -512,16 +518,18 @@
usage_msg = usage_msg + " -f <filename> Read the flow(s) to install from a file\n"
usage_msg = usage_msg + " File format: one line per flow starting with <flow-id>\n"
usage_msg = usage_msg + "\n"
- usage_msg = usage_msg + " Flow Path Flags:\n"
+ usage_msg = usage_msg + " Flow Attributes:\n"
usage_msg = usage_msg + " flowPathFlags <Flags> (flag names separated by ',')\n"
- usage_msg = usage_msg + "\n"
- usage_msg = usage_msg + " Known flags:\n"
+ usage_msg = usage_msg + " Known flags:\n"
usage_msg = usage_msg + " DISCARD_FIRST_HOP_ENTRY : Discard the first-hop flow entry\n"
usage_msg = usage_msg + " KEEP_ONLY_FIRST_HOP_ENTRY : Keep only the first-hop flow entry\n"
usage_msg = usage_msg + "\n"
- usage_msg = usage_msg + " Timeouts (in seconds in the [0, 65535] interval):\n"
- usage_msg = usage_msg + " idleTimeout <idleTimeoutInSeconds> (default to 0: no timeout)\n"
- usage_msg = usage_msg + " hardTimeout <hardTimeoutInSeconds> (default to 0: no timeout)\n"
+ usage_msg = usage_msg + " idleTimeout <idleTimeoutInSeconds> (in the [0, 65535] interval;\n"
+ usage_msg = usage_msg + " default to 0: no timeout)\n"
+ usage_msg = usage_msg + " hardTimeout <hardTimeoutInSeconds> (in the [0, 65535] interval;\n"
+ usage_msg = usage_msg + " default to 0: no timeout)\n"
+ usage_msg = usage_msg + "\n"
+ usage_msg = usage_msg + " priority <flowPriority> (in the [0, 65535] interval; default to 32768)\n"
usage_msg = usage_msg + "\n"
usage_msg = usage_msg + " Match Conditions:\n"
usage_msg = usage_msg + " matchInPort <True|False> (default to True)\n"
diff --git a/web/get_flow.py b/web/get_flow.py
index 382238f..bdf89df 100755
--- a/web/get_flow.py
+++ b/web/get_flow.py
@@ -166,6 +166,7 @@
flowPathFlags = parsedResult['flowPathFlags']['flags']
idleTimeout = parsedResult['idleTimeout']
hardTimeout = parsedResult['hardTimeout']
+ priority = parsedResult['priority']
srcSwitch = parsedResult['dataPath']['srcPort']['dpid']['value']
srcPort = parsedResult['dataPath']['srcPort']['port']['value']
dstSwitch = parsedResult['dataPath']['dstPort']['dpid']['value']
@@ -183,7 +184,7 @@
flowPathFlagsStr += ","
flowPathFlagsStr += "KEEP_ONLY_FIRST_HOP_ENTRY"
- print "FlowPath: (flowId = %s installerId = %s flowPathType = %s flowPathUserState = %s flowPathFlags = 0x%x(%s) src = %s/%s dst = %s/%s idleTimeout = %s hardTimeout = %s)" % (flowId, installerId, flowPathType, flowPathUserState, flowPathFlags, flowPathFlagsStr, srcSwitch, srcPort, dstSwitch, dstPort, idleTimeout, hardTimeout)
+ print "FlowPath: (flowId = %s installerId = %s flowPathType = %s flowPathUserState = %s flowPathFlags = 0x%x(%s) src = %s/%s dst = %s/%s idleTimeout = %s hardTimeout = %s priority = %s)" % (flowId, installerId, flowPathType, flowPathUserState, flowPathFlags, flowPathFlagsStr, srcSwitch, srcPort, dstSwitch, dstPort, idleTimeout, hardTimeout, priority)
#
# Print the common match conditions
@@ -209,13 +210,14 @@
flowEntryId = f['flowEntryId']
idleTimeout = f['idleTimeout']
hardTimeout = f['hardTimeout']
+ priority = f['priority']
dpid = f['dpid']['value']
userState = f['flowEntryUserState']
switchState = f['flowEntrySwitchState']
match = f['flowEntryMatch'];
actions = f['flowEntryActions']['actions']
- print " FlowEntry: (%s, %s, %s, %s, idleTimeout = %s, hardTimeout = %s)" % (flowEntryId, dpid, userState, switchState, idleTimeout, hardTimeout)
+ print " FlowEntry: (%s, %s, %s, %s, idleTimeout = %s, hardTimeout = %s, priority = %s)" % (flowEntryId, dpid, userState, switchState, idleTimeout, hardTimeout, priority)
#
# Print the match conditions