Aggressively purging Accton switch

Change-Id: Ie523895ecbb0a84b155b621f6b7cb8677a2edc83
diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index 36db256..b2a11be 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -190,13 +190,12 @@
     """
 
     def runTest(self):
-
+        Groups = Queue.LifoQueue()
         try:
             intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
             dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip=0xc0a80001
             ports = sorted(config["port_map"].keys())
-            Groups = Queue.LifoQueue()
 
             for port in ports:
                 #add l2 interface group
@@ -241,11 +240,11 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             ports = sorted(config["port_map"].keys())
             vlan_id = 1
 
-            Groups = Queue.LifoQueue()
             for port in ports:
                 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
                                                           vlan_id, True, False)
@@ -332,10 +331,11 @@
     """
 
     def runTest(self):
+
+        Groups = Queue.LifoQueue()
         try:
             ports = sorted(config["port_map"].keys())
             vlan_id = 1;
-            Groups = Queue.LifoQueue()
             for port in ports:
                 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
                                                           vlan_id, True, False)
@@ -370,10 +370,10 @@
 
 class Mtu1500(base_tests.SimpleDataPlane):
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             ports = sorted(config["port_map"].keys())
             vlan_id = 18
-            Groups = Queue.LifoQueue()
             for port in ports:
                 L2gid, msg = add_one_l2_interface_group(self.controller, port,
                                                         vlan_id, True, False)
@@ -411,6 +411,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             test_id = 26
             if len(config["port_map"]) < 2:
@@ -421,7 +422,6 @@
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 vlan_id = port + test_id
@@ -485,6 +485,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
@@ -494,7 +495,6 @@
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 id = port
@@ -566,6 +566,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
@@ -575,7 +576,6 @@
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 id = port
@@ -648,8 +648,8 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
-            Groups = Queue.LifoQueue()
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
                 return
@@ -725,6 +725,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
@@ -734,7 +735,6 @@
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 id = port
@@ -803,6 +803,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
@@ -810,7 +811,6 @@
             intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
-            Groups = Queue.LifoQueue()
             ports = config["port_map"].keys()
             for port in ports:
                 # add l2 interface group
@@ -888,8 +888,8 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
-            Groups = Queue.LifoQueue()
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
                 return
@@ -1056,12 +1056,12 @@
         """
         port1 (vlan 300)-> All Ports (vlan 300)
         """
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 3:
                 logging.info("Port count less than 3, can't run this case")
                 assert (False)
                 return
-            Groups = Queue.LifoQueue()
             vlan_id = 300
             intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
             intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
@@ -1134,8 +1134,8 @@
         """
         port1 (vlan 1)-> port 2 (vlan 2)
         """
+        Groups = Queue.LifoQueue()
         try:
-            Groups = Queue.LifoQueue()
             if len(config["port_map"]) < 3:
                 logging.info("Port count less than 3, can't run this case")
                 assert (False)
@@ -1221,8 +1221,8 @@
         Receive MPLS packet
     """
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
-            Groups = Queue.LifoQueue()
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
                 return
@@ -1296,8 +1296,8 @@
         Receive MPLS packet
     """
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
-            Groups = Queue.LifoQueue()
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
                 return
@@ -1365,17 +1365,16 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             test_id = 26
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
                 return
-
             intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 vlan_id = port + test_id
@@ -1438,6 +1437,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             if len(config["port_map"]) < 2:
                 logging.info("Port count less than 2, can't run this case")
@@ -1447,7 +1447,6 @@
             dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
             dip = 0xc0a80001
             ports = config["port_map"].keys()
-            Groups = Queue.LifoQueue()
             for port in ports:
                 # add l2 interface group
                 vlan_id = port
@@ -1629,6 +1628,7 @@
     """
 
     def runTest(self):
+        Groups = Queue.LifoQueue()
         try:
             ports = sorted(config["port_map"].keys())
 
@@ -1647,5 +1647,4 @@
                 verify_no_other_packets(self)
         finally:
             delete_all_flows(self.controller)
-            delete_groups(self.controller, Groups)
             delete_all_groups(self.controller)
\ No newline at end of file
diff --git a/ofdpa/ofdpa_utils.py b/ofdpa/ofdpa_utils.py
deleted file mode 100644
index 4fa4d0a..0000000
--- a/ofdpa/ofdpa_utils.py
+++ /dev/null
@@ -1,156 +0,0 @@
-"""
-
-A set of inter-test utility functions for dealing with OF-DPA
-
-
-"""
-
-import logging
-import ofp
-
-from oftest import config
-from oftest.testutils import *
-
-
-
-class table(object):
-    """ Metadata on each OFDPA table """
-    def __init__(self, table_id, table_name):
-        self.table_id = table_id
-        self.table_name = table_name
-    # TODO consider adding type checking verification here
-
-INGRESS_TABLE           = table(0, "Ingress")
-VLAN_TABLE              = table(10, "VLAN")
-MACTERM_TABLE           = table(20, "MacTerm")
-UNICAST_ROUTING_TABLE   = table(30, "Unicast Routing")
-MULTICAST_ROUTING_TABLE = table(40, "Multicast Routing")
-BRIDGING_TABLE          = table(50, "Bridging Table")
-ACL_TABLE               = table(60, "ACL Policy Table")
-#.... FIXME add all tables
-
-DEFAULT_VLAN = 1
-
-def enableVlanOnPort(controller, vlan, port=ofp.OFPP_ALL, priority=0):
-    if port == ofp.OFPP_ALL:
-        ports = sorted(config["port_map"].keys())
-    else:
-        ports = [port]
-    for port in ports:
-        tagged_match = ofp.match([
-                ofp.oxm.in_port(port),
-                ofp.oxm.vlan_vid(vlan | ofp.OFPVID_PRESENT)
-                ])
-
-        request = ofp.message.flow_add(
-            table_id = VLAN_TABLE.table_id,
-            cookie = 0xdead,
-            match = tagged_match,
-            instructions = [
-                ofp.instruction.goto_table(MACTERM_TABLE.table_id),
-#                 ofp.instruction.apply_actions(
-#                     actions=[
-#                         ofp.action.push_vlan(ethertype=0x8100), # DO NOT PUT THIS FOR OF-DPA 2.0 EA1 - seems to not matter for EA2
-#                         ofp.action.set_field(ofp.oxm.vlan_vid( ofp.OFPVID_PRESENT | vlan))
-#                     ]),
-                    ],
-            buffer_id = ofp.OFP_NO_BUFFER,
-            priority = priority)
-
-        logging.info("Inserting vlan rule allowing tagged vlan %d on port %d" % (vlan, port))
-        controller.message_send(request)
-        do_barrier(controller)
-        verify_no_errors(controller)
-
-
-def installDefaultVlan(controller, vlan=DEFAULT_VLAN, port=ofp.OFPP_ALL, priority=0):
-    """ Insert a rule that maps all untagged traffic to vlan $vlan
-
-    In OFDPA, table 10 (the vlan table) requires that all traffic be
-    mapped to an internal vlan else the packets be dropped.  This function
-    sets up a default vlan mapping all untagged traffic to an internal VLAN.
-
-    With OF-DPA, before you can insert a 'untagged to X' rule on a
-    port, you must first insert a 'X --> X' rule for the same port.
-
-    Further, the 'X --> X' rule must set ofp.OFPVID_PRESENT even
-    though 'X' is non-zero.
-
-    The 'controller' variable is self.controller from a test
-    """
-    # OFDPA seems to be dumb and wants each port set individually
-    #       Can't set all ports by using OFPP_ALL
-    if port == ofp.OFPP_ALL:
-        ports = sorted(config["port_map"].keys())
-    else:
-        ports = [port]
-
-    for port in ports:
-        # enable this vlan on this port before we can map untagged packets to the vlan
-        enableVlanOnPort(controller, vlan, port)
-
-        untagged_match = ofp.match([
-                ofp.oxm.in_port(port),
-                # OFDPA 2.0 says untagged is vlan_id=0, mask=ofp.OFPVID_PRESENT
-                ofp.oxm.vlan_vid_masked(0,ofp.OFPVID_PRESENT)    # WTF OFDPA 2.0EA2 -- really!?
-                ])
-
-        request = ofp.message.flow_add(
-            table_id = VLAN_TABLE.table_id,
-            cookie = 0xbeef,
-            match = untagged_match,
-            instructions = [
-                ofp.instruction.apply_actions(
-                    actions=[
-                        #ofp.action.push_vlan(ethertype=0x8100),
-                        ofp.action.set_field(ofp.oxm.vlan_vid(ofp.OFPVID_PRESENT | vlan))
-                    ]),
-                ofp.instruction.goto_table(MACTERM_TABLE.table_id)   
-                    ],
-            buffer_id = ofp.OFP_NO_BUFFER,
-            priority = priority)
-
-        logging.info("Inserting default vlan sending all untagged traffic to vlan %d on port %d" % (vlan, port))
-        controller.message_send(request)
-        do_barrier(controller)
-        verify_no_errors(controller)
-
-
-_group_types = {
-    "L2 Interface": 0,
-    "L2 Rewrite" : 1,
-    "L3 Unicast" : 2,
-    "L2 Multicast" : 3,
-    "L2 Flood" : 4,
-    "L3 Interface" : 5,
-    "L3 Multicast": 6,
-    "L3 ECMP": 7,
-    "L2 Data Center Overlay": 8,
-    "MPLS Label" : 9,
-    "MPLS Forwarding" :10,
-    "L2 Unfiltered Interface": 11,
-    "L2 Loopback": 12,
-}
-
-
-def makeGroupID(groupType, local_id):
-    """ Group IDs in OF-DPA have rich meaning
-
-    @param groupType is a key in _group_types
-    @param local_id is an integer 0<= local_id < 2**27,
-        but it may have more semantic meaning depending on the
-        groupType
-
-
-    Read Section 4.3 of the OF-DPA manual on groups for 
-    details
-    """
-    if groupType not in _group_types:
-        raise KeyError("%s not a valid OF-DPA group type" % groupType)
-    if local_id < 0 or local_id >=134217728:
-        raise ValueError("local_id %d must be  0<= local_id < 2**27" % local_id)
-    return (_group_types[groupType] << 28) + local_id
-
-
-def delete_all_recursive_groups(controller):
-    pass