Actually working CHO
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 93dc11b..d7b1e4d 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -42,7 +42,7 @@
         cell_name = main.params[ 'ENV' ][ 'cellName' ]
         git_pull = main.params[ 'GIT' ][ 'autoPull' ]
         git_branch = main.params[ 'GIT' ][ 'branch' ]
-        
+        main.newTopo = ""
         main.CLIs = []
         main.nodes = []
         for i in range( 1, int(main.numCtrls) + 1 ):
@@ -102,8 +102,8 @@
                                      onfail="Test step FAIL" )
             uninstallResult = ( uninstallResult and u_result )
 
-        main.step( "Removing copy-cat logs from ONOS nodes" )
-        main.ONOSbench.onosRemoveRaftLogs()
+        #main.step( "Removing copy-cat logs from ONOS nodes" )
+        #main.ONOSbench.onosRemoveRaftLogs()
 
         main.step( "Install ONOS package on all Nodes" )
         installResult = main.TRUE
@@ -126,7 +126,7 @@
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
             statusResult = ( statusResult and onos_status )
-
+        
         main.step( "Start ONOS CLI on all nodes" )
         cliResult = main.TRUE
         karafTimeout = "3600000"
@@ -152,8 +152,8 @@
         
         if not startCliResult:
                 main.log.info("ONOS CLI did not start up properly")
-                main.cleanup()
-                main.exit()
+                #main.cleanup()
+                #main.exit()
         else:
             main.log.info("Successful CLI startup")
             startCliResult = main.TRUE
@@ -164,28 +164,35 @@
                                  onpass="Set up test environment PASS",
                                  onfail="Set up test environment FAIL" )
         time.sleep(30)
+
     def CASE2( self, main ):
         """
-        This test loads a Topology (ATT) on Mininet and balances all switches.
+        This test script Loads a new Topology (Att) on CHO setup and balances all switches
         """
         import re
         import time
         import copy
+
         main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
         main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
         main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
-        main.pingTimeout = 60
+        main.pingTimeout = 60 
         main.log.report(
-            "Assign and Balance all Mininet switches across controllers" )
+            "Load Att topology and Balance all Mininet switches across controllers" )
         main.log.report(
-            "_________________________________________________________" )
-        # need to wait here for sometime. This will be removed once ONOS is
-        # stable enough
-        time.sleep( 15 )
+            "________________________________________________________________________" )
         main.case(
             "Assign and Balance all Mininet switches across controllers" )
+        main.step( "Stop any previous Mininet network topology" )
+        cliResult = main.TRUE
+        if main.newTopo == main.params['TOPO3']['topo']:
+            stopStatus = main.Mininet1.stopNet( fileName = "topoSpine" )
+
+        main.step( "Start Mininet with Att topology" )
+        main.newTopo = main.params['TOPO1']['topo']
+        startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+
         main.step( "Assign switches to controllers" )
-        netStatus = main.Mininet1.startNet()
         for i in range( 1, ( main.numMNswitches + 1 ) ):  # 1 to ( num of switches +1 )
             main.Mininet1.assignSwController(
                 sw=str( i ),
@@ -214,19 +221,22 @@
             main.log.report( "Controller assignment successfull" )
         else:
             main.log.report( "Controller assignment failed" )
-        time.sleep( 15 )
-
-        #main.step( "Balance devices across controllers" )
-        #for i in range( int( main.numCtrls ) ):
-        #    balanceResult = main.ONOScli1.balanceMasters()
+        time.sleep( 5 )
+        #Don't balance master for now..
+        """
+        main.step( "Balance devices across controllers" )
+        for i in range( int( main.numCtrls ) ):
+            balanceResult = main.ONOScli1.balanceMasters()
             # giving some breathing time for ONOS to complete re-balance
-        #    time.sleep( 3 )
-
-        #utilities.assert_equals(
-         #   expect=main.TRUE,
-          #  actual=balanceResult,
-           # onpass="Assign and Balance devices test PASS",
-            #onfail="Assign and Balance devices test FAIL" )
+            time.sleep( 3 )
+        """
+        case2Result = ( switch_mastership and startStatus )
+        time.sleep(45)
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case2Result,
+            onpass="Starting new Att topology test PASS",
+            onfail="Starting new Att topology test FAIL" )
 
     def CASE3( self, main ):
         """
@@ -251,8 +261,7 @@
         topology_result = main.ONOSbench.getTopology( topology_output )
         numOnosDevices = topology_result[ 'deviceCount' ]
         numOnosLinks = topology_result[ 'linkCount' ]
-        print numOnosDevices
-        print numOnosLinks
+        topoResult = main.TRUE
 
         if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks >= int(numOnosLinks) ) ):
             main.step( "Store Device DPIDs" )
@@ -330,24 +339,26 @@
             main.log.info("Devices (actual): %s, Links (actual): %s" %
                     ( numOnosDevices , numOnosLinks ) )
             main.log.info("Topology does not match, exiting CHO test...")
+            topoResult = main.FALSE
+            
             #time.sleep(300)
-            main.cleanup()
-            main.exit()
+            #main.cleanup()
+            #main.exit()
 
         # just returning TRUE for now as this one just collects data
-        case3Result = main.TRUE
+        case3Result = topoResult
         utilities.assert_equals( expect=main.TRUE, actual=case3Result,
                                  onpass="Saving ONOS topology data test PASS",
                                  onfail="Saving ONOS topology data test FAIL" )
 
     def CASE4( self, main ):
         """
-        Enable onos-app-fwd, Verify Reactive forwarding through ping all and Disable it
+        Verify Reactive forwarding (Att Topology)
         """
         import re
         import copy
         import time
-        main.log.report( "Enable Reactive forwarding and Verify ping all" )
+        main.log.report( "Verify Reactive forwarding (Att Topology)" )
         main.log.report( "______________________________________________" )
         main.case( "Enable Reactive forwarding and Verify ping all" )
         main.step( "Enable Reactive forwarding" )
@@ -373,8 +384,8 @@
         
         if not installResult:
                 main.log.info("Did not install onos-app-fwd feature properly")
-                main.cleanup()
-                main.exit()
+                #main.cleanup()
+                #main.exit()
         else:
             main.log.info("Successful feature:install onos-app-fwd")
         main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
@@ -416,14 +427,192 @@
         
         if not uninstallResult:
                 main.log.info("Did not uninstall onos-app-fwd feature properly")
-                main.cleanup()
-                main.exit()
+                #main.cleanup()
+                #main.exit()
         else:
             main.log.info("Successful feature:uninstall onos-app-fwd")
         main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
 
         # Waiting for reative flows to be cleared.
+        time.sleep( 20 )
+        case4Result =  installResult and uninstallResult and ping_result
+        utilities.assert_equals( expect=main.TRUE, actual=case4Result,
+                                 onpass="Reactive Mode Pingall test PASS",
+                                 onfail="Reactive Mode Pingall test FAIL" )
+
+    def CASE41( self, main ):
+        """
+        Verify Reactive forwarding (Chordal Topology)
+        """
+        import re
+        import copy
+        import time
+        main.log.report( "Verify Reactive forwarding (Chordal Topology)" )
+        main.log.report( "______________________________________________" )
+        main.case( "Enable Reactive forwarding and Verify ping all" )
+        main.step( "Enable Reactive forwarding" )
+        installResult = main.TRUE
+        feature = "onos-app-fwd"
+        
+        pool = []
+        time1 = time.time()
+        for cli in main.CLIs:
+            t = main.Thread( target=cli.featureInstall,
+                    threadID=main.threadID,
+                    name="featureInstall",
+                    args=['onos-app-fwd'])
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+            
+        installResult = main.TRUE
+        for t in pool:
+            t.join()
+            installResult = installResult and t.result
+        time2 = time.time()
+        
+        if not installResult:
+                main.log.info("Did not install onos-app-fwd feature properly")
+                #main.cleanup()
+                #main.exit()
+        else:
+            main.log.info("Successful feature:install onos-app-fwd")
+        main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
+        
         time.sleep( 5 )
+
+        main.step( "Verify Pingall" )
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+
+        if ping_result == main.TRUE:
+            main.log.report( "Pingall Test in Reactive mode successful" )
+        else:
+            main.log.report( "Pingall Test in Reactive mode failed" )
+
+        main.step( "Disable Reactive forwarding" )
+        uninstallResult = main.TRUE
+        pool = []
+        time1 = time.time()
+        for cli in main.CLIs:
+            t = main.Thread( target=cli.featureUninstall,
+                             threadID=main.threadID,
+                             name="featureUninstall",
+                             args=['onos-app-fwd'])
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+        for t in pool:
+            t.join()
+            uninstallResult = uninstallResult and t.result
+        time2 = time.time()
+        
+        if not uninstallResult:
+                main.log.info("Did not uninstall onos-app-fwd feature properly")
+                #main.cleanup()
+                #main.exit()
+        else:
+            main.log.info("Successful feature:uninstall onos-app-fwd")
+        main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
+
+        # Waiting for reative flows to be cleared.
+        time.sleep( 20 )
+        case4Result =  installResult and uninstallResult and ping_result
+        utilities.assert_equals( expect=main.TRUE, actual=case4Result,
+                                 onpass="Reactive Mode Pingall test PASS",
+                                 onfail="Reactive Mode Pingall test FAIL" )
+
+    def CASE42( self, main ):
+        """
+        Verify Reactive forwarding (Spine Topology)
+        """
+        import re
+        import copy
+        import time
+        main.log.report( "Verify Reactive forwarding (Spine Topology)" )
+        main.log.report( "______________________________________________" )
+        main.case( "Enable Reactive forwarding and Verify ping all" )
+        main.step( "Enable Reactive forwarding" )
+        installResult = main.TRUE
+        feature = "onos-app-fwd"
+        
+        pool = []
+        time1 = time.time()
+        for cli in main.CLIs:
+            t = main.Thread( target=cli.featureInstall,
+                    threadID=main.threadID,
+                    name="featureInstall",
+                    args=['onos-app-fwd'])
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+            
+        installResult = main.TRUE
+        for t in pool:
+            t.join()
+            installResult = installResult and t.result
+        time2 = time.time()
+        
+        if not installResult:
+                main.log.info("Did not install onos-app-fwd feature properly")
+                #main.cleanup()
+                #main.exit()
+        else:
+            main.log.info("Successful feature:install onos-app-fwd")
+        main.log.info("Time for feature:install onos-app-fwd: %2f seconds" %(time2-time1))
+        
+        time.sleep( 5 )
+
+        main.step( "Verify Pingall" )
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall(timeout=main.pingTimeout)
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+
+        if ping_result == main.TRUE:
+            main.log.report( "Pingall Test in Reactive mode successful" )
+        else:
+            main.log.report( "Pingall Test in Reactive mode failed" )
+
+        main.step( "Disable Reactive forwarding" )
+        uninstallResult = main.TRUE
+        pool = []
+        time1 = time.time()
+        for cli in main.CLIs:
+            t = main.Thread( target=cli.featureUninstall,
+                             threadID=main.threadID,
+                             name="featureUninstall",
+                             args=['onos-app-fwd'])
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+        for t in pool:
+            t.join()
+            uninstallResult = uninstallResult and t.result
+        time2 = time.time()
+        
+        if not uninstallResult:
+                main.log.info("Did not uninstall onos-app-fwd feature properly")
+                #main.cleanup()
+                #main.exit()
+        else:
+            main.log.info("Successful feature:uninstall onos-app-fwd")
+        main.log.info("Time for feature:uninstall onos-app-fwd: %2f seconds" %(time2-time1))
+
+        # Waiting for reative flows to be cleared.
+        time.sleep( 20 )
         case4Result =  installResult and uninstallResult and ping_result
         utilities.assert_equals( expect=main.TRUE, actual=case4Result,
                                  onpass="Reactive Mode Pingall test PASS",
@@ -526,9 +715,9 @@
 
     def CASE6( self ):
         """
-        Install 300 host intents and verify ping all
+        Install 300 host intents and verify ping all (Att Topology)
         """
-        main.log.report( "Add 300 host intents and verify pingall" )
+        main.log.report( "Add 300 host intents and verify pingall (Att Topology)" )
         main.log.report( "_______________________________________" )
         import itertools
         import time
@@ -539,6 +728,11 @@
         
         intentIdList = []
         time1 = time.time()
+        """
+        for i in xrange(0 ,len(hostCombos)):
+            tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
+            intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
+        """
         for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
             pool = []
             for cli in main.CLIs:
@@ -549,7 +743,7 @@
                         name="addHostIntent",
                         args=[hostCombos[i][0],hostCombos[i][1]])
                 pool.append(t)
-                time.sleep(1)
+                #time.sleep(1)
                 t.start()
                 i = i + 1
                 main.threadID = main.threadID + 1
@@ -557,12 +751,13 @@
                 thread.join()
                 intentIdList.append(thread.result)
         time2 = time.time()
-        main.log.info("Time for adding host intents: %2f seconds" %(time2-time1))
+        main.log.info("Time for adding host intents: %2f seconds" %(time2-time1)) 
         intentResult = main.TRUE
         intentsJson = main.ONOScli2.intents()
         getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
                 intentsJson = intentsJson)
         print getIntentStateResult
+        # Takes awhile for all the onos to get the intents
         time.sleep(30)
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
@@ -588,7 +783,7 @@
 
     def CASE70( self, main ):
         """
-        Randomly bring some core links down and verify ping all ( Host Intents Scenario )
+        Randomly bring some core links down and verify ping all ( Host Intents-Att Topo)
         """
         import random
         main.randomLink1 = []
@@ -603,15 +798,15 @@
         switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
         link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
-        main.log.report( "_________________________________________________________________" )
+        main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Att Topo)" )
+        main.log.report( "___________________________________________________________________________" )
         main.case( "Host intents - Randomly bring some core links down and verify ping all" )
         main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
         if ( int( switchLinksToToggle ) ==
              0 or int( switchLinksToToggle ) > 5 ):
             main.log.info( "Please check your PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
-            main.cleanup()
-            main.exit()
+            #main.cleanup()
+            #main.exit()
         else:
             main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
 
@@ -667,7 +862,7 @@
 
     def CASE80( self, main ):
         """
-        Bring the core links up that are down and verify ping all ( Host Intents Scenario )
+        Bring the core links up that are down and verify ping all ( Host Intents-Att Topo )
         """
         import random
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
@@ -677,7 +872,7 @@
         switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
 
         main.log.report(
-            "Host intents - Bring the core links up that are down and verify ping all" )
+            "Bring the core links up that are down and verify ping all (Host Intents-Att Topo" )
         main.log.report(
             "__________________________________________________________________" )
         main.case(
@@ -732,7 +927,7 @@
 
     def CASE71( self, main ):
         """
-        Randomly bring some core links down and verify ping all ( Point Intents Scenario )
+        Randomly bring some core links down and verify ping all ( Point Intents-Att Topo )
         """
         import random
         main.randomLink1 = []
@@ -747,7 +942,7 @@
         switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
         link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
 
-        main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
+        main.log.report( "Randomly bring some core links down and verify ping all (Point Intents-Att Topo" )
         main.log.report( "__________________________________________________________________" )
         main.case( "Point Intents - Randomly bring some core links down and verify ping all" )
         main.step( "Verify number of Switch links to toggle on each Core Switch are between 1 - 5" )
@@ -755,8 +950,8 @@
              0 or int( switchLinksToToggle ) > 5 ):
             main.log.info(
                 "Please check you PARAMS file. Valid range for number of switch links to toggle is between 1 to 5" )
-            main.cleanup()
-            main.exit()
+            #main.cleanup()
+            #main.exit()
         else:
             main.log.info(
                 "User provided Core switch links range to toggle is correct, proceeding to run the test" )
@@ -813,7 +1008,7 @@
 
     def CASE81( self, main ):
         """
-        Bring the core links up that are down and verify ping all ( Point Intents Scenario )
+        Bring the core links up that are down and verify ping all ( Point Intents-Att Topo )
         """
         import random
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
@@ -823,7 +1018,7 @@
         switchLinksToToggle = main.params[ 'CORELINKS' ][ 'toggleLinks' ]
 
         main.log.report(
-            "Point intents - Bring the core links up that are down and verify ping all" )
+            "Bring the core links up that are down and verify ping all (Point Intents-Att Topo" )
         main.log.report(
             "___________________________________________________________________" )
         main.case(
@@ -876,56 +1071,272 @@
                                  onpass="Link Up Test PASS",
                                  onfail="Link Up Test FAIL" )
 
+    def CASE72( self, main ):
+        """
+        Randomly bring some links down and verify ping all ( Host Intents-Chordal Topo)
+        """
+        import random
+        import itertools 
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        
+        main.log.report( "Randomly bring some core links down and verify ping all (Host Intents-Chordal Topo)" )
+        main.log.report( "___________________________________________________________________________" )
+        main.case( "Host intents - Randomly bring some core links down and verify ping all" )
+        switches = []
+        switchesComb = []
+        for i in range( main.numMNswitches ):
+            switches.append('s%d'%(i+1))
+        switchesLinksComb = list(itertools.combinations(switches,2))
+        main.randomLinks = random.sample(switchesLinksComb, 5 )
+        print main.randomLinks
+        main.step( "Cut links on random devices" )
+        
+        for switch in main.randomLinks:
+            main.Mininet1.link(
+                END1=switch[0],
+                END2=switch[1],
+                OPTION="down")
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkDown = main.ONOSbench.checkStatus(
+            topology_output, main.numMNswitches, str(
+                int( main.numMNlinks ) - 5 * 2 ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkDown,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkDown = main.FALSE
+        time1 = time.time()
+        pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult72 = pingResultLinkDown
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult72,
+                                 onpass="Random Link cut Test PASS",
+                                 onfail="Random Link cut Test FAIL" )
+
+    def CASE82( self, main ):
+        """
+        Bring the core links up that are down and verify ping all ( Host Intents Chordal Topo )
+        """
+        import random
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+       
+        main.log.report(
+            "Bring the core links up that are down and verify ping all (Host Intents-Chordal Topo" )
+        main.log.report(
+            "__________________________________________________________________" )
+        main.case(
+            "Host intents - Bring the core links up that are down and verify ping all" )
+        main.step( "Bring randomly cut links on devices up" )
+        
+        for switch in main.randomLinks:
+            main.Mininet1.link(
+                END1=switch[0],
+                END2=switch[1],
+                OPTION="up")
+
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkUp = main.ONOSbench.checkStatus(
+            topology_output,
+            main.numMNswitches,
+            str( main.numMNlinks ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkUp,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkUp = main.FALSE
+        time1 = time.time()
+        pingResultLinkUp = main.Mininet1.pingall()
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult82 = linkUp and pingResultLinkUp
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult82,
+                                 onpass="Link Up Test PASS",
+                                 onfail="Link Up Test FAIL" )
+ 
+    def CASE73( self, main ):
+        """
+        Randomly bring some core links down and verify ping all ( Host Intents-Spine Topo)
+        """
+        import random
+        main.pingTimeout = 600
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+
+        main.log.report( "Bring some core links down and verify ping all (Host Intents-Spine Topo)" )
+        main.log.report( "___________________________________________________________________________" )
+
+        main.someLinks = [('s1','s9'),('s3','s9'),('s6','s10'),('s8','s10')]
+        for switch in main.someLinks:
+            main.Mininet1.link(
+                END1=switch[0],
+                END2=switch[1],
+                OPTION="down" )
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkDown = main.ONOSbench.checkStatus(
+            topology_output, main.numMNswitches, str(
+                int( main.numMNlinks ) - 8 ))
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkDown,
+            onpass="Link Down discovered properly",
+            onfail="Link down was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkDown = main.FALSE
+        time1 = time.time()
+        pingResultLinkDown = main.Mininet1.pingall(timeout=main.pingTimeout)
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkDown,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult73 = linkDown and pingResultLinkDown
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult73,
+                                 onpass="Random Link cut Test PASS",
+                                 onfail="Random Link cut Test FAIL" )
+
+    def CASE83( self, main ):
+        """
+        Bring the core links up that are down and verify ping all ( Host Intents-Spine Topo )
+        """
+        import random
+
+        link_sleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
+        main.log.report(
+            "Bring the core links up that are down and verify ping all (Host Intents-Spine Topo" )
+        main.log.report(
+            "__________________________________________________________________" )
+        main.case(
+            "Host intents - Bring the core links up that are down and verify ping all" )
+        
+        for switch in main.someLinks:
+            main.Mininet1.link(
+                END1=switch[0],
+                END2=switch[1],
+                OPTION="up")
+        time.sleep( link_sleep )
+
+        topology_output = main.ONOScli2.topology()
+        linkUp = main.ONOSbench.checkStatus(
+            topology_output,
+            main.numMNswitches,
+            str( main.numMNlinks ) )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=linkUp,
+            onpass="Link up discovered properly",
+            onfail="Link up was not discovered in " +
+            str( link_sleep ) +
+            " seconds" )
+
+        main.step( "Verify Ping across all hosts" )
+        pingResultLinkUp = main.FALSE
+        time1 = time.time()
+        pingResultLinkUp = main.Mininet1.pingall()
+        time2 = time.time()
+        timeDiff = round( ( time2 - time1 ), 2 )
+        main.log.report(
+            "Time taken for Ping All: " +
+            str( timeDiff ) +
+            " seconds" )
+        utilities.assert_equals( expect=main.TRUE, actual=pingResultLinkUp,
+                                 onpass="PING ALL PASS",
+                                 onfail="PING ALL FAIL" )
+
+        caseResult83 = linkUp and pingResultLinkUp
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult83,
+                                 onpass="Link Up Test PASS",
+                                 onfail="Link Up Test FAIL" )
+        
     def CASE9( self ):
         """
-        Install 114 point intents and verify Ping all works
+        Install 300 point intents and verify ping all (Att Topology)
         """
-        import copy
-        main.log.report( "Install 114 point intents and verify Ping all" )
-        main.log.report( "___________________________________________" )
-        main.case( "Install 114 point intents and Ping all" )
-        deviceLinksCopy = copy.copy( main.deviceLinks )
-        main.step( "Install 114 point intents" )
-        for i in range( len( deviceLinksCopy ) ):
-            pointLink = str(
-                deviceLinksCopy[ i ] ).replace(
-                "src=",
-                "" ).replace(
-                "dst=",
-                "" ).split( ',' )
-            point1 = pointLink[ 0 ].split( '/' )
-            point2 = pointLink[ 1 ].split( '/' )
-            installResult = main.ONOScli1.addPointIntent(
-                point1[ 0 ], point2[ 0 ], int(
-                    point1[ 1 ] ), int(
-                    point2[ 1 ] ) )
-            if installResult == main.TRUE:
-                print "Installed Point intent between :", point1[ 0 ], int( point1[ 1 ] ), point2[ 0 ], int( point2[ 1 ] )
-
-        main.step( "Obtain the intent id's" )
-        intentsList = main.ONOScli1.getAllIntentIds()
-        ansi_escape = re.compile( r'\x1b[^m]*m' )
-        intentsList = ansi_escape.sub( '', intentsList )
-        intentsList = intentsList.replace(
-            " onos:intents | grep id=",
-            "" ).replace(
-            "id=",
-            "" ).replace(
-            "\r\r",
-             "" )
-        intentsList = intentsList.splitlines()
-        intentsList = intentsList[ 1: ]
+        main.log.report( "Add 300 point intents and verify pingall (Att Topology)" )
+        main.log.report( "_______________________________________" )
+        import itertools
+        import time
+        main.case( "Install 300 point intents" )
+        main.step( "Add point Intents" )
+        intentResult = main.TRUE
+        deviceCombos = list( itertools.permutations( main.deviceDPIDs, 2 ) ) 
+        
         intentIdList = []
-        for i in range( len( intentsList ) ):
-            intentsTemp = intentsList[ i ].split( ',' )
-            intentIdList.append( intentsTemp[ 0 ] )
-        print "Intent IDs: ", intentIdList
-        print "Total Intents installed: ", len( intentIdList )
-
+        time1 = time.time()
+        """
+        for i in xrange(0 ,len(hostCombos)):
+            tempId = ONOScli1.addHostIntent( hostCombos[i][0],hostCombos[i][1]] )
+            intentIdList.append(hostCombos[i][0],hostCombos[i][1]])
+        """
+        for i in xrange( 0, len( deviceCombos ), int(main.numCtrls) ):
+            pool = []
+            for cli in main.CLIs:
+                if i >= len( deviceCombos ):
+                    break
+                t = main.Thread( target=cli.addPointIntent,
+                        threadID=main.threadID,
+                        name="addPointIntent",
+                        args=[deviceCombos[i][0],deviceCombos[i][1],1,1,"IPV4"])
+                pool.append(t)
+                time.sleep(1)
+                t.start()
+                i = i + 1
+                main.threadID = main.threadID + 1
+            for thread in pool:
+                thread.join()
+                intentIdList.append(thread.result)
+        time2 = time.time()
+        main.log.info("Time for adding point intents: %2f seconds" %(time2-time1)) 
+        intentResult = main.TRUE
+        intentsJson = main.ONOScli2.intents()
+        getIntentStateResult = main.ONOScli1.getIntentState(intentsId = intentIdList,
+                intentsJson = intentsJson)
+        print getIntentStateResult
+        # Takes awhile for all the onos to get the intents
+        time.sleep(30)
         main.step( "Verify Ping across all hosts" )
         pingResult = main.FALSE
         time1 = time.time()
-        pingResult = main.Mininet1.pingall()
+        pingResult = main.Mininet1.pingall(timeout=main.pingTimeout)
         time2 = time.time()
         timeDiff = round( ( time2 - time1 ), 2 )
         main.log.report(
@@ -936,12 +1347,13 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        case8_result = installResult and pingResult
+        case6Result = ( intentResult and pingResult )
+        
         utilities.assert_equals(
             expect=main.TRUE,
-            actual=case8_result,
-            onpass="Ping all test after Point intents addition successful",
-            onfail="Ping all test after Point intents addition failed" )
+            actual=case6Result,
+            onpass="Install 300 point Intents and Ping All test PASS",
+            onfail="Install 300 point Intents and Ping All test FAIL" )
 
     def CASE90( self ):
         """
@@ -1176,6 +1588,8 @@
             results = main.TRUE
             main.log.info("Removing intent...")
             while moreIntents:
+                if removeIntentCount == 5:
+                    break
                 removeIntentCount = removeIntentCount + 1
                 intentsList1 = main.ONOScli1.getAllIntentIds()
                 if len( intentsList1 ) == 0:
@@ -1194,7 +1608,7 @@
                 print "Round %d intents to remove: " %(removeIntentCount)
                 print intentsList1
                 intentIdList1 = []
-                if ( len( intentsList1 ) > 1 ):
+                if ( len( intentsList1 ) > 0 ):
                     moreIntents = main.TRUE
                     for i in range( len( intentsList1 ) ):
                         intentsTemp1 = intentsList1[ i ].split( ',' )
@@ -1203,13 +1617,12 @@
                     print len(intentIdList1)
                     for intent in intentIdList1:
                         main.CLIs[0].removeIntent(intent,'org.onosproject.cli',True,False)
+                    time.sleep(10)
                 else:
                     time.sleep(15)
-                    if len(main.ONOScli1.intents()):
+                    if len( main.ONOScli1.intents()):
                         continue
                     break
-                if removeIntentCount == 5:
-                    break
 
             else:
                 print "There are no more intents that need to be removed"
@@ -1260,8 +1673,8 @@
         
         if( all(result == main.TRUE for result in results) == False):
                 main.log.info("Did not install onos-app-ifwd feature properly")
-                main.cleanup()
-                main.exit()
+                #main.cleanup()
+                #main.exit()
         else:
             main.log.info("Successful feature:install onos-app-ifwd")
             installResult = main.TRUE
@@ -1303,8 +1716,9 @@
         
         if( all(result == main.TRUE for result in results) == False):
                 main.log.info("Did not uninstall onos-app-ifwd feature properly")
-                main.cleanup()
-                main.exit()
+                uninstallResult = main.FALSE
+                #main.cleanup()
+                #main.exit()
         else:
             main.log.info("Successful feature:uninstall onos-app-ifwd")
             uninstallResult = main.TRUE
@@ -1326,40 +1740,23 @@
         import time
         import copy
 
-        Thread = imp.load_source('Thread','/home/admin/ONLabTest/TestON/tests/OnosCHO/Thread.py')
-        newTopo = main.params['TOPO2']['topo']
+        main.newTopo = main.params['TOPO2']['topo']
         main.numMNswitches = int ( main.params[ 'TOPO2' ][ 'numSwitches' ] )
         main.numMNlinks = int ( main.params[ 'TOPO2' ][ 'numLinks' ] )
         main.numMNhosts = int ( main.params[ 'TOPO2' ][ 'numHosts' ] )
-        main.pingTimeout = 60
-        
-        time.sleep(60)
+        main.pingTimeout = 120
         main.log.report(
             "Load Chordal topology and Balance all Mininet switches across controllers" )
         main.log.report(
             "________________________________________________________________________" )
-        # need to wait here for sometime until ONOS bootup
-        time.sleep( 15 )
         main.case(
             "Assign and Balance all Mininet switches across controllers" )
         main.step( "Stop any previous Mininet network topology" )
-        stopStatus = main.Mininet1.stopNet()
-
-        # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
-        main.step( "Stop ONOS on all Nodes" )
-        stopResult = main.TRUE
-        for i in range( 1, int( main.numCtrls ) + 1 ):
-            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
-            main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
-            sresult = main.ONOSbench.onosStop( ONOS_ip )
-            utilities.assert_equals( expect=main.TRUE, actual=sresult,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            stopResult = ( stopResult and sresult )
-
+        stopStatus = main.Mininet1.stopNet(fileName = "topoChordal" )
+        time.sleep(10)
         main.step( "Start Mininet with Chordal topology" )
-        startStatus = main.Mininet1.startNet(topoFile = newTopo)
-
+        startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+        time.sleep(15)
         main.step( "Assign switches to controllers" )
         for i in range( 1, ( main.numMNswitches + 1 ) ):  # 1 to ( num of switches +1 )
             main.Mininet1.assignSwController(
@@ -1390,61 +1787,23 @@
         else:
             main.log.report( "Controller assignment failed" )
         time.sleep( 5 )
-
-        main.step( "Start ONOS on all Nodes" )
-        startResult = main.TRUE
-        for i in range( 1, int( main.numCtrls ) + 1 ):
-            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
-            main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
-            sresult = main.ONOSbench.onosStart( ONOS_ip )
-            utilities.assert_equals( expect=main.TRUE, actual=sresult,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            startResult = ( startResult and sresult )
-
-        main.step( "Start ONOS CLI on all nodes" )
-        cliResult = main.TRUE
-        #karafTimeout = "3600000" # This is not needed here as it is already set before.
-        # need to wait here sometime for ONOS to bootup.
-        time.sleep( 30 )
-
-        main.log.step(" Start ONOS cli using thread ")
-        pool = []
-        time1 = time.time()
-        for i in range( int( main.numCtrls ) ):
-            t = main.Thread(target=cli.startOnosCli,
-                    threadID=main.threadID,
-                    name="startOnosCli",
-                    args=[nodes[i].ip_address])
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            cliResult = cliResult and t.result
-        time2 = time.time()
         
-        if not cliResult:
-                main.log.info("ONOS CLI did not start up properly")
-                main.cleanup()
-                main.exit()
-        else:
-            main.log.info("Successful CLI startup")
-        main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
-
+        #Don't balance master for now..
+        """
         main.step( "Balance devices across controllers" )
         for i in range( int( main.numCtrls ) ):
             balanceResult = main.ONOScli1.balanceMasters()
             # giving some breathing time for ONOS to complete re-balance
             time.sleep( 3 )
-
-        case12Result = ( startResult and cliResult )
+        """
+        case12Result = switch_mastership
+        time.sleep(30)
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case12Result,
             onpass="Starting new Chordal topology test PASS",
             onfail="Starting new Chordal topology test FAIL" )
-
+        
     def CASE13( self, main ):
         """
         This test script Loads a new Topology (Spine) on CHO setup and balances all switches
@@ -1453,44 +1812,29 @@
         import time
         import copy
 
-        newTopo = main.params['TOPO3']['topo']
+        main.newTopo = main.params['TOPO3']['topo']
         main.numMNswitches = int ( main.params[ 'TOPO3' ][ 'numSwitches' ] )
         main.numMNlinks = int ( main.params[ 'TOPO3' ][ 'numLinks' ] )
         main.numMNhosts = int ( main.params[ 'TOPO3' ][ 'numHosts' ] )
         main.pingTimeout = 600
         
-        time.sleep(60)
         main.log.report(
             "Load Spine and Leaf topology and Balance all Mininet switches across controllers" )
         main.log.report(
             "________________________________________________________________________" )
         # need to wait here for sometime until ONOS bootup
-        time.sleep( 15 )
         main.case(
             "Assign and Balance all Mininet switches across controllers" )
         main.step( "Stop any previous Mininet network topology" )
-        stopStatus = main.Mininet1.stopNet()
-
-        # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
-        main.step( "Stop ONOS on all Nodes" )
-        stopResult = main.TRUE
-        for i in range( 1, int( main.numCtrls ) + 1 ):
-            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
-            main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
-            sresult = main.ONOSbench.onosStop( ONOS_ip )
-            utilities.assert_equals( expect=main.TRUE, actual=sresult,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            stopResult = ( stopResult and sresult )
-
+        stopStatus = main.Mininet1.stopNet(fileName = "topoSpine" )
         main.step( "Start Mininet with Spine topology" )
-        startStatus = main.Mininet1.startNet(topoFile = newTopo)
-
+        startStatus = main.Mininet1.startNet(topoFile = main.newTopo)
+        time.sleep(20)
         main.step( "Assign switches to controllers" )
         for i in range( 1, ( main.numMNswitches + 1 ) ):  # 1 to ( num of switches +1 )
             main.Mininet1.assignSwController(
                 sw=str( i ),
-                count=int( main.numCtrls ),
+                count= 1,
                 ip1=main.ONOS1_ip,
                 port1=main.ONOS1_port,
                 ip2=main.ONOS2_ip,
@@ -1510,54 +1854,15 @@
                 switch_mastership = switch_mastership and main.TRUE
             else:
                 switch_mastership = main.FALSE
-
+        
         if switch_mastership == main.TRUE:
             main.log.report( "Controller assignment successfull" )
         else:
             main.log.report( "Controller assignment failed" )
         time.sleep( 5 )
-
-        main.step( "Start ONOS on all Nodes" )
-        startResult = main.TRUE
-        for i in range( 1, int( main.numCtrls ) + 1 ):
-            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
-            main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
-            sresult = main.ONOSbench.onosStart( ONOS_ip )
-            utilities.assert_equals( expect=main.TRUE, actual=sresult,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            startResult = ( startResult and sresult )
-
-        main.step( "Start ONOS CLI on all nodes" )
-        cliResult = main.TRUE
-        #karafTimeout = "3600000" # This is not needed here as it is already set before.
-        # need to wait here sometime for ONOS to bootup.
-        time.sleep( 30 )
-        
-        main.log.step(" Start ONOS cli using thread ")
-        pool = []
-        for i in range( int( main.numCtrls ) ):
-            t = main.Thread(target=cli.startOnosCli,
-                    threadID=main.threadID,
-                    name="startOnosCli",
-                    args=[nodes[i].ip_address])
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            cliResult = cliResult and t.result
-        time2 = time.time()
-        
-        if not cliResult:
-                main.log.info("ONOS CLI did not start up properly")
-                main.cleanup()
-                main.exit()
-        else:
-            main.log.info("Successful CLI startup")
-        main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
-
+        """
         main.step( "Balance devices across controllers" )
+        
         for i in range( int( main.numCtrls ) ):
             balanceResult = main.ONOScli1.balanceMasters()
             # giving some breathing time for ONOS to complete re-balance
@@ -1568,8 +1873,9 @@
             balanceResult = main.ONOScli1.balanceMasters()
             # giving some breathing time for ONOS to complete re-balance
             time.sleep( 3 )
-
-        case13Result = ( startResult and cliResult )
+        """
+        case13Result = switch_mastership
+        time.sleep(30)
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case13Result,
@@ -1580,7 +1886,7 @@
         """
         Install 300 host intents and verify ping all for Chordal Topology
         """
-        main.log.report( "Add 300 host intents and verify pingall" )
+        main.log.report( "Add 300 host intents and verify pingall (Chordal Topo)" )
         main.log.report( "_______________________________________" )
         import itertools
         
@@ -1640,17 +1946,17 @@
 
     def CASE15( self ):
         """
-        Install 300 host intents and verify ping all for Spine Topology
+        Install 2278 host intents and verify ping all for Spine Topology
         """
-        main.log.report( "Add 300 host intents and verify pingall" )
+        main.log.report( "Add 2278 host intents and verify pingall (Spine Topo)" )
         main.log.report( "_______________________________________" )
         import itertools
         
-        main.case( "Install 300 host intents" )
+        main.case( "Install 2278 host intents" )
         main.step( "Add host Intents" )
         intentResult = main.TRUE
         hostCombos = list( itertools.combinations( main.hostMACs, 2 ) ) 
-        
+        main.pingTimeout = 300
         intentIdList = []
         time1 = time.time()
         for i in xrange( 0, len( hostCombos ), int(main.numCtrls) ):
@@ -1696,7 +2002,69 @@
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case15Result,
-            onpass="Install 300 Host Intents and Ping All test PASS",
-            onfail="Install 300 Host Intents and Ping All test FAIL" )
+            onpass="Install 2278 Host Intents and Ping All test PASS",
+            onfail="Install 2278 Host Intents and Ping All test FAIL" )
+
+    def CASE99(self):
+        import time
+        # WORK AROUND FOR ONOS-581. STOP ONOS BEFORE ASSIGNING CONTROLLERS AT MININET & START ONCE DONE
+        main.step( "Stop ONOS on all Nodes" )
+        stopResult = main.TRUE
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            main.log.info( "Stopping ONOS Node IP: " + ONOS_ip )
+            sresult = main.ONOSbench.onosStop( ONOS_ip )
+            utilities.assert_equals( expect=main.TRUE, actual=sresult,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            stopResult = ( stopResult and sresult )
+
+        main.step( "Start ONOS on all Nodes" )
+        startResult = main.TRUE
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            main.log.info( "Starting ONOS Node IP: " + ONOS_ip )
+            sresult = main.ONOSbench.onosStart( ONOS_ip )
+            utilities.assert_equals( expect=main.TRUE, actual=sresult,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            startResult = ( startResult and sresult )
+    
+        main.step( "Start ONOS CLI on all nodes" )
+        cliResult = main.TRUE
+        time.sleep( 30 )
+        main.log.step(" Start ONOS cli using thread ")
+        pool = []
+        time1 = time.time()
+        for i in range( int( main.numCtrls ) ):
+            t = main.Thread(target=main.CLIs[i].startOnosCli,
+                    threadID=main.threadID,
+                    name="startOnosCli",
+                    args=[main.nodes[i].ip_address])
+            pool.append(t)
+            t.start()
+            main.threadID = main.threadID + 1
+        for t in pool:
+            t.join()
+            cliResult = cliResult and t.result
+        time2 = time.time()
+        
+        if not cliResult:
+                main.log.info("ONOS CLI did not start up properly")
+                #main.cleanup()
+                #main.exit()
+        else:
+            main.log.info("Successful CLI startup")
+        main.log.info("Time for connecting to CLI: %2f seconds" %(time2-time1))
+
+        case99Result = ( startResult and cliResult )
+        time.sleep(30)
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case99Result,
+            onpass="Starting new Chordal topology test PASS",
+            onfail="Starting new Chordal topology test FAIL" )
+
+