Update Cluster Driver

Change-Id: I8a3a57e19637ff210548e57d41178e6f194cf694
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
index 30e6e02..6914862 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.params
@@ -69,6 +69,13 @@
         <skipReleaseResourcesOnWithdrawal>true</skipReleaseResourcesOnWithdrawal>
         <flowObj>False</flowObj>
     </TEST>
+    <CFG>
+        <intentManager>org.onosproject.net.intent.impl.IntentManager</intentManager>
+        <intentConfigRegi>org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator</intentConfigRegi>
+        <nullProvider>org.onosproject.provider.nil.NullProviders</nullProvider>
+        <linkCollectionIntent>org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler</linkCollectionIntent>
+        <intentPerfInstaller>org.onosproject.intentperf.IntentPerfInstaller</intentPerfInstaller>
+    </CFG>
     <DATABASE>
         <dbName>/tmp/IntentEventTPDB</dbName>
         <dbFlowObj>/tmp/IntentEventTPflowObjDB</dbFlowObj>
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
index 1b55d54..3599806 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.py
@@ -54,22 +54,26 @@
         main.testSetUp.envSetupDescription()
         stepResult = main.FALSE
         try:
-            main.cellName = main.params[ 'ENV'][ 'cellName']
+            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.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.scale = ( main.params[ 'SCALE' ] ).split( "," )
             main.testDuration = main.params[ 'TEST' ][ 'duration' ]
             main.logInterval = main.params[ 'TEST' ][ 'log_interval' ]
             main.debug = main.params[ 'debugMode' ]
+            main.intentManagerCfg = main.params[ 'CFG' ][ 'intentManager' ]
+            main.intentConfigRegiCfg = main.params[ 'CFG' ][ 'intentConfigRegi' ]
+            main.nullProviderCfg = main.params[ 'CFG' ][ 'nullProvider' ]
+            main.linkCollectionIntentCfg = main.params[ 'CFG' ][ 'linkCollectionIntent' ]
+            main.intentPerfInstallerCfg = main.params[ 'CFG' ][ 'intentPerfInstaller' ]
             main.timeout = int( main.params[ 'SLEEP' ][ 'timeout' ] )
             main.cyclePeriod = main.params[ 'TEST' ][ 'cyclePeriod' ]
             if main.flowObj == "True":
@@ -81,7 +85,7 @@
                 main.dbFileName = main.params[ 'DATABASE' ][ 'dbName' ]
                 main.numKeys = main.params[ 'TEST' ][ 'numKeys' ]
 
-            stepResult = main.testSetUp.gitPulling()
+            stepResult = main.testSetUp.envSetup()
             # Create DataBase file
             main.log.info( "Create Database file " + main.dbFileName )
             resultsDB = open( main.dbFileName, "w+" )
@@ -98,75 +102,78 @@
         # Clean up test environment and set up
         import time
         main.maxNumBatch = 0
-        main.testSetUp.getNumCtrls( True )
-        main.testSetUp.envSetup( includeGitPull=False, makeMaxNodes=False )
-        main.testSetUp.ONOSSetUp( main.MN1Ip, True,
-                                  cellName=main.cellName, killRemoveMax=False,
-                                  CtrlsSet=False )
+        main.testSetUp.ONOSSetUp( main.MN1Ip, main.Cluster, True,
+                                  cellName=main.cellName, killRemoveMax=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", "topoShape linear" )
-        main.CLIs[0].setCfg( "org.onosproject.provider.nil.NullProviders", "enabled true" )
+        main.Cluster.active( 0 ).CLI.setCfg( main.intentManagerCfg,
+                                             "skipReleaseResourcesOnWithdrawal " + main.skipRelRsrc )
+        main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg,
+                                             "deviceCount " + str( int( main.Cluster.numCtrls * 10 ) ) )
+        main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "topoShape linear" )
+        main.Cluster.active( 0 ).CLI.setCfg( main.nullProviderCfg, "enabled 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",
-                                "defaultFlowObjectiveCompiler",
-                                value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler')
+            main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg(),
+                                                 "useFlowObjectives", value="true" )
+            main.Cluster.active( 0 ).CLI.setCfg( main.intentConfigRegiCfg(),
+                                                 "defaultFlowObjectiveCompiler",
+                                                 value=main.linkCollectionIntentCfg )
         time.sleep( main.startUpSleep )
 
         # balanceMasters
-        main.CLIs[0].balanceMasters()
+        main.Cluster.active( 0 ).CLI.balanceMasters()
         time.sleep( main.startUpSleep )
 
-    def CASE2(self, main):
+    def CASE2( self, main ):
         import numpy
 
-        main.log.info( "Cluster Count = " + str( main.numCtrls ) )
+        main.log.info( "Cluster Count = " + str( main.Cluster.numCtrls ) )
         # adjust neighbors
-        if main.numCtrls == 1:
+        if main.Cluster.numCtrls == 1:
             main.neighbors = "0"
             main.log.info( "Neighbors: 0" )
         elif main.neighbors != "0":
             main.neighbors = "0"
             main.log.info( "Neighbors: 0" )
         elif main.neighbors == "0":
-            main.neighbors = str( main.numCtrls - 1 )
+            main.neighbors = str( main.Cluster.numCtrls - 1 )
             main.log.info( "Neighbors: " + main.neighbors )
 
         main.log.info( "Config intent-perf app" )
-        main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numKeys " + main.numKeys )
-        main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "numNeighbors " + str( main.neighbors ) )
-        main.CLIs[0].setCfg( "org.onosproject.intentperf.IntentPerfInstaller", "cyclePeriod " + main.cyclePeriod )
+        main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
+                                             "numKeys " + main.numKeys )
+        main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
+                                             "numNeighbors " + str( main.neighbors ) )
+        main.Cluster.active( 0 ).CLI.setCfg( main.intentPerfInstallerCfg,
+                                             "cyclePeriod " + main.cyclePeriod )
 
-        main.log.info( "Starting intent-perf test for " + str( main.testDuration) + " seconds..." )
-        main.CLIs[0].sendline( "intent-perf-start" )
+        main.log.info( "Starting intent-perf test for " + str( main.testDuration ) + " seconds..." )
+        main.Cluster.active( 0 ).CLI.sendline( "intent-perf-start" )
         stop = time.time() + float( main.testDuration )
 
         while time.time() < stop:
-            time.sleep(15)
-            result = main.CLIs[0].getIntentPerfSummary()
+            time.sleep( 15 )
+            result = main.Cluster.active( 0 ).CLI.getIntentPerfSummary()
             if result:
-                for i in range( main.numCtrls ):
-                    main.log.info( "Node {} Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) )
+                for ctrl in main.Cluster.active():
+                    main.log.info( "Node {} Overall Rate: {}".format( ctrl.ipAddress,
+                                                                      result[ ctrl.ipAddress ] ) )
         main.log.info( "Stop intent-perf" )
-        for i in range( main.numCtrls ):
-            main.CLIs[i].sendline( "intent-perf-stop" )
+        for ctrl in main.Cluster.active():
+            ctrl.CLI.sendline( "intent-perf-stop" )
         if result:
-            for i in range( main.numCtrls ):
-                main.log.info( "Node {} final Overall Rate: {}".format( main.ONOSip[ i ], result[ main.ONOSip[ i ] ] ) )
+            for ctrl in main.Cluster.active():
+                main.log.info( "Node {} final Overall Rate: {}".format( ctrl.ipAddress,
+                                                                        result[ ctrl.ipAddress ] ) )
 
         with open( main.dbFileName, "a" ) as resultDB:
-            for nodes in range( main.numCtrls ):
+            for nodes in range( main.Cluster.numCtrls ):
                 resultString = "'" + main.commit + "',"
                 resultString += "'1gig',"
-                resultString += str( main.numCtrls) + ","
-                resultString += "'baremetal" + str( nodes+1 ) + "',"
+                resultString += str( main.Cluster.numCtrls ) + ","
+                resultString += "'baremetal" + str( nodes + 1 ) + "',"
                 resultString += main.neighbors + ","
-                resultString += result[ main.ONOSip[ nodes ] ]+","
-                resultString += str(0) + "\n"  # no stddev
+                resultString += result[ main.Cluster.active( nodes ).ipAddress ] + ","
+                resultString += str( 0 ) + "\n"  # no stddev
                 resultDB.write( resultString )
         resultDB.close()
diff --git a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.topo b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.topo
index acafd82..93e1e9d 100644
--- a/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.topo
+++ b/TestON/tests/SCPF/SCPFintentEventTp/SCPFintentEventTp.topo
@@ -1,177 +1,25 @@
 <TOPOLOGY>
-
     <COMPONENT>
 
-        <ONOSbench>
-            <host>localhost</host>
+        <ONOScell>
+            <host>localhost</host>  # ONOS "bench" machine
             <user>sdn</user>
             <password>rocks</password>
-            <type>OnosDriver</type>
+            <type>OnosClusterDriver</type>
             <connect_order>1</connect_order>
             <COMPONENTS>
-                <home>~/onos</home>
-                <nodes>7</nodes>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOSbench>
-
-        <ONOScli1>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>2</connect_order>
-            <COMPONENTS>
+                <cluster_name></cluster_name>  # Used as a prefix for cluster components. Defaults to 'ONOS'
+                <diff_clihost></diff_clihost>  # if it has different host other than localhost for CLI. True or empty. OC# will be used if True.
                 <karaf_username></karaf_username>
                 <karaf_password></karaf_password>
-                <prompt></prompt>
+                <web_user></web_user>
+                <web_pass></web_pass>
+                <rest_port></rest_port>
+                <prompt></prompt>  # TODO: we technically need a few of these, one per component
+                <onos_home></onos_home>  # defines where onos home is
+                <nodes> 7 </nodes>  # number of nodes in the cluster
             </COMPONENTS>
-        </ONOScli1>
-
-        <ONOScli2>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>3</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli2>
-
-        <ONOScli3>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>4</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli3>
-
-        <ONOScli4>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>5</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli4>
-
-        <ONOScli5>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>6</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli5>
-
-        <ONOScli6>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>7</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli6>
-
-        <ONOScli7>
-            <host>localhost</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosCliDriver</type>
-            <connect_order>8</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOScli7>
-
-        <ONOS1>
-            <host>OC1</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>9</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS1>
-
-        <ONOS2>
-            <host>OC2</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>10</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS2>
-
-        <ONOS3>
-            <host>OC3</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>11</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS3>
-
-        <ONOS4>
-            <host>OC4</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>12</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS4>
-
-        <ONOS5>
-            <host>OC5</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>13</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS5>
-
-        <ONOS6>
-            <host>OC6</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>14</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS6>
-
-        <ONOS7>
-            <host>OC7</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>15</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS7>
+        </ONOScell>
 
     </COMPONENT>
-
-</TOPOLOGY>
- 
+</TOPOLOGY>
\ No newline at end of file