CHO tests with Chordal and Spine topology
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index ceedc19..af23c70 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -12,15 +12,36 @@
     # 10. Remove all intents on ONOS
     # 1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100
 
-    <testcases>1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100</testcases>
+    <testcases>1,2,3,4,5,12,3,4,5,13,3,4,5</testcases>
     <ENV>
         <cellName>choTest5</cellName>
     </ENV>
     <GIT>
         #autoPull 'on' or 'off'
-        <autoPull>on</autoPull>
-        <branch>onos-1.0</branch>
+        <autoPull>off</autoPull>
+        <branch>master</branch>
     </GIT>
+    <TOPO1>
+	<topo>~/mininet/custom/topoAtt.py</topo>
+	<numSwitches>25</numSwitches>
+	<numHosts>25</numHosts>
+	<numLinks>114</numLinks>
+	<numPaths>1</numPaths>
+    </TOPO1>
+    <TOPO2>
+	<topo>~/mininet/custom/topoChordal.py</topo>
+	<numSwitches>25</numSwitches>
+	<numHosts>25</numHosts>
+	<numLinks>600</numLinks>
+	<numPaths>1</numPaths>
+    </TOPO2>
+    <TOPO3>
+	<topo>~/mininet/custom/topoSpine.py</topo>
+	<numSwitches>78</numSwitches>
+	<numHosts>68</numHosts>
+	<numLinks>284</numLinks>
+	<numPaths>1</numPaths>
+    </TOPO3>
     <CTRL>
 	<numCtrl>5</numCtrl>
         <ip1>10.128.40.41</ip1>
@@ -38,13 +59,6 @@
 	<startMAC>00:00:00:00:00:01</startMAC>
 	<endMAC>00:00:00:00:00:19</endMAC>
     </HOSTS>
-    <ONOSTOPO>
-	<numDevices>25</numDevices>
-	<numLinks>114</numLinks>
-	<numHosts>25</numHosts>
-	<numIntents>300</numIntents>
-	<numPaths>1360</numPaths>
-    </ONOSTOPO>
     <CORELINKS>
         <toggleLinks>3</toggleLinks>
 	
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index db7bc4e..eb71518 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -11,13 +11,6 @@
 
     def __init__( self ):
         self.default = ''
-        global deviceDPIDs
-        global hostMACs
-        global deviceLinks
-        global deviceActiveLinksCount
-        global devicePortsEnabledCount
-        global installedIntents
-        global randomLink1, randomLink2, randomLink3, numSwitches, numLinks
 
     def CASE1( self, main ):
         """
@@ -31,9 +24,20 @@
         onos-wait-for-start
         """
         import time
+
+        main.numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+        main.ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
+        main.ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
+        main.ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
+        main.ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
+        main.ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
+        main.ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
+        main.ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
+        main.ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
+        main.ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
         cell_name = main.params[ 'ENV' ][ 'cellName' ]
         git_pull = main.params[ 'GIT' ][ 'autoPull' ]
-        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
         git_branch = main.params[ 'GIT' ][ 'branch' ]
 
         main.case( "Set up test environment" )
@@ -55,10 +59,14 @@
                                  onfail="Test step FAIL" )
 
         main.step( "mvn clean & install" )
-        mvn_result = main.ONOSbench.cleanInstall()
-        utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
+        if git_pull == 'on':
+            mvn_result = main.ONOSbench.cleanInstall()
+            utilities.assert_equals( expect=main.TRUE, actual=mvn_result,
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
+        else:
+            mvn_result = main.TRUE
+            main.log.info("Skipped mvn clean install as git pull is disabled in params file")
 
         main.ONOSbench.getVersion( report=True )
 
@@ -76,7 +84,7 @@
 
         main.step( "Uninstall ONOS package on all Nodes" )
         uninstallResult = main.TRUE
-        for i in range( 1, int( numCtrls ) + 1 ):
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             main.log.info( "Unintsalling package on ONOS Node IP: " + ONOS_ip )
             u_result = main.ONOSbench.onosUninstall( ONOS_ip )
@@ -90,7 +98,7 @@
 
         main.step( "Install ONOS package on all Nodes" )
         installResult = main.TRUE
-        for i in range( 1, int( numCtrls ) + 1 ):
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             main.log.info( "Intsalling package on ONOS Node IP: " + ONOS_ip )
             i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
@@ -101,7 +109,7 @@
 
         main.step( "Verify ONOS nodes UP status" )
         statusResult = main.TRUE
-        for i in range( 1, int( numCtrls ) + 1 ):
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             main.log.info( "ONOS Node " + ONOS_ip + " status:" )
             onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
@@ -115,8 +123,8 @@
         karafTimeout = "3600000"
         # need to wait here for sometime. This will be removed once ONOS is
         # stable enough
-        time.sleep( 15 )
-        for i in range( 1, int( numCtrls ) + 1 ):
+        time.sleep( 20 )
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             ONOScli = 'ONOScli' + str( i )
             main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
@@ -135,24 +143,15 @@
 
     def CASE2( self, main ):
         """
-        This test script still needs more refactoring
+        This test loads a Topology (ATT) on Mininet and balances all switches.
         """
         import re
         import time
         import copy
-        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
-        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
-        ONOS2_ip = main.params[ 'CTRL' ][ 'ip2' ]
-        ONOS3_ip = main.params[ 'CTRL' ][ 'ip3' ]
-        ONOS4_ip = main.params[ 'CTRL' ][ 'ip4' ]
-        ONOS5_ip = main.params[ 'CTRL' ][ 'ip5' ]
-        ONOS1_port = main.params[ 'CTRL' ][ 'port1' ]
-        ONOS2_port = main.params[ 'CTRL' ][ 'port2' ]
-        ONOS3_port = main.params[ 'CTRL' ][ 'port3' ]
-        ONOS4_port = main.params[ 'CTRL' ][ 'port4' ]
-        ONOS5_port = main.params[ 'CTRL' ][ 'port5' ]
+        main.numMNswitches = int ( main.params[ 'TOPO1' ][ 'numSwitches' ] )
+        main.numMNlinks = int ( main.params[ 'TOPO1' ][ 'numLinks' ] )
+        main.numMNhosts = int ( main.params[ 'TOPO1' ][ 'numHosts' ] )
 
-        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
         main.log.report(
             "Assign and Balance all Mininet switches across controllers" )
         main.log.report(
@@ -163,26 +162,27 @@
         main.case(
             "Assign and Balance all Mininet switches across controllers" )
         main.step( "Assign switches to controllers" )
-        for i in range( 1, 26 ):  # 1 to ( num of switches +1 )
+        netStatus = main.Mininet1.startNet()
+        for i in range( 1, ( main.numMNswitches + 1 ) ):  # 1 to ( num of switches +1 )
             main.Mininet1.assignSwController(
                 sw=str( i ),
-                count=int( numCtrls ),
-                ip1=ONOS1_ip,
-                port1=ONOS1_port,
-                ip2=ONOS2_ip,
-                port2=ONOS2_port,
-                ip3=ONOS3_ip,
-                port3=ONOS3_port,
-                ip4=ONOS4_ip,
-                port4=ONOS4_port,
-                ip5=ONOS5_ip,
-                port5=ONOS5_port )
+                count=int( main.numCtrls ),
+                ip1=main.ONOS1_ip,
+                port1=main.ONOS1_port,
+                ip2=main.ONOS2_ip,
+                port2=main.ONOS2_port,
+                ip3=main.ONOS3_ip,
+                port3=main.ONOS3_port,
+                ip4=main.ONOS4_ip,
+                port4=main.ONOS4_port,
+                ip5=main.ONOS5_ip,
+                port5=main.ONOS5_port )
 
         switch_mastership = main.TRUE
-        for i in range( 1, 26 ):
+        for i in range( 1, ( main.numMNswitches + 1 ) ):
             response = main.Mininet1.getSwController( "s" + str( i ) )
             print( "Response is " + str( response ) )
-            if re.search( "tcp:" + ONOS1_ip, response ):
+            if re.search( "tcp:" + main.ONOS1_ip, response ):
                 switch_mastership = switch_mastership and main.TRUE
             else:
                 switch_mastership = main.FALSE
@@ -191,19 +191,19 @@
             main.log.report( "Controller assignment successfull" )
         else:
             main.log.report( "Controller assignment failed" )
-        time.sleep( 5 )
+        time.sleep( 15 )
 
-        main.step( "Balance devices across controllers" )
-        for i in range( int( numCtrls ) ):
-            balanceResult = main.ONOScli1.balanceMasters()
+        #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 )
+        #    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" )
+        #utilities.assert_equals(
+         #   expect=main.TRUE,
+          #  actual=balanceResult,
+           # onpass="Assign and Balance devices test PASS",
+            #onfail="Assign and Balance devices test FAIL" )
 
     def CASE3( self, main ):
         """
@@ -212,11 +212,11 @@
         """
         import re
         import copy
-        deviceDPIDs = []
-        hostMACs = []
-        deviceLinks = []
-        deviceActiveLinksCount = []
-        devicePortsEnabledCount = []
+        main.deviceDPIDs = []
+        main.hostMACs = []
+        main.deviceLinks = []
+        main.deviceActiveLinksCount = []
+        main.devicePortsEnabledCount = []
 
         main.log.report(
             "Collect and Store topology details from ONOS before running any Tests" )
@@ -227,57 +227,64 @@
         main.step( "Collect and store current number of switches and links" )
         topology_output = main.ONOScli1.topology()
         topology_result = main.ONOSbench.getTopology( topology_output )
-        numSwitches = topology_result[ 'devices' ]
-        numLinks = topology_result[ 'links' ]
-        main.log.info(
-            "Currently there are %s switches and %s links" %
-            ( str( numSwitches ), str( numLinks ) ) )
+        numOnosDevices = topology_result[ 'devices' ]
+        numOnosLinks = topology_result[ 'links' ]
 
-        main.step( "Store Device DPIDs" )
-        for i in range( 1, 26 ):
-            deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
-        print "Device DPIDs in Store: \n", str( deviceDPIDs )
+        if ( ( main.numMNswitches == int(numOnosDevices) ) and ( main.numMNlinks == int(numOnosLinks) ) ):
+            main.step( "Store Device DPIDs" )
+            for i in range( 1, (main.numMNswitches+1) ):
+                main.deviceDPIDs.append( "of:00000000000000" + format( i, '02x' ) )
+            print "Device DPIDs in Store: \n", str( main.deviceDPIDs )
 
-        main.step( "Store Host MACs" )
-        for i in range( 1, 26 ):
-            hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
-        print "Host MACs in Store: \n", str( hostMACs )
+            main.step( "Store Host MACs" )
+            for i in range( 1, ( main.numMNhosts + 1 ) ):
+                main.hostMACs.append( "00:00:00:00:00:" + format( i, '02x' ) + "/-1" )
+            print "Host MACs in Store: \n", str( main.hostMACs )
 
-        main.step( "Collect and store all Devices Links" )
-        linksResult = main.ONOScli1.links( jsonFormat=False )
-        ansi_escape = re.compile( r'\x1b[^m]*m' )
-        linksResult = ansi_escape.sub( '', linksResult )
-        linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
-        linksResult = linksResult.splitlines()
-        linksResult = linksResult[ 1: ]
-        deviceLinks = copy.copy( linksResult )
-        print "Device Links Stored: \n", str( deviceLinks )
-        # this will be asserted to check with the params provided count of
-        # links
-        print "Length of Links Store", len( deviceLinks )
+            main.step( "Collect and store all Devices Links" )
+            linksResult = main.ONOScli1.links( jsonFormat=False )
+            ansi_escape = re.compile( r'\x1b[^m]*m' )
+            linksResult = ansi_escape.sub( '', linksResult )
+            linksResult = linksResult.replace( " links", "" ).replace( "\r\r", "" )
+            linksResult = linksResult.splitlines()
+            linksResult = linksResult[ 1: ]
+            main.deviceLinks = copy.copy( linksResult )
+            print "Device Links Stored: \n", str( main.deviceLinks )
+            # this will be asserted to check with the params provided count of
+            # links
+            print "Length of Links Store", len( main.deviceLinks )
 
-        main.step( "Collect and store each Device ports enabled Count" )
-        for i in range( 1, 26 ):
-            portResult = main.ONOScli1.getDevicePortsEnabledCount(
-                "of:00000000000000" + format( i,'02x' ) )
-            print portResult
-            portTemp = re.split( r'\t+', portResult )
-            portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
-            devicePortsEnabledCount.append( portCount )
-        print "Device Enabled Port Counts Stored: \n", str( devicePortsEnabledCount )
+            main.step( "Collect and store each Device ports enabled Count" )
+            for i in range( 1, ( main.numMNswitches + 1) ):
+                portResult = main.ONOScli1.getDevicePortsEnabledCount(
+                    "of:00000000000000" + format( i,'02x' ) )
+                portTemp = re.split( r'\t+', portResult )
+                portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+                main.devicePortsEnabledCount.append( portCount )
+            print "Device Enabled Port Counts Stored: \n", str( main.devicePortsEnabledCount )
 
-        main.step( "Collect and store each Device active links Count" )
-        for i in range( 1, 26 ):
-            linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
-                "of:00000000000000" + format( i,'02x' ) )
-            linkCountTemp = re.split( r'\t+', linkCountResult )
-            linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
-            deviceActiveLinksCount.append( linkCount )
-        print "Device Active Links Count Stored: \n", str( deviceActiveLinksCount )
+            main.step( "Collect and store each Device active links Count" )
+            for i in range( 1, ( main.numMNswitches + 1) ):
+                linkCountResult = main.ONOScli1.getDeviceLinksActiveCount(
+                    "of:00000000000000" + format( i,'02x' ) )
+                linkCountTemp = re.split( r'\t+', linkCountResult )
+                linkCount = linkCountTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
+                main.deviceActiveLinksCount.append( linkCount )
+            print "Device Active Links Count Stored: \n", str( main.deviceActiveLinksCount )
+
+        else:
+            main.log.info("Devices (expected): %s, Links (expected): %s" % 
+                    ( str( main.numMNswitches ), str( main.numMNlinks ) ) )
+            main.log.info("Devices (actual): %s, Links (actual): %s" %
+                    ( numOnosDevices , numOnosLinks ) )
+            main.log.info("Topology does not match, exiting CHO test...")
+            time.sleep(300)
+            #main.cleanup()
+            #main.exit()
 
         # just returning TRUE for now as this one just collects data
-        caseResult = main.TRUE
-        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+        case3Result = main.TRUE
+        utilities.assert_equals( expect=main.TRUE, actual=case3Result,
                                  onpass="Saving ONOS topology data test PASS",
                                  onfail="Saving ONOS topology data test FAIL" )
 
@@ -288,13 +295,13 @@
         import re
         import copy
         import time
-        numCtrls = main.params[ 'CTRL' ][ 'numCtrl' ]
+
         main.log.report( "Enable Reactive forwarding and Verify ping all" )
         main.log.report( "______________________________________________" )
         main.case( "Enable Reactive forwarding and Verify ping all" )
         main.step( "Enable Reactive forwarding" )
         installResult = main.TRUE
-        for i in range( 1, int( numCtrls ) + 1 ):
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             onosFeature = 'onos-app-fwd'
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             ONOScli = 'ONOScli' + str( i )
@@ -323,7 +330,7 @@
 
         main.step( "Disable Reactive forwarding" )
         uninstallResult = main.TRUE
-        for i in range( 1, int( numCtrls ) + 1 ):
+        for i in range( 1, int( main.numCtrls ) + 1 ):
             onosFeature = 'onos-app-fwd'
             ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
             ONOScli = 'ONOScli' + str( i )
@@ -344,11 +351,11 @@
         Compare current ONOS topology with reference data
         """
         import re
-        devicesDPID_tmp = []
-        hostMACs_tmp = []
-        deviceLinks_tmp = []
-        deviceActiveLinksCount_tmp = []
-        devicePortsEnabledCount_tmp = []
+        devicesDPIDTemp = []
+        hostMACsTemp = []
+        deviceLinksTemp = []
+        deviceActiveLinksCountTemp = []
+        devicePortsEnabledCountTemp = []
 
         main.log.report(
             "Compare ONOS topology with reference data in Stores" )
@@ -364,16 +371,16 @@
                     '02x' ) )
             portTemp = re.split( r'\t+', portResult )
             portCount = portTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
-            devicePortsEnabledCount_tmp.append( portCount )
+            devicePortsEnabledCountTemp.append( portCount )
             time.sleep( 2 )
-        print (
-            "Device Enabled ports EXPECTED: \n" +
-            str( devicePortsEnabledCount ) )
-        print (
-            "Device Enabled ports ACTUAL: \n" +
-            str( devicePortsEnabledCount_tmp ) )
-        if ( cmp( devicePortsEnabledCount,
-                  devicePortsEnabledCount_tmp ) == 0 ):
+        main.log.info (
+            "Device Enabled ports EXPECTED: %s" % 
+	     str( main.devicePortsEnabledCount ) )
+        main.log.info (
+            "Device Enabled ports ACTUAL: %s" % 
+            str( devicePortsEnabledCountTemp ) )
+        if ( cmp( main.devicePortsEnabledCount,
+                  devicePortsEnabledCountTemp ) == 0 ):
             stepResult1 = main.TRUE
         else:
             stepResult1 = main.FALSE
@@ -387,29 +394,26 @@
                     '02x' ) )
             linkTemp = re.split( r'\t+', linkResult )
             linkCount = linkTemp[ 1 ].replace( "\r\r\n\x1b[32m", "" )
-            deviceActiveLinksCount_tmp.append( linkCount )
+            deviceActiveLinksCountTemp.append( linkCount )
             time.sleep( 3 )
-        print (
-            "Device Active links EXPECTED: \n" +
-            str( deviceActiveLinksCount ) )
-        print (
-            "Device Active links ACTUAL: \n" +
-            str( deviceActiveLinksCount_tmp ) )
-        if ( cmp( deviceActiveLinksCount, deviceActiveLinksCount_tmp ) == 0 ):
+        main.log.info (
+            "Device Active links EXPECTED: %s" %
+              str( main.deviceActiveLinksCount ) )
+        main.log.info (
+            "Device Active links ACTUAL: %s" % str( deviceActiveLinksCountTemp ) )
+        if ( cmp( main.deviceActiveLinksCount, deviceActiveLinksCountTemp ) == 0 ):
             stepResult2 = main.TRUE
         else:
             stepResult2 = main.FALSE
 
         """
-        place holder for comparing devices, hosts and paths if required.
+        place holder for comparing devices, hosts, paths and intents if required.
         Links and ports data would be incorrect with out devices anyways.
         """
-        caseResult = ( stepResult1 and stepResult2 )
-        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
+        case5Result = ( stepResult1 and stepResult2 )
+        utilities.assert_equals( expect=main.TRUE, actual=case5Result,
                                  onpass="Compare Topology test PASS",
                                  onfail="Compare Topology test FAIL" )
-        if caseResult == main.TRUE:
-            main.log.report( "Compare Topology test Pass" )
 
     def CASE6( self ):
         """
@@ -418,10 +422,11 @@
         main.log.report( "Add 300 host intents and verify pingall" )
         main.log.report( "_______________________________________" )
         import itertools
+
         main.case( "Install 300 host intents" )
         main.step( "Add host Intents" )
         intentResult = main.TRUE
-        hostCombos = list( itertools.combinations( hostMACs, 2 ) )
+        hostCombos = list( itertools.combinations( main.hostMACs, 2 ) )
         for i in range( len( hostCombos ) ):
             iResult = main.ONOScli1.addHostIntent(
                 hostCombos[ i ][ 0 ],
@@ -455,7 +460,9 @@
         Randomly bring some core links down and verify ping all ( Host Intents Scenario )
         """
         import random
-        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.randomLink1 = []
+        main.randomLink2 = []
+        main.randomLink3 = []
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
         link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
         link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
@@ -478,28 +485,28 @@
             main.log.info( "User provided Core switch links range to toggle is correct, proceeding to run the test" )
 
         main.step( "Cut links on Core devices using user provided range" )
-        randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
-        randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
-        randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
+        main.randomLink1 = random.sample( link1End2, int( switchLinksToToggle ) )
+        main.randomLink2 = random.sample( link2End2, int( switchLinksToToggle ) )
+        main.randomLink3 = random.sample( link3End2, int( switchLinksToToggle ) )
         for i in range( int( switchLinksToToggle ) ):
             main.Mininet1.link(
                 END1=link1End1,
-                END2=randomLink1[ i ],
+                END2=main.randomLink1[ i ],
                 OPTION="down" )
             main.Mininet1.link(
                 END1=link2End1,
-                END2=randomLink2[ i ],
+                END2=main.randomLink2[ i ],
                 OPTION="down" )
             main.Mininet1.link(
                 END1=link3End1,
-                END2=randomLink3[ i ],
+                END2=main.randomLink3[ i ],
                 OPTION="down" )
         time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
         linkDown = main.ONOSbench.checkStatus(
-            topology_output, numSwitches, str(
-                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+            topology_output, main.numMNswitches, str(
+                int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkDown,
@@ -522,8 +529,8 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        caseResult7 = linkDown and pingResultLinkDown
-        utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
+        caseResult70 = linkDown and pingResultLinkDown
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult70,
                                  onpass="Random Link cut Test PASS",
                                  onfail="Random Link cut Test FAIL" )
 
@@ -532,7 +539,6 @@
         Bring the core links up that are down and verify ping all ( Host Intents Scenario )
         """
         import random
-        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
         link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
         link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
@@ -564,8 +570,8 @@
         topology_output = main.ONOScli2.topology()
         linkUp = main.ONOSbench.checkStatus(
             topology_output,
-            numSwitches,
-            str( numLinks ) )
+            main.numMNswitches,
+            str( main.numMNlinks ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkUp,
@@ -588,8 +594,8 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        caseResult8 = linkUp and pingResultLinkUp
-        utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+        caseResult80 = linkUp and pingResultLinkUp
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult80,
                                  onpass="Link Up Test PASS",
                                  onfail="Link Up Test FAIL" )
 
@@ -598,7 +604,9 @@
         Randomly bring some core links down and verify ping all ( Point Intents Scenario )
         """
         import random
-        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
+        main.randomLink1 = []
+        main.randomLink2 = []
+        main.randomLink3 = []
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
         link1End2 = main.params[ 'CORELINKS' ][ 'linkS3b' ].split( ',' )
         link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
@@ -629,22 +637,22 @@
         for i in range( int( switchLinksToToggle ) ):
             main.Mininet1.link(
                 END1=link1End1,
-                END2=randomLink1[ i ],
+                END2=main.randomLink1[ i ],
                 OPTION="down" )
             main.Mininet1.link(
                 END1=link2End1,
-                END2=randomLink2[ i ],
+                END2=main.randomLink2[ i ],
                 OPTION="down" )
             main.Mininet1.link(
                 END1=link3End1,
-                END2=randomLink3[ i ],
+                END2=main.randomLink3[ i ],
                 OPTION="down" )
         time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
         linkDown = main.ONOSbench.checkStatus(
-            topology_output, numSwitches, str(
-                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+            topology_output, main.numSwitches, str(
+                int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkDown,
@@ -677,7 +685,6 @@
         Bring the core links up that are down and verify ping all ( Point Intents Scenario )
         """
         import random
-        ONOS1_ip = main.params[ 'CTRL' ][ 'ip1' ]
         link1End1 = main.params[ 'CORELINKS' ][ 'linkS3a' ]
         link2End1 = main.params[ 'CORELINKS' ][ 'linkS14a' ]
         link3End1 = main.params[ 'CORELINKS' ][ 'linkS18a' ]
@@ -694,23 +701,23 @@
         for i in range( int( switchLinksToToggle ) ):
             main.Mininet1.link(
                 END1=link1End1,
-                END2=randomLink1[ i ],
+                END2=main.randomLink1[ i ],
                 OPTION="up" )
             main.Mininet1.link(
                 END1=link2End1,
-                END2=randomLink2[ i ],
+                END2=main.randomLink2[ i ],
                 OPTION="up" )
             main.Mininet1.link(
                 END1=link3End1,
-                END2=randomLink3[ i ],
+                END2=main.randomLink3[ i ],
                 OPTION="up" )
         time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
         linkUp = main.ONOSbench.checkStatus(
             topology_output,
-            numSwitches,
-            str( numLinks ) )
+            main.numMNswitches,
+            str( main.numMNlinks ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkUp,
@@ -733,8 +740,8 @@
                                  onpass="PING ALL PASS",
                                  onfail="PING ALL FAIL" )
 
-        caseResult8 = linkUp and pingResultLinkUp
-        utilities.assert_equals( expect=main.TRUE, actual=caseResult8,
+        caseResult81 = linkUp and pingResultLinkUp
+        utilities.assert_equals( expect=main.TRUE, actual=caseResult81,
                                  onpass="Link Up Test PASS",
                                  onfail="Link Up Test FAIL" )
 
@@ -746,11 +753,11 @@
         main.log.report( "Install 114 point intents and verify Ping all" )
         main.log.report( "___________________________________________" )
         main.case( "Install 114 point intents and Ping all" )
-        deviceLinks_copy = copy.copy( deviceLinks )
+        deviceLinksCopy = copy.copy( main.deviceLinks )
         main.step( "Install 114 point intents" )
-        for i in range( len( deviceLinks_copy ) ):
+        for i in range( len( deviceLinksCopy ) ):
             pointLink = str(
-                deviceLinks_copy[ i ] ).replace(
+                deviceLinksCopy[ i ] ).replace(
                 "src=",
                 "" ).replace(
                 "dst=",
@@ -836,7 +843,7 @@
             for id in range( len( intentIdList ) ):
                 print "Removing intent id (round 1) :", intentIdList[ id ]
                 main.ONOScli1.removeIntent( intentId=intentIdList[ id ] )
-                time.sleep( 1 )
+                #time.sleep( 1 )
 
             main.log.info(
                 "Verify all intents are removed and if any leftovers try remove one more time" )
@@ -863,7 +870,7 @@
                     print "Removing intent id (round 2):", intentIdList1[ id ]
                     main.ONOScli1.removeIntent(
                         intentId=intentIdList1[ id ] )
-                    time.sleep( 2 )
+                    #time.sleep( 2 )
             else:
                 print "There are no more intents that need to be removed"
                 step1Result = main.TRUE
@@ -875,3 +882,281 @@
         utilities.assert_equals( expect=main.TRUE, actual=caseResult7,
                                  onpass="Intent removal test successful",
                                  onfail="Intent removal test failed" )
+
+    def CASE11( self, main ):
+        """
+        Enable onos-app-ifwd, Verify Intent based Reactive forwarding through ping all and Disable it
+        """
+        import re
+        import copy
+        import time
+
+        main.log.report( "Enable Intent based Reactive forwarding and Verify ping all" )
+        main.log.report( "_____________________________________________________" )
+        main.case( "Enable Intent based Reactive forwarding and Verify ping all" )
+        main.step( "Enable intent based Reactive forwarding" )
+        installResult = main.TRUE
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            onosFeature = 'onos-app-ifwd'
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "Enabling Intent based Reactive forwarding on ONOS Node " + ONOS_ip )
+            exec "inResult=main." + ONOScli + ".featureInstall(onosFeature)"
+            time.sleep( 3 )
+            installResult = inResult and installResult
+
+        time.sleep( 5 )
+
+        main.step( "Verify Pingall" )
+        ping_result = main.FALSE
+        time1 = time.time()
+        ping_result = main.Mininet1.pingall()
+        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 Intent based Reactive forwarding" )
+        uninstallResult = main.TRUE
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            onosFeature = 'onos-app-ifwd'
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "Disabling Intent based Reactive forwarding on ONOS Node " + ONOS_ip )
+            exec "unResult=main." + ONOScli + ".featureUninstall(onosFeature)"
+            uninstallResult = unResult and uninstallResult
+
+        # Waiting for reative flows to be cleared.
+        time.sleep( 10 )
+
+        case11Result = installResult and ping_result and uninstallResult
+        utilities.assert_equals( expect=main.TRUE, actual=case11Result,
+                                 onpass="Intent based Reactive forwarding Pingall test PASS",
+                                 onfail="Intent based Reactive forwarding Pingall test FAIL" )
+
+    def CASE12( self, main ):
+        """
+        This test script Loads a new Topology (Chordal) on CHO setup and balances all switches
+        """
+        import re
+        import time
+        import copy
+
+        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.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 )
+
+        main.step( "Start Mininet with Chordal topology" )
+        startStatus = main.Mininet1.startNet(topoFile = newTopo)
+
+        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 ),
+                ip1=main.ONOS1_ip,
+                port1=main.ONOS1_port,
+                ip2=main.ONOS2_ip,
+                port2=main.ONOS2_port,
+                ip3=main.ONOS3_ip,
+                port3=main.ONOS3_port,
+                ip4=main.ONOS4_ip,
+                port4=main.ONOS4_port,
+                ip5=main.ONOS5_ip,
+                port5=main.ONOS5_port )
+
+        switch_mastership = main.TRUE
+        for i in range( 1, ( main.numMNswitches + 1 ) ):
+            response = main.Mininet1.getSwController( "s" + str( i ) )
+            print( "Response is " + str( response ) )
+            if re.search( "tcp:" + main.ONOS1_ip, response ):
+                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 )
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
+            exec "startcli=main." + ONOScli + \
+                ".startOnosCli(ONOS_ip)"
+            utilities.assert_equals( expect=main.TRUE, actual=startcli,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            cliResult = ( cliResult and startcli )
+
+        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 )
+        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
+        """
+        import re
+        import time
+        import copy
+
+        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.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 )
+
+        main.step( "Start Mininet with Spine topology" )
+        startStatus = main.Mininet1.startNet(topoFile = newTopo)
+
+        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 ),
+                ip1=main.ONOS1_ip,
+                port1=main.ONOS1_port,
+                ip2=main.ONOS2_ip,
+                port2=main.ONOS2_port,
+                ip3=main.ONOS3_ip,
+                port3=main.ONOS3_port,
+                ip4=main.ONOS4_ip,
+                port4=main.ONOS4_port,
+                ip5=main.ONOS5_ip,
+                port5=main.ONOS5_port )
+
+        switch_mastership = main.TRUE
+        for i in range( 1, ( main.numMNswitches + 1 ) ):
+            response = main.Mininet1.getSwController( "s" + str( i ) )
+            print( "Response is " + str( response ) )
+            if re.search( "tcp:" + main.ONOS1_ip, response ):
+                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 )
+        for i in range( 1, int( main.numCtrls ) + 1 ):
+            ONOS_ip = main.params[ 'CTRL' ][ 'ip' + str( i ) ]
+            ONOScli = 'ONOScli' + str( i )
+            main.log.info( "ONOS Node " + ONOS_ip + " cli start:" )
+            exec "startcli=main." + ONOScli + \
+                ".startOnosCli(ONOS_ip)"
+            utilities.assert_equals( expect=main.TRUE, actual=startcli,
+                                     onpass="Test step PASS",
+                                     onfail="Test step FAIL" )
+            cliResult = ( cliResult and startcli )
+
+        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 )
+
+        case13Result = ( startResult and cliResult )
+        utilities.assert_equals(
+            expect=main.TRUE,
+            actual=case13Result,
+            onpass="Starting new Spine topology test PASS",
+            onfail="Starting new Spine topology test FAIL" )
diff --git a/TestON/tests/OnosCHO/OnosCHO.topo b/TestON/tests/OnosCHO/OnosCHO.topo
index 2a79611..b36c789 100644
--- a/TestON/tests/OnosCHO/OnosCHO.topo
+++ b/TestON/tests/OnosCHO/OnosCHO.topo
@@ -101,7 +101,7 @@
         </ONOS5>
 	
         <Mininet1>
-            <host>10.128.40.40</host>
+            <host>10.128.40.50</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>MininetCliDriver</type>
@@ -116,7 +116,7 @@
         </Mininet1>
 
         <Mininet2>
-            <host>10.128.40.40</host>
+            <host>10.128.40.50</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>RemoteMininetDriver</type>