Fix for Bug #308: Zombie Flows after Flow add/delete

Store the common matching conditions for all Flow Entries
in the FlowPath entry.
Thus, if the Shortest Path computation fails and the Flow Entries
are deleted, those common matching conditions are preserved.
diff --git a/web/add_flow.py b/web/add_flow.py
index 5a248eb..4f502f6 100755
--- a/web/add_flow.py
+++ b/web/add_flow.py
@@ -340,6 +340,9 @@
   flow_path['flowId'] = flow_id
   flow_path['installerId'] = installer_id
 
+  if (len(match) > 0):
+    flow_path['flowEntryMatch'] = copy.deepcopy(match)
+
   #
   # Add the match conditions to each flow entry
   #
@@ -393,7 +396,6 @@
     dst_port = {}
     src_switch_port = {}
     dst_switch_port = {}
-    flow_entry = {}
     flow_entries = []
 
     src_dpid['value'] = parsed_args[idx]['my_src_dpid']
@@ -404,9 +406,6 @@
     src_switch_port['port'] = src_port
     dst_switch_port['dpid'] = dst_dpid
     dst_switch_port['port'] = dst_port
-    match = parsed_args[idx]['match']
-    flow_entry['flowEntryMatch'] = match
-    flow_entries.append(flow_entry)
 
     data_path['srcPort'] = copy.deepcopy(src_switch_port)
     data_path['dstPort'] = copy.deepcopy(dst_switch_port)
diff --git a/web/get_flow.py b/web/get_flow.py
index 5704457..033176d 100755
--- a/web/get_flow.py
+++ b/web/get_flow.py
@@ -42,6 +42,61 @@
   dstPort = parsedResult['dataPath']['dstPort']['port']['value']
 
   print "FlowPath: (flowId = %s installerId = %s src = %s/%s dst = %s/%s)" % (flowId, installerId, srcSwitch, srcPort, dstSwitch, dstPort)
+  match = parsedResult['flowEntryMatch'];
+  #
+  # Print the common conditions
+  #
+  if match == None:
+    print "   Match: %s" % (match)
+  else:
+    # inPort = match['inPort']
+    # matchInPort = match['matchInPort']
+    srcMac = match['srcMac']
+    matchSrcMac = match['matchSrcMac']
+    dstMac = match['dstMac']
+    matchDstMac = match['matchDstMac']
+    vlanId = match['vlanId']
+    matchVlanId = match['matchVlanId']
+    vlanPriority = match['vlanPriority']
+    matchVlanPriority = match['matchVlanPriority']
+    ethernetFrameType = match['ethernetFrameType']
+    matchEthernetFrameType = match['matchEthernetFrameType']
+    ipToS = match['ipToS']
+    matchIpToS = match['matchIpToS']
+    ipProto = match['ipProto']
+    matchIpProto = match['matchIpProto']
+    srcIPv4Net = match['srcIPv4Net']
+    matchSrcIPv4Net = match['matchSrcIPv4Net']
+    dstIPv4Net = match['dstIPv4Net']
+    matchDstIPv4Net = match['matchDstIPv4Net']
+    srcTcpUdpPort = match['srcTcpUdpPort']
+    matchSrcTcpUdpPort = match['matchSrcTcpUdpPort']
+    dstTcpUdpPort = match['dstTcpUdpPort']
+    matchDstTcpUdpPort = match['matchDstTcpUdpPort']
+    # if matchInPort == True:
+    #  print "    inPort: %s" % inPort['value']
+    if matchSrcMac == True:
+      print "    srcMac: %s" % srcMac['value']
+    if matchDstMac == True:
+      print "    dstMac: %s" % dstMac['value']
+    if matchVlanId == True:
+      print "    vlanId: %s" % vlanId
+    if matchVlanPriority == True:
+      print "    vlanPriority: %s" % vlanPriority
+    if matchEthernetFrameType == True:
+      print "    ethernetFrameType: %s" % hex(ethernetFrameType)
+    if matchIpToS == True:
+      print "    ipToS: %s" % ipToS
+    if matchIpProto == True:
+      print "    ipProto: %s" % ipProto
+    if matchSrcIPv4Net == True:
+      print "    srcIPv4Net: %s" % srcIPv4Net['value']
+    if matchDstIPv4Net == True:
+      print "    dstIPv4Net: %s" % dstIPv4Net['value']
+    if matchSrcTcpUdpPort == True:
+      print "    srcTcpUdpPort: %s" % srcTcpUdpPort
+    if matchDstTcpUdpPort == True:
+      print "    dstTcpUdpPort: %s" % dstTcpUdpPort
 
   for f in parsedResult['dataPath']['flowEntries']:
     flowEntryId = f['flowEntryId']
diff --git a/web/js/main.js b/web/js/main.js
index 9fb6f66..51ffd1a 100644
--- a/web/js/main.js
+++ b/web/js/main.js
@@ -14,7 +14,7 @@
    limitations under the License.
 */
 
-var hackBase = "http://localhost:9000"; // put a URL here to access a different REST server
+var hackBase = "http://vm-ubuntu:9000"; // put a URL here to access a different REST server
 
 var AppRouter = Backbone.Router.extend({