SAMP tests now use the same way to start ONOS as other tests

Change-Id: I2d1fb795d421ec89183cf5db45bfd917a9d7a28d
diff --git a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
index bd35266..794cc75 100644
--- a/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
+++ b/TestON/tests/FUNC/FUNCbgpls/FUNCbgpls.py
@@ -450,7 +450,7 @@
         bgplsConfig = BgpLs()
         bgplsConfig.ipValue( main.ipList, main.scapy_ip )
 
-        main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.scapy_ip, True, main.ipList )
+        main.testSetUp.createApplyCell( main.Cluster, True, main.cellName, main.apps, main.scapy_ip, True, main.ipList )
         bgplsConfig.Comments()
         main.testSetUp.startOnosClis( main.Cluster )
         bgplsConfig.Comments()
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.params b/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.params
index 159edbf..09c7fc2 100755
--- a/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.params
+++ b/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.params
@@ -49,7 +49,7 @@
     <CASE10>
         <numNodes>1</numNodes>
         <Apps>
-            org.onosproject.openflow,org.onosproject.fwd
+            org.onosproject.openflow
         </Apps>
         <ONOS_Configuration>
             <org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator>
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.py b/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.py
index 37020b3..c940bde 100644
--- a/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.py
+++ b/TestON/tests/SAMP/SAMPstartTemplate_1node/SAMPstartTemplate_1node.py
@@ -34,15 +34,8 @@
             test env. We want Jenkins jobs to pull&build for flexibility to handle
             different versions of ONOS.
         """
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
+        from tests.dependencies.ONOSSetup import ONOSSetup
+        main.testSetUp = ONOSSetup()
         main.testSetUp.gitPulling()
 
     def CASE1( self, main ):
@@ -51,16 +44,6 @@
             Uninstall all running cells in test env defined in .topo file
 
         """
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
-
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
         try:
@@ -95,27 +78,14 @@
         3 ) configure onos via ONOSCliDriver;
         """
         import time
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
         main.case( "Start up " + str( main.Cluster.numCtrls ) + "-node onos cluster." )
         main.step( "Start ONOS cluster with basic (drivers) app." )
-        stepResult = main.ONOSbench.startBasicONOS( nodeList=main.Cluster.getIps(),
-                                                    opSleep=200,
-                                                    onosUser=main.ONOScell.karafUser )
+        stepResult = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
                                  onpass="Successfully started basic ONOS cluster ",
                                  onfail="Failed to start basic ONOS Cluster " )
 
-        main.testSetUp.startOnosClis( main.Cluster )
-
         main.step( "Activate onos apps." )
         main.apps = main.params[ 'CASE10' ].get( 'Apps' )
         if main.apps:
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
index 41adb4c..0eead29 100755
--- a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
+++ b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.params
@@ -35,7 +35,7 @@
 
     <CASE10>
         <Apps>
-            org.onosproject.openflow,org.onosproject.fwd
+            org.onosproject.openflow
         </Apps>
         <ONOS_Configuration>
         <org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator>
diff --git a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
index 08b5729..80994b8 100644
--- a/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
+++ b/TestON/tests/SAMP/SAMPstartTemplate_3node/SAMPstartTemplate_3node.py
@@ -34,16 +34,8 @@
             test env. We want Jenkins jobs to pull&build for flexibility to handle
             different versions of ONOS.
         """
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
-
+        from tests.dependencies.ONOSSetup import ONOSSetup
+        main.testSetUp = ONOSSetup()
         main.testSetUp.gitPulling()
 
     def CASE1( self, main ):
@@ -52,16 +44,6 @@
             Uninstall all running cells in test env defined in .topo file
 
         """
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
-
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
         try:
@@ -95,23 +77,12 @@
         2 ) activate apps via ONOSCliDriver;
         3 ) configure onos via ONOSCliDriver;
         """
-        try:
-            from tests.dependencies.ONOSSetup import ONOSSetup
-        except ImportError:
-            main.log.error( "ONOSSetup not found. exiting the test" )
-            main.cleanAndExit()
-        try:
-            main.testSetUp
-        except ( NameError, AttributeError ):
-            main.testSetUp = ONOSSetup()
-
         import time
 
         main.case( "Start up " + str( main.Cluster.numCtrls ) + "-node onos cluster." )
 
         main.step( "Start ONOS cluster with basic (drivers) app." )
-        stepResult = main.ONOSbench.startBasicONOS( nodeList=main.Cluster.getIps(), opSleep=200,
-                                                    onosUser=main.ONOScell.karafUser )
+        stepResult = main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
                                  onpass="Successfully started basic ONOS cluster ",
diff --git a/TestON/tests/dependencies/Cluster.py b/TestON/tests/dependencies/Cluster.py
index 1532039..af17ab5 100644
--- a/TestON/tests/dependencies/Cluster.py
+++ b/TestON/tests/dependencies/Cluster.py
@@ -149,23 +149,28 @@
         """
         self.iterator = iter( self.active() )
 
-    def createCell( self, cellName, Mininet, useSSH, ips, installMax=False ):
+    def createCell( self, cellName, cellApps, Mininet, useSSH, ips, installMax=False ):
         """
         Description:
             create a new cell
         Required:
             * cellName - The name of the cell.
+            * cellApps - The ONOS apps string.
             * Mininet - a mininet driver that will be used.
             * useSSH - True for using ssh when creating a cell
             * ips - ip( s ) of the node( s ).
         Returns:
         """
+        try:
+            apps = main.apps
+        except ( NameError, AttributeError ):
+            apps = cellApps
         self.command( "createCellFile",
                       args=[ main.ONOSbench.ip_address,
                              cellName,
                              Mininet if isinstance( Mininet, str ) else
                              Mininet.ip_address,
-                             main.apps,
+                             apps,
                              ips,
                              main.ONOScell.karafUser,
                              useSSH ],
diff --git a/TestON/tests/dependencies/ONOSSetup.py b/TestON/tests/dependencies/ONOSSetup.py
index ed4d978..11f5886 100644
--- a/TestON/tests/dependencies/ONOSSetup.py
+++ b/TestON/tests/dependencies/ONOSSetup.py
@@ -197,7 +197,7 @@
 
         return cluster.kill( killRemoveMax, stopOnos )
 
-    def createApplyCell( self, cluster, newCell, cellName,
+    def createApplyCell( self, cluster, newCell, cellName, cellApps,
                          Mininet, useSSH, ips, installMax=False ):
         """
         Description:
@@ -207,6 +207,7 @@
             * cluster - the cluster driver that will be used.
             * newCell - True for making a new cell and False for not making it.
             * cellName - The name of the cell.
+            * cellApps - The onos apps string.
             * Mininet - a mininet driver that will be used.
             * useSSH - True for using ssh when creating a cell
             * ips - ip( s ) of the node( s ).
@@ -214,7 +215,7 @@
             Returns main.TRUE if it successfully executed.
         """
         if newCell:
-            cluster.createCell( cellName, Mininet, useSSH, ips )
+            cluster.createCell( cellName, cellApps, Mininet, useSSH, ips )
         main.step( "Apply cell to environment" )
         stepResult = cluster.applyCell( cellName )
         utilities.assert_equals( expect=main.TRUE,
@@ -352,9 +353,9 @@
                 functions( *args ) if args is not None else functions()
 
     def ONOSSetUp( self, Mininet, cluster, hasMultiNodeRounds=False, startOnos=True, newCell=True,
-                   cellName="temp", removeLog=False, extraApply=None, applyArgs=None, extraClean=None,
-                   cleanArgs=None, skipPack=False, installMax=False, useSSH=True, killRemoveMax=True,
-                   stopOnos=False, installParallel=True ):
+                   cellName="temp", cellApps="drivers", removeLog=False, extraApply=None, applyArgs=None,
+                   extraClean=None, cleanArgs=None, skipPack=False, installMax=False, useSSH=True,
+                   killRemoveMax=True, stopOnos=False, installParallel=True ):
         """
         Description:
             Initial ONOS setting up of the tests. It will also verify the result of each steps.
@@ -377,6 +378,7 @@
             * startOnos - True if wish to start onos.
             * newCell - True for making a new cell and False for not making it.
             * cellName - Name of the cell that will be used.
+            * cellApps - The cell apps string.
             * removeLog - True if wish to remove raft logs
             * extraApply - Function( s ) that will be called before building ONOS. Default to None.
             * applyArgs - argument of the functon( s ) of the extraApply. Should be in list.
@@ -410,9 +412,9 @@
             for ctrl in cluster.runningNodes:
                 tempOnosIp.append( ctrl.ipAddress )
             cellResult = self.createApplyCell( cluster, newCell,
-                                               cellName, Mininet,
-                                               useSSH, tempOnosIp,
-                                               installMax )
+                                               cellName, cellApps,
+                                               Mininet, useSSH,
+                                               tempOnosIp, installMax )
             if removeLog:
                 main.log.info( "Removing raft logs" )
                 main.ONOSbench.onosRemoveRaftLogs()