[ONOS-6593]Review and Refactor ONOS startup procedures in TestON

Change-Id: I509a8ee7a26c198957bebf59da5c85a0edb8b995
diff --git a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.params b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.params
index 0b51d1a..633955f 100644
--- a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.params
+++ b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.params
@@ -16,8 +16,8 @@
     </TEST>
 
     <GIT>
-        <autopull>off</autopull>
-        <checkout>master</checkout>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <CTRL>
diff --git a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
index 9de1993..2547317 100644
--- a/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
+++ b/TestON/tests/SCPF/SCPFcbench/SCPFcbench.py
@@ -27,96 +27,41 @@
         except NameError:
             init = False
 
-        #Load values from params file
-        checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
-        gitPull = main.params[ 'GIT' ][ 'autopull' ]
-        BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
-        BENCHUser = main.params[ 'BENCH' ][ 'user' ]
-        CBENCHuser = main.params[ 'CBENCH'][ 'user' ]
-        MN1Ip = os.environ[ main.params[ 'MN' ][ 'ip1' ] ]
-        maxNodes = int(main.params[ 'availableNodes' ])
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        cellApps = main.params[ 'ENV' ][ 'cellApps' ]
-
         # -- INIT SECTION, ONLY RUNS ONCE -- #
         if init == False:
             init = True
-            global clusterCount             #number of nodes running
-            global ONOSIp                   #list of ONOS IP addresses
-            global scale
+            try:
+                from tests.dependencies.ONOSSetup import ONOSSetup
+                main.testSetUp = ONOSSetup()
+            except ImportError:
+                main.log.error( "ONOSSetup not found. exiting the test" )
+                main.exit()
+            main.testSetUp.envSetupDescription()
+            stepResult = main.FALSE
+            try:
+                # Load values from params file
+                BENCHIp = main.params['BENCH']['ip1']
+                BENCHUser = main.params['BENCH']['user']
+                CBENCHuser = main.params['CBENCH']['user']
+                MN1Ip = os.environ[main.params['MN']['ip1']]
+                main.maxNodes = int(main.params['availableNodes'])
+                main.cellName = main.params['ENV']['cellName']
+                main.apps = main.params['ENV']['cellApps']
+                main.scale = (main.params['SCALE']).split(",")
 
-            clusterCount = 0
-            ONOSIp = [ 0 ]
-            scale = (main.params[ 'SCALE' ]).split(",")
-            clusterCount = int(scale[0])
+                stepResult = main.testSetUp.envSetup( hasCli=False )
+            except Exception as e:
+                main.testSetUp.envSetupException( e )
+            main.testSetUp.evnSetupConclusion( stepResult )
 
-            #Populate ONOSIp with ips from params
-            for i in range(1, maxNodes + 1):
-                ipString = os.environ[main.params['CTRL']['ip1']]
-                ONOSIp.append(ipString)
-
-            #git
-            main.step( "Git checkout and pull " + checkoutBranch )
-            if gitPull == 'on':
-                checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
-                pullResult = main.ONOSbench.gitPull()
-
-            else:
-                checkoutResult = main.TRUE
-                pullResult = main.TRUE
-                main.log.info( "Skipped git checkout and pull" )
-
+            main.commit = ( main.commit.split( " " ) )[ 1 ]
         # -- END OF INIT SECTION --#
 
-        clusterCount = int(scale[0])
-        scale.remove(scale[0])
-
-        #kill off all onos processes
-        main.step("Safety check, killing all ONOS processes")
-        main.step("before initiating environment setup")
-        for node in range(1, maxNodes + 1):
-            main.ONOSbench.onosStop(ONOSIp[node])
-            main.ONOSbench.onosKill(ONOSIp[node])
-
-        #Uninstall everywhere
-        main.step( "Cleaning Enviornment..." )
-        for i in range(1, maxNodes + 1):
-            main.log.info(" Uninstalling ONOS " + str(i) )
-            main.ONOSbench.onosUninstall( ONOSIp[i] )
-
-        time.sleep(10)
-
-        print "Cellname is: "+ cellName + "ONOS IP is: " + str(ONOSIp)
-        main.ONOSbench.createCellFile(BENCHIp, cellName, MN1Ip,
-                                      cellApps, [ONOSIp[1]], main.ONOScli1.karafUser)
-
-        main.step( "Set Cell" )
-        main.ONOSbench.setCell(cellName)
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-
-        main.step( "verify cells" )
-        verifyCellResult = main.ONOSbench.verifyCell()
-
-        main.log.report( "Initializing " + str( clusterCount ) + " node cluster." )
-        for node in range(1, clusterCount + 1):
-            main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
-            main.ONOSbench.onosInstall( ONOSIp[node])
-            main.ONOSbench.onosSecureSSH( node=ONOSIp[node] )
-
-        for node in range(1, clusterCount + 1):
-            for i in range( 2 ):
-                isup = main.ONOSbench.isup( ONOSIp[node] )
-                if isup:
-                    main.log.info("ONOS " + str(node) + " is up\n")
-                    break
-            if not isup:
-                main.log.report( "ONOS " + str(node) + " didn't start!" )
-        main.log.info("Startup sequence complete")
+        main.testSetUp.ONOSSetUp( MN1Ip, True, hasCli=False,
+                                  cellName=main.cellName )
 
         for i in range(5):
-            main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true")
+            main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.fwd.ReactiveForwarding","packetOutOnly true")
             time.sleep(5)
             main.ONOSbench.handle.sendline("onos $OC1 cfg get|grep packetOutOnly")
             main.ONOSbench.handle.expect(":~")
@@ -146,7 +91,7 @@
         if mode != "t":
             mode = " "
 
-        runCbench = ( "ssh " + CBENCHuser + "@" + ONOSIp[1] + " " + cbenchCMD + mode )
+        runCbench = ( "ssh " + CBENCHuser + "@" + main.ONOSip[0] + " " + cbenchCMD + mode )
         main.ONOSbench.handle.sendline(runCbench)
         time.sleep(30)
         main.ONOSbench.handle.expect(":~")
@@ -174,20 +119,16 @@
                 main.log.info("Average: \t\t\t" + avg)
                 main.log.info("Standard Deviation: \t" + stdev)
 
-
-                commit = main.ONOSbench.getVersion()
-                commit = (commit.split(" "))[1]
-
                 try:
                     dbFileName="/tmp/CbenchDB"
                     dbfile = open(dbFileName, "w+")
-                    temp = "'" + commit + "',"
+                    temp = "'" + main.commit + "',"
                     temp += "'" + mode + "',"
                     temp += "'" + avg + "',"
                     temp += "'" + stdev + "'\n"
                     dbfile.write(temp)
                     dbfile.close()
-                    main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
+                    main.ONOSbench.logReport(main.ONOSip[0], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
                 except IOError:
                     main.log.warn("Error opening " + dbFileName + " to write results.")
 
diff --git a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.params b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.params
index 3ce83c0..a263ca6 100644
--- a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.params
+++ b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.params
@@ -26,8 +26,8 @@
     </TEST>
 
     <GIT>
-        <autopull>off</autopull>
-        <checkout>master</checkout>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <CTRL>
diff --git a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
index af88ab5..7dd924d 100644
--- a/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
+++ b/TestON/tests/SCPF/SCPFflowTp1g/SCPFflowTp1g.py
@@ -18,122 +18,43 @@
         import time
         global init
         try:
-            if type(init) is not bool:
+            if type( init ) is not bool:
                 init = False
         except NameError:
             init = False
 
-        #Load values from params file
-        checkoutBranch = main.params[ 'GIT' ][ 'checkout' ]
-        gitPull = main.params[ 'GIT' ][ 'autopull' ]
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-        Apps = main.params[ 'ENV' ][ 'cellApps' ]
-        BENCHUser = main.params[ 'BENCH' ][ 'user' ]
-        BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
-        main.maxNodes = int(main.params[ 'max' ])
-        cellName = main.params[ 'ENV' ][ 'cellName' ]
-
-        main.log.info("==========DEBUG VERSION 3===========")
+        main.log.info( "==========DEBUG VERSION 3===========" )
 
         # -- INIT SECTION, ONLY RUNS ONCE -- #
         if init == False:
-            init = True
-            global clusterCount             #number of nodes running
-            global ONOSIp                   #list of ONOS IP addresses
-            global scale
-            global commit
-
-            clusterCount = 0
-            ONOSIp = [ 0 ]
-            scale = (main.params[ 'SCALE' ]).split(",")
-            clusterCount = int(scale[0])
-
-            #Populate ONOSIp with ips from params
-            for i in range(1, main.maxNodes + 1):
-                ipString = 'ip' + str(i)
-                ONOSIp.append(main.params[ 'CTRL' ][ ipString ])
-
-            ONOSIp = [0]
-            ONOSIp.extend(main.ONOSbench.getOnosIps())
-
-            #git
-            main.step( "Git checkout and pull " + checkoutBranch )
-            if gitPull == 'on':
-                checkoutResult = main.ONOSbench.gitCheckout( checkoutBranch )
-                pullResult = main.ONOSbench.gitPull()
-
-            else:
-                checkoutResult = main.TRUE
-                pullResult = main.TRUE
-                main.log.info( "Skipped git checkout and pull" )
-
-            commit = main.ONOSbench.getVersion()
-            commit = (commit.split(" "))[1]
-
-            resultsDB = open("/tmp/flowTP1gDB", "w+")
-            resultsDB.close()
-
+            try:
+                init = True
+                try:
+                    from tests.dependencies.ONOSSetup import ONOSSetup
+                    main.testSetUp = ONOSSetup()
+                except ImportError:
+                    main.log.error( "ONOSSetup not found. exiting the test" )
+                    main.exit()
+                main.testSetUp.envSetupDescription()
+                #Load values from params file
+                cellName = main.params[ 'ENV' ][ 'cellName' ]
+                main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+                BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+                BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+                main.scale = ( main.params[ 'SCALE' ]  ).split( "," )
+                stepResult = main.testSetUp.envSetup()
+                resultsDB = open( "/tmp/flowTP1gDB", "w+" )
+                resultsDB.close()
+            except Exception as e:
+                main.testSetUp.envSetupException( e )
+            main.testSetUp.evnSetupConclusion( stepResult )
+            main.commit = (main.commit.split(" "))[1]
         # -- END OF INIT SECTION --#
 
-        clusterCount = int(scale[0])
-        scale.remove(scale[0])
-        main.log.info("CLUSTER COUNT: " + str(clusterCount))
-
-        #kill off all onos processes
-        main.step("Safety check, killing all ONOS processes")
-        main.step("before initiating environment setup")
-        for node in range(1, main.maxNodes + 1):
-            main.ONOSbench.onosStop(ONOSIp[node])
-            main.ONOSbench.onosKill(ONOSIp[node])
-
-        #Uninstall everywhere
-        main.step( "Cleaning Enviornment..." )
-        for i in range(1, main.maxNodes + 1):
-            main.log.info(" Uninstalling ONOS " + str(i) )
-            main.ONOSbench.onosUninstall( ONOSIp[i] )
-
-        #construct the cell file
-        main.log.info("Creating cell file")
-        cellIp = []
-        for node in range (1, clusterCount + 1):
-            cellIp.append(ONOSIp[node])
-
-        main.ONOSbench.createCellFile(BENCHIp, cellName, "localhost",
-                                      str(Apps), cellIp, main.ONOScli1.karafUser)
-        main.log.info("Cell Ip list: " + str(cellIp))
-
-        main.step( "Set Cell" )
-        main.ONOSbench.setCell(cellName)
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-
-        main.step( "verify cells" )
-        verifyCellResult = main.ONOSbench.verifyCell()
-
-        main.log.report( "Initializeing " + str( clusterCount ) + " node cluster." )
-        for node in range(1, clusterCount + 1):
-            main.log.info("Starting ONOS " + str(node) + " at IP: " + ONOSIp[node])
-            main.ONOSbench.onosInstall( ONOSIp[node])
-
-        for node in range(1, clusterCount + 1):
-            secureSshResult = main.ONOSbench.onosSecureSSH( ONOSIp[node] )
-
-        for node in range(1, clusterCount + 1):
-            for i in range( 2 ):
-                isup = main.ONOSbench.isup( ONOSIp[node] )
-                if isup:
-                    main.log.info("ONOS " + str(node) + " is up\n")
-                    break
-            if not isup:
-                main.log.report( "ONOS " + str(node) + " didn't start!" )
-
-        for node in range(1, clusterCount + 1):
-            exec "a = main.ONOScli%s.startOnosCli" %str(node)
-            a(ONOSIp[node])
+        main.testSetUp.ONOSSetUp( "localhost", True, cellName=cellName )
 
         main.log.info("Startup sequence complete")
-        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
+        main.ONOSbench.logReport(main.ONOSip[0], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
 
     def CASE2( self, main ):
         #
@@ -164,7 +85,6 @@
         neighborList = (main.params[ 'TEST' ][ 'neighbors' ]).split(",")
         testCMD[0] = main.params[ 'TEST' ][ 'testCMD0' ]
         testCMD[1] = main.params[ 'TEST' ][ 'testCMD1' ]
-        main.maxNodes = main.params[ 'max' ]
         cooldown = main.params[ 'TEST' ][ 'cooldown' ]
         cellName = main.params[ 'ENV' ][ 'cellName' ]
         BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
@@ -174,14 +94,14 @@
         flowRuleBackup = str(main.params[ 'TEST' ][ 'enableFlowRuleStoreBackup' ])
         main.log.info("Flow Rule Backup is set to:" + flowRuleBackup)
 
-        servers = str(clusterCount)
+        servers = str( main.numCtrls )
 
-        if clusterCount == 1:
+        if main.numCtrls == 1:
             neighborList = ['0']
             currentNeighbors = "r"
         else:
             if currentNeighbors == "a":
-                neighborList = [str(clusterCount-1)]
+                neighborList = [ str( main.numCtrls - 1 ) ]
                 currentNeighbors = "r"
             else:
                 neighborList = ['0']
@@ -193,23 +113,23 @@
 
         for n in neighborList:
             main.step("\tSTARTING TEST")
-            main.step("\tLOADING FROM SERVERS:  \t" + str(clusterCount) )
+            main.step("\tLOADING FROM SERVERS:  \t" + str( main.numCtrls ) )
             main.step("\tNEIGHBORS:\t" + n )
             main.log.info("=============================================================")
             main.log.info("=============================================================")
             #write file to configure nil link
             ipCSV = ""
-            for i in range (1, int(main.maxNodes) + 1):
-                tempstr = "ip" + str(i)
+            for i in range ( main.maxNodes ):
+                tempstr = "ip" + str( i + 1 )
                 ipCSV += main.params[ 'CTRL' ][ tempstr ]
-                if i < int(main.maxNodes):
+                if i + 1 < main.maxNodes:
                     ipCSV +=","
 
-            main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupCount 1")
+            main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.store.flow.impl.DistributedFlowRuleStore", "backupCount 1")
             for i in range(3):
-                main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
-                main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
-                main.ONOSbench.onosCfgSet(ONOSIp[1], "org.onosproject.provider.nil.NullProviders", "enabled true")
+                main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "deviceCount 35")
+                main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "topoShape linear")
+                main.ONOSbench.onosCfgSet(main.ONOSip[0], "org.onosproject.provider.nil.NullProviders", "enabled true")
 
                 time.sleep(5)
                 main.ONOSbench.handle.sendline("onos $OC1 summary")
@@ -236,8 +156,8 @@
 
             #build list of servers in "$OC1, $OC2...." format
             serverEnvVars = ""
-            for i in range (1,int(servers)+1):
-                serverEnvVars += ("-s " + ONOSIp[i] + " ")
+            for i in range( int( servers ) ):
+                serverEnvVars += ( "-s " + main.ONOSip[ i ] + " " )
 
             data = [[""]*int(servers)]*int(sampleSize)
             maxes = [""]*int(sampleSize)
@@ -263,10 +183,10 @@
                 if "failed" in rawResult:
                     main.log.report("FLOW_TESTER.PY FAILURE")
                     main.log.report( " \n" + rawResult + " \n")
-                    for i in range(1, clusterCount+1):
+                    for i in range( main.numCtrls ):
                         main.log.report("=======================================================")
-                        main.log.report(" ONOS " + str(i) + "LOG REPORT")
-                        main.ONOSbench.logReport(ONOSIp[i], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
+                        main.log.report(" ONOS " + str( i + 1 ) + "LOG REPORT")
+                        main.ONOSbench.logReport( main.ONOSip[ i ], ["ERROR", "WARNING", "EXCEPT"], outputMode="d" )
                     main.ONOSbench.handle.sendline("onos $OC1 flows")
                     main.ONOSbench.handle.expect(":~")
                     main.log.info(main.ONOSbench.handle.before)
@@ -274,17 +194,17 @@
                     break
 
             ########################################################################################
-                result = [""]*(clusterCount)
+                result = [""]*( main.numCtrls )
 
                 #print("rawResult: " + rawResult)
 
                 rawResult = rawResult.splitlines()
 
-                for node in range(1, clusterCount + 1):
+                for node in range( main.numCtrls ):
                     for line in rawResult:
                         #print("line: " + line)
-                        if ONOSIp[node] in line and "server" in line:
-                            temp = line.split(" ")
+                        if main.ONOSip[ node ] in line and "server" in line:
+                            temp = line.split( " " )
                             for word in temp:
                                 #print ("word: " + word)
                                 if "elapsed" in repr(word):
@@ -292,8 +212,8 @@
                                     myParsed = (temp[index]).replace(",","")
                                     myParsed = myParsed.replace("}","")
                                     myParsed = int(myParsed)
-                                    result[node-1] = myParsed
-                                    main.log.info( ONOSIp[node] + " : " + str(myParsed))
+                                    result[ node ] = myParsed
+                                    main.log.info( main.ONOSip[ node ] + " : " + str( myParsed ) )
                                     break
 
                 if test >= warmUp:
@@ -370,16 +290,16 @@
             main.log.info("Average thoughput:  " + str(avgTP) + " Kflows/second" )
             main.log.info("Standard deviation of throughput: " + str(stdTP) + " Kflows/second")
 
-            resultsLog = open("/tmp/flowTP1gDB","a")
-            resultString = ("'" + commit + "',")
-            resultString += ("'1gig',")
-            resultString += ((main.params[ 'TEST' ][ 'flows' ]) + ",")
-            resultString += (str(clusterCount) + ",")
-            resultString += (str(n) + ",")
-            resultString += (str(avgTP) + "," + str(stdTP) + "\n")
-            resultsLog.write(resultString)
+            resultsLog = open( "/tmp/flowTP1gDB", "a" )
+            resultString = ( "'" + main.commit + "'," )
+            resultString += ( "'1gig'," )
+            resultString += ( (main.params[ 'TEST' ][ 'flows' ] ) + "," )
+            resultString += ( str( main.numCtrls ) + "," )
+            resultString += ( str( n ) + "," )
+            resultString += ( str( avgTP ) + "," + str( stdTP ) + "\n" )
+            resultsLog.write( resultString )
             resultsLog.close()
 
-            main.log.report("Result line to file: " + resultString)
+            main.log.report( "Result line to file: " + resultString )
 
-        main.ONOSbench.logReport(ONOSIp[1], ["ERROR", "WARNING", "EXCEPT"], outputMode="d")
+        main.ONOSbench.logReport( main.ONOSip[ 0 ], [ "ERROR", "WARNING", "EXCEPT" ], outputMode="d" )
diff --git a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
index e3af24a..8ab7a44 100644
--- a/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
+++ b/TestON/tests/SCPF/SCPFhostLat/SCPFhostLat.py
@@ -18,83 +18,69 @@
         import time
         import os
         import imp
-
-        main.case( "Constructing test variables and building ONOS package" )
-        main.step( "Constructing test variables" )
-        stepResult = main.FALSE
-
-        # Test variables
-        main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
-        main.cellName = main.params[ 'ENV' ][ 'cellName' ]
-        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
-        main.scale = ( main.params[ 'SCALE' ] ).split( "," )
-        main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
-        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
-        main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
-        main.measurementSleep = int( main.params['SLEEP']['measurement'])
-        main.timeout = int( main.params['SLEEP']['timeout'] )
-        main.dbFileName = main.params['DATABASE']['file']
-        main.cellData = {} # for creating cell file
-
-        # Tshark params
-        main.tsharkResultPath = main.params['TSHARK']['tsharkPath']
-        main.tsharkPacketIn = main.params['TSHARK']['tsharkPacketIn']
-
-        main.numlter = main.params['TEST']['numIter']
-        main.iterIgnore = int(main.params['TEST']['iterIgnore'])
-        main.hostTimestampKey = main.params['TEST']['hostTimestamp']
-        main.thresholdStr = main.params['TEST']['singleSwThreshold']
-        main.thresholdObj = main.thresholdStr.split(',')
-        main.thresholdMin = int(main.thresholdObj[0])
-        main.thresholdMax = int(main.thresholdObj[1])
-        main.threadID = 0
-
-        main.CLIs = []
-        main.ONOSip = []
-        main.maxNumBatch = 0
-        main.ONOSip = main.ONOSbench.getOnosIps()
-        main.log.info(main.ONOSip)
-        main.setupSkipped = False
-
-        gitBranch = main.params[ 'GIT' ][ 'branch' ]
-        gitPull = main.params[ 'GIT' ][ 'pull' ]
-        nic = main.params['DATABASE']['nic']
-        node = main.params['DATABASE']['node']
-        nic = main.params['DATABASE']['nic']
-        node = main.params['DATABASE']['node']
-        stepResult = main.TRUE
-
-        main.log.info("Cresting DB file")
-        with open(main.dbFileName, "w+") as dbFile:
-            dbFile.write("")
-
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="environment set up successfull",
-                                 onfail="environment set up Failed" )
-
-    def CASE1( self ):
-        # main.scale[ 0 ] determines the current number of ONOS controller
-        main.CLIs = []
-        main.numCtrls = int( main.scale[ 0 ] )
-        main.log.info( "Creating list of ONOS cli handles" )
-        for i in range(main.numCtrls):
-            main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
-
-        main.log.info(main.CLIs)
-        if not main.CLIs:
-            main.log.error( "Failed to create the list of ONOS cli handles" )
-            main.cleanup()
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
             main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
 
-        main.commit = main.ONOSbench.getVersion(report=True)
-        main.commit = main.commit.split(" ")[1]
+            # Test variables
+            main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+            main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+            main.measurementSleep = int( main.params[ 'SLEEP' ][ 'measurement' ] )
+            main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
+            main.dbFileName = main.params[ 'DATABASE' ][ 'file' ]
 
-        with open(main.dbFileName, "a") as dbFile:
+            # Tshark params
+            main.tsharkResultPath = main.params[ 'TSHARK' ][ 'tsharkPath' ]
+            main.tsharkPacketIn = main.params[ 'TSHARK' ][ 'tsharkPacketIn' ]
+
+            main.numlter = main.params[ 'TEST' ][ 'numIter' ]
+            main.iterIgnore = int( main.params[ 'TEST' ][ 'iterIgnore' ] )
+            main.hostTimestampKey = main.params[ 'TEST' ][ 'hostTimestamp' ]
+            main.thresholdStr = main.params[ 'TEST' ][ 'singleSwThreshold' ]
+            main.thresholdObj = main.thresholdStr.split( ',' )
+            main.thresholdMin = int( main.thresholdObj[ 0 ] )
+            main.thresholdMax = int( main.thresholdObj[ 1 ] )
+            main.threadID = 0
+
+            main.maxNumBatch = 0
+            main.setupSkipped = False
+
+            nic = main.params[ 'DATABASE' ][ 'nic' ]
+            node = main.params[ 'DATABASE' ][ 'node' ]
+            nic = main.params[ 'DATABASE' ][ 'nic' ]
+            node = main.params[ 'DATABASE' ][ 'node' ]
+            stepResult = main.TRUE
+
+            main.log.info( "Cresting DB file" )
+            with open( main.dbFileName, "w+" ) as dbFile:
+                dbFile.write( "" )
+
+            stepResult = main.testSetUp.gitPulling()
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+
+        main.commit = main.commit.split( " " )[ 1 ]
+
+        with open( main.dbFileName, "a" ) as dbFile:
             temp = "'" + main.commit + "',"
             temp += "'" + nic + "',"
-            dbFile.write(temp)
+            dbFile.write( temp )
             dbFile.close()
+    def CASE1( self ):
+        # main.scale[ 0 ] determines the current number of ONOS controller
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
 
     def CASE2( self, main ):
         """
@@ -103,118 +89,9 @@
         - Install ONOS cluster
         - Connect to cli
         """
-        main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls)
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.numCtrls ):
-            main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            main.ONOSbench.onosKill( main.ONOSip[ i ] )
-
-        main.log.info( "NODE COUNT = %s" % main.numCtrls)
-
-        tempOnosIp = []
-        for i in range( main.numCtrls ):
-            tempOnosIp.append( main.ONOSip[i] )
-
-        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
-                                       "temp",
-                                       main.Mininet1.ip_address,
-                                       main.apps,
-                                       tempOnosIp,
-                                       main.ONOScli1.karafUser )
-
-        main.step( "Apply cell to environment" )
-        cellResult = main.ONOSbench.setCell( "temp" )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully applied cell to " + \
-                                        "environment",
-                                 onfail="Failed to apply cell to environment " )
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully created ONOS package",
-                                 onfail="Failed to create ONOS package" )
-
-        main.step( "Uninstall ONOS package on all Nodes" )
-        uninstallResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
-            u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=u_result,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            uninstallResult = ( uninstallResult and u_result )
-
-        main.step( "Install ONOS package on all Nodes" )
-        installResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
-            i_result = main.ONOSbench.onosInstall( node=main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=i_result,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        main.step( "Start ONOS CLI on all nodes" )
-        cliResult = main.TRUE
-        main.step(" Start ONOS cli using thread ")
-        time.sleep( main.startUpSleep )
-        startCliResult  = main.TRUE
-        pool = []
-
-        for i in range( int( main.numCtrls) ):
-            t = main.Thread( target=main.CLIs[i].startOnosCli,
-                             threadID=main.threadID,
-                             name="startOnosCli",
-                             args=[ main.ONOSip[i] ],
-                             kwargs = {"onosStartTimeout":main.timeout} )
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep( main.startUpSleep )
+        main.testSetUp.ONOSSetUp( main.Mininet1, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
 
     def CASE11( self, main ):
         main.log.info( "set and configure Application" )
@@ -224,7 +101,7 @@
         main.step( "Activating org.onosproject.proxyarp" )
         appStatus = utilities.retry( main.ONOSrest1.activateApp,
                                      main.FALSE,
-                                     ['org.onosproject.proxyarp'],
+                                     [ 'org.onosproject.proxyarp' ],
                                      sleep=3,
                                      attempts=3 )
         utilities.assert_equals( expect=main.TRUE,
@@ -246,7 +123,7 @@
                                  onpass="Successfully set DefaultTopologyProvider",
                                  onfail="Failed to set DefaultTopologyProvider" )
 
-        time.sleep(main.startUpSleep)
+        time.sleep( main.startUpSleep)
         main.step('Starting mininet topology')
         mnStatus = main.Mininet1.startNet(args='--topo=linear,1')
         utilities.assert_equals( expect=main.TRUE,
@@ -261,7 +138,7 @@
                                  onpass="Successfully assigned switches to masters",
                                  onfail="Failed assign switches to masters" )
 
-        time.sleep(main.startUpSleep)
+        time.sleep( main.startUpSleep)
 
     def CASE20(self, main):
         """
@@ -278,72 +155,80 @@
         import requests
         import os
         import numpy
-
+        try:
+            from tests.dependencies.utils import Utils
+        except ImportError:
+            main.log.error( "Utils not found exiting the test" )
+            main.exit()
+        try:
+            main.Utils
+        except ( NameError, AttributeError ):
+            main.Utils = Utils()
         # Host adding measurement
         assertion = main.TRUE
 
         main.log.report('Latency of adding one host to ONOS')
-        main.log.report('First ' + str(main.iterIgnore) + ' iterations ignored' + ' for jvm warmup time')
-        main.log.report('Total iterations of test: ' + str(main.numlter))
+        main.log.report('First ' + str( main.iterIgnore ) + ' iterations ignored' + ' for jvm warmup time')
+        main.log.report('Total iterations of test: ' + str( main.numlter ) )
 
         addingHostTime = []
         metricsResultList = []
-        for i in range(0, int(main.numlter)):
-            main.log.info('Clean up data file')
-            with open(main.tsharkResultPath, "w") as dbFile:
-                dbFile.write("")
+        for i in range( 0, int( main.numlter ) ):
+            main.log.info( 'Clean up data file' )
+            with open( main.tsharkResultPath, "w" ) as dbFile:
+                dbFile.write( "" )
 
             main.log.info('Starting tshark capture')
-            main.ONOSbench.tsharkGrep(main.tsharkPacketIn, main.tsharkResultPath)
-            time.sleep(main.measurementSleep)
+            main.ONOSbench.tsharkGrep( main.tsharkPacketIn, main.tsharkResultPath )
+            time.sleep( main.measurementSleep )
 
             main.log.info('host 1 arping...')
             main.Mininet1.arping(srcHost='h1', dstHost='10.0.0.2')
 
-            time.sleep(main.measurementSleep)
+            time.sleep( main.measurementSleep )
 
             main.log.info('Stopping all Tshark processes')
             main.ONOSbench.tsharkStop()
 
-            time.sleep(main.measurementSleep)
+            time.sleep( main.measurementSleep )
 
             # Get tshark output
-            with open(main.tsharkResultPath, "r") as resultFile:
+            with open( main.tsharkResultPath, "r" ) as resultFile:
                 resultText = resultFile.readline()
-                main.log.info('Capture result:' + resultText)
+                main.log.info( 'Capture result:' + resultText )
                 resultText = resultText.split(' ')
-                if len(resultText) > 1:
-                    tsharkResultTime = float(resultText[1]) * 1000.0
+                if len( resultText ) > 1:
+                    tsharkResultTime = float( resultText[ 1 ] ) * 1000.0
                 else:
-                    main.log.error('Tshark output file for packet_in' + ' returned unexpected results')
+                    main.log.error( 'Tshark output file for packet_in' + ' returned unexpected results' )
                     hostTime = 0
                     caseResult = main.FALSE
                 resultFile.close()
             # Compare the timestemps, and get the lowest one.
             temp = 0;
             # Get host event timestamps from each nodes
-            for node in range (0, main.numCtrls):
-                metricsResult = json.loads(main.CLIs[node].topologyEventsMetrics())
-                metricsResult = metricsResult.get(main.hostTimestampKey).get("value")
-                main.log.info("ONOS topology event matrics timestemp: {}".format(str(metricsResult)) )
+            for node in range ( 0, main.numCtrls ):
+                metricsResult = json.loads( main.CLIs[ node ].topologyEventsMetrics() )
+                metricsResult = metricsResult.get( main.hostTimestampKey ).get( "value" )
+                main.log.info( "ONOS topology event matrics timestemp: {}".format( str( metricsResult ) ) )
 
                 if temp < metricsResult:
                     temp = metricsResult
                 metricsResult = temp
 
-            addingHostTime.append(float(metricsResult) - tsharkResultTime)
-            main.log.info("Result of this iteration: {}".format( str( float(metricsResult) - tsharkResultTime) ))
+            addingHostTime.append( float( metricsResult ) - tsharkResultTime )
+            main.log.info( "Result of this iteration: {}".format( str( float( metricsResult ) - tsharkResultTime) ) )
             # gethost to remove
             gethost = main.ONOSrest1.hosts()
             HosttoRemove = []
-            HosttoRemove.append( json.loads( gethost[1:len(gethost)-1] ).get('id') )
-            main.CLIs[0].removeHost(HosttoRemove)
+            HosttoRemove.append( json.loads( gethost[ 1:len( gethost )-1 ] ).get( 'id' ) )
+            main.CLIs[0].removeHost( HosttoRemove )
 
-        main.log.info("Result List: {}".format(addingHostTime))
+        main.log.info( "Result List: {}".format( addingHostTime ) )
 
         # calculate average latency from each nodes
-        averageResult = numpy.average(addingHostTime)
-        main.log.info("Average Latency: {}".format(averageResult))
+        averageResult = numpy.average( addingHostTime )
+        main.log.info( "Average Latency: {}".format( averageResult ) )
 
         # calculate std
         stdResult = numpy.std(addingHostTime)
@@ -368,5 +253,4 @@
                 onpass='Host latency test successful',
                 onfail='Host latency test failed')
 
-        main.Mininet1.stopNet()
-        del main.scale[0]
+        main.Utils.mininetCleanup( main.Mininet1 )
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
index 7952499..30e6e02 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
@@ -13,8 +13,8 @@
     <max>7</max>
 
     <GIT>
-        <gitPull>off</gitPull>
-        <gitBranch>master</gitBranch>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <CTRL>
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
index f71d2e5..adc6ac2 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
@@ -24,196 +24,69 @@
             different versions of ONOS.
         - Construct tests variables
         '''
-        gitPull = main.params['GIT']['gitPull']
-        gitBranch = main.params['GIT']['gitBranch']
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
+            main.cellName = main.params[ 'ENV'][ 'cellName']
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+            main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+            main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+            main.maxNodes = int( main.params[ 'max' ] )
+            main.numSwitches = ( main.params[ 'TEST' ][ 'numSwitches' ] ).split(",")
+            main.skipRelRsrc = main.params[ 'TEST' ][ 'skipReleaseResourcesOnWithdrawal' ]
+            main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+            main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
+            main.scale = ( main.params[ 'SCALE' ] ).split(",")
+            main.testDuration = main.params[ 'TEST' ][ 'duration' ]
+            main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
+            main.debug = main.params[ 'debugMode' ]
+            main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
+            main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
+            if main.flowObj == "True":
+                main.flowObj = True
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
+                main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ]
+            else:
+                main.flowObj = False
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
+                main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
 
-        main.case( "Pull onos branch and build onos on Teststation." )
+            stepResult = main.testSetUp.gitPulling()
+            # Create DataBase file
+            main.log.info( "Create Database file " + main.dbFileName )
+            resultsDB = open( main.dbFileName, "w+" )
+            resultsDB.close()
 
-        if gitPull == 'True':
-            main.step( "Git Checkout ONOS branch: " + gitBranch )
-            stepResult = main.ONOSbench.gitCheckout( branch=gitBranch )
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully checkout onos branch.",
-                                    onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult: main.exit()
-
-            main.step( "Git Pull on ONOS branch:" + gitBranch )
-            stepResult = main.ONOSbench.gitPull()
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully pull onos. ",
-                                    onfail="Failed to pull onos. Exiting test ...")
-            if not stepResult: main.exit()
-
-        else:
-            main.log.warn( "Skipped pulling onos" )
-
-        main.cellName = main.params['ENV']['cellName']
-        main.Apps = main.params['ENV']['cellApps']
-        main.BENCHIp = main.params['BENCH']['ip1']
-        main.BENCHUser = main.params['BENCH']['user']
-        main.MN1Ip = main.params['MN']['ip1']
-        main.maxNodes = int(main.params['max'])
-        main.numSwitches = (main.params['TEST']['numSwitches']).split(",")
-        main.skipRelRsrc = main.params['TEST']['skipReleaseResourcesOnWithdrawal']
-        main.flowObj = main.params['TEST']['flowObj']
-        main.startUpSleep = int(main.params['SLEEP']['startup'])
-        main.installSleep = int(main.params['SLEEP']['install'])
-        main.verifySleep = int(main.params['SLEEP']['verify'])
-        main.scale = (main.params['SCALE']).split(",")
-        main.testDuration = main.params[ 'TEST' ][ 'duration' ]
-        main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
-        main.debug = main.params[ 'debugMode' ]
-        main.timeout = int(main.params['SLEEP']['timeout'])
-        main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
-        if main.flowObj == "True":
-            main.flowObj = True
-            main.dbFileName = main.params['DATABASE']['dbFlowObj']
-            main.numKeys = main.params[ 'TEST' ][ 'numKeysFlowObj' ]
-        else:
-            main.flowObj = False
-            main.dbFileName = main.params['DATABASE']['dbName']
-            main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
-        # Create DataBase file
-        main.log.info( "Create Database file " + main.dbFileName )
-        resultsDB = open( main.dbFileName, "w+" )
-        resultsDB.close()
-
-        # set neighbors
-        main.neighbors = "1"
+            # set neighbors
+            main.neighbors = "1"
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
 
     def CASE1( self, main ):
         # Clean up test environment and set up
         import time
-        main.log.info( "Get ONOS cluster IP" )
-        print( main.scale )
-        main.numCtrls = int( main.scale.pop(0) )
-        main.ONOSip = []
         main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range( main.numCtrls ):
-            main.ONOSip.append( main.AllONOSip[i] )
-        main.log.info( main.ONOSip )
-        main.CLIs = []
-        main.log.info( "Creating list of ONOS cli handles" )
-        for i in range( main.numCtrls ):
-            main.CLIs.append( getattr( main, 'ONOScli%s' % (i + 1) ) )
-
-        if not main.CLIs:
-            main.log.error( "Failed to create the list of ONOS cli handles" )
-            main.cleanup()
-            main.exit()
-
-        main.commit = main.ONOSbench.getVersion( report=True )
-        main.commit = main.commit.split(" ")[1]
-        main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls )
-        main.log.info("Safety check, killing all ONOS processes" +
-                      " before initiating environment setup")
-
-        for i in range( main.numCtrls ):
-            main.ONOSbench.onosStop( main.ONOSip[i] )
-            main.ONOSbench.onosKill( main.ONOSip[i] )
-
-        main.log.info( "NODE COUNT = %s" % main.numCtrls )
-        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
-                                      main.cellName,
-                                      main.MN1Ip,
-                                      main.Apps,
-                                      main.ONOSip,
-                                      main.ONOScli1.karafUser )
-        main.step( "Apply cell to environment" )
-        cellResult = main.ONOSbench.setCell( main.cellName )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully applied cell to " + \
-                                       "environment",
-                                onfail="Failed to apply cell to environment ")
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully created ONOS package",
-                                onfail="Failed to create ONOS package")
-
-        main.step( "Uninstall ONOS package on all Nodes" )
-        uninstallResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
-            u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            uninstallResult = ( uninstallResult and u_result )
-
-        main.step( "Install ONOS package on all Nodes" )
-        installResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
-            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        main.step( "Start ONOS cli using thread" )
-        startCliResult = main.TRUE
-        pool = []
-        main.threadID = 0
-        for i in range(int(main.numCtrls)):
-            t = main.Thread(target=main.CLIs[i].startOnosCli,
-                            threadID=main.threadID,
-                            name="startOnosCli",
-                            args=[main.ONOSip[i]],
-                            kwargs={"onosStartTimeout": main.timeout})
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep( main.startUpSleep )
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
+        main.testSetUp.ONOSSetUp( main.MN1Ip, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
 
         # config apps
         main.CLIs[0].setCfg( "org.onosproject.net.intent.impl.IntentManager",
                                   "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc )
-        main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int(main.numCtrls*10)) )
+        main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount " + str(int( main.numCtrls*10)) )
         main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape linear" )
         main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" )
         if main.flowObj:
@@ -248,7 +121,7 @@
         main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) )
         main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod )
 
-        main.log.info( "Starting intent-perf test for " + str(main.testDuration) + " seconds..." )
+        main.log.info( "Starting intent-perf test for " + str( main.testDuration) + " seconds..." )
         main.CLIs[0].sendline( "intent-perf-start" )
         stop = time.time() + float( main.testDuration )
 
@@ -256,20 +129,20 @@
             time.sleep(15)
             result = main.CLIs[0].getIntentPerfSummary()
             if result:
-                for ip in main.ONOSip:
-                    main.log.info( "Node {} Overall Rate: {}".format( ip, result[ip] ) )
+                for i in range( main.numCtrls ):
+                    main.log.info( "Node {} Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) )
         main.log.info( "Stop intent-perf" )
-        for node in main.CLIs:
-            node.sendline( "intent-perf-stop" )
+        for i in range( main.numCtrls ):
+            main.CLIs[i].sendline( "intent-perf-stop" )
         if result:
-            for ip in main.ONOSip:
-                main.log.info( "Node {} final Overall Rate: {}".format( ip, result[ip] ) )
+            for i in range( main.numCtrls ):
+                main.log.info( "Node {} final Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) )
 
         with open( main.dbFileName, "a" ) as resultDB:
-            for nodes in range( 0, len( main.ONOSip ) ):
+            for nodes in range( main.numCtrls ):
                 resultString = "'" + main.commit + "',"
                 resultString += "'1gig',"
-                resultString += str(main.numCtrls) + ","
+                resultString += str( main.numCtrls) + ","
                 resultString += "'baremetal" + str( nodes+1 ) + "',"
                 resultString += main.neighbors + ","
                 resultString += result[ main.ONOSip[ nodes ] ]+","
diff --git a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.params b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.params
index 308e0d0..033c05f 100644
--- a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.params
+++ b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.params
@@ -21,8 +21,8 @@
      </TEST>
 
     <GIT>
-        <gitPull>off</gitPull>
-        <gitBranch>master</gitBranch>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <DATABASE>
diff --git a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
index 345bd44..093b5ca 100644
--- a/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
+++ b/TestON/tests/SCPF/SCPFintentInstallWithdrawLat/SCPFintentInstallWithdrawLat.py
@@ -4,7 +4,7 @@
     - Use Push-test-intents command to push intents
     - Use Null provider with 7 devices and linear topology
     - Always push intents between 1/6 and 7/5
-    - The batch size is defined in parm file. (default 1,100,1000)
+    - The batch size is defined in parm file. ( default 1,100,1000)
 
     yunpeng@onlab.us
 """
@@ -22,220 +22,91 @@
             different versions of ONOS.
         - Construct tests variables
         '''
-        gitPull = main.params['GIT']['gitPull']
-        gitBranch = main.params['GIT']['gitBranch']
 
-        main.case("Pull onos branch and build onos on Teststation.")
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
 
-        if gitPull == 'True':
-            main.step("Git Checkout ONOS branch: " + gitBranch)
-            stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully checkout onos branch.",
-                                    onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult: main.exit()
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+            main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+            main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+            main.maxNodes = int( main.params[ 'max' ] )
+            main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+            main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+            main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+            main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
+            main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
+            main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
+            main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
+            main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
+            main.ingress = main.params[ 'TEST' ][ 'ingress' ]
+            main.egress = main.params[ 'TEST' ][ 'egress' ]
+            main.debug = main.params[ 'TEST' ][ 'debug' ]
+            main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
 
-            main.step("Git Pull on ONOS branch:" + gitBranch)
-            stepResult = main.ONOSbench.gitPull()
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully pull onos. ",
-                                    onfail="Failed to pull onos. Exiting test ...")
-            if not stepResult: main.exit()
+            if main.flowObj == "True":
+                main.flowObj = True
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
+            else:
+                main.flowObj = False
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
 
+            for i in range( 0, len( main.intentsList ) ):
+                main.intentsList[ i ] = int( main.intentsList[ i ] )
 
-        else:
-            main.log.warn("Skipped pulling onos and Skipped building ONOS")
-
-        main.apps = main.params['ENV']['cellApps']
-        main.BENCHUser = main.params['BENCH']['user']
-        main.BENCHIp = main.params['BENCH']['ip1']
-        main.MN1Ip = main.params['MN']['ip1']
-        main.maxNodes = int(main.params['max'])
-        main.cellName = main.params['ENV']['cellName']
-        main.scale = (main.params['SCALE']).split(",")
-        main.timeout = int(main.params['SLEEP']['timeout'])
-        main.startUpSleep = int(main.params['SLEEP']['startup'])
-        main.installSleep = int(main.params['SLEEP']['install'])
-        main.verifySleep = int(main.params['SLEEP']['verify'])
-        main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
-        main.sampleSize = int(main.params['TEST']['sampleSize'])
-        main.warmUp = int(main.params['TEST']['warmUp'])
-        main.intentsList = (main.params['TEST']['intents']).split(",")
-        main.ingress = main.params['TEST']['ingress']
-        main.egress = main.params['TEST']['egress']
-        main.debug = main.params['TEST']['debug']
-        main.flowObj = main.params['TEST']['flowObj']
-
-        if main.flowObj == "True":
-            main.flowObj = True
-            main.dbFileName = main.params['DATABASE']['dbFlowObj']
-        else:
-            main.flowObj = False
-            main.dbFileName = main.params['DATABASE']['dbName']
-
-        for i in range(0, len(main.intentsList)):
-            main.intentsList[i] = int(main.intentsList[i])
-        # Create DataBase file
-        main.log.info("Create Database file " + main.dbFileName)
-        resultsDB = open(main.dbFileName, "w+")
-        resultsDB.close()
-
+            stepResult = main.testSetUp.gitPulling()
+            # Create DataBase file
+            main.log.info( "Create Database file " + main.dbFileName )
+            resultsDB = open( main.dbFileName, "w+" )
+            resultsDB.close()
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
     def CASE1( self, main ):
         # Clean up test environment and set up
         import time
-        main.log.info("Get ONOS cluster IP")
-        print(main.scale)
-        main.numCtrls = int(main.scale[0])
-        main.ONOSip = []
+
         main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range(main.numCtrls):
-            main.ONOSip.append(main.AllONOSip[i])
-        main.log.info(main.ONOSip)
-        main.CLIs = []
-        main.log.info("Creating list of ONOS cli handles")
-        for i in range(main.numCtrls):
-            main.CLIs.append(getattr(main, 'ONOScli%s' %(i + 1)))
-
-        if not main.CLIs:
-            main.log.error("Failed to create the list of ONOS cli handles")
-            main.cleanup()
-            main.exit()
-
-        main.commit = main.ONOSbench.getVersion(report=True)
-        main.commit = main.commit.split(" ")[1]
-        main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
-        main.log.info("Safety check, killing all ONOS processes" +
-                      " before initiating environment setup")
-
-        for i in range(main.numCtrls):
-            main.ONOSbench.onosStop(main.ONOSip[i])
-            main.ONOSbench.onosKill(main.ONOSip[i])
-
-        main.log.info("NODE COUNT = %s" % main.numCtrls)
-        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
-                                      main.cellName,
-                                      main.MN1Ip,
-                                      main.apps,
-                                      main.ONOSip,
-                                      main.ONOScli1.karafUser )
-        main.step("Apply cell to environment")
-        cellResult = main.ONOSbench.setCell(main.cellName)
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully applied cell to " + \
-                                       "environment",
-                                onfail="Failed to apply cell to environment ")
-
-        main.step("Creating ONOS package")
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully created ONOS package",
-                                onfail="Failed to create ONOS package")
-
-        main.step("Uninstall ONOS package on all Nodes")
-        uninstallResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
-            u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            uninstallResult = (uninstallResult and u_result)
-
-        main.step("Install ONOS package on all Nodes")
-        installResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
-            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        time.sleep(2)
-        main.step("Start ONOS CLI on all nodes")
-        cliResult = main.TRUE
-        main.step(" Start ONOS cli using thread ")
-        startCliResult = main.TRUE
-        pool = []
-        main.threadID = 0
-        for i in range(int(main.numCtrls)):
-            t = main.Thread(target=main.CLIs[i].startOnosCli,
-                            threadID=main.threadID,
-                            name="startOnosCli",
-                            args=[main.ONOSip[i]],
-                            kwargs={"onosStartTimeout": main.timeout})
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep(main.startUpSleep)
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
+        main.testSetUp.ONOSSetUp( main.MN1Ip, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
 
         # configure apps
-        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=7)
-        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="linear")
-        main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "enabled", value="true")
-        main.CLIs[0].setCfg("org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true")
+        main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "deviceCount", value=7 )
+        main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "topoShape", value="linear" )
+        main.CLIs[ 0 ].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled", value="true" )
+        main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.IntentManager", "skipReleaseResourcesOnWithdrawal", value="true" )
         if main.flowObj:
-            main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
-                                "useFlowObjectives", value="true")
-            main.CLIs[0].setCfg("org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
+            main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
+                                "useFlowObjectives", value="true" )
+            main.CLIs[ 0 ].setCfg( "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator",
                                 "defaultFlowObjectiveCompiler",
-                                value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
-        time.sleep(main.startUpSleep)
+                                value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' )
+        time.sleep( main.startUpSleep )
 
         # balanceMasters
-        main.CLIs[0].balanceMasters()
-        time.sleep(main.startUpSleep)
+        main.CLIs[ 0 ].balanceMasters()
+        time.sleep( main.startUpSleep )
 
     def CASE2( self, main ):
         import time
         import numpy
         import json
-        print(main.intentsList)
+        print( main.intentsList )
         for batchSize in main.intentsList:
-            main.log.report("Intent Batch size: {}".format(batchSize))
+            main.log.report( "Intent Batch size: {}".format( batchSize ) )
             main.installLatList = []
             main.withdrawLatList = []
             validrun = 0
@@ -243,20 +114,20 @@
             # we use two variables to control the iteration
             while validrun <= main.warmUp + main.sampleSize and invalidrun < 20:
                 if validrun >= main.warmUp:
-                    main.log.info("================================================")
-                    main.log.info("Starting test iteration " + str(validrun - main.warmUp))
-                    main.log.info("Total test iteration: " + str(invalidrun + validrun))
-                    main.log.info("================================================")
+                    main.log.info( "================================================" )
+                    main.log.info( "Starting test iteration " + str( validrun - main.warmUp ) )
+                    main.log.info( "Total test iteration: " + str( invalidrun + validrun ) )
+                    main.log.info( "================================================" )
                 else:
-                    main.log.info("====================Warm Up=====================")
+                    main.log.info( "====================Warm Up=====================" )
 
                 # push intents
-                installResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
+                installResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize,
                                                              offset=1, options="-i", timeout=main.timeout,
-                                                             getResponse=True)
-                if type(installResult) is str:
+                                                             getResponse=True )
+                if type( installResult ) is str:
                     if "Failure" in installResult:
-                        main.log.error("Install Intents failure, ignore this iteration.")
+                        main.log.error( "Install Intents failure, ignore this iteration." )
                         if validrun < main.warmUp:
                             validrun += 1
                             continue
@@ -265,12 +136,12 @@
                             continue
 
                     try:
-                        latency = int(installResult.split()[5])
-                        main.log.info(installResult)
+                        latency = int( installResult.split()[ 5 ] )
+                        main.log.info( installResult )
                     except:
-                        main.log.error("Failed to get latency, ignore this iteration.")
-                        main.log.error("Response from ONOS:")
-                        print(installResult)
+                        main.log.error( "Failed to get latency, ignore this iteration." )
+                        main.log.error( "Response from ONOS:" )
+                        print( installResult )
                         if validrun < main.warmUp:
                             validrun += 1
                             continue
@@ -279,19 +150,19 @@
                             continue
 
                     if validrun >= main.warmUp:
-                        main.installLatList.append(latency)
+                        main.installLatList.append( latency )
                 else:
                     invalidrun += 1
                     continue
-                time.sleep(2)
+                time.sleep( 2 )
                 # Withdraw Intents
-                withdrawResult = main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
+                withdrawResult = main.CLIs[ 0 ].pushTestIntents( main.ingress, main.egress, batchSize,
                                                               offset=1, options="-w", timeout=main.timeout,
-                                                              getResponse=True)
+                                                              getResponse=True )
 
-                if type(withdrawResult) is str:
+                if type( withdrawResult ) is str:
                     if "Failure" in withdrawResult:
-                        main.log.error("withdraw Intents failure, ignore this iteration.")
+                        main.log.error( "withdraw Intents failure, ignore this iteration." )
                         if validrun < main.warmUp:
                             validrun += 1
                             continue
@@ -300,12 +171,12 @@
                             continue
 
                     try:
-                        latency = int(withdrawResult.split()[5])
-                        main.log.info(withdrawResult)
+                        latency = int( withdrawResult.split()[ 5 ] )
+                        main.log.info( withdrawResult )
                     except:
-                        main.log.error("Failed to get latency, ignore this iteration.")
-                        main.log.error("Response from ONOS:")
-                        print(withdrawResult)
+                        main.log.error( "Failed to get latency, ignore this iteration." )
+                        main.log.error( "Response from ONOS:" )
+                        print( withdrawResult )
                         if validrun < main.warmUp:
                             validrun += 1
                             continue
@@ -314,34 +185,33 @@
                             continue
 
                     if validrun >= main.warmUp:
-                        main.withdrawLatList.append(latency)
+                        main.withdrawLatList.append( latency )
                 else:
                     invalidrun += 1
                     continue
-                time.sleep(2)
-                main.CLIs[0].purgeWithdrawnIntents()
+                time.sleep( 2 )
+                main.CLIs[ 0 ].purgeWithdrawnIntents()
                 validrun += 1
-            installave = numpy.average(main.installLatList)
-            installstd = numpy.std(main.installLatList)
-            withdrawave = numpy.average(main.withdrawLatList)
-            withdrawstd = numpy.std(main.withdrawLatList)
+            installave = numpy.average( main.installLatList )
+            installstd = numpy.std( main.installLatList )
+            withdrawave = numpy.average( main.withdrawLatList )
+            withdrawstd = numpy.std( main.withdrawLatList )
             # log report
-            main.log.report("----------------------------------------------------")
-            main.log.report("Scale: " + str(main.numCtrls))
-            main.log.report("Intent batch: " + str(batchSize))
-            main.log.report("Install average: {}    std: {}".format(installave, installstd))
-            main.log.report("Withdraw average: {}   std: {}".format(withdrawave, withdrawstd))
+            main.log.report( "----------------------------------------------------" )
+            main.log.report( "Scale: " + str( main.numCtrls ) )
+            main.log.report( "Intent batch: " + str( batchSize ) )
+            main.log.report( "Install average: {}    std: {}".format( installave, installstd ) )
+            main.log.report( "Withdraw average: {}   std: {}".format( withdrawave, withdrawstd ) )
             # write result to database file
-            if not (numpy.isnan(installave) or numpy.isnan(installstd) or\
-                    numpy.isnan(withdrawstd) or numpy.isnan(withdrawave)):
+            if not ( numpy.isnan( installave ) or numpy.isnan( installstd ) or\
+                    numpy.isnan( withdrawstd ) or numpy.isnan( withdrawave ) ):
                 databaseString = "'" + main.commit + "',"
-                databaseString += str(main.numCtrls) + ","
-                databaseString += str(batchSize) + ","
-                databaseString += str(installave) + ","
-                databaseString += str(installstd) + ","
-                databaseString += str(withdrawave) + ","
-                databaseString += str(withdrawstd) + "\n"
-                resultsDB = open(main.dbFileName, "a")
-                resultsDB.write(databaseString)
+                databaseString += str( main.numCtrls ) + ","
+                databaseString += str( batchSize ) + ","
+                databaseString += str( installave ) + ","
+                databaseString += str( installstd ) + ","
+                databaseString += str( withdrawave ) + ","
+                databaseString += str( withdrawstd ) + "\n"
+                resultsDB = open( main.dbFileName, "a" )
+                resultsDB.write( databaseString )
                 resultsDB.close()
-        del main.scale[0]
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
index fd3553c..87e3888 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.params
@@ -46,8 +46,8 @@
     </DATABASE>
 
     <GIT>
-        <gitPull>False</gitPull>
-        <gitBranch>master</gitBranch>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <ATTEMPTS>
diff --git a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
index 3ef9be8..baff10b 100644
--- a/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
+++ b/TestON/tests/SCPF/SCPFintentRerouteLat/SCPFintentRerouteLat.py
@@ -31,76 +31,65 @@
             different versions of ONOS.
         - Construct tests variables
         '''
-        gitPull = main.params['GIT']['gitPull']
-        gitBranch = main.params['GIT']['gitBranch']
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
+            main.onosIp = main.ONOSbench.getOnosIps()
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.BENCHUser = main.params[ 'BENCH' ][ 'user' ]
+            main.BENCHIp = main.params[ 'BENCH' ][ 'ip1' ]
+            main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+            main.maxNodes = int( main.params[ 'max' ] )
+            main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+            main.scale = ( main.params[ 'SCALE' ] ).split(",")
+            main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+            main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
+            main.setMasterSleep = int( main.params[ 'SLEEP' ][ 'setmaster' ] )
+            main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
+            main.maxInvalidRun = int( main.params[ 'ATTEMPTS' ][ 'maxInvalidRun' ] )
+            main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
+            main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
+            main.ingress = main.params[ 'TEST' ][ 'ingress' ]
+            main.egress = main.params[ 'TEST' ][ 'egress' ]
+            main.debug = main.params[ 'TEST' ][ 'debug' ]
+            main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
+            main.deviceCount = int( main.params[ 'TEST' ][ 'deviceCount' ] )
+            main.end1 = main.params[ 'TEST' ][ 'end1' ]
+            main.end2 = main.params[ 'TEST' ][ 'end2' ]
+            main.searchTerm = main.params[ 'SEARCHTERM' ]
+            if main.flowObj == "True":
+                main.flowObj = True
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
+                main.intentsList = ( main.params[ 'TEST' ][ 'FObjintents' ] ).split( "," )
+            else:
+                main.flowObj = False
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
+                main.intentsList = ( main.params[ 'TEST' ][ 'intents' ] ).split( "," )
 
-        main.case("Pull onos branch and build onos on Teststation.")
+            stepResult = main.testSetUp.gitPulling()
 
-        if gitPull == 'True':
-            main.step("Git Checkout ONOS branch: " + gitBranch)
-            stepResult = main.ONOSbench.gitCheckout(branch=gitBranch)
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully checkout onos branch.",
-                                    onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult:
-                main.exit()
+            for i in range( 0, len( main.intentsList) ):
+                main.intentsList[ i ] = int( main.intentsList[ i ] )
+                # Create DataBase file
+            main.log.info( "Create Database file " + main.dbFileName )
+            resultsDB = open( main.dbFileName, "w+" )
+            resultsDB.close()
+            file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
+            main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
+            main.intentRerouteLatFuncs = imp.load_source( file1, main.dependencyPath + file1 + ".py" )
 
-            main.step("Git Pull on ONOS branch:" + gitBranch)
-            stepResult = main.ONOSbench.gitPull()
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully pull onos. ",
-                                    onfail="Failed to pull onos. Exiting test ...")
-            if not stepResult: main.exit()
-
-        else:
-            main.log.warn("Skipped pulling onos and Skipped building ONOS")
-        main.onosIp = main.ONOSbench.getOnosIps()
-        main.apps = main.params['ENV']['cellApps']
-        main.BENCHUser = main.params['BENCH']['user']
-        main.BENCHIp = main.params['BENCH']['ip1']
-        main.MN1Ip = main.params['MN']['ip1']
-        main.maxNodes = int(main.params['max'])
-        main.cellName = main.params['ENV']['cellName']
-        main.scale = (main.params['SCALE']).split(",")
-        main.timeout = int(main.params['SLEEP']['timeout'])
-        main.startUpSleep = int(main.params['SLEEP']['startup'])
-        main.installSleep = int(main.params['SLEEP']['install'])
-        main.verifySleep = int(main.params['SLEEP']['verify'])
-        main.setMasterSleep = int(main.params['SLEEP']['setmaster'])
-        main.verifyAttempts = int(main.params['ATTEMPTS']['verify'])
-        main.maxInvalidRun = int(main.params['ATTEMPTS']['maxInvalidRun'])
-        main.sampleSize = int(main.params['TEST']['sampleSize'])
-        main.warmUp = int(main.params['TEST']['warmUp'])
-        main.ingress = main.params['TEST']['ingress']
-        main.egress = main.params['TEST']['egress']
-        main.debug = main.params['TEST']['debug']
-        main.flowObj = main.params['TEST']['flowObj']
-        main.deviceCount = int(main.params['TEST']['deviceCount'])
-        main.end1 = main.params['TEST']['end1']
-        main.end2 = main.params['TEST']['end2']
-        main.searchTerm = main.params['SEARCHTERM']
-        if main.flowObj == "True":
-            main.flowObj = True
-            main.dbFileName = main.params['DATABASE']['dbFlowObj']
-            main.intentsList = (main.params['TEST']['FObjintents']).split(",")
-        else:
-            main.flowObj = False
-            main.dbFileName = main.params['DATABASE']['dbName']
-            main.intentsList = (main.params['TEST']['intents']).split(",")
-
-        for i in range(0, len(main.intentsList)):
-            main.intentsList[i] = int(main.intentsList[i])
-            # Create DataBase file
-        main.log.info("Create Database file " + main.dbFileName)
-        resultsDB = open(main.dbFileName, "w+")
-        resultsDB.close()
-        file1 = main.params[ "DEPENDENCY" ][ "FILE1" ]
-        main.dependencyPath = os.path.dirname( os.getcwd() ) + main.params[ "DEPENDENCY" ][ "PATH" ]
-        main.intentRerouteLatFuncs = imp.load_source(file1, main.dependencyPath + file1 + ".py")
-
-        main.record = 0
+            main.record = 0
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
 
     def CASE1( self, main ):
         '''
@@ -108,133 +97,12 @@
         '''
         import time
 
-        main.log.info("Get ONOS cluster IP")
-        print(main.scale)
-        main.numCtrls = int(main.scale[0])
-        main.ONOSip = []
         main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range(main.numCtrls):
-            main.ONOSip.append(main.AllONOSip[i])
-        main.log.info(main.ONOSip)
-        main.CLIs = []
-        main.log.info("Creating list of ONOS cli handles")
-        for i in range(main.numCtrls):
-            main.CLIs.append(getattr(main, 'ONOScli%s' % (i + 1)))
-
-        if not main.CLIs:
-            main.log.error("Failed to create the list of ONOS cli handles")
-            main.cleanup()
-            main.exit()
-
-        main.commit = main.ONOSbench.getVersion(report=True)
-        main.commit = main.commit.split(" ")[1]
-        main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
-        main.log.info("Safety check, killing all ONOS processes" +
-                      " before initiating environment setup")
-
-        for i in range(main.numCtrls):
-            main.ONOSbench.onosStop(main.ONOSip[i])
-            main.ONOSbench.onosKill(main.ONOSip[i])
-
-        main.log.info("NODE COUNT = %s" % main.numCtrls)
-        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
-                                      main.cellName,
-                                      main.MN1Ip,
-                                      main.apps,
-                                      main.ONOSip,
-                                      main.ONOScli1.karafUser)
-        main.step("Apply cell to environment")
-        cellResult = main.ONOSbench.setCell(main.cellName)
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully applied cell to " + \
-                                       "environment",
-                                onfail="Failed to apply cell to environment ")
-
-        main.step("Creating ONOS package")
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully created ONOS package",
-                                onfail="Failed to create ONOS package")
-
-        main.step("Uninstall ONOS package on all Nodes")
-        uninstallResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
-            u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            uninstallResult = (uninstallResult and u_result)
-
-        main.step("Install ONOS package on all Nodes")
-        installResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
-            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL" )
-
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE, actual=stepResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep(main.startUpSleep)
-        main.step("Start ONOS CLI on all nodes")
-        cliResult = main.TRUE
-        main.step(" Start ONOS cli using thread ")
-        startCliResult = main.TRUE
-        pool = []
-        main.threadID = 0
-        for i in range(int(main.numCtrls)):
-            t = main.Thread(target=main.CLIs[i].startOnosCli,
-                            threadID=main.threadID,
-                            name="startOnosCli",
-                            args=[main.ONOSip[i]],
-                            kwargs={"onosStartTimeout": main.timeout})
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep(main.startUpSleep)
-
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
+        main.testSetUp.ONOSSetUp( main.MN1Ip, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
         # configure apps
         main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "deviceCount", value=main.deviceCount)
         main.CLIs[0].setCfg("org.onosproject.provider.nil.NullProviders", "topoShape", value="reroute")
@@ -252,9 +120,9 @@
         # Balance Master
         main.CLIs[0].balanceMasters()
         time.sleep( main.setMasterSleep )
-        if len(main.ONOSip) > 1:
-            main.CLIs[0].deviceRole(main.end1[ 'name' ], main.ONOSip[0])
-            main.CLIs[0].deviceRole(main.end2[ 'name' ], main.ONOSip[0])
+        if main.numCtrls:
+            main.CLIs[0].deviceRole( main.end1[ 'name' ], main.ONOSip[0] )
+            main.CLIs[0].deviceRole( main.end2[ 'name' ], main.ONOSip[0] )
         time.sleep( main.setMasterSleep )
 
     def CASE2( self, main ):
@@ -264,7 +132,7 @@
         import json
         # from scipy import stats
 
-        print(main.intentsList)
+        print( main.intentsList)
         for batchSize in main.intentsList:
             main.batchSize = batchSize
             main.log.report("Intent Batch size: " + str(batchSize) + "\n      ")
@@ -278,18 +146,18 @@
             while main.validRun <= main.warmUp + main.sampleSize and main.invalidRun <= main.maxInvalidRun:
                 if main.validRun >= main.warmUp:
                     main.log.info("================================================")
-                    main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp))
-                    main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun))
+                    main.log.info("Valid iteration: {} ".format( main.validRun - main.warmUp) )
+                    main.log.info("Total iteration: {}".format( main.validRun + main.invalidRun) )
                     main.log.info("================================================")
                 else:
                     main.log.info("====================Warm Up=====================")
 
                 # push intents
-                main.CLIs[0].pushTestIntents(main.ingress, main.egress, main.batchSize,
+                main.CLIs[0].pushTestIntents( main.ingress, main.egress, main.batchSize,
                                              offset=1, options="-i", timeout=main.timeout)
 
                 # check links, flows and intents
-                main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * (main.deviceCount - 1 ), main.batchSize )
+                main.intentRerouteLatFuncs.sanityCheck( main, main.deviceCount * 2, batchSize * ( main.deviceCount - 1 ), main.batchSize )
                 if not main.verify:
                     main.log.warn( "Sanity check failed, skipping this iteration..." )
                     continue
@@ -303,7 +171,7 @@
                                   timeout=main.timeout, showResponse=False)
 
                 # check links, flows and intents
-                main.intentRerouteLatFuncs.sanityCheck( main, (main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize )
+                main.intentRerouteLatFuncs.sanityCheck( main, ( main.deviceCount - 1) * 2, batchSize * main.deviceCount, main.batchSize )
                 if not main.verify:
                     main.log.warn( "Sanity check failed, skipping this iteration..." )
                     continue
@@ -366,7 +234,7 @@
                 # bring up link and withdraw intents
                 main.CLIs[0].link( main.end1[ 'port' ], main.end2[ 'port' ], "up",
                                   timeout=main.timeout)
-                main.CLIs[0].pushTestIntents(main.ingress, main.egress, batchSize,
+                main.CLIs[0].pushTestIntents( main.ingress, main.egress, batchSize,
                                              offset=1, options="-w", timeout=main.timeout)
                 main.CLIs[0].purgeWithdrawnIntents()
 
@@ -396,4 +264,3 @@
                 resultsDB.write( str( aveLocalLatency ) + "," )
                 resultsDB.write( str( stdLocalLatency ) + "\n" )
                 resultsDB.close()
-        del main.scale[ 0 ]
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
index 4fc830f..6dbd03d 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.params
@@ -20,8 +20,8 @@
     </DEPENDENCY>
 
     <GIT>
-        <gitPull>off</gitPull>
-        <gitBranch>master</gitBranch>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <TSHARK>
diff --git a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
index 24e8e60..f00af91 100644
--- a/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
+++ b/TestON/tests/SCPF/SCPFportLat/SCPFportLat.py
@@ -22,214 +22,89 @@
             different versions of ONOS.
         - Construct tests variables
         '''
-        gitPull = main.params['GIT']['gitPull']
-        gitBranch = main.params['GIT']['gitBranch']
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
+            main.MN1Ip = main.params[ 'MN' ][ 'ip1' ]
+            main.dependencyPath = main.testOnDirectory + \
+                                  main.params[ 'DEPENDENCY' ][ 'path' ]
+            main.dependencyFunc = main.params[ 'DEPENDENCY' ][ 'function' ]
+            main.topoName = main.params[ 'DEPENDENCY' ][ 'topology' ]
+            main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+            main.ofportStatus = main.params[ 'TSHARK' ][ 'ofpPortStatus' ]
+            main.tsharkResultPath = main.params[ 'TSHARK' ][ 'tsharkReusltPath' ]
+            main.sampleSize = int( main.params[ 'TEST' ][ 'sampleSize' ] )
+            main.warmUp = int( main.params[ 'TEST' ][ 'warmUp' ] )
+            main.maxProcessTime = int( main.params[ 'TEST' ][ 'maxProcessTime' ] )
+            main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.measurementSleep = int( main.params[ 'SLEEP' ][ 'measure' ] )
+            main.maxScale = int( main.params[ 'max' ] )
+            main.interface = main.params[ 'TEST' ][ 'interface' ]
+            main.timeout = int( main.params[ 'TIMEOUT' ][ 'timeout' ] )
+            main.MNSleep = int( main.params[ 'SLEEP' ][ 'mininet' ] )
+            main.device = main.params[ 'TEST' ][ 'device' ]
+            main.debug = main.params[ 'TEST' ][ 'debug' ]
 
-        main.case( "Pull onos branch and build onos on Teststation." )
+            if main.debug == "True":
+                main.debug = True
+            else:
+                main.debug = False
 
-        if gitPull == 'True':
-            main.step( "Git Checkout ONOS branch: " + gitBranch )
-            stepResult = main.ONOSbench.gitCheckout( branch=gitBranch )
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully checkout onos branch.",
-                                    onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult: main.exit()
+            stepResult = main.testSetUp.gitPulling()
+            main.log.info( "Create Database file " + main.dbFileName )
+            resultsDB = open( main.dbFileName, "w+" )
+            resultsDB.close()
 
-            main.step( "Git Pull on ONOS branch:" + gitBranch )
-            stepResult = main.ONOSbench.gitPull()
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully pull onos. ",
-                                    onfail="Failed to pull onos. Exiting test ...")
-            if not stepResult: main.exit()
-
-
-        else:
-            main.log.warn( "Skipped pulling onos and Skipped building ONOS" )
-
-        main.testOnDirectory = os.path.dirname( os.getcwd() )
-        main.MN1Ip = main.params['MN']['ip1']
-        main.dependencyPath = main.testOnDirectory + \
-                              main.params['DEPENDENCY']['path']
-        main.dependencyFunc = main.params['DEPENDENCY']['function']
-        main.topoName = main.params['DEPENDENCY']['topology']
-        main.cellName = main.params['ENV']['cellName']
-        main.Apps = main.params['ENV']['cellApps']
-        main.scale = (main.params['SCALE']).split(",")
-        main.ofportStatus = main.params['TSHARK']['ofpPortStatus']
-        main.tsharkResultPath = main.params['TSHARK']['tsharkReusltPath']
-        main.sampleSize = int( main.params['TEST']['sampleSize'] )
-        main.warmUp = int( main.params['TEST']['warmUp'] )
-        main.maxProcessTime = int( main.params['TEST']['maxProcessTime'])
-        main.dbFileName = main.params['DATABASE']['dbName']
-        main.startUpSleep = int( main.params['SLEEP']['startup'] )
-        main.measurementSleep = int( main.params['SLEEP']['measure'] )
-        main.maxScale = int( main.params['max'] )
-        main.interface = main.params['TEST']['interface']
-        main.timeout = int( main.params['TIMEOUT']['timeout'] )
-        main.MNSleep = int( main.params['SLEEP']['mininet'])
-        main.device = main.params['TEST']['device']
-        main.debug = main.params['TEST']['debug']
-
-        if main.debug == "True":
-            main.debug = True
-        else:
-            main.debug = False
-
-        main.log.info( "Create Database file " + main.dbFileName )
-        resultsDB = open( main.dbFileName, "w+" )
-        resultsDB.close()
-
-        main.portFunc = imp.load_source(main.dependencyFunc,
-                                       main.dependencyPath +
-                                       main.dependencyFunc +
-                                       ".py")
+            main.portFunc = imp.load_source( main.dependencyFunc,
+                                           main.dependencyPath +
+                                           main.dependencyFunc +
+                                           ".py" )
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
 
     def CASE1( self, main ):
         # Clean up test environment and set up
         import time
-        main.log.info( "Get ONOS cluster IP" )
-        print( main.scale )
-        main.numCtrls = int( main.scale.pop(0) )
-        main.ONOSip = []
-        main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range( main.numCtrls ):
-            main.ONOSip.append( main.AllONOSip[i] )
-        main.log.info( main.ONOSip )
-        main.CLIs = []
-        main.log.info( "Creating list of ONOS cli handles" )
-        for i in range( main.numCtrls ):
-            main.CLIs.append( getattr(main, 'ONOScli%s' % (i + 1)) )
-
-        if not main.CLIs:
-            main.log.error( "Failed to create the list of ONOS cli handles" )
-            main.cleanup()
-            main.exit()
-
-        main.commit = main.ONOSbench.getVersion( report=True )
-        main.commit = main.commit.split(" ")[1]
-        main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls )
-        main.log.info("Safety check, killing all ONOS processes" +
-                      " before initiating environment setup")
-
-        for i in range( main.numCtrls ):
-            main.ONOSbench.onosStop( main.ONOSip[i] )
-            main.ONOSbench.onosKill( main.ONOSip[i] )
-
-        main.log.info( "NODE COUNT = %s" % main.numCtrls )
-        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
-                                      main.cellName,
-                                      main.MN1Ip,
-                                      main.Apps,
-                                      main.ONOSip,
-                                      main.ONOScli1.karafUser)
-        main.step( "Apply cell to environment" )
-        cellResult = main.ONOSbench.setCell( main.cellName )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully applied cell to " + \
-                                       "environment",
-                                onfail="Failed to apply cell to environment ")
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully created ONOS package",
-                                onfail="Failed to create ONOS package")
-
-        main.step( "Uninstall ONOS package on all Nodes" )
-        uninstallResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
-            u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            uninstallResult = uninstallResult and u_result
-
-        main.step( "Install ONOS package on all Nodes" )
-        installResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
-            i_result = main.ONOSbench.onosInstall( node=main.ONOSip[i] )
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        main.step( "Start ONOS CLI on all nodes" )
-        cliResult = main.TRUE
-        main.step( " Start ONOS cli using thread " )
-        startCliResult = main.TRUE
-        pool = []
-        main.threadID = 0
-        for i in range( int( main.numCtrls ) ):
-            t = main.Thread(target=main.CLIs[i].startOnosCli,
-                            threadID=main.threadID,
-                            name="startOnosCli",
-                            args=[main.ONOSip[i]],
-                            kwargs={"onosStartTimeout": main.timeout})
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep( main.startUpSleep )
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
+        main.testSetUp.ONOSSetUp( main.Mininet1, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
 
         main.log.info( "Configure apps" )
-        main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
-                            "maxEvents 1")
-        main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
-                            "maxBatchMs 0")
-        main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
-                            "maxIdleMs 0")
+        main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
+                            "maxEvents 1" )
+        main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
+                            "maxBatchMs 0" )
+        main.CLIs[0].setCfg( "org.onosproject.net.topology.impl.DefaultTopologyProvider",
+                            "maxIdleMs 0" )
         time.sleep(1)
         main.log.info( "Copy topology file to Mininet" )
-        main.ONOSbench.copyMininetFile(main.topoName,
+        main.ONOSbench.copyMininetFile( main.topoName,
                                        main.dependencyPath,
                                        main.Mininet1.user_name,
                                        main.Mininet1.ip_address)
-        main.log.info( "Stop Mininet..." )
-        main.Mininet1.stopNet()
+        try:
+            from tests.dependencies.utils import Utils
+        except ImportError:
+            main.log.error( "Utils not found exiting the test" )
+            main.exit()
+        try:
+            main.Utils
+        except ( NameError, AttributeError ):
+            main.Utils = Utils()
+        main.Utils.mininetCleanup( main.Mininet1 )
         time.sleep( main.MNSleep )
         main.log.info( "Start new mininet topology" )
         main.Mininet1.startNet()
@@ -270,66 +145,66 @@
 
         # Dictionary for result
         maxDict  = {}
-        maxDict['down'] = {}
-        maxDict['up'] = {}
-        maxDict['down']['max'] = 0
-        maxDict['up']['max'] = 0
-        maxDict['down']['node'] = 0
-        maxDict['up']['node'] = 0
+        maxDict[ 'down' ] = {}
+        maxDict[ 'up' ] = {}
+        maxDict[ 'down' ][ 'max' ] = 0
+        maxDict[ 'up' ][ 'max' ] = 0
+        maxDict[ 'down' ][ 'node' ] = 0
+        maxDict[ 'up' ][ 'node' ] = 0
         EtoEtemp = 0
         for d in resultDict:
             for i in range( 1, main.numCtrls + 1 ):
                 # calculate average and std for result, and grep the max End to End data
-                EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ]['EtoE'] )
+                EtoEtemp = numpy.average( resultDict[d][ 'node' + str(i) ][ 'EtoE' ] )
                 resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] = EtoEtemp
-                if maxDict[d]['max'] < EtoEtemp:
+                if maxDict[d][ 'max' ] < EtoEtemp:
                     # get max End to End latency
-                    maxDict[d]['max'] = EtoEtemp
-                    maxDict[d]['node'] = i
-                resultDict[d]['node' + str(i)]['Ave']['PtoD'] = numpy.average(resultDict[d]['node' + str(i)]['PtoD'])
-                resultDict[d]['node' + str(i)]['Ave']['DtoL'] = numpy.average(resultDict[d]['node' + str(i)]['DtoL'])
-                resultDict[d]['node' + str(i)]['Ave']['LtoG'] = numpy.average(resultDict[d]['node' + str(i)]['LtoG'])
+                    maxDict[d][ 'max' ] = EtoEtemp
+                    maxDict[d][ 'node' ] = i
+                resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
+                resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
+                resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] = numpy.average(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
 
-                resultDict[d]['node' + str(i)]['Std']['EtoE'] = numpy.std(resultDict[d]['node' + str(i)]['EtoE'])
-                resultDict[d]['node' + str(i)]['Std']['PtoD'] = numpy.std(resultDict[d]['node' + str(i)]['PtoD'])
-                resultDict[d]['node' + str(i)]['Std']['DtoL'] = numpy.std(resultDict[d]['node' + str(i)]['DtoL'])
-                resultDict[d]['node' + str(i)]['Std']['LtoG'] = numpy.std(resultDict[d]['node' + str(i)]['LtoG'])
+                resultDict[d][ 'node' + str(i)][ 'Std' ][ 'EtoE' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'EtoE' ] )
+                resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'PtoD' ] )
+                resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'DtoL' ] )
+                resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] = numpy.std(resultDict[d][ 'node' + str(i)][ 'LtoG' ] )
 
                 main.log.report( "=====node{} Summary:=====".format( str(i) ) )
                 main.log.report( "=============Port {}=======".format( str(d) ) )
                 main.log.report(
-                    "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ]) ) )
+                    "End to End average: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Ave' ][ 'EtoE' ] ) ) )
                 main.log.report(
-                    "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ]) ) )
+                    "End to End Std: {}".format( str(resultDict[d][ 'node' + str(i) ][ 'Std' ][ 'EtoE' ] ) ) )
                 main.log.report(
-                    "Package to Device average: {}".format( str(resultDict[d]['node' + str(i)]['Ave']['PtoD']) ) )
+                    "Package to Device average: {}".format( str(resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'PtoD' ] ) ) )
                 main.log.report(
-                    "Package to Device Std: {}".format( str( resultDict[d]['node' + str(i)]['Std']['PtoD'])))
+                    "Package to Device Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'PtoD' ] ) ))
                 main.log.report(
-                    "Device to Link average: {}".format( str( resultDict[d]['node' + str(i)]['Ave']['DtoL']) ) )
+                    "Device to Link average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'DtoL' ] ) ) )
                 main.log.report(
-                    "Device to Link Std: {}".format( str( resultDict[d]['node' + str(i)]['Std']['DtoL'])))
+                    "Device to Link Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'DtoL' ] ) ))
                 main.log.report(
-                    "Link to Grapg average: {}".format( str( resultDict[d]['node' + str(i)]['Ave']['LtoG']) ) )
+                    "Link to Grapg average: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Ave' ][ 'LtoG' ] ) ) )
                 main.log.report(
-                    "Link to Grapg Std: {}".format( str( resultDict[d]['node' + str(i)]['Std']['LtoG'] ) ) )
+                    "Link to Grapg Std: {}".format( str( resultDict[d][ 'node' + str(i)][ 'Std' ][ 'LtoG' ] ) ) )
 
         with open( main.dbFileName, "a" ) as dbFile:
             # Scale number
             temp = str( main.numCtrls )
             temp += ",'baremetal1'"
             # put result
-            temp += "," + str( resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'EtoE' ] )
-            temp += "," + str( resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'PtoD' ] )
-            temp += "," + str( resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'DtoL' ] )
-            temp += "," + str( resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Ave' ][ 'LtoG' ] )
-            temp += "," + str( resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'EtoE' ] )
-            temp += "," + str( resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'PtoD' ] )
-            temp += "," + str( resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'DtoL' ] )
-            temp += "," + str( resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Ave' ][ 'LtoG' ] )
+            temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
+            temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
+            temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
+            temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
+            temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'EtoE' ] )
+            temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'PtoD' ] )
+            temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'DtoL' ] )
+            temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Ave' ][ 'LtoG' ] )
 
-            temp += "," + str( resultDict['up'][ 'node' + str(maxDict['up']['node']) ][ 'Std' ][ 'EtoE' ] )
-            temp += "," + str( resultDict['down'][ 'node' + str(maxDict['down']['node']) ][ 'Std' ][ 'EtoE' ] )
+            temp += "," + str( resultDict[ 'up' ][ 'node' + str( maxDict[ 'up' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
+            temp += "," + str( resultDict[ 'down' ][ 'node' + str( maxDict[ 'down' ][ 'node' ] ) ][ 'Std' ][ 'EtoE' ] )
 
             temp += "\n"
             dbFile.write( temp )
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
index 32bd302..58505e9 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
@@ -19,106 +19,88 @@
             - Install ONOS package
             - Build ONOS package
         """
-        main.case( "Constructing test variables" )
-        main.step( "Constructing test variables" )
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
-        # The variable to decide if the data should be written into data base.
-        # 1 means Yes and -1 means No.
-        main.writeData = 1
-        main.searchTerm = main.params[ 'SearchTerm' ]
-        main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
-        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
-        gitBranch = main.params[ 'GIT' ][ 'branch' ]
-        main.dependencyPath = main.testOnDirectory + \
-                              main.params[ 'DEPENDENCY' ][ 'path' ]
-        main.tsharkResultPath = main.params[ 'TsharkPath' ]
-        main.roleRequest = main.params[ 'SearchTerm' ]['roleRequest']
-        main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
-        main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
-        main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
-        main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
-        main.topoScaleSize = len( main.topoScale )
-        wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
-        wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
-        wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
-        main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
-        main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
-        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
-        main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
-        main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
-        main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
-        main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
-        main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
-        main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
-        main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
-        if main.hostDiscover == 'True':
-            main.hostDiscover = True
-        else:
-            main.hostDiscover = False
-        gitPull = main.params[ 'GIT' ][ 'pull' ]
-        main.homeDir = os.path.expanduser('~')
-        main.cellData = {} # for creating cell file
-        main.hostsData = {}
-        main.CLIs = []
-        main.ONOSip = []
-        main.activeNodes = []
-        main.ONOSip = main.ONOSbench.getOnosIps()
-
-        for i in range(main.numCtrls):
-                main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
-
-        main.allinfo = {} # The dictionary to record all the data from karaf.log
-
-        for i in range( 2 ):
-            main.allinfo[ i ]={}
-            for w in range ( 3 ):
-                # Totaltime: the time from the new switchConnection to its end
-                # swConnection: the time from the first new switchConnection to the last new switchConnection
-                # lastSwToLastRr: the time from the last new switchConnection to the last role request
-                # lastRrToLastTopology: the time form the last role request to the last topology
-                # disconnectRate: the rate that shows how many switch disconnect after connection
-                main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
-
-        main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
-        main.log.info( "Create Database file " + main.dbFilePath )
-        resultDB = open(main.dbFilePath, 'w+' )
-        resultDB.close()
+        try:
+            # The variable to decide if the data should be written into data base.
+            # 1 means Yes and -1 means No.
+            main.writeData = 1
+            main.searchTerm = main.params[ 'SearchTerm' ]
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.dependencyPath = main.testOnDirectory + \
+                                  main.params[ 'DEPENDENCY' ][ 'path' ]
+            main.tsharkResultPath = main.params[ 'TsharkPath' ]
+            main.roleRequest = main.params[ 'SearchTerm' ]['roleRequest']
+            main.multiovs = main.params[ 'DEPENDENCY' ][ 'multiovs' ]
+            main.topoName = main.params[ 'TOPOLOGY' ][ 'topology' ]
+            main.numCtrls = int( main.params[ 'CTRL' ][ 'numCtrls' ] )
+            main.topoScale = ( main.params[ 'TOPOLOGY' ][ 'scale' ] ).split( "," )
+            main.topoScaleSize = len( main.topoScale )
+            wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+            wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ]
+            wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ]
+            main.topoCmpAttempts = int( main.params[ 'ATTEMPTS' ][ 'topoCmp' ] )
+            main.pingallAttempts = int( main.params[ 'ATTEMPTS' ][ 'pingall' ] )
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.balanceSleep = int( main.params[ 'SLEEP' ][ 'balance' ] )
+            main.nodeSleep = int( main.params[ 'SLEEP' ][ 'nodeSleep' ] )
+            main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
+            main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
+            main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
+            main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
+            main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
+            if main.hostDiscover == 'True':
+                main.hostDiscover = True
+            else:
+                main.hostDiscover = False
+            main.homeDir = os.path.expanduser('~')
+            main.hostsData = {}
+            main.activeNodes = []
 
 
-        main.startUp = imp.load_source( wrapperFile1,
-                                        main.dependencyPath +
-                                        wrapperFile1 +
-                                        ".py" )
+            stepResult = main.testSetUp.envSetup()
+            main.allinfo = {} # The dictionary to record all the data from karaf.log
 
-        main.scaleTopoFunction = imp.load_source( wrapperFile2,
-                                                  main.dependencyPath +
-                                                  wrapperFile2 +
-                                                  ".py" )
+            for i in range( 2 ):
+                main.allinfo[ i ]={}
+                for w in range ( 3 ):
+                    # Totaltime: the time from the new switchConnection to its end
+                    # swConnection: the time from the first new switchConnection to the last new switchConnection
+                    # lastSwToLastRr: the time from the last new switchConnection to the last role request
+                    # lastRrToLastTopology: the time form the last role request to the last topology
+                    # disconnectRate: the rate that shows how many switch disconnect after connection
+                    main.allinfo[ i ][ 'info' + str( w ) ]= { 'totalTime': 0, 'swConnection': 0, 'lastSwToLastRr': 0, 'lastRrToLastTopology': 0, 'disconnectRate': 0 }
 
-        main.topo = imp.load_source( wrapperFile3,
-                                     main.dependencyPath +
-                                     wrapperFile3 +
-                                     ".py" )
+            main.dbFilePath = main.params[ 'DATABASE' ][ 'dbPath' ]
+            main.log.info( "Create Database file " + main.dbFilePath )
+            resultDB = open(main.dbFilePath, 'w+' )
+            resultDB.close()
 
-        main.ONOSbench.scp( main.Mininet1,
-                            main.dependencyPath +
-                            main.multiovs,
-                            main.Mininet1.home,
-                            direction="to" )
+            main.scaleTopoFunction = imp.load_source( wrapperFile2,
+                                                      main.dependencyPath +
+                                                      wrapperFile2 +
+                                                      ".py" )
 
-        if main.CLIs:
-                stepResult = main.TRUE
-        else:
-            main.log.error( "Did not properly created list of " +
-                            "ONOS CLI handle" )
-            stepResult = main.FALSE
+            main.topo = imp.load_source( wrapperFile3,
+                                         main.dependencyPath +
+                                         wrapperFile3 +
+                                         ".py" )
 
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully construct " +
-                                        "test variables ",
-                                 onfail="Failed to construct test variables" )
-
+            main.ONOSbench.scp( main.Mininet1,
+                                main.dependencyPath +
+                                main.multiovs,
+                                main.Mininet1.home,
+                                direction="to" )
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
 
     def CASE2( self, main):
         """
@@ -133,127 +115,20 @@
         - Connect to cli
         """
         import time
-        main.log.info( "Checking if mininet is already running" )
-        if len( main.topoScale ) < main.topoScaleSize:
-            main.log.info( "Mininet is already running. Stopping mininet." )
-            main.Mininet1.stopNet()
-            time.sleep(main.MNSleep)
-        else:
-            main.log.info( "Mininet was not running" )
-
-        main.commit = main.ONOSbench.getVersion(report=True)
-        main.commit = main.commit.split(" ")[1]
-
-        main.case( "Starting up " + str( main.numCtrls ) +
-                   " node(s) ONOS cluster" )
-        main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\
-                                " node(s) ONOS cluster"
-
-        #kill off all onos processes
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.numCtrls ):
-            main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            main.ONOSbench.onosKill( main.ONOSip[ i ] )
-
-        tempOnosIp = []
-        for i in range( main.numCtrls ):
-            tempOnosIp.append( main.ONOSip[i] )
-
-        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
-                                       "temp", main.Mininet1.ip_address,
-                                       main.apps, tempOnosIp, main.ONOScli1.karafUser )
-
-        main.step( "Apply cell to environment" )
-        cellResult = main.ONOSbench.setCell( "temp" )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully applied cell to " + \
-                                        "environment",
-                                 onfail="Failed to apply cell to environment " )
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully created ONOS package",
-                                 onfail="Failed to create ONOS package" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Uninstalling ONOS package" )
-        onosUninstallResult = main.TRUE
-        for ip in main.ONOSip:
-            onosUninstallResult = onosUninstallResult and \
-                    main.ONOSbench.onosUninstall( nodeIp=ip )
-        stepResult = onosUninstallResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully uninstalled ONOS package",
-                                 onfail="Failed to uninstall ONOS package" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Installing ONOS package" )
-        onosInstallResult = main.TRUE
-        for i in range( main.numCtrls ):
-            onosInstallResult = onosInstallResult and \
-                    main.ONOSbench.onosInstall( node=main.ONOSip[ i ] )
-        stepResult = onosInstallResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully installed ONOS package",
-                                 onfail="Failed to install ONOS package" )
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        main.step( "Start ONOS cli" )
-        cliResult = main.TRUE
+        try:
+            from tests.dependencies.utils import Utils
+        except ImportError:
+            main.log.error( "Utils not found exiting the test" )
+            main.exit()
+        try:
+            main.Utils
+        except ( NameError, AttributeError ):
+            main.Utils = Utils()
+        main.Utils.mininetCleanup( main.Mininet1 )
+        main.testSetUp.ONOSSetUp( main.Mininet1 )
         main.activeNodes = []
         for i in range( main.numCtrls ):
-            cliResult = cliResult and \
-                        main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
             main.activeNodes.append( i )
-        stepResult = cliResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully start ONOS cli",
-                                 onfail="Failed to start ONOS cli" )
-        time.sleep( main.startUpSleep )
 
     def CASE10( self, main ):
         """
@@ -303,6 +178,15 @@
         """
         import json
         import time
+        try:
+            from tests.dependencies.topology import Topology
+        except ImportError:
+            main.log.error( "Topology not found exiting the test" )
+            main.exit()
+        try:
+            main.topoRelated
+        except ( NameError, AttributeError ):
+            main.topoRelated = Topology()
         # First capture
         for i in range( 3 ):
             # Calculate total time
@@ -328,30 +212,22 @@
         compareRetry = 0
         while compareRetry < 3:
             #While loop for retry
-            devices = main.topo.getAllDevices( main )
-            ports = main.topo.getAllPorts( main )
-            links = main.topo.getAllLinks( main)
+            devices = main.topoRelated.getAllDevices( main.numCtrls, False )
+            ports = main.topoRelated.getAllPorts( main.numCtrls, False )
+            links = main.topoRelated.getAllLinks( main.numCtrls, False)
             mnSwitches = main.Mininet1.getSwitches()
             mnLinks = main.Mininet1.getLinks(timeout=180)
 
             for controller in range(len(main.activeNodes)):
                 # controllerStr = str( main.activeNodes[controller] + 1 )
-                if devices[ controller ] and ports[ controller ] and \
-                                "Error" not in devices[ controller ] and \
-                                "Error" not in ports[ controller ]:
-                    currentDevicesResult = main.Mininet1.compareSwitches(
-                            mnSwitches,
-                            json.loads( devices[ controller ] ),
-                            json.loads( ports[ controller ] ) )
-                else:
-                    currentDevicesResult = main.FALSE
+                currentDevicesResult = main.topoRelated.compareDevicePort(
+                                                            main.Mininet1, controller,
+                                                            mnSwitches,
+                                                            devices, ports )
 
-                if links[ controller ] and "Error" not in links[ controller ]:
-                    currentLinksResult = main.Mininet1.compareLinks(
-                            mnSwitches, mnLinks,
-                            json.loads( links[ controller ] ) )
-                else:
-                    currentLinksResult = main.FALSE
+                currentLinksResult = main.topoRelated.compareBase( links, controller,
+                                                        main.Mininet1.compareLinks,
+                                                        [ mnSwitches, mnLinks ] )
 
                 stepResult = stepResult and currentDevicesResult and currentLinksResult
             if stepResult:
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/startUp.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/startUp.py
deleted file mode 100644
index 501cbb3..0000000
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/startUp.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
-    This wrapper function is use for starting up onos instance
-"""
-
-import time
-import os
-import json
-
-def onosBuild( main, gitBranch ):
-    """
-        This includes pulling ONOS and building it using maven install
-    """
-
-    buildResult = main.FALSE
-
-    # Git checkout a branch of ONOS
-    checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
-    # Does the git pull on the branch that was checked out
-    if not checkOutResult:
-        main.log.warn( "Failed to checked out " + gitBranch +
-                                           " branch")
-    else:
-        main.log.info( "Successfully checked out " + gitBranch +
-                                           " branch")
-    gitPullResult = main.ONOSbench.gitPull()
-    if gitPullResult == main.ERROR:
-        main.log.error( "Error pulling git branch" )
-    else:
-        main.log.info( "Successfully pulled " + gitBranch + " branch" )
-
-    # buck build
-    buildResult = main.ONOSbench.buckBuild()
-
-    return buildResult
-
-
-
-
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
index 22505ff..d7a878e 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
@@ -6,97 +6,6 @@
 import os
 import json
 
-def getAllDevices( main ):
-    """
-        Return a list containing the devices output from each ONOS node
-    """
-    devices = []
-    threads = []
-    for i in main.activeNodes:
-        t = main.Thread( target=main.CLIs[i].devices,
-                         name="devices-" + str( i ),
-                         args=[ ] )
-        threads.append( t )
-        t.start()
-
-    for t in threads:
-        t.join()
-        devices.append( t.result )
-    return devices
-
-def getAllHosts( main ):
-    """
-        Return a list containing the hosts output from each ONOS node
-    """
-    hosts = []
-    ipResult = main.TRUE
-    threads = []
-    for i in main.activeNodes:
-        t = main.Thread( target=main.CLIs[i].hosts,
-                         name="hosts-" + str( i ),
-                         args=[ ] )
-        threads.append( t )
-        t.start()
-
-    for t in threads:
-        t.join()
-        hosts.append( t.result )
-    return hosts
-
-def getAllPorts( main ):
-    """
-        Return a list containing the ports output from each ONOS node
-    """
-    ports = []
-    threads = []
-    for i in main.activeNodes:
-        t = main.Thread( target=main.CLIs[i].ports,
-                         name="ports-" + str( i ),
-                         args=[ ] )
-        threads.append( t )
-        t.start()
-
-    for t in threads:
-        t.join()
-        ports.append( t.result )
-    return ports
-
-def getAllLinks( main ):
-    """
-        Return a list containing the links output from each ONOS node
-    """
-    links = []
-    threads = []
-    for i in main.activeNodes:
-        t = main.Thread( target=main.CLIs[i].links,
-                         name="links-" + str( i ),
-                         args=[ ] )
-        threads.append( t )
-        t.start()
-
-    for t in threads:
-        t.join()
-        links.append( t.result )
-    return links
-
-def getAllClusters( main ):
-    """
-        Return a list containing the clusters output from each ONOS node
-    """
-    clusters = []
-    threads = []
-    for i in main.activeNodes:
-        t = main.Thread( target=main.CLIs[i].clusters,
-                         name="clusters-" + str( i ),
-                         args=[ ] )
-        threads.append( t )
-        t.start()
-
-    for t in threads:
-        t.join()
-        clusters.append( t.result )
-    return clusters
-
 def sendArpPackage( main, hostList ):
     import json
     import time
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
index 5a81c23..1106f83 100644
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
+++ b/TestON/tests/SCPF/SCPFscalingMaxIntents/SCPFscalingMaxIntents.py
@@ -21,105 +21,70 @@
         import time
         import os
         import imp
-
-        main.case( "Constructing test variables and building ONOS package" )
-        main.step( "Constructing test variables" )
-        stepResult = main.FALSE
-
-        # Test variables
-        main.testOnDirectory = os.path.dirname( os.getcwd ( ) )
-        main.dependencyPath = main.testOnDirectory + \
-                main.params['DEPENDENCY']['path']
-        main.cellName = main.params[ 'ENV' ][ 'cellName' ]
-        main.apps = main.params[ 'ENV' ][ 'cellApps' ]
-        main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
-        main.scale = ( main.params[ 'SCALE' ] ).split( "," )
-        main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
-        main.timeout = int(main.params['SLEEP']['timeout'])
-        main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
-        main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
-        main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
-        main.rerouteSleep = int ( main.params['SLEEP']['reroute'] )
-        main.verifyAttempts = int( main.params['ATTEMPTS']['verify'] )
-        main.ingress = main.params['LINK']['ingress']
-        main.egress = main.params['LINK']['egress']
-        main.cellData = {} # for creating cell file
-        main.reroute = main.params['reroute']
-        main.flowObj = main.params['TEST']['flowObj']
-        if main.flowObj == "True":
-            main.flowObj = True
-            main.dbFileName = main.params['DATABASE']['dbFlowObj']
-        else:
-            main.flowObj = False
-            main.dbFileName = main.params['DATABASE']['dbName']
-        main.threadID = 0
-
-        if main.reroute == "True":
-            main.reroute = True
-        else:
-            main.reroute = False
-
-        main.CLIs = []
-        main.setupSkipped = False
-
-        wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
-        gitBranch = main.params[ 'GIT' ][ 'branch' ]
-        gitPull = main.params[ 'GIT' ][ 'pull' ]
-        nic = main.params['DATABASE']['nic']
-        node = main.params['DATABASE']['node']
-        nic = main.params['DATABASE']['nic']
-        node = main.params['DATABASE']['node']
-        stepResult = main.TRUE
-
-        main.log.info("Cresting DB file")
-        with open(main.dbFileName, "w+") as dbFile:
-            dbFile.write("")
-
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="environment set up successfull",
-                                 onfail="environment set up Failed" )
-
-    def CASE1( self ):
-        # main.scale[ 0 ] determines the current number of ONOS controller
-        main.CLIs = []
-        main.numCtrls = int( main.scale[ 0 ] )
-        main.ONOSip = []
-        main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range(main.numCtrls):
-            main.ONOSip.append(main.AllONOSip[i])
-        main.log.info(main.ONOSip)
-
-        main.log.info( "Creating list of ONOS cli handles" )
-        for i in range(main.numCtrls):
-            main.CLIs.append( getattr( main, 'ONOScli%s' % (i+1) ) )
-
-        main.log.info(main.CLIs)
-        if not main.CLIs:
-            main.log.error( "Failed to create the list of ONOS cli handles" )
-            main.cleanup()
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
             main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
+            # Test variables
+            main.dependencyPath = main.testOnDirectory + \
+                    main.params[ 'DEPENDENCY' ][ 'path' ]
+            main.cellName = main.params[ 'ENV' ][ 'cellName' ]
+            main.apps = main.params[ 'ENV' ][ 'cellApps' ]
+            main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ]
+            main.scale = ( main.params[ 'SCALE' ] ).split( "," )
+            main.ONOSport = main.params[ 'CTRL' ][ 'port' ]
+            main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
+            main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+            main.installSleep = int( main.params[ 'SLEEP' ][ 'install' ] )
+            main.verifySleep = int( main.params[ 'SLEEP' ][ 'verify' ] )
+            main.rerouteSleep = int ( main.params[ 'SLEEP' ][ 'reroute' ] )
+            main.verifyAttempts = int( main.params[ 'ATTEMPTS' ][ 'verify' ] )
+            main.ingress = main.params[ 'LINK' ][ 'ingress' ]
+            main.egress = main.params[ 'LINK' ][ 'egress' ]
+            main.reroute = main.params[ 'reroute' ]
+            main.flowObj = main.params[ 'TEST' ][ 'flowObj' ]
+            if main.flowObj == "True":
+                main.flowObj = True
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbFlowObj' ]
+            else:
+                main.flowObj = False
+                main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
+            main.threadID = 0
 
-        main.log.info( "Loading wrapper files" )
-        main.startUp = imp.load_source( wrapperFile1,
-                                        main.dependencyPath +
-                                        wrapperFile1 +
-                                        ".py" )
+            if main.reroute == "True":
+                main.reroute = True
+            else:
+                main.reroute = False
+            main.setupSkipped = False
 
+            wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ]
+            nic = main.params[ 'DATABASE' ][ 'nic' ]
+            node = main.params[ 'DATABASE' ][ 'node' ]
+            stepResult = main.testSetUp.gitPulling()
+            main.log.info( "Cresting DB file" )
+            with open( main.dbFileName, "w+" ) as dbFile:
+                dbFile.write("")
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
+        with open( main.dbFileName, "a" ) as dbFile:
+            temp = "'" + main.commit + "',"
+            temp += "'" + nic + "',"
+            dbFile.write( temp )
+    def CASE1( self ):
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
         copyResult = main.ONOSbench.copyMininetFile( main.topology,
                                                      main.dependencyPath,
                                                      main.Mininet1.user_name,
                                                      main.Mininet1.ip_address )
 
-        commit = main.ONOSbench.getVersion(report=True)
-        commit = commit.split(" ")[1]
-
-        with open(main.dbFileName, "a") as dbFile:
-            temp = "'" + commit + "',"
-            temp += "'" + nic + "',"
-            dbFile.write(temp)
-
     def CASE2( self, main ):
         """
         - Uninstall ONOS cluster
@@ -127,115 +92,8 @@
         - Install ONOS cluster
         - Connect to cli
         """
-        main.log.info( "Starting up %s node(s) ONOS cluster" % main.numCtrls)
-        main.log.info( "Safety check, killing all ONOS processes" +
-                       " before initiating environment setup" )
-
-        for i in range( main.numCtrls ):
-            main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            main.ONOSbench.onosKill( main.ONOSip[ i ] )
-
-        main.log.info( "NODE COUNT = %s" % main.numCtrls)
-
-        tempOnosIp = []
-        for i in range( main.numCtrls ):
-            tempOnosIp.append( main.ONOSip[i] )
-
-        main.ONOSbench.createCellFile( main.ONOSbench.ip_address,
-                                       "temp",
-                                       main.Mininet1.ip_address,
-                                       main.apps,
-                                       tempOnosIp, main.ONOScli1.karafUser )
-
-        main.step( "Apply cell to environment" )
-        cellResult = main.ONOSbench.setCell( "temp" )
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully applied cell to " + \
-                                        "environment",
-                                 onfail="Failed to apply cell to environment " )
-
-        main.step( "Creating ONOS package" )
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="Successfully created ONOS package",
-                                 onfail="Failed to create ONOS package" )
-
-        main.step( "Uninstall ONOS package on all Nodes" )
-        uninstallResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Uninstalling package on ONOS Node IP: " + main.ONOSip[i] )
-            u_result = main.ONOSbench.onosUninstall( main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=u_result,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            uninstallResult = ( uninstallResult and u_result )
-
-        main.step( "Install ONOS package on all Nodes" )
-        installResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            main.log.info( "Installing package on ONOS Node IP: " + main.ONOSip[i] )
-            i_result = main.ONOSbench.onosInstall( node=main.ONOSip[i] )
-            utilities.assert_equals( expect=main.TRUE, actual=i_result,
-                                     onpass="Test step PASS",
-                                     onfail="Test step FAIL" )
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        main.step( "Start ONOS CLI on all nodes" )
-        cliResult = main.TRUE
-        main.step(" Start ONOS cli using thread ")
-        startCliResult  = main.TRUE
-        pool = []
-
-        for i in range( int( main.numCtrls) ):
-            t = main.Thread( target=main.CLIs[i].startOnosCli,
-                             threadID=main.threadID,
-                             name="startOnosCli",
-                             args=[ main.ONOSip[i] ],
-                             kwargs = {"onosStartTimeout":main.timeout} )
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep( main.startUpSleep )
+        main.testSetUp.ONOSSetUp( main.Mininet1, True,
+                                  killRemoveMax=False, CtrlsSet=False )
 
     def CASE10( self, main ):
         """
@@ -246,7 +104,7 @@
         main.step("Activating null-provider")
         appStatus = utilities.retry( main.CLIs[0].activateApp,
                                      main.FALSE,
-                                     ['org.onosproject.null'],
+                                     [ 'org.onosproject.null' ],
                                      sleep=main.verifySleep,
                                      attempts=main.verifyAttempts )
         utilities.assert_equals( expect=main.TRUE,
@@ -259,20 +117,20 @@
         cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet,
                                     main.FALSE,
                                     [ main.ONOSip[0],
-                                      'org.onosproject.provider.nil.NullProviders', 'deviceCount 8'],
+                                      'org.onosproject.provider.nil.NullProviders', 'deviceCount 8' ],
                                     sleep=main.verifySleep,
                                     attempts = main.verifyAttempts )
         cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
                                                    main.FALSE,
                                                    [ main.ONOSip[0],
-                                                     'org.onosproject.provider.nil.NullProviders', 'topoShape reroute'],
+                                                     'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' ],
                                                    sleep=main.verifySleep,
                                                    attempts = main.verifyAttempts )
 
         cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
                                                    main.FALSE,
                                                    [ main.ONOSip[0],
-                                                     'org.onosproject.provider.nil.NullProviders', 'enabled true'],
+                                                     'org.onosproject.provider.nil.NullProviders', 'enabled true' ],
                                                    sleep=main.verifySleep,
                                                    attempts = main.verifyAttempts )
 
@@ -405,16 +263,25 @@
 
 
     def CASE20( self, main ):
+        try:
+            from tests.dependencies.utils import Utils
+        except ImportError:
+            main.log.error( "Utils not found exiting the test" )
+            main.exit()
+        try:
+            main.Utils
+        except ( NameError, AttributeError ):
+            main.Utils = Utils()
         if main.reroute:
-            main.minIntents = int(main.params['NULL']['REROUTE']['min_intents'])
-            main.maxIntents = int(main.params['NULL']['REROUTE']['max_intents'])
-            main.checkInterval = int(main.params['NULL']['REROUTE']['check_interval'])
-            main.batchSize = int(main.params['NULL']['REROUTE']['batch_size'])
+            main.minIntents = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'min_intents' ] )
+            main.maxIntents = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'max_intents' ] )
+            main.checkInterval = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'check_interval' ] )
+            main.batchSize = int(main.params[ 'NULL' ][ 'REROUTE' ][ 'batch_size' ] )
         else:
-            main.minIntents = int(main.params['NULL']['PUSH']['min_intents'])
-            main.maxIntents = int(main.params['NULL']['PUSH']['max_intents'])
-            main.checkInterval = int(main.params['NULL']['PUSH']['check_interval'])
-            main.batchSize = int(main.params['NULL']['PUSH']['batch_size'])
+            main.minIntents = int(main.params[ 'NULL' ][ 'PUSH' ][ 'min_intents' ] )
+            main.maxIntents = int(main.params[ 'NULL' ][ 'PUSH' ][ 'max_intents' ] )
+            main.checkInterval = int(main.params[ 'NULL' ][ 'PUSH' ][ 'check_interval' ] )
+            main.batchSize = int(main.params[ 'NULL' ][ 'PUSH' ][ 'batch_size' ] )
 
         # check if the case needs to be skipped
         if main.setupSkipped:
@@ -536,7 +403,6 @@
                     main.log.info("Total Intents: {}".format( verifyTotalIntents) )
                     break
 
-        del main.scale[0]
         utilities.assert_equals( expect = main.TRUE,
                                  actual = intentsState,
                                  onpass = "Successfully pushed and verified intents",
@@ -545,8 +411,8 @@
         main.log.info( "Total Intents Installed before crash: {}".format( totalIntents ) )
         main.log.info( "Total Flows ADDED before crash: {}".format( totalFlows ) )
 
-        main.step('clean up Mininet')
-        main.Mininet1.stopNet()
+        main.Utils.mininetCleanup( main.Mininet1 )
+
         main.log.info("Writing results to DS file")
         with open(main.dbFileName, "a") as dbFile:
             # Scale number
diff --git a/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/startUp.py b/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/startUp.py
deleted file mode 100644
index 501cbb3..0000000
--- a/TestON/tests/SCPF/SCPFscalingMaxIntents/dependencies/startUp.py
+++ /dev/null
@@ -1,38 +0,0 @@
-"""
-    This wrapper function is use for starting up onos instance
-"""
-
-import time
-import os
-import json
-
-def onosBuild( main, gitBranch ):
-    """
-        This includes pulling ONOS and building it using maven install
-    """
-
-    buildResult = main.FALSE
-
-    # Git checkout a branch of ONOS
-    checkOutResult = main.ONOSbench.gitCheckout( gitBranch )
-    # Does the git pull on the branch that was checked out
-    if not checkOutResult:
-        main.log.warn( "Failed to checked out " + gitBranch +
-                                           " branch")
-    else:
-        main.log.info( "Successfully checked out " + gitBranch +
-                                           " branch")
-    gitPullResult = main.ONOSbench.gitPull()
-    if gitPullResult == main.ERROR:
-        main.log.error( "Error pulling git branch" )
-    else:
-        main.log.info( "Successfully pulled " + gitBranch + " branch" )
-
-    # buck build
-    buildResult = main.ONOSbench.buckBuild()
-
-    return buildResult
-
-
-
-
diff --git a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.params b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.params
index c45fef8..f06a7c8 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.params
+++ b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.params
@@ -16,8 +16,8 @@
     </DEPENDENCY>
 
     <GIT>
-        <gitPull>off</gitPull>
-        <gitBranch>master</gitBranch>
+        <pull>False</pull>
+        <branch>master</branch>
     </GIT>
 
     <CTRL>
diff --git a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
index 6a5731d..deaaead 100644
--- a/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
+++ b/TestON/tests/SCPF/SCPFswitchLat/SCPFswitchLat.py
@@ -25,198 +25,75 @@
             different versions of ONOS.
         - Construct tests variables
         '''
-        gitPull = main.params['GIT']['gitPull']
-        gitBranch = main.params['GIT']['gitBranch']
+        try:
+            from tests.dependencies.ONOSSetup import ONOSSetup
+            main.testSetUp = ONOSSetup()
+        except ImportError:
+            main.log.error( "ONOSSetup not found. exiting the test" )
+            main.exit()
+        main.testSetUp.envSetupDescription()
+        stepResult = main.FALSE
+        try:
+            # The dictionary to record different type of wrongs
+            main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0,
+                    'TypeError' : 0, 'decodeJasonError': 0,
+                    'checkResultIncorrect': 0}
+            main.maxWrong = int( main.params['TEST'] ['MaxWrong'] )
+            main.resultRange = main.params['TEST']['ResultRange']
+            main.searchTerm = main.params['TEST']['SearchTerm']
+            main.MN1Ip = main.params['MN']['ip1']
+            main.dependencyPath = main.testOnDirectory + \
+                                  main.params['DEPENDENCY']['path']
+            main.topoName = main.params['DEPENDENCY']['topology']
+            main.dependencyFunc = main.params['DEPENDENCY']['function']
+            main.cellName = main.params['ENV']['cellName']
+            main.apps = main.params['ENV']['cellApps']
+            main.scale = (main.params['SCALE']).split(",")
 
-        main.case( "Pull onos branch and build onos on Teststation." )
+            main.ofPackage = main.params['TSHARK']
 
-        if gitPull == 'True':
-            main.step( "Git Checkout ONOS branch: " + gitBranch )
-            stepResult = main.ONOSbench.gitCheckout( branch=gitBranch )
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully checkout onos branch.",
-                                    onfail="Failed to checkout onos branch. Exiting test...")
-            if not stepResult: main.exit()
+            main.tsharkResultPath = main.params['TEST']['tsharkResultPath']
+            main.sampleSize = int(main.params['TEST']['sampleSize'])
+            main.warmUp = int(main.params['TEST']['warmUp'])
+            main.dbFileName = main.params['DATABASE']['dbName']
+            main.startUpSleep = int(main.params['SLEEP']['startup'])
+            main.measurementSleep = int( main.params['SLEEP']['measure'] )
+            main.deleteSwSleep = int( main.params['SLEEP']['deleteSW'] )
+            main.maxScale = int( main.params['max'] )
+            main.timeout = int( main.params['TIMEOUT']['timeout'] )
+            main.MNSleep = int( main.params['SLEEP']['mininet'])
+            main.device = main.params['TEST']['device']
+            stepResult = main.testSetUp.gitPulling()
+            main.log.info("Create Database file " + main.dbFileName)
+            resultsDB = open(main.dbFileName, "w+")
+            resultsDB.close()
 
-            main.step( "Git Pull on ONOS branch:" + gitBranch )
-            stepResult = main.ONOSbench.gitPull()
-            utilities.assert_equals(expect=main.TRUE,
-                                    actual=stepResult,
-                                    onpass="Successfully pull onos. ",
-                                    onfail="Failed to pull onos. Exiting test ...")
-            if not stepResult: main.exit()
-
-
-        else:
-            main.log.warn( "Skipped pulling onos and Skipped building ONOS" )
-        # The dictionary to record different type of wrongs
-        main.wrong = { 'totalWrong': 0, 'skipDown' : 0, 'TsharkValueIncorrect': 0,
-                'TypeError' : 0, 'decodeJasonError': 0,
-                'checkResultIncorrect': 0}
-        main.maxWrong = int( main.params['TEST'] ['MaxWrong'] )
-        main.resultRange = main.params['TEST']['ResultRange']
-        main.searchTerm = main.params['TEST']['SearchTerm']
-        main.testOnDirectory = os.path.dirname( os.getcwd() )
-        main.MN1Ip = main.params['MN']['ip1']
-        main.dependencyPath = main.testOnDirectory + \
-                              main.params['DEPENDENCY']['path']
-        main.topoName = main.params['DEPENDENCY']['topology']
-        main.dependencyFunc = main.params['DEPENDENCY']['function']
-        main.cellName = main.params['ENV']['cellName']
-        main.Apps = main.params['ENV']['cellApps']
-        main.scale = (main.params['SCALE']).split(",")
-
-        main.ofPackage = main.params['TSHARK']
-
-        main.tsharkResultPath = main.params['TEST']['tsharkResultPath']
-        main.sampleSize = int(main.params['TEST']['sampleSize'])
-        main.warmUp = int(main.params['TEST']['warmUp'])
-        main.dbFileName = main.params['DATABASE']['dbName']
-        main.startUpSleep = int(main.params['SLEEP']['startup'])
-        main.measurementSleep = int( main.params['SLEEP']['measure'] )
-        main.deleteSwSleep = int( main.params['SLEEP']['deleteSW'] )
-        main.maxScale = int( main.params['max'] )
-        main.timeout = int( main.params['TIMEOUT']['timeout'] )
-        main.MNSleep = int( main.params['SLEEP']['mininet'])
-        main.device = main.params['TEST']['device']
-        main.log.info("Create Database file " + main.dbFileName)
-        resultsDB = open(main.dbFileName, "w+")
-        resultsDB.close()
-
-        main.switchFunc = imp.load_source(main.dependencyFunc,
-                                       main.dependencyPath +
-                                       main.dependencyFunc +
-                                       ".py")
-
+            main.switchFunc = imp.load_source(main.dependencyFunc,
+                                           main.dependencyPath +
+                                           main.dependencyFunc +
+                                           ".py")
+        except Exception as e:
+            main.testSetUp.envSetupException( e )
+        main.testSetUp.evnSetupConclusion( stepResult )
+        main.commit = main.commit.split( " " )[ 1 ]
     def CASE1(self, main):
         # Clean up test environment and set up
         import time
-        main.log.info("Get ONOS cluster IP")
-        print(main.scale)
-        main.numCtrls = int(main.scale.pop(0))
-        main.ONOSip = []
-        main.maxNumBatch = 0
-        main.AllONOSip = main.ONOSbench.getOnosIps()
-        for i in range(main.numCtrls):
-            main.ONOSip.append(main.AllONOSip[i])
-        main.log.info(main.ONOSip)
-        main.CLIs = []
-        main.log.info("Creating list of ONOS cli handles")
-        for i in range(main.numCtrls):
-            main.CLIs.append(getattr(main, 'ONOScli%s' % (i + 1)))
-
-        if not main.CLIs:
-            main.log.error("Failed to create the list of ONOS cli handles")
-            main.cleanup()
+        try:
+            from tests.dependencies.utils import Utils
+        except ImportError:
+            main.log.error( "Utils not found exiting the test" )
             main.exit()
-
-        main.commit = main.ONOSbench.getVersion(report=True)
-        main.commit = main.commit.split(" ")[1]
-        main.log.info("Starting up %s node(s) ONOS cluster" % main.numCtrls)
-        main.log.info("Safety check, killing all ONOS processes" +
-                      " before initiating environment setup")
-
-        for i in range(main.numCtrls):
-            main.ONOSbench.onosStop(main.ONOSip[i])
-            main.ONOSbench.onosKill(main.ONOSip[i])
-
-        main.log.info("NODE COUNT = %s" % main.numCtrls)
-        main.ONOSbench.createCellFile(main.ONOSbench.ip_address,
-                                      main.cellName,
-                                      main.MN1Ip,
-                                      main.Apps,
-                                      main.ONOSip, main.ONOScli1.karafUser)
-        main.step("Apply cell to environment")
-        cellResult = main.ONOSbench.setCell(main.cellName)
-        verifyResult = main.ONOSbench.verifyCell()
-        stepResult = cellResult and verifyResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully applied cell to " + \
-                                       "environment",
-                                onfail="Failed to apply cell to environment ")
-
-        main.step("Creating ONOS package")
-        packageResult = main.ONOSbench.buckBuild()
-        stepResult = packageResult
-        utilities.assert_equals(expect=main.TRUE,
-                                actual=stepResult,
-                                onpass="Successfully created ONOS package",
-                                onfail="Failed to create ONOS package")
-
-        main.step("Uninstall ONOS package on all Nodes")
-        uninstallResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Uninstalling package on ONOS Node IP: " + main.ONOSip[i])
-            u_result = main.ONOSbench.onosUninstall(main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=u_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            uninstallResult = (uninstallResult and u_result)
-
-        main.step("Install ONOS package on all Nodes")
-        installResult = main.TRUE
-        for i in range(int(main.numCtrls)):
-            main.log.info("Installing package on ONOS Node IP: " + main.ONOSip[i])
-            i_result = main.ONOSbench.onosInstall(node=main.ONOSip[i])
-            utilities.assert_equals(expect=main.TRUE, actual=i_result,
-                                    onpass="Test step PASS",
-                                    onfail="Test step FAIL")
-            installResult = installResult and i_result
-
-        main.step( "Set up ONOS secure SSH" )
-        secureSshResult = main.TRUE
-        for i in range( int( main.numCtrls ) ):
-            secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[i] )
-        utilities.assert_equals( expect=main.TRUE, actual=secureSshResult,
-                                 onpass="Test step PASS",
-                                 onfail="Test step FAIL" )
-
-        time.sleep( main.startUpSleep )
-        main.step( "Starting ONOS service" )
-        stopResult = main.TRUE
-        startResult = main.TRUE
-        onosIsUp = main.TRUE
-        for i in range( main.numCtrls ):
-            onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] )
-        if onosIsUp == main.TRUE:
-            main.log.report( "ONOS instance is up and ready" )
-        else:
-            main.log.report( "ONOS instance may not be up, stop and " +
-                             "start ONOS again " )
-            for i in range( main.numCtrls ):
-                stopResult = stopResult and \
-                        main.ONOSbench.onosStop( main.ONOSip[ i ] )
-            for i in range( main.numCtrls ):
-                startResult = startResult and \
-                        main.ONOSbench.onosStart( main.ONOSip[ i ] )
-        stepResult = onosIsUp and stopResult and startResult
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass="ONOS service is ready",
-                                 onfail="ONOS service did not start properly" )
-
-        time.sleep(2)
-        main.step("Start ONOS CLI on all nodes")
-        cliResult = main.TRUE
-        main.step(" Start ONOS cli using thread ")
-        startCliResult = main.TRUE
-        pool = []
-        main.threadID = 0
-        for i in range(int(main.numCtrls)):
-            t = main.Thread(target=main.CLIs[i].startOnosCli,
-                            threadID=main.threadID,
-                            name="startOnosCli",
-                            args=[main.ONOSip[i]],
-                            kwargs={"onosStartTimeout": main.timeout})
-            pool.append(t)
-            t.start()
-            main.threadID = main.threadID + 1
-        for t in pool:
-            t.join()
-            startCliResult = startCliResult and t.result
-        time.sleep(main.startUpSleep)
+        try:
+            main.Utils
+        except ( NameError, AttributeError ):
+            main.Utils = Utils()
+        main.maxNumBatch = 0
+        main.testSetUp.getNumCtrls( True )
+        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
+        main.testSetUp.ONOSSetUp( main.Mininet1, True,
+                                  cellName=main.cellName, killRemoveMax=False,
+                                  CtrlsSet=False )
 
         main.log.info("Configure apps")
         main.CLIs[0].setCfg("org.onosproject.net.topology.impl.DefaultTopologyProvider",
@@ -234,8 +111,7 @@
                                        main.dependencyPath,
                                        main.Mininet1.user_name,
                                        main.Mininet1.ip_address)
-        main.log.info("Stop Mininet...")
-        main.Mininet1.stopNet()
+        main.Utils.mininetCleanup( main.Mininet1 )
         time.sleep(main.MNSleep)
         main.log.info("Start new mininet topology")
         main.Mininet1.startNet()