Merge pull request #79 from opennetworkinglab/lincoe_disconnect

modify disconnect() in remotemininetdriver to take care to exit from min...
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 3f07691..0925edd 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -146,6 +146,7 @@
         '''
         This method will initialize specified component
         '''
+        import importlib
         global driver_options
         self.log.info("Creating component Handle: "+component)
         driver_options = {}
@@ -157,7 +158,7 @@
         driver_options ['type'] = driverName
         
         classPath = self.getDriverPath(driverName.lower())
-        driverModule = __import__(classPath, globals(), locals(), [driverName.lower()], -1)
+        driverModule = importlib.import_module(classPath)
         driverClass = getattr(driverModule, driverName)
         driverObject = driverClass()
          
@@ -240,8 +241,10 @@
                 exec code[testCaseNumber][step] in module.__dict__
                 self.stepCount = self.stepCount + 1
             except TypeError,e:
+                print "Exception in the following section of code:"
+                print code[testCaseNumber][step]
                 self.stepCount = self.stepCount + 1
-                self.log.error(e)
+                self.log.exception(e)
             return main.TRUE
         
         if cli.stop:
@@ -442,8 +445,8 @@
             try :
                 import json
                 response_dict = json.loads(response)
-            except Exception , e :
-                print e
+            except Exception, e:
+                main.log.exception(e)
                 main.log.error("Json Parser is unable to parse the string")
             return response_dict
         
@@ -461,7 +464,7 @@
             try :
                 response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>")
             except Exception, e:
-                main.log.error(e)
+                main.log.exception(e)
             return response_dict
         
     def dict_to_return_format(self,response,return_format,response_dict):
diff --git a/TestON/dependencies/Jenkins_getresult_HA.py b/TestON/dependencies/Jenkins_getresult_HA.py
index 1ac3a4c..9cb3b8b 100755
--- a/TestON/dependencies/Jenkins_getresult_HA.py
+++ b/TestON/dependencies/Jenkins_getresult_HA.py
@@ -106,7 +106,7 @@
         #NOTE if page name starts with number it prepends 'id-' to anchor links
         page_name = "id-1.0-HA"
 
-    header += "<li><a href=\'#" + str(page_name) + "-" + str(test) + "\'> " + str(test) + " - Results: " + str(passes) + " Passed, " + str(fails) + " Failed</a></li>"
+    header += "<li><a href=\'#" + str(page_name) + "-Test" + str(test) + "\'> " + str(test) + " - Results: " + str(passes) + " Passed, " + str(fails) + " Failed</a></li>"
 
     #*********************
     #include any other phrase specific to case you would like to include in wiki here
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 4dd6d28..fbd863e 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -190,9 +190,18 @@
                                         pexpect.EOF ,
                                         pexpect.TIMEOUT ],
                                         timeout)
-                main.log.info(self.name + ": Network started")
+                if i == 0:
+                    main.log.info(self.name + ": Network started")
+                    return main.TRUE
+                elif i == 1:
+                    main.log.error( self.name + ": Connection timeout" )
+                    return main.FALSE
+                elif i == 2:  # timeout
+                    main.log.error(
+                        self.name +
+                        ": Something took too long... " )
+                    return main.FALSE
                 return main.TRUE
-
         else:  # if no handle
             main.log.error(
                 self.name +
@@ -1272,7 +1281,7 @@
             main.log.error( "Connection failed to the host" )
         return response
 
-    def stopNet( self ):
+    def stopNet( self , timeout = 5):
         """
         Stops mininet.
         Returns main.TRUE if the mininet succesfully stops and
@@ -1285,6 +1294,15 @@
         response = ''
         if self.handle:
             try:
+                self.handle.sendline("")
+                i = self.handle.expect( [ 'mininet>',
+                                          '\$',
+                                          pexpect.EOF,
+                                          pexpect.TIMEOUT ],
+                                        timeout )
+                if i == 0:
+                    main.log.info( "Exiting mininet..." )
+               
                 response = self.execute(
                     cmd="exit",
                     prompt="(.*)",
@@ -1292,6 +1310,16 @@
                 main.log.info( self.name + ": Stopped")
                 self.handle.sendline( "sudo mn -c" )
                 response = main.TRUE
+
+                if i == 1:
+                    main.log.info( " Mininet trying to exit while not " +
+                                   "in the mininet prompt" )
+                elif i == 2:
+                    main.log.error( "Something went wrong exiting mininet" )
+                elif i == 3:  # timeout
+                    main.log.error( "Something went wrong exiting mininet " +
+                                    "TIMEOUT" )
+                
             except pexpect.EOF:
                 main.log.error( self.name + ": EOF exception found" )
                 main.log.error( self.name + ":     " + self.handle.before )
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 48f516d..5a040ec 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -43,7 +43,9 @@
                 if key == "home":
                     self.home = self.options[ 'home' ]
                     break
-
+            if self.home == None or self.home == "":
+                self.home = "~/ONOS"
+            
             self.name = self.options[ 'name' ]
             self.handle = super( OnosCliDriver, self ).connect(
                 user_name=self.user_name,
@@ -146,7 +148,7 @@
                 # Expect the cellname in the ONOSCELL variable.
                 # Note that this variable name is subject to change
                 #   and that this driver will have to change accordingly
-                self.handle.expect( "ONOS_CELL=" + str( cellname ) )
+                self.handle.expect( "ONOS_CELL" )
                 handleBefore = self.handle.before
                 handleAfter = self.handle.after
                 # Get the rest of the handle
@@ -250,6 +252,41 @@
             main.cleanup()
             main.exit()
 
+    def log( self, cmdStr , level = "" ):
+        """
+            log  the commands in the onos CLI.
+            returns main.TRUE on success
+            returns main.FALSE if Error occured
+            Available level: DEBUG, TRACE, INFO, WARN, ERROR
+            Level defaults to INFO
+        """
+        try:
+            lvlStr = ""
+            if level:
+                lvlStr = "--level=" + level
+
+            self.handle.sendline( "" )
+            self.handle.expect( "onos>" )
+            self.handle.sendline( "log:log " + lvlStr + " " + cmdStr )
+            self.handle.expect( "onos>" )
+            
+            response = self.handle.before
+            if re.search( "Error", response ):
+                return main.FALSE
+            return main.TRUE
+
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except:
+            main.log.info( self.name + " ::::::" )
+            main.log.error( traceback.print_exc() )
+            main.log.info( self.name + " ::::::" )
+            main.cleanup()
+            main.exit()
+
     def sendline( self, cmdStr ):
         """
         Send a completely user specified string to
@@ -260,12 +297,9 @@
         sent using this method.
         """
         try:
-            self.handle.sendline( "" )
-            self.handle.expect( "onos>" )
-
-            self.handle.sendline( "log:log \"Sending CLI command: '"
-                                  + cmdStr + "'\"" )
-            self.handle.expect( "onos>" )
+            
+            logStr = "\"Sending CLI command: '" + cmdStr + "'\""
+            self.log( logStr )
             self.handle.sendline( cmdStr )
             self.handle.expect( "onos>" )
             main.log.info( "Command '" + str( cmdStr ) + "' sent to "
@@ -904,6 +938,7 @@
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return None
+
         except pexpect.EOF:
             main.log.error( self.name + ": EOF exception found" )
             main.log.error( self.name + ":    " + self.handle.before )
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index c2b3693..328ac0e 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1590,3 +1590,49 @@
             main.cleanup()
             main.exit()
 
+    def detailed_status(self, log_filename):
+        '''
+        This method is used by STS to check the status of the controller
+        Reports RUNNING, STARTING, STOPPED, FROZEN, ERROR (and reason)
+        '''
+        import re
+        try:
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "cd " + self.home )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "service onos status" )
+            self.handle.expect( "\$" )
+            response = self.handle.before
+            if re.search( "onos start/running", response ):
+                # onos start/running, process 10457
+                return 'RUNNING'
+            # FIXME: Implement this case
+            # elif re.search( pattern, response ):
+            #      return 'STARTING'
+            elif re.search( "onos stop/", response ):
+                # onos stop/waiting
+                # FIXME handle this differently?:  onos stop/pre-stop
+                return 'STOPPED'
+            # FIXME: Implement this case
+            # elif re.search( pattern, response ):
+            #      return 'FROZEN'
+            else:
+                main.log.warn( self.name +
+                               " WARNING: status recieved unknown response" )
+                main.log.warn( response )
+                return 'ERROR', "Unknown response: %s" % response
+        except pexpect.TIMEOUT:
+            main.log.exception( self.name + ": Timeout exception in "
+                                "setIpTables function" )
+            return 'ERROR', "Pexpect Timeout"
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except:
+            main.log.exception( "Unknown error:")
+            main.cleanup()
+            main.exit()
+
diff --git a/TestON/drivers/component.py b/TestON/drivers/component.py
index 1e87d03..f05be55 100644
--- a/TestON/drivers/component.py
+++ b/TestON/drivers/component.py
@@ -23,9 +23,6 @@
 
 
 """
-import re
-from logging import Logger
-
 
 class Component( object ):
 
@@ -35,30 +32,39 @@
     def __init__( self ):
         self.default = ''
         self.wrapped = sys.modules[ __name__ ]
+        self.count = 0
 
     def __getattr__( self, name ):
         """
          This will invoke, if the attribute wasn't found the usual ways.
-          Here it will look for assert_attribute and will execute when AttributeError occurs.
-          It will return the result of the assert_attribute.
+         Here it will look for assert_attribute and will execute when
+         AttributeError occurs.
+         It will return the result of the assert_attribute.
         """
         try:
             return getattr( self.wrapped, name )
-        except AttributeError:
+        except AttributeError as error:
+            # NOTE: The first time we load a driver module we get this error
+            if "'module' object has no attribute '__path__'" in error\
+                    and self.count == 0:
+                self.count += 1
+            else:
+                main.log.error( str(error.__class__) + " " + str(error) )
             try:
-                def experimentHandling( **kwargs ):
+                def experimentHandling( *args, **kwargs ):
                     if main.EXPERIMENTAL_MODE == main.TRUE:
-                        result = self.experimentRun( **kwargs )
-                        main.log.info( "EXPERIMENTAL MODE. API " + str(
-                            name ) + " not yet implemented. Returning dummy values" )
+                        result = self.experimentRun( *args, **kwargs )
+                        main.log.info( "EXPERIMENTAL MODE. API " +
+                                       str( name ) +
+                                       " not yet implemented. " +
+                                       "Returning dummy values" )
                         return result
                     else:
                         return main.FALSE
                 return experimentHandling
             except TypeError as e:
-                main.log.error(
-                    "Arguments for experimental mode does not have key 'retruns'" +
-                    e )
+                main.log.error( "Arguments for experimental mode does not" +
+                                " have key 'retruns'" + e )
 
     def connect( self ):
 
@@ -110,7 +116,8 @@
     def get_version( self ):
         return "Version unknown"
 
-    def experimentRun( self, **kwargs ):
+    def experimentRun( self, *args, **kwargs ):
+        # FIXME handle *args
         args = utilities.parse_args( [ "RETURNS" ], **kwargs )
         return args[ "RETURNS" ]
 
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.params b/TestON/tests/IntentPerfNext/IntentPerfNext.params
index 88f2bc7..7b3f876 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.params
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.params
@@ -47,6 +47,12 @@
         <intfs>s3-eth2</intfs>
     </TEST>
 
+    <DB>
+        <intentFilePath>
+        /home/admin/ONLabTest/TestON/tests/IntentPerfNext/intentInstallPathDb.log
+        </intentFilePath>
+    </DB>
+
     <JSON>
         <submittedTime>intentSubmittedTimestamp</submittedTime>
         <installedTime>intentInstalledTimestamp</installedTime>
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index 8fd8089..422f1c9 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -16,12 +16,18 @@
         """
         import time
         global clusterCount
+        global timeToPost
+        global runNum
+
         clusterCount = 1
+        timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
+        runNum = time.strftime("%d%H%M%S")
 
         cellName = main.params[ 'ENV' ][ 'cellName' ]
 
         gitPull = main.params[ 'GIT' ][ 'autoPull' ]
         checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
+        intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
 
         ONOSIp = []
         for i in range(1, 8):
@@ -33,13 +39,20 @@
 
         main.case( "Setting up test environment" )
 
+        main.step( "Clearing previous DB log file" )
+        fIntentLog = open(intentFilePath, 'w')
+        # Overwrite with empty line and close 
+        fIntentLog.write('')
+        fIntentLog.close()
+
         main.step( "Starting mininet topology" )
         main.Mininet1.startNet()
 
         main.step( "Creating cell file" )
         cellFileResult = main.ONOSbench.createCellFile(
             BENCHIp, cellName, MN1Ip,
-            "onos-core,onos-app-metrics,onos-gui",
+            ("onos-core,webconsole,onos-api,onos-app-metrics,onos-gui,"
+            "onos-cli,onos-openflow"),
             ONOSIp[0] )
 
         main.step( "Applying cell file to environment" )
@@ -552,6 +565,7 @@
         import os
         import numpy
         global clusterCount
+        global timeToPost
 
         ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
         ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
@@ -582,6 +596,9 @@
         nThread = main.params[ 'TEST' ][ 'numMult' ]
         #nThread = 105
 
+        # DB operation variables
+        intentFilePath = main.params[ 'DB' ][ 'intentFilePath' ]
+
         # Switch assignment NOTE: hardcoded
         if clusterCount == 1:
             for i in range( 1, numSwitch + 1 ):
@@ -659,17 +676,21 @@
         for device in jsonObj:
             deviceIdList.append( device[ 'id' ] )
 
+        # List of install / witdhraw latencies for each batch
         batchInstallLat = []
         batchWithdrawLat = []
 
-        # Max intent install measurement of all nodes
-        maxInstallLat = []
-        maxWithdrawLat = []
         sleepTime = 10
 
         baseDir = "/tmp/"
 
+        # Batch size increase loop
         for batch in range( 0, 5 ):
+            # Max intent install measurement of all nodes
+            # Resets after each batch calculation
+            maxInstallLat = []
+            maxWithdrawLat = []
+            # Statistical gathering loop over number of iterations
             for i in range( 0, int( numIter ) ):
                 main.log.info( "Pushing " +
                                str( int( batchIntentSize ) * int( nThread ) ) +
@@ -741,6 +762,8 @@
                                    str( batchIntentSize ) + "intents: " +
                                    str( withdrawResult ) + " ms" )
 
+                #NOTE: END node loop
+
                 if len( batchInstallLat ) > 0 and int( i ) > numIgnore:
                     maxInstallLat.append( max( batchInstallLat ) )
                 elif len( batchInstallLat ) == 0:
@@ -755,13 +778,18 @@
                 # Sleep in between iterations
                 time.sleep( 5 )
 
+            #NOTE: END iteration loop
+
             if maxInstallLat:
                 avgInstallLat = str( round(
                                             sum( maxInstallLat ) /
                                             len( maxInstallLat )
                                           , 2 ))
+                stdInstallLat = str( round(
+                                    numpy.std(maxInstallLat), 2))
             else:
                 avgInstallLat = "NA"
+                stdInstallLat = "NA"
                 main.log.report( "Batch installation failed" )
                 assertion = main.FALSE
 
@@ -770,8 +798,11 @@
                                             sum( maxWithdrawLat ) /
                                             len( maxWithdrawLat )
                                             , 2 ))
+                stdWithdrawLat = str( round(
+                                    numpy.std(maxWithdrawLat), 2))
             else:
                 avgWithdrawLat = "NA"
+                stdWithdrawLat = "NA"
                 main.log.report( "Batch withdraw failed" )
                 assertion = main.FALSE
 
@@ -780,16 +811,28 @@
                              str( avgInstallLat ) + " ms" )
             main.log.report( "Std Deviation of batch installation latency " +
                              ": " +
-                             str( round(numpy.std( maxInstallLat ),2)) +
-                             " ms" )
+                             str( stdInstallLat ) + " ms" )
 
             main.log.report( "Avg of batch withdraw latency " +
                              "of size " + str( batchIntentSize ) + ": " +
                              str( avgWithdrawLat ) + " ms" )
             main.log.report( "Std Deviation of batch withdraw latency " +
                              ": " +
-                             str( round(numpy.std( maxWithdrawLat ),2)) +
-                             " ms" )
+                             str( stdWithdrawLat ) + " ms" )
+
+            dbCmd = (
+                "INSERT INTO intent_latency_tests VALUES("
+                "'"+timeToPost+"','intent_latency_results',"
+                ""+runNum+","+str(clusterCount)+","+str(batchIntentSize)+","
+                ""+str(avgInstallLat)+","+str(stdInstallLat)+","
+                ""+str(avgWithdrawLat)+","+str(stdWithdrawLat)+");"
+            )
+
+            # Write result to file (which is posted to DB by jenkins)
+            fResult = open(intentFilePath, 'a')
+            if dbCmd:        
+                fResult.write(dbCmd+"\n")
+            fResult.close()
 
             if batch == 0:
                 batchIntentSize = 10
@@ -803,6 +846,8 @@
                 main.log.report( "Increasing batch intent size to " +
                              str(batchIntentSize) )
 
+        #NOTE: END batch loop
+
         #main.log.info( "Removing all intents for next test case" )
         #jsonTemp = main.ONOS1cli.intents( jsonFormat=True )
         #jsonObjIntents = json.loads( jsonTemp )
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.topo b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
index 9de0291..5575237 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.topo
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
@@ -24,7 +24,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>3</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS2cli>
         
@@ -33,7 +33,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>4</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS3cli>
         
@@ -42,7 +42,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>5</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS4cli>
         
@@ -51,7 +51,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>6</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS5cli>
         
@@ -60,7 +60,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>7</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS6cli>
         
@@ -69,7 +69,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
+            <connect_order>8</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS7cli>
 
@@ -78,7 +78,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosDriver</type>
-            <connect_order>3</connect_order>
+            <connect_order>9</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS1>
 
@@ -87,7 +87,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>MininetCliDriver</type>
-            <connect_order>4</connect_order>
+            <connect_order>10</connect_order>
             <COMPONENTS>
                 <arg1> --custom topo-intent-8sw.py </arg1>
                 <arg2> --arp --mac --topo mytopo </arg2>
@@ -101,7 +101,7 @@
             <user>admin</user>
             <password>onos_test</password>
             <type>RemoteMininetDriver</type>
-            <connect_order>5</connect_order>
+            <connect_order>11</connect_order>
             <COMPONENTS> </COMPONENTS>
         </Mininet2>
 
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index c0325a9..af23c70 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    #CHO sequence : 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
+    #CHO sequence : 1,2,3,[4,5,6,5,70,80,5,10,5,9,5,71,81,5,10,5]*100
     # 1. ONOS brinup Test case
     # 2. Assign and Balance all Mininet switches across controllers
     # 3. Collect reference toplogy for topo compare
@@ -10,17 +10,38 @@
     # 8. Bring core links Up that were down and verify pingall
     # 9. Install 114 point intents and verify ping all
     # 10. Remove all intents on ONOS
-    # 1,2,3,[4,5,6,5,7,8,5,10,5,9,5,7,8,5,10,5]*2
+    # 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>
+        <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 3be5cbb..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" )
@@ -42,8 +46,8 @@
 
         main.step( "Git checkout and pull " + git_branch )
         if git_pull == 'on':
-            checkout_result = main.ONOSbench.git_checkout( git_branch )
-            pull_result = main.ONOSbench.git_pull()
+            checkout_result = main.ONOSbench.gitCheckout( git_branch )
+            pull_result = main.ONOSbench.gitPull()
             cp_result = ( checkout_result and pull_result )
         else:
             checkout_result = main.TRUE
@@ -55,45 +59,49 @@
                                  onfail="Test step FAIL" )
 
         main.step( "mvn clean & install" )
-        mvn_result = main.ONOSbench.clean_install()
-        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.get_version( report=True )
+        main.ONOSbench.getVersion( report=True )
 
         main.step( "Apply Cell environment for ONOS" )
-        cell_result = main.ONOSbench.set_cell( cell_name )
+        cell_result = main.ONOSbench.setCell( cell_name )
         utilities.assert_equals( expect=main.TRUE, actual=cell_result,
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
         main.step( "Create ONOS package" )
-        packageResult = main.ONOSbench.onos_package()
+        packageResult = main.ONOSbench.onosPackage()
         utilities.assert_equals( expect=main.TRUE, actual=packageResult,
                                  onpass="Test step PASS",
                                  onfail="Test step FAIL" )
 
         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.onos_uninstall( ONOS_ip )
+            u_result = main.ONOSbench.onosUninstall( ONOS_ip )
             utilities.assert_equals( expect=main.TRUE, actual=u_result,
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
             uninstallResult = ( uninstallResult and u_result )
 
         main.step( "Removing copy-cat logs from ONOS nodes" )
-        main.ONOSbench.onos_remove_raft_logs()
+        main.ONOSbench.onosRemoveRaftLogs()
 
         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.onos_install( node=ONOS_ip )
+            i_result = main.ONOSbench.onosInstall( node=ONOS_ip )
             utilities.assert_equals( expect=main.TRUE, actual=i_result,
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
@@ -101,10 +109,10 @@
 
         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.onos_status( node=ONOS_ip )
+            onos_status = main.ONOSbench.onosStatus( node=ONOS_ip )
             utilities.assert_equals( expect=main.TRUE, actual=onos_status,
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
@@ -115,13 +123,13 @@
         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:" )
             exec "startcli=main." + ONOScli + \
-                ".start_onos_cli(ONOS_ip, karafTimeout=karafTimeout)"
+                ".startOnosCli(ONOS_ip, karafTimeout=karafTimeout)"
             utilities.assert_equals( expect=main.TRUE, actual=startcli,
                                      onpass="Test step PASS",
                                      onfail="Test step FAIL" )
@@ -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 )
-            main.Mininet1.assign_sw_controller(
+        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 ):
-            response = main.Mininet1.get_sw_controller( "s" + str( i ) )
+        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.balance_masters()
+        #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" )
@@ -226,63 +226,65 @@
 
         main.step( "Collect and store current number of switches and links" )
         topology_output = main.ONOScli1.topology()
-        topology_result = main.ONOSbench.get_topology( 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 ) ) )
+        topology_result = main.ONOSbench.getTopology( topology_output )
+        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( json_format=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' ) )
-            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" )
 
@@ -293,18 +295,18 @@
         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 )
             main.log.info( "Enabling Reactive mode on ONOS Node " + ONOS_ip )
-            exec "inResult=main." + ONOScli + ".feature_install(onosFeature)"
+            exec "inResult=main." + ONOScli + ".featureInstall(onosFeature)"
             time.sleep( 3 )
             installResult = inResult and installResult
 
@@ -328,12 +330,12 @@
 
         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 )
             main.log.info( "Disabling Reactive mode on ONOS Node " + ONOS_ip )
-            exec "unResult=main." + ONOScli + ".feature_uninstall(onosFeature)"
+            exec "unResult=main." + ONOScli + ".featureUninstall(onosFeature)"
             uninstallResult = unResult and uninstallResult
 
         # Waiting for reative flows to be cleared.
@@ -349,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" )
@@ -369,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
@@ -392,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 ):
         """
@@ -423,12 +422,13 @@
         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.add_host_intent(
+            iResult = main.ONOScli1.addHostIntent(
                 hostCombos[ i ][ 0 ],
                 hostCombos[ i ][ 1 ] )
             intentResult = ( intentResult and iResult )
@@ -448,6 +448,7 @@
                                  onfail="PING ALL FAIL" )
 
         case4Result = ( intentResult and pingResult )
+        #case4Result = pingResult
         utilities.assert_equals(
             expect=main.TRUE,
             actual=case4Result,
@@ -459,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' ]
@@ -469,47 +472,41 @@
         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.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" )
+        main.log.report( "Host intents - Randomly bring some core links down and verify ping all" )
+        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 you PARAMS file. Valid range for number of switch links to toggle is between 1 to 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()
         else:
-            main.log.info(
-                "User provided Core switch links range to toggle is correct, proceeding to run the test" )
+            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.check_status(
-            topology_output, numSwitches, str(
-                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+        linkDown = main.ONOSbench.checkStatus(
+            topology_output, main.numMNswitches, str(
+                int( main.numMNlinks ) - int( switchLinksToToggle ) * 6 ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkDown,
@@ -532,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" )
 
@@ -542,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' ]
@@ -572,10 +568,10 @@
         time.sleep( link_sleep )
 
         topology_output = main.ONOScli2.topology()
-        linkUp = main.ONOSbench.check_status(
+        linkUp = main.ONOSbench.checkStatus(
             topology_output,
-            numSwitches,
-            str( numLinks ) )
+            main.numMNswitches,
+            str( main.numMNlinks ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkUp,
@@ -598,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" )
 
@@ -608,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' ]
@@ -618,14 +616,10 @@
         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(
-            "__________________________________________________________________" )
-        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" )
+        main.log.report( "Point Intents - Randomly bring some core links down and verify ping all" )
+        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" )
         if ( int( switchLinksToToggle ) ==
              0 or int( switchLinksToToggle ) > 5 ):
             main.log.info(
@@ -643,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.check_status(
-            topology_output, numSwitches, str(
-                int( numLinks ) - int( switchLinksToToggle ) * 6 ) )
+        linkDown = main.ONOSbench.checkStatus(
+            topology_output, main.numSwitches, str(
+                int( main.numLinks ) - int( switchLinksToToggle ) * 6 ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkDown,
@@ -691,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' ]
@@ -708,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.check_status(
+        linkUp = main.ONOSbench.checkStatus(
             topology_output,
-            numSwitches,
-            str( numLinks ) )
+            main.numMNswitches,
+            str( main.numMNlinks ) )
         utilities.assert_equals(
             expect=main.TRUE,
             actual=linkUp,
@@ -747,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" )
 
@@ -760,18 +753,18 @@
         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=",
                 "" ).split( ',' )
             point1 = pointLink[ 0 ].split( '/' )
             point2 = pointLink[ 1 ].split( '/' )
-            installResult = main.ONOScli1.add_point_intent(
+            installResult = main.ONOScli1.addPointIntent(
                 point1[ 0 ], point2[ 0 ], int(
                     point1[ 1 ] ), int(
                     point2[ 1 ] ) )
@@ -849,8 +842,8 @@
             print "Intent IDs: ", intentIdList
             for id in range( len( intentIdList ) ):
                 print "Removing intent id (round 1) :", intentIdList[ id ]
-                main.ONOScli1.remove_intent( intent_id=intentIdList[ id ] )
-                time.sleep( 1 )
+                main.ONOScli1.removeIntent( intentId=intentIdList[ id ] )
+                #time.sleep( 1 )
 
             main.log.info(
                 "Verify all intents are removed and if any leftovers try remove one more time" )
@@ -875,9 +868,9 @@
                 print "Leftover Intent IDs: ", intentIdList1
                 for id in range( len( intentIdList1 ) ):
                     print "Removing intent id (round 2):", intentIdList1[ id ]
-                    main.ONOScli1.remove_intent(
-                        intent_id=intentIdList1[ id ] )
-                    time.sleep( 2 )
+                    main.ONOScli1.removeIntent(
+                        intentId=intentIdList1[ id ] )
+                    #time.sleep( 2 )
             else:
                 print "There are no more intents that need to be removed"
                 step1Result = main.TRUE
@@ -889,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>
diff --git a/TestON/tests/PingallExample/PingallExample.params b/TestON/tests/PingallExample/PingallExample.params
index aecaab6..8d0d10b 100644
--- a/TestON/tests/PingallExample/PingallExample.params
+++ b/TestON/tests/PingallExample/PingallExample.params
@@ -1,12 +1,12 @@
 <PARAMS>
     <testcases>1,2,3</testcases>
     <ENV>
-        <cellName>HA</cellName>
+        <cellName>kelvin</cellName>
     </ENV>
     <Git>True</Git>
 
     <CTRL>
-        <ip1>10.128.30.11</ip1>
+        <ip1>10.128.10.21</ip1>
         <port1>6633</port1>
     </CTRL>
 </PARAMS>
diff --git a/TestON/tests/PingallExample/PingallExample.topo b/TestON/tests/PingallExample/PingallExample.topo
index 1712756..dba7a5d 100644
--- a/TestON/tests/PingallExample/PingallExample.topo
+++ b/TestON/tests/PingallExample/PingallExample.topo
@@ -2,7 +2,7 @@
     <COMPONENT>
 
         <ONOSbench>
-            <host>10.128.30.10</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>OnosDriver</type>
@@ -11,7 +11,7 @@
         </ONOSbench>
 
         <ONOScli1>
-            <host>10.128.30.10</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>OnosCliDriver</type>
@@ -20,16 +20,16 @@
         </ONOScli1>
 
         <ONOS1>
-            <host>10.128.30.11</host>
-            <user>sdn</user>
-            <password>rocks</password>
+            <host>10.128.10.21</host>
+            <user>admin</user>
+            <password></password>
             <type>OnosDriver</type>
             <connect_order>3</connect_order>
             <COMPONENTS> </COMPONENTS>
         </ONOS1>
 
         <Mininet1>
-            <host>10.128.30.9</host>
+            <host>10.128.10.20</host>
             <user>admin</user>
             <password></password>
             <type>MininetCliDriver</type>
diff --git a/TestON/tests/ProdFunc/ProdFunc.py.fixed b/TestON/tests/ProdFunc/ProdFunc.py.fixed
deleted file mode 100644
index 6f4b72b..0000000
--- a/TestON/tests/ProdFunc/ProdFunc.py.fixed
+++ /dev/null
@@ -1,1395 +0,0 @@
-
-# Testing the basic functionality of ONOS Next
-# For sanity and driver functionality excercises only.
-
-import time
-# import sys
-# import os
-# import re
-import json
-
-time.sleep( 1 )
-
-
-class ProdFunc:
-
-    def __init__( self ):
-        self.default = ''
-
-    def CASE1( self, main ):
-        """
-        Startup sequence:
-        cell <name>
-        onos-verify-cell
-        onos-remove-raft-log
-        git pull
-        mvn clean install
-        onos-package
-        onos-install -f
-        onos-wait-for-start
-        """
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
-        main.case( "Setting up test environment" )
-        main.log.report(
-            "This testcase is testing setting up test environment" )
-        main.log.report( "__________________________________" )
-
-        main.step( "Applying cell variable to environment" )
-        cellResult = main.ONOSbench.setCell( cellName )
-        verifyResult = main.ONOSbench.verifyCell()
-
-        main.step( "Removing raft logs before a clen installation of ONOS" )
-        main.ONOSbench.onosRemoveRaftLogs()
-
-        main.step( "Git checkout and pull master and get version" )
-        main.ONOSbench.gitCheckout( "master" )
-        gitPullResult = main.ONOSbench.gitPull()
-        main.log.info( "git_pull_result = " + gitPullResult )
-        main.ONOSbench.getVersion( report=True )
-
-        if gitPullResult == 1:
-            main.step( "Using mvn clean & install" )
-            main.ONOSbench.cleanInstall()
-        elif gitPullResult == 0:
-            main.log.report(
-                "Git Pull Failed, look into logs for detailed reason" )
-            main.cleanup()
-            main.exit()
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.onosPackage()
-
-        main.step( "Installing ONOS package" )
-        onosInstallResult = main.ONOSbench.onosInstall()
-        if onosInstallResult == main.TRUE:
-            main.log.report( "Installing ONOS package successful" )
-        else:
-            main.log.report( "Installing ONOS package failed" )
-
-        onos1Isup = main.ONOSbench.isup()
-        if onos1Isup == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up" )
-
-        main.step( "Starting ONOS service" )
-        startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
-        main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
-        case1Result = ( packageResult and
-                        cellResult and verifyResult
-                        and onosInstallResult and
-                        onos1Isup and startResult )
-        utilities.assert_equals( expect=main.TRUE, actual=case1Result,
-                                onpass="Test startup successful",
-                                onfail="Test startup NOT successful" )
-
-    def CASE2( self, main ):
-        """
-        Switch Down
-        """
-        # NOTE: You should probably run a topology check after this
-        import time
-
-        main.case( "Switch down discovery" )
-        main.log.report( "This testcase is testing a switch down discovery" )
-        main.log.report( "__________________________________" )
-
-        switchSleep = int( main.params[ 'timers' ][ 'SwitchDiscovery' ] )
-
-        description = "Killing a switch to ensure it is discovered correctly"
-        main.log.report( description )
-        main.case( description )
-
-        # TODO: Make this switch parameterizable
-        main.step( "Kill s28 " )
-        main.log.report( "Deleting s28" )
-        # FIXME: use new dynamic topo functions
-        main.Mininet1.delSwitch( "s28" )
-        main.log.info(
-            "Waiting " +
-            str( switchSleep ) +
-            " seconds for switch down to be discovered" )
-        time.sleep( switchSleep )
-        # Peek at the deleted switch
-        device = main.ONOS2.getDevice( dpid="0028" )
-        print "device = ", device
-        if device[ u'available' ] == 'False':
-            case2Result = main.FALSE
-        else:
-            case2Result = main.TRUE
-        utilities.assert_equals( expect=main.TRUE, actual=case2Result,
-                                onpass="Switch down discovery successful",
-                                onfail="Switch down discovery failed" )
-
-    def CASE11( self, main ):
-        """
-        Cleanup sequence:
-        onos-service <nodeIp> stop
-        onos-uninstall
-
-        TODO: Define rest of cleanup
-
-        """
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
-        main.case( "Cleaning up test environment" )
-
-        main.step( "Testing ONOS kill function" )
-        killResult = main.ONOSbench.onosKill( ONOS1Ip )
-
-        main.step( "Stopping ONOS service" )
-        stopResult = main.ONOSbench.onosStop( ONOS1Ip )
-
-        main.step( "Uninstalling ONOS service" )
-        uninstallResult = main.ONOSbench.onosUninstall()
-
-        case11Result = killResult and stopResult and uninstallResult
-        utilities.assert_equals( expect=main.TRUE, actual=case11Result,
-                                onpass="Cleanup successful",
-                                onfail="Cleanup failed" )
-
-    def CASE3( self, main ):
-        """
-        Test 'onos' command and its functionality in driver
-        """
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
-        main.case( "Testing 'onos' command" )
-
-        main.step( "Sending command 'onos -w <onos-ip> system:name'" )
-        cmdstr1 = "system:name"
-        cmdResult1 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr1 )
-        main.log.info( "onos command returned: " + cmdResult1 )
-
-        main.step( "Sending command 'onos -w <onos-ip> onos:topology'" )
-        cmdstr2 = "onos:topology"
-        cmdResult2 = main.ONOSbench.onosCli( ONOS1Ip, cmdstr2 )
-        main.log.info( "onos command returned: " + cmdResult2 )
-
-    def CASE20( self ):
-        """
-            Exit from mininet cli
-            reinstall ONOS
-        """
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-
-        main.log.report( "This testcase exits the mininet cli and reinstalls\
-                        ONOS to switch over to Packet Optical topology" )
-        main.log.report( "_____________________________________________" )
-        main.case( "Disconnecting mininet and restarting ONOS" )
-        main.step( "Disconnecting mininet and restarting ONOS" )
-        mininetDisconnect = main.Mininet1.disconnect()
-
-        main.step( "Removing raft logs before a clen installation of ONOS" )
-        main.ONOSbench.onosRemoveRaftLogs()
-
-        main.step( "Applying cell variable to environment" )
-        cellResult = main.ONOSbench.setCell( cellName )
-        verifyResult = main.ONOSbench.verifyCell()
-
-        onosInstallResult = main.ONOSbench.onosInstall()
-        if onosInstallResult == main.TRUE:
-            main.log.report( "Installing ONOS package successful" )
-        else:
-            main.log.report( "Installing ONOS package failed" )
-
-        onos1Isup = main.ONOSbench.isup()
-        if onos1Isup == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up" )
-
-        main.step( "Starting ONOS service" )
-        startResult = main.ONOSbench.onosStart( ONOS1Ip )
-
-        main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-        case20Result = mininetDisconnect and cellResult and verifyResult \
-            and onosInstallResult and onos1Isup and \
-            startResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case20Result,
-            onpass="Exiting functionality mininet topology and reinstalling \
-                    ONOS successful",
-            onfail="Exiting functionality mininet topology and reinstalling \
-                    ONOS failed" )
-
-    def CASE21( self, main ):
-        """
-            On ONOS bench, run this command:
-             ./~/ONOS/tools/test/bin/onos-topo-cfg
-            which starts the rest and copies the links
-            json file to the onos instance.
-            Note that in case of Packet Optical, the links are not learnt
-            from the topology, instead the links are learnt
-            from the json config file
-        """
-        main.log.report(
-            "This testcase starts the packet layer topology and REST" )
-        main.log.report( "_____________________________________________" )
-        main.case( "Starting LINC-OE and other components" )
-        main.step( "Starting LINC-OE and other components" )
-        startConsoleResult = main.LincOE1.startConsole()
-        opticalMnScript = main.LincOE2.runOpticalMnScript()
-        onosTopoCfgResult = main.ONOSbench.runOnosTopoCfg(
-            instanceName=main.params[ 'CTRL' ][ 'ip1' ],
-            jsonFile=main.params[ 'OPTICAL' ][ 'jsonfile' ] )
-
-        print "start_console_result =", startConsoleResult
-        print "optical_mn_script = ", opticalMnScript
-        print "onos_topo_cfg_result =", onosTopoCfgResult
-
-        case21Result = startConsoleResult and opticalMnScript and \
-            onosTopoCfgResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case21Result,
-            onpass="Packet optical topology spawned successsfully",
-            onfail="Packet optical topology spawning failed" )
-
-    def CASE22( self, main ):
-        """
-            Curretly we use, 4 linear switch optical topology and
-            2 packet layer mininet switches each with one host.
-            Therefore, the roadmCount variable = 4,
-            packetLayerSWCount variable = 2 and hostCount = 2
-            and this is hardcoded in the testcase. If the topology changes,
-            these hardcoded values need to be changed
-        """
-        main.log.report(
-            "This testcase compares the optical+packet topology against what\
-             is expected" )
-        main.case( "Topology comparision" )
-        main.step( "Topology comparision" )
-        main.ONOS3.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-        devicesResult = main.ONOS3.devices( jsonFormat=False )
-
-        print "devices_result = ", devicesResult
-        devicesLinewise = devicesResult.split( "\n" )
-        devicesLinewise = devicesLinewise[ 1:-1 ]
-        roadmCount = 0
-        packetLayerSWCount = 0
-        for line in devicesLinewise:
-            components = line.split( "," )
-            availability = components[ 1 ].split( "=" )[ 1 ]
-            type = components[ 3 ].split( "=" )[ 1 ]
-            if availability == 'true' and type == 'ROADM':
-                roadmCount += 1
-            elif availability == 'true' and type == 'SWITCH':
-                packetLayerSWCount += 1
-        if roadmCount == 4:
-            print "Number of Optical Switches = %d and is \
-                    correctly detected" % roadmCount
-            main.log.info(
-                "Number of Optical Switches = " +
-                str( roadmCount ) +
-                " and is correctly detected" )
-            opticalSWResult = main.TRUE
-        else:
-            print "Number of Optical Switches = %d and is wrong" % roadmCount
-            main.log.info(
-                "Number of Optical Switches = " +
-                str( roadmCount ) +
-                " and is wrong" )
-            opticalSWResult = main.FALSE
-
-        if packetLayerSWCount == 2:
-            print "Number of Packet layer or mininet Switches = %d and \
-                    is correctly detected" % packetLayerSWCount
-            main.log.info(
-                "Number of Packet layer or mininet Switches = " +
-                str( packetLayerSWCount ) +
-                " and is correctly detected" )
-            packetSWResult = main.TRUE
-        else:
-            print "Number of Packet layer or mininet Switches = %d and \
-                    is wrong" % packetLayerSWCount
-            main.log.info(
-                "Number of Packet layer or mininet Switches = " +
-                str( packetLayerSWCount ) +
-                " and is wrong" )
-            packetSWResult = main.FALSE
-        print "_________________________________"
-
-        linksResult = main.ONOS3.links( jsonFormat=False )
-        print "links_result = ", linksResult
-        print "_________________________________"
-
-        # NOTE:Since only point intents are added, there is no
-        # requirement to discover the hosts
-        # Therfore, the below portion of the code is commented.
-        """
-        #Discover hosts using pingall
-        pingallResult = main.LincOE2.pingall()
-
-        hostsResult = main.ONOS3.hosts( jsonFormat=False )
-        main.log.info( "hosts_result = "+hostsResult )
-        main.log.info( "_________________________________" )
-        hostsLinewise = hostsResult.split( "\n" )
-        hostsLinewise = hostsLinewise[ 1:-1 ]
-        hostCount = 0
-        for line in hostsLinewise:
-            hostid = line.split( "," )[ 0 ].split( "=" )[ 1 ]
-            hostCount +=1
-        if hostCount ==2:
-            print "Number of hosts = %d and is correctly detected" %hostCount
-            main.log.info( "Number of hosts = " + str( hostCount ) +" and \
-                            is correctly detected" )
-            hostDiscovery = main.TRUE
-        else:
-            print "Number of hosts = %d and is wrong" %hostCount
-            main.log.info( "Number of hosts = " + str( hostCount ) +" and \
-                            is wrong" )
-            hostDiscovery = main.FALSE
-        """
-        case22Result = opticalSWResult and packetSWResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case22Result,
-            onpass="Packet optical topology discovery successful",
-            onfail="Packet optical topology discovery failed" )
-
-    def CASE23( self, main ):
-        import time
-        """
-            Add bidirectional point intents between 2 packet layer( mininet )
-            devices and
-            ping mininet hosts
-        """
-        main.log.report(
-            "This testcase adds bidirectional point intents between 2 \
-                packet layer( mininet ) devices and ping mininet hosts" )
-        main.case( "Topology comparision" )
-        main.step( "Adding point intents" )
-        ptpIntentResult = main.ONOS3.addPointIntent(
-            "of:0000ffffffff0001/1",
-            "of:0000ffffffff0002/1" )
-        if ptpIntentResult == main.TRUE:
-            main.ONOS3.intents( jsonFormat=False )
-            main.log.info( "Point to point intent install successful" )
-
-        ptpIntentResult = main.ONOS3.addPointIntent(
-            "of:0000ffffffff0002/1",
-            "of:0000ffffffff0001/1" )
-        if ptpIntentResult == main.TRUE:
-            main.ONOS3.intents( jsonFormat=False )
-            main.log.info( "Point to point intent install successful" )
-
-        time.sleep( 10 )
-        flowHandle = main.ONOS3.flows()
-        main.log.info( "flows :" + flowHandle )
-
-        # Sleep for 30 seconds to provide time for the intent state to change
-        time.sleep( 30 )
-        intentHandle = main.ONOS3.intents( jsonFormat=False )
-        main.log.info( "intents :" + intentHandle )
-
-        PingResult = main.TRUE
-        count = 1
-        main.log.info( "\n\nh1 is Pinging h2" )
-        ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
-        # ping = main.LincOE2.pinghost()
-        if ping == main.FALSE and count < 5:
-            count += 1
-            PingResult = main.FALSE
-            main.log.info(
-                "Ping between h1 and h2  failed. Making attempt number " +
-                str( count ) +
-                " in 2 seconds" )
-            time.sleep( 2 )
-        elif ping == main.FALSE:
-            main.log.info( "All ping attempts between h1 and h2 have failed" )
-            PingResult = main.FALSE
-        elif ping == main.TRUE:
-            main.log.info( "Ping test between h1 and h2 passed!" )
-            PingResult = main.TRUE
-        else:
-            main.log.info( "Unknown error" )
-            PingResult = main.ERROR
-
-        if PingResult == main.FALSE:
-            main.log.report(
-                "Point intents for packet optical have not ben installed\
-                correctly. Cleaning up" )
-        if PingResult == main.TRUE:
-            main.log.report(
-                "Point Intents for packet optical have been\
-                installed correctly" )
-
-        case23Result = PingResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case23Result,
-            onpass="Point intents addition for packet optical and\
-                    Pingall Test successful",
-            onfail="Point intents addition for packet optical and\
-                    Pingall Test NOT successful" )
-
-    def CASE24( self, main ):
-        import time
-        import json
-        """
-            Test Rerouting of Packet Optical by bringing a port down
-            ( port 22 ) of a switch( switchID=1 ), so that link
-            ( between switch1 port22 - switch4-port30 ) is inactive
-            and do a ping test. If rerouting is successful,
-            ping should pass. also check the flows
-        """
-        main.log.report(
-            "This testcase tests rerouting and pings mininet hosts" )
-        main.case( "Test rerouting and pings mininet hosts" )
-        main.step( "Bring a port down and verify the link state" )
-        main.LincOE1.portDown( swId="1", ptId="22" )
-        linksNonjson = main.ONOS3.links( jsonFormat=False )
-        main.log.info( "links = " + linksNonjson )
-
-        links = main.ONOS3.links()
-        main.log.info( "links = " + links )
-
-        linksResult = json.loads( links )
-        linksStateResult = main.FALSE
-        for item in linksResult:
-            if item[ 'src' ][ 'device' ] == "of:0000ffffffffff01" and item[
-                    'src' ][ 'port' ] == "22":
-                if item[ 'dst' ][ 'device' ] == "of:0000ffffffffff04" and item[
-                        'dst' ][ 'port' ] == "30":
-                    linksState = item[ 'state' ]
-                    if linksState == "INACTIVE":
-                        main.log.info(
-                            "Links state is inactive as expected due to one \
-                            of the ports being down" )
-                        main.log.report(
-                            "Links state is inactive as expected due to one \
-                            of the ports being down" )
-                        linksStateResult = main.TRUE
-                        break
-                    else:
-                        main.log.info(
-                            "Links state is not inactive as expected" )
-                        main.log.report(
-                            "Links state is not inactive as expected" )
-                        linksStateResult = main.FALSE
-
-        print "links_state_result = ", linksStateResult
-        time.sleep( 10 )
-        flowHandle = main.ONOS3.flows()
-        main.log.info( "flows :" + flowHandle )
-
-        main.step( "Verify Rerouting by a ping test" )
-        PingResult = main.TRUE
-        count = 1
-        main.log.info( "\n\nh1 is Pinging h2" )
-        ping = main.LincOE2.pingHostOptical( src="h1", target="h2" )
-        # ping = main.LincOE2.pinghost()
-        if ping == main.FALSE and count < 5:
-            count += 1
-            PingResult = main.FALSE
-            main.log.info(
-                "Ping between h1 and h2  failed. Making attempt number " +
-                str( count ) +
-                " in 2 seconds" )
-            time.sleep( 2 )
-        elif ping == main.FALSE:
-            main.log.info( "All ping attempts between h1 and h2 have failed" )
-            PingResult = main.FALSE
-        elif ping == main.TRUE:
-            main.log.info( "Ping test between h1 and h2 passed!" )
-            PingResult = main.TRUE
-        else:
-            main.log.info( "Unknown error" )
-            PingResult = main.ERROR
-
-        if PingResult == main.TRUE:
-            main.log.report( "Ping test successful " )
-        if PingResult == main.FALSE:
-            main.log.report( "Ping test failed" )
-
-        case24Result = PingResult and linksStateResult
-        utilities.assert_equals( expect=main.TRUE, actual=case24Result,
-                                onpass="Packet optical rerouting successful",
-                                onfail="Packet optical rerouting failed" )
-
-    def CASE4( self, main ):
-        import re
-        import time
-        main.log.report( "This testcase is testing the assignment of \
-                         all the switches to all the controllers and \
-                         discovering the hists in reactive mode" )
-        main.log.report( "__________________________________" )
-        main.case( "Pingall Test" )
-        main.step( "Assigning switches to controllers" )
-        ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
-        ONOS1Port = main.params[ 'CTRL' ][ 'port1' ]
-        for i in range( 1, 29 ):
-            if i == 1:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-            elif i >= 2 and i < 5:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-            elif i >= 5 and i < 8:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-            elif i >= 8 and i < 18:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-            elif i >= 18 and i < 28:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-            else:
-                main.Mininet1.assignSwController(
-                    sw=str( i ),
-                    ip1=ONOS1Ip,
-                    port1=ONOS1Port )
-        SwitchMastership = main.TRUE
-        for i in range( 1, 29 ):
-            if i == 1:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is " + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-            elif i >= 2 and i < 5:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is " + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-            elif i >= 5 and i < 8:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is " + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-            elif i >= 8 and i < 18:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is " + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-            elif i >= 18 and i < 28:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is " + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-            else:
-                response = main.Mininet1.getSwController( "s" + str( i ) )
-                print( "Response is" + str( response ) )
-                if re.search( "tcp:" + ONOS1Ip, response ):
-                    SwitchMastership = SwitchMastership and main.TRUE
-                else:
-                    SwitchMastership = main.FALSE
-
-        if SwitchMastership == main.TRUE:
-            main.log.report( "Controller assignmnet successful" )
-        else:
-            main.log.report( "Controller assignmnet failed" )
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=SwitchMastership,
-            onpass="MasterControllers assigned correctly" )
-        """
-        for i in range ( 1,29 ):
-            main.Mininet1.assignSwController( sw=str( i ),count=5,
-                    ip1=ONOS1Ip,port1=ONOS1Port,
-                    ip2=ONOS2Ip,port2=ONOS2Port,
-                    ip3=ONOS3Ip,port3=ONOS3Port,
-                    ip4=ONOS4Ip,port4=ONOS4Port,
-                    ip5=ONOS5Ip,port5=ONOS5Port )
-        """
-        # REACTIVE FWD test
-
-        main.step( "Get list of hosts from Mininet" )
-        hostList = main.Mininet1.getHosts()
-        main.log.info( hostList )
-
-        main.step( "Get host list in ONOS format" )
-        hostOnosList = main.ONOS2.getHostsId( hostList )
-        main.log.info( hostOnosList )
-        # time.sleep( 5 )
-
-        main.step( "Pingall" )
-        pingResult = main.FALSE
-        while pingResult == main.FALSE:
-            time1 = time.time()
-            pingResult = main.Mininet1.pingall()
-            time2 = time.time()
-            print "Time for pingall: %2f seconds" % ( time2 - time1 )
-
-        # Start onos cli again because u might have dropped out of
-        # onos prompt to the shell prompt
-        # if there was no activity
-        main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-
-        case4Result = SwitchMastership and pingResult
-        if pingResult == main.TRUE:
-            main.log.report( "Pingall Test in reactive mode to \
-                             discover the hosts successful" )
-        else:
-            main.log.report( "Pingall Test in reactive mode to \
-                              discover the hosts failed" )
-
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case4Result,
-            onpass="Controller assignment and Pingall Test successful",
-            onfail="Controller assignment and Pingall Test NOT successful" )
-
-    def CASE10( self ):
-        main.log.report(
-            "This testcase uninstalls the reactive forwarding app" )
-        main.log.report( "__________________________________" )
-        main.case( "Uninstalling reactive forwarding app" )
-        # Unistall onos-app-fwd app to disable reactive forwarding
-        appUninstallResult = main.ONOS2.featureUninstall( "onos-app-fwd" )
-        main.log.info( "onos-app-fwd uninstalled" )
-
-        # After reactive forwarding is disabled, the reactive flows on
-        # switches timeout in 10-15s
-        # So sleep for 15s
-        time.sleep( 15 )
-
-        flows = main.ONOS2.flows()
-        main.log.info( flows )
-
-        case10Result = appUninstallResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case10Result,
-            onpass="Reactive forwarding app uninstallation successful",
-            onfail="Reactive forwarding app uninstallation failed" )
-
-    def CASE6( self ):
-        main.log.report( "This testcase is testing the addition of \
-                         host intents and then does pingall" )
-        main.log.report( "__________________________________" )
-        main.case( "Obtaining host id's" )
-        main.step( "Get hosts" )
-        hosts = main.ONOS2.hosts()
-        main.log.info( hosts )
-
-        main.step( "Get all devices id" )
-        devicesIdList = main.ONOS2.getAllDevicesId()
-        main.log.info( devicesIdList )
-
-        # ONOS displays the hosts in hex format unlike mininet which does
-        # in decimal format
-        # So take care while adding intents
-        """
-        main.step( "Add host-to-host intents for mininet hosts h8 and h18 or
-                    ONOS hosts h8 and h12" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:08/-1", "00:00:00:00:00:12/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:09/-1", "00:00:00:00:00:13/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0A/-1", "00:00:00:00:00:14/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0B/-1", "00:00:00:00:00:15/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0C/-1", "00:00:00:00:00:16/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0D/-1", "00:00:00:00:00:17/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0E/-1", "00:00:00:00:00:18/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:0F/-1", "00:00:00:00:00:19/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:10/-1", "00:00:00:00:00:1A/-1" )
-        hthIntentResult = main.ONOS2.addHostIntent(
-                            "00:00:00:00:00:11/-1", "00:00:00:00:00:1B/-1" )
-        print "______________________________________________________"
-        """
-        for i in range( 8, 18 ):
-            main.log.info(
-                "Adding host intent between h" + str( i ) +
-                " and h" + str( i + 10 ) )
-            host1 = "00:00:00:00:00:" + \
-                str( hex( i )[ 2: ] ).zfill( 2 ).upper()
-            host2 = "00:00:00:00:00:" + \
-                str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper()
-            # NOTE: get host can return None
-            # TODO: handle this
-            host1Id = main.ONOS2.getHost( host1 )[ 'id' ]
-            host2Id = main.ONOS2.getHost( host2 )[ 'id' ]
-            main.ONOS2.addHostIntent( host1Id, host2Id )
-
-        time.sleep( 10 )
-        hIntents = main.ONOS2.intents( jsonFormat=False )
-        main.log.info( "intents:" + hIntents )
-        main.ONOS2.flows()
-
-        count = 1
-        i = 8
-        PingResult = main.TRUE
-        # while i<10:
-        while i < 18:
-            main.log.info(
-                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
-            ping = main.Mininet1.pingHost(
-                src="h" + str( i ), target="h" + str( i + 10 ) )
-            if ping == main.FALSE and count < 5:
-                count += 1
-                # i = 8
-                PingResult = main.FALSE
-                main.log.report( "Ping between h" +
-                                 str( i ) +
-                                 " and h" +
-                                 str( i +
-                                      10 ) +
-                                 " failed. Making attempt number " +
-                                 str( count ) +
-                                 " in 2 seconds" )
-                time.sleep( 2 )
-            elif ping == main.FALSE:
-                main.log.report( "All ping attempts between h" +
-                                 str( i ) +
-                                 " and h" +
-                                 str( i +
-                                      10 ) +
-                                 "have failed" )
-                i = 19
-                PingResult = main.FALSE
-            elif ping == main.TRUE:
-                main.log.info( "Ping test between h" +
-                               str( i ) +
-                               " and h" +
-                               str( i +
-                                    10 ) +
-                               "passed!" )
-                i += 1
-                PingResult = main.TRUE
-            else:
-                main.log.info( "Unknown error" )
-                PingResult = main.ERROR
-        if PingResult == main.FALSE:
-            main.log.report(
-                "Ping all test after Host intent addition failed. Cleaning up" )
-            # main.cleanup()
-            # main.exit()
-        if PingResult == main.TRUE:
-            main.log.report(
-                "Ping all test after Host intent addition successful" )
-
-        case6Result = PingResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case6Result,
-            onpass="Pingall Test after Host intents addition successful",
-            onfail="Pingall Test after Host intents addition failed" )
-
-    def CASE5( self, main ):
-        import json
-        # assumes that sts is already in you PYTHONPATH
-        from sts.topology.testonTopology import TestONTopology
-        # main.ONOS2.startOnosCli( ONOSIp=main.params[ 'CTRL' ][ 'ip1' ] )
-        main.log.report( "This testcase is testing if all ONOS nodes \
-                         are in topology sync with mininet" )
-        main.log.report( "__________________________________" )
-        main.case( "Comparing Mininet topology with the topology of ONOS" )
-        main.step( "Start continuous pings" )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source1' ],
-            target=main.params[ 'PING' ][ 'target1' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source2' ],
-            target=main.params[ 'PING' ][ 'target2' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source3' ],
-            target=main.params[ 'PING' ][ 'target3' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source4' ],
-            target=main.params[ 'PING' ][ 'target4' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source5' ],
-            target=main.params[ 'PING' ][ 'target5' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source6' ],
-            target=main.params[ 'PING' ][ 'target6' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source7' ],
-            target=main.params[ 'PING' ][ 'target7' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source8' ],
-            target=main.params[ 'PING' ][ 'target8' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source9' ],
-            target=main.params[ 'PING' ][ 'target9' ],
-            pingTime=500 )
-        main.Mininet2.pingLong(
-            src=main.params[ 'PING' ][ 'source10' ],
-            target=main.params[ 'PING' ][ 'target10' ],
-            pingTime=500 )
-
-        main.step( "Create TestONTopology object" )
-        global ctrls
-        ctrls = []
-        count = 1
-        while True:
-            temp = ()
-            if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]:
-                temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), )
-                temp = temp + ( "ONOS" + str( count ), )
-                temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], )
-                temp = temp + \
-                    ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), )
-                ctrls.append( temp )
-                count = count + 1
-            else:
-                break
-        global MNTopo
-        Topo = TestONTopology(
-            main.Mininet1,
-            ctrls )  # can also add Intent API info for intent operations
-        MNTopo = Topo
-
-        TopologyCheck = main.TRUE
-        main.step( "Compare ONOS Topology to MN Topology" )
-        devicesJson = main.ONOS2.devices()
-        linksJson = main.ONOS2.links()
-        # portsJson = main.ONOS2.ports()
-
-        result1 = main.Mininet1.compareSwitches(
-            MNTopo,
-            json.loads( devicesJson ) )
-        result2 = main.Mininet1.compareLinks(
-            MNTopo,
-            json.loads( linksJson ) )
-        # result3 = main.Mininet1.comparePorts(
-        # MNTopo, json.loads( portsJson ) )
-
-        # result = result1 and result2 and result3
-        result = result1 and result2
-
-        print "***********************"
-        if result == main.TRUE:
-            main.log.report( "ONOS" + " Topology matches MN Topology" )
-        else:
-            main.log.report( "ONOS" + " Topology does not match MN Topology" )
-
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=result,
-            onpass="ONOS" +
-            " Topology matches MN Topology",
-            onfail="ONOS" +
-            " Topology does not match MN Topology" )
-
-        TopologyCheck = TopologyCheck and result
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=TopologyCheck,
-            onpass="Topology checks passed",
-            onfail="Topology checks failed" )
-
-    def CASE7( self, main ):
-        from sts.topology.testonTopology import TestONTopology
-
-        linkSleep = int( main.params[ 'timers' ][ 'LinkDiscovery' ] )
-
-        main.log.report( "This testscase is killing a link to ensure that \
-                         link discovery is consistent" )
-        main.log.report( "__________________________________" )
-        main.log.report( "Killing a link to ensure that link discovery \
-                         is consistent" )
-        main.case( "Killing a link to Ensure that Link Discovery \
-                   is Working Properly" )
-        """
-        main.step( "Start continuous pings" )
-
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source1' ],
-                               target=main.params[ 'PING' ][ 'target1' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source2' ],
-                               target=main.params[ 'PING' ][ 'target2' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source3' ],
-                               target=main.params[ 'PING' ][ 'target3' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source4' ],
-                               target=main.params[ 'PING' ][ 'target4' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source5' ],
-                               target=main.params[ 'PING' ][ 'target5' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source6' ],
-                               target=main.params[ 'PING' ][ 'target6' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source7' ],
-                               target=main.params[ 'PING' ][ 'target7' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source8' ],
-                               target=main.params[ 'PING' ][ 'target8' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source9' ],
-                               target=main.params[ 'PING' ][ 'target9' ],
-                               pingTime=500 )
-        main.Mininet2.pingLong( src=main.params[ 'PING' ][ 'source10' ],
-                               target=main.params[ 'PING' ][ 'target10' ],
-                               pingTime=500 )
-        """
-        main.step( "Determine the current number of switches and links" )
-        topologyOutput = main.ONOS2.topology()
-        topologyResult = main.ONOS1.getTopology( topologyOutput )
-        activeSwitches = topologyResult[ 'devices' ]
-        links = topologyResult[ 'links' ]
-        print "activeSwitches = ", type( activeSwitches )
-        print "links = ", type( links )
-        main.log.info(
-            "Currently there are %s switches and %s links" %
-            ( str( activeSwitches ), str( links ) ) )
-
-        main.step( "Kill Link between s3 and s28" )
-        main.Mininet1.link( END1="s3", END2="s28", OPTION="down" )
-        time.sleep( linkSleep )
-        topologyOutput = main.ONOS2.topology()
-        LinkDown = main.ONOS1.checkStatus(
-            topologyOutput, activeSwitches, str(
-                int( links ) - 2 ) )
-        if LinkDown == main.TRUE:
-            main.log.report( "Link Down discovered properly" )
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=LinkDown,
-            onpass="Link Down discovered properly",
-            onfail="Link down was not discovered in " +
-            str( linkSleep ) +
-            " seconds" )
-
-        # Check ping result here..add code for it
-
-        main.step( "Bring link between s3 and s28 back up" )
-        LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" )
-        time.sleep( linkSleep )
-        topologyOutput = main.ONOS2.topology()
-        LinkUp = main.ONOS1.checkStatus(
-            topologyOutput,
-            activeSwitches,
-            str( links ) )
-        if LinkUp == main.TRUE:
-            main.log.report( "Link up discovered properly" )
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=LinkUp,
-            onpass="Link up discovered properly",
-            onfail="Link up was not discovered in " +
-            str( linkSleep ) +
-            " seconds" )
-
-        # NOTE Check ping result here..add code for it
-
-        main.step( "Compare ONOS Topology to MN Topology" )
-        Topo = TestONTopology(
-            main.Mininet1,
-            ctrls )  # can also add Intent API info for intent operations
-        MNTopo = Topo
-        TopologyCheck = main.TRUE
-
-        devicesJson = main.ONOS2.devices()
-        linksJson = main.ONOS2.links()
-        portsJson = main.ONOS2.ports()
-
-        result1 = main.Mininet1.compareSwitches(
-            MNTopo,
-            json.loads( devicesJson ) )
-        result2 = main.Mininet1.compareLinks(
-            MNTopo,
-            json.loads( linksJson ) )
-        # result3 = main.Mininet1.comparePorts(
-        # MNTopo, json.loads( portsJson ) )
-
-        # result = result1 and result2 and result3
-        result = result1 and result2
-        print "***********************"
-
-        if result == main.TRUE:
-            main.log.report( "ONOS" + " Topology matches MN Topology" )
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=result,
-            onpass="ONOS" +
-            " Topology matches MN Topology",
-            onfail="ONOS" +
-            " Topology does not match MN Topology" )
-
-        TopologyCheck = TopologyCheck and result
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=TopologyCheck,
-            onpass="Topology checks passed",
-            onfail="Topology checks failed" )
-
-        result = LinkDown and LinkUp and TopologyCheck
-        utilities.assert_equals( expect=main.TRUE, actual=result,
-                                onpass="Link failure is discovered correctly",
-                                onfail="Link Discovery failed" )
-
-    def CASE8( self ):
-        """
-        Host intents removal
-        """
-        main.log.report( "This testcase removes any previously added intents \
-                         before adding the same intents or point intents" )
-        main.log.report( "__________________________________" )
-        main.log.info( "Host intents removal" )
-        main.case( "Removing host intents" )
-        main.step( "Obtain the intent id's" )
-        intentResult = main.ONOS2.intents( jsonFormat=False )
-        main.log.info( "intent_result = " + intentResult )
-
-        intentLinewise = intentResult.split( "\n" )
-        intentList = []
-        for line in intentLinewise:
-            if line.startswith( "id=" ):
-                intentList.append( line )
-
-        intentids = []
-        for line in intentList:
-            intentids.append( line.split( "," )[ 0 ].split( "=" )[ 1 ] )
-        for id in intentids:
-            print "id = ", id
-
-        main.step(
-            "Iterate through the intentids list and remove each intent" )
-        for id in intentids:
-            main.ONOS2.removeIntent( intentId=id )
-
-        intentResult = main.ONOS2.intents( jsonFormat=False )
-        main.log.info( "intent_result = " + intentResult )
-
-        case8Result = main.TRUE
-        if case8Result == main.TRUE:
-            main.log.report( "Intent removal successful" )
-        else:
-            main.log.report( "Intent removal failed" )
-
-        PingResult = main.TRUE
-        if case8Result == main.TRUE:
-            i = 8
-            while i < 18:
-                main.log.info(
-                    "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
-                ping = main.Mininet1.pingHost(
-                    src="h" + str( i ), target="h" + str( i + 10 ) )
-                if ping == main.TRUE:
-                    i = 19
-                    PingResult = PingResult and main.TRUE
-                elif ping == main.FALSE:
-                    i += 1
-                    PingResult = PingResult and main.FALSE
-                else:
-                    main.log.info( "Unknown error" )
-                    PingResult = main.ERROR
-
-            # Note: If the ping result failed, that means the intents have been
-            # withdrawn correctly.
-        if PingResult == main.TRUE:
-            main.log.report( "Host intents have not been withdrawn correctly" )
-            # main.cleanup()
-            # main.exit()
-        if PingResult == main.FALSE:
-            main.log.report( "Host intents have been withdrawn correctly" )
-
-        case8Result = case8Result and PingResult
-
-        if case8Result == main.FALSE:
-            main.log.report( "Intent removal successful" )
-        else:
-            main.log.report( "Intent removal failed" )
-
-        utilities.assert_equals( expect=main.FALSE, actual=case8Result,
-                                onpass="Intent removal test failed",
-                                onfail="Intent removal test passed" )
-
-    def CASE9( self ):
-        main.log.report(
-            "This testcase adds point intents and then does pingall" )
-        main.log.report( "__________________________________" )
-        main.log.info( "Adding point intents" )
-        main.case(
-            "Adding bidirectional point for mn hosts \
-                  ( h8-h18, h9-h19, h10-h20, h11-h21, h12-h22,\
-                   h13-h23, h14-h24, h15-h25, h16-h26, h17-h27 )" )
-        main.step(
-            "Add point intents for mininet hosts h8 and h18 or \
-                  ONOS hosts h8 and h12" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003008/1",
-            "of:0000000000006018/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006018/1",
-            "of:0000000000003008/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h9 and h19 or \
-                  ONOS hosts h9 and h13" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003009/1",
-            "of:0000000000006019/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006019/1",
-            "of:0000000000003009/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h10 and h20 or \
-                  ONOS hosts hA and h14" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003010/1",
-            "of:0000000000006020/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006020/1",
-            "of:0000000000003010/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h11 and h21 or \
-                  ONOS hosts hB and h15" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003011/1",
-            "of:0000000000006021/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006021/1",
-            "of:0000000000003011/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h12 and h22 \
-                  ONOS hosts hC and h16" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003012/1",
-            "of:0000000000006022/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006022/1",
-            "of:0000000000003012/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h13 and h23 or \
-                  ONOS hosts hD and h17" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003013/1",
-            "of:0000000000006023/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006023/1",
-            "of:0000000000003013/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h14 and h24 or \
-                  ONOS hosts hE and h18" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003014/1",
-            "of:0000000000006024/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006024/1",
-            "of:0000000000003014/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h15 and h25 or \
-                  ONOS hosts hF and h19" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003015/1",
-            "of:0000000000006025/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006025/1",
-            "of:0000000000003015/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add intents for mininet hosts h16 and h26 or \
-                  ONOS hosts h10 and h1A" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003016/1",
-            "of:0000000000006026/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006026/1",
-            "of:0000000000003016/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            # main.log.info( getIntentResult )
-
-        main.step(
-            "Add point intents for mininet hosts h17 and h27 or \
-                  ONOS hosts h11 and h1B" )
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000003017/1",
-            "of:0000000000006027/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            main.log.info( getIntentResult )
-
-        ptpIntentResult = main.ONOS2.addPointIntent(
-            "of:0000000000006027/1",
-            "of:0000000000003017/1" )
-        if ptpIntentResult == main.TRUE:
-            getIntentResult = main.ONOS2.intents()
-            main.log.info( "Point to point intent install successful" )
-            main.log.info( getIntentResult )
-
-        print(
-            "___________________________________________________________" )
-
-        flowHandle = main.ONOS2.flows()
-        # print "flowHandle = ", flowHandle
-        main.log.info( "flows :" + flowHandle )
-
-        count = 1
-        i = 8
-        PingResult = main.TRUE
-        while i < 18:
-            main.log.info(
-                "\n\nh" + str( i ) + " is Pinging h" + str( i + 10 ) )
-            ping = main.Mininet1.pingHost(
-                src="h" + str( i ), target="h" + str( i + 10 ) )
-            if ping == main.FALSE and count < 5:
-                count += 1
-                # i = 8
-                PingResult = main.FALSE
-                main.log.report( "Ping between h" +
-                                 str( i ) +
-                                 " and h" +
-                                 str( i +
-                                      10 ) +
-                                 " failed. Making attempt number " +
-                                 str( count ) +
-                                 " in 2 seconds" )
-                time.sleep( 2 )
-            elif ping == main.FALSE:
-                main.log.report( "All ping attempts between h" +
-                                 str( i ) +
-                                 " and h" +
-                                 str( i +
-                                      10 ) +
-                                 "have failed" )
-                i = 19
-                PingResult = main.FALSE
-            elif ping == main.TRUE:
-                main.log.info( "Ping test between h" +
-                               str( i ) +
-                               " and h" +
-                               str( i +
-                                    10 ) +
-                               "passed!" )
-                i += 1
-                PingResult = main.TRUE
-            else:
-                main.log.info( "Unknown error" )
-                PingResult = main.ERROR
-
-        if PingResult == main.FALSE:
-            main.log.report(
-                "Point intents have not ben installed correctly. Cleaning up" )
-            # main.cleanup()
-            # main.exit()
-        if PingResult == main.TRUE:
-            main.log.report( "Point Intents have been installed correctly" )
-
-        case9Result = PingResult
-        utilities.assert_equals(
-            expect=main.TRUE,
-            actual=case9Result,
-            onpass="Point intents addition and Pingall Test successful",
-            onfail="Point intents addition and Pingall Test NOT successful" )
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index c653090..dc2d519 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -72,6 +72,9 @@
         <portEventResultPath>
         /home/admin/ONLabTest/TestON/tests/TopoPerfNext/portEventResultDb.log
         </portEventResultPath>
+        <switchEventResultPath>
+        /home/admin/ONLabTest/TestON/tests/TopoPerfNext/switchEventResultDb.log
+        </switchEventResultPath>
     </DB>
 
     <JSON>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index 0d2a596..0f37909 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -29,6 +29,10 @@
         global clusterCount
         #TODO: fix run number implementation
         global runNum 
+        global timeToPost
+
+        #Test run time
+        timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
         # Set initial cluster count
         clusterCount = 1
         ##
@@ -54,6 +58,9 @@
         topoCfgFile = main.params[ 'TEST' ][ 'topoConfigFile' ]
         topoCfgName = main.params[ 'TEST' ][ 'topoConfigName' ]
 
+        portEventResultPath = main.params[ 'DB' ][ 'portEventResultPath' ]
+        switchEventResultPath = main.params[ 'DB' ][ 'switchEventResultPath' ]
+
         mvnCleanInstall = main.params[ 'TEST' ][ 'mci' ]
         
         main.case( "Setting up test environment" )
@@ -78,10 +85,19 @@
         main.ONOSbench.onosUninstall( nodeIp=ONOS6Ip )
         main.ONOSbench.onosUninstall( nodeIp=ONOS7Ip )
 
+        main.step( "Clearing previous DB log files" )
+        fPortLog = open(portEventResultPath, 'w')
+        fPortLog.write('')
+        fPortLog.close()
+        fSwitchLog = open(switchEventResultPath, 'w')
+        fSwitchLog.write('')
+        fSwitchLog.close()
+        
         main.step( "Creating cell file" )
         cellFileResult = main.ONOSbench.createCellFile(
             BENCHIp, cellName, MN1Ip,
-            "onos-core,onos-app-metrics,onos-app-gui",
+            ("onos-core,onos-api,webconsole,onos-app-metrics,onos-app-gui,"
+            "onos-cli,onos-openflow"),
             ONOS1Ip )
 
         main.step( "Applying cell file to environment" )
@@ -117,23 +133,17 @@
 
         main.step( "Set cell for ONOS cli env" )
         main.ONOS1cli.setCell( cellName )
-        # main.ONOS2cli.setCell( cellName )
-        # main.ONOS3cli.setCell( cellName )
 
         main.step( "Creating ONOS package" )
         packageResult = main.ONOSbench.onosPackage()
 
         main.step( "Installing ONOS package" )
         install1Result = main.ONOSbench.onosInstall( node=ONOS1Ip )
-        #install2Result = main.ONOSbench.onosInstall( node=ONOS2Ip )
-        #install3Result = main.ONOSbench.onosInstall( node=ONOS3Ip )
 
         time.sleep( 10 )
 
         main.step( "Start onos cli" )
         cli1 = main.ONOS1cli.startOnosCli( ONOS1Ip )
-        #cli2 = main.ONOS2cli.startOnosCli( ONOS2Ip )
-        #cli3 = main.ONOS3cli.startOnosCli( ONOS3Ip )
 
         utilities.assert_equals( expect=main.TRUE,
                                 actual=cellFileResult and cellApplyResult and
@@ -168,6 +178,7 @@
         import os
         import numpy
         global clusterCount
+        global timeToPost
 
         ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
         ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
@@ -193,6 +204,7 @@
 
         debugMode = main.params[ 'TEST' ][ 'debugMode' ]
         onosLog = main.params[ 'TEST' ][ 'onosLogFile' ]
+        resultPath = main.params[ 'DB' ][ 'switchEventResultPath' ]
 
         # Threshold for the test
         thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ]
@@ -543,10 +555,17 @@
                     ofpToGraphLatNodeIter[6][i] = deltaOfpGraph7
                     main.log.info("ONOS7 iter"+str(i)+" ofp-to-graph: "+
                             str(deltaOfpGraph7)+" ms")
+                    
+            main.log.info("Switch up discovery latency")
+                
+            main.log.info("Starting tshark capture")
 
             main.step( "Remove switch from controller" )
             main.Mininet1.deleteSwController( "s1" )
 
+            #TODO: del controller does not have an OFP message.
+            #      However, we can capture TCP Fin,Ack as T0
+
             time.sleep( 5 )
 
         # END of for loop iteration
@@ -557,6 +576,7 @@
         ofpToGraphAvg = 0
         endToEndList = []
         ofpToGraphList = []
+        dbCmdList = []
 
         for node in range( 0, clusterCount ):
             # The latency 2d array was initialized to 0. 
@@ -574,14 +594,22 @@
                 if item > 0.0:
                     ofpToGraphList.append(item)
 
-            endToEndAvg = numpy.mean(endToEndList)
+            endToEndAvg = round(numpy.mean(endToEndList), 2)
             ofpToGraphAvg = numpy.mean(ofpToGraphList)
+            endToEndStd = round(numpy.std(endToEndList), 2)
 
             main.log.report( " - Node "+str(node+1)+" Summary - " )
             main.log.report( " End-to-end Avg: "+
                              str(round(endToEndAvg,2))+" ms"+
                              " End-to-end Std dev: "+
-                             str(round(numpy.std(endToEndList),2))+" ms")
+                             str(round(endToEndStd,2))+" ms")
+            
+            dbCmdList.append(
+                "INSERT INTO switch_latency_tests VALUES("
+                   "'"+timeToPost+"','switch_latency_results',"
+                   ""+runNum+","+str(clusterCount)+",'baremetal"+str(node+1)+"',"
+                   ""+str(endToEndAvg)+","+str(endToEndStd)+",0,0);"
+            )
             #main.log.report( " Ofp-to-graph Avg: "+
             #                 str(round(ofpToGraphAvg,2))+" ms"+
             #                 " Ofp-to-graph Std dev: "+
@@ -591,6 +619,13 @@
         if debugMode == 'on':
             main.ONOS1.cpLogsToDir( "/opt/onos/log/karaf.log",
                                       "/tmp/", copyFileName="sw_lat_karaf" )
+        
+        #Write to file for posting to DB
+        fResult = open(resultPath, 'a')
+        for line in dbCmdList:
+            if line:
+                fResult.write(line+"\n")
+        fResult.close()
 
         #TODO: correct assert
         assertion = main.TRUE
@@ -616,6 +651,7 @@
         import numpy
         global clusterCount
         global runNum
+        global timeToPost
 
         ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ]
         ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ]
@@ -637,7 +673,6 @@
         debugMode = main.params[ 'TEST' ][ 'debugMode' ]
         postToDB = main.params[ 'DB' ][ 'postToDB' ]
         resultPath = main.params[ 'DB' ][ 'portEventResultPath' ]
-        timeToPost = time.strftime("%Y-%m-%d %H:%M:%S")
 
         localTime = time.strftime( '%x %X' )
         localTime = localTime.replace( "/", "" )
@@ -1165,6 +1200,9 @@
             portDownDevAvg = round(numpy.mean(portDownDevList), 2)
             portDownGraphAvg = round(numpy.mean(portDownGraphList), 2)
 
+            portUpStdDev = round(numpy.std(portUpGraphList),2)
+            portDownStdDev = round(numpy.std(portDownGraphList),2)
+
             main.log.report( " - Node "+str(node+1)+" Summary - " )
             #main.log.report( " Port up ofp-to-device "+
             #                 str(round(portUpDevAvg, 2))+" ms")
@@ -1179,7 +1217,8 @@
                 "INSERT INTO port_latency_tests VALUES("
                    "'"+timeToPost+"','port_latency_results',"
                    ""+runNum+","+str(clusterCount)+",'baremetal"+str(node+1)+"',"
-                   ""+str(portUpGraphAvg)+",0,"+str(portDownGraphAvg)+",0);"
+                   ""+str(portUpGraphAvg)+","+str(portUpStdDev)+
+                   ","+str(portDownGraphAvg)+","+str(portDownStdDev)+");"
             )
         
         #Write to file for posting to DB
@@ -1189,6 +1228,8 @@
                 fResult.write(line+"\n")
         fResult.close()
 
+        print dbCmdList
+
         # Remove switches from controller for next test
         main.Mininet1.deleteSwController( "s1" )
         main.Mininet1.deleteSwController( "s2" )