Update Cluster Driver

Change-Id: I8a3a57e19637ff210548e57d41178e6f194cf694
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
index a0a061a..0b8c85d 100644
--- a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.py
@@ -64,15 +64,15 @@
             cellName = main.params[ 'ENV' ][ 'cellName' ]
 
             main.apps = main.params[ 'ENV' ][ 'cellApps' ]
-            main.numCtrls = int( main.params[ 'num_controllers' ] )
 
             ofPort = main.params[ 'CTRL' ][ 'port' ]
-            stepResult = main.testSetUp.envSetup( hasRest=True, hasNode=True )
+            stepResult = main.testSetUp.envSetup()
         except Exception as e:
             main.testSetUp.envSetupException( e )
         main.testSetUp.evnSetupConclusion( stepResult )
 
-        main.testSetUp.ONOSSetUp( main.Mininet1, cellName=cellName )
+        main.testSetUp.ONOSSetUp( main.Mininet1, main.Cluster,
+                                  cellName=cellName )
 
         main.step( "Starting Mininet" )
         # scp topo file to mininet
@@ -86,15 +86,14 @@
                             direction="to" )
         topo = " --custom " + main.Mininet1.home + topoFile + " --topo " + topoName
         args = " --switch ovs,protocols=OpenFlow13"
-        for node in main.nodes:
-            args += " --controller=remote,ip=" + node.ip_address
+        for ctrl in main.Cluster.active():
+            args += " --controller=remote,ip=" + ctrl.ipAddress
         mnCmd = "sudo mn" + topo + args
         mnResult = main.Mininet1.startNet( mnCmd=mnCmd )
         utilities.assert_equals( expect=main.TRUE, actual=mnResult,
                                  onpass="Mininet Started",
                                  onfail="Error starting Mininet" )
 
-        main.activeNodes = [ i for i in range( 0, len( main.CLIs ) ) ]
 
         main.step( "Activate apps defined in the params file" )
         # get data from the params
@@ -104,11 +103,11 @@
             main.log.warn( apps )
             activateResult = True
             for app in apps:
-                main.CLIs[ 0 ].app( app, "Activate" )
+                main.Cluster.active( 0 ).CLI.app( app, "Activate" )
             # TODO: check this worked
             time.sleep( SLEEP )  # wait for apps to activate
             for app in apps:
-                state = main.CLIs[ 0 ].appStatus( app )
+                state = main.Cluster.active( 0 ).CLI.appStatus( app )
                 if state == "ACTIVE":
                     activateResult = activateResult and True
                 else:
@@ -129,7 +128,7 @@
             for component in config:
                 for setting in config[ component ]:
                     value = config[ component ][ setting ]
-                    check = main.CLIs[ 0 ].setCfg( component, setting, value )
+                    check = main.Cluster.active( 0 ).CLI.setCfg( component, setting, value )
                     main.log.info( "Value was changed? {}".format( main.TRUE == check ) )
                     checkResult = check and checkResult
             utilities.assert_equals( expect=main.TRUE,
@@ -140,22 +139,11 @@
             main.log.warn( "No configurations were specified to be changed after startup" )
 
         main.step( "App Ids check" )
-        appCheck = main.TRUE
-        threads = []
-        for i in main.activeNodes:
-            t = main.Thread( target=main.CLIs[ i ].appToIDCheck,
-                             name="appToIDCheck-" + str( i ),
-                             args=[] )
-            threads.append( t )
-            t.start()
-
-        for t in threads:
-            t.join()
-            appCheck = appCheck and t.result
-        if appCheck != main.TRUE:
-            main.log.warn( main.CLIs[ 0 ].apps() )
-            main.log.warn( main.CLIs[ 0 ].appIDs() )
-        utilities.assert_equals( expect=main.TRUE, actual=appCheck,
+        appCheck = main.Cluster.command( "appToIDCheck", returnBool=True )
+        if appCheck != True:
+            main.log.warn( main.Cluster.active( 0 ).CLI.apps() )
+            main.log.warn( main.Cluster.active( 0 ).CLI.appIDs() )
+        utilities.assert_equals( expect=True, actual=appCheck,
                                  onpass="App Ids seem to be correct",
                                  onfail="Something is wrong with app Ids" )
 
@@ -167,7 +155,7 @@
         from tests.USECASE.VPLS.dependencies import vpls
 
         main.vpls = vpls
-        pprint = main.ONOSrest1.pprint
+        pprint = main.Cluster.active( 0 ).REST.pprint
         hosts = int( main.params[ 'vpls' ][ 'hosts' ] )
         SLEEP = int( main.params[ 'SLEEP' ][ 'netcfg' ] )
 
@@ -184,7 +172,7 @@
         fileName = main.params[ 'DEPENDENCY' ][ 'topology' ]
         app = main.params[ 'vpls' ][ 'name' ]
 
-        loadVPLSResult = main.ONOSbench.onosNetCfg( main.nodes[ 0 ].ip_address, "", fileName )
+        loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=loadVPLSResult,
                                  onpass="Loaded vpls configuration.",
@@ -211,7 +199,7 @@
 
         main.step( "Check interface configurations" )
         result = False
-        getPorts = utilities.retry( f=main.ONOSrest1.getNetCfg,
+        getPorts = utilities.retry( f=main.Cluster.active( 0 ).REST.getNetCfg,
                                     retValue=False,
                                     kwargs={"subjectClass":"ports"},
                                     sleep=SLEEP )
@@ -234,7 +222,7 @@
         vpls.verify( main )
 
         main.step( "Loading vpls configuration in case any configuration was missed." )
-        loadVPLSResult = main.ONOSbench.onosNetCfg( main.nodes[ 0 ].ip_address, "", fileName )
+        loadVPLSResult = main.ONOSbench.onosNetCfg( main.Cluster.active( 0 ).ipAddress, "", fileName )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=loadVPLSResult,
                                  onpass="Loaded vpls configuration.",
@@ -255,10 +243,10 @@
         """
         from tests.USECASE.VPLS.dependencies import vpls
         SLEEP = int( main.params[ 'SLEEP' ][ 'netcfg' ] )
-        pprint = main.ONOSrest1.pprint
+        pprint = main.Cluster.active( 0 ).REST.pprint
 
         main.step( "Remove an interface from a vpls network" )
-        main.CLIs[ 0 ].vplsRemIface( 'VPLS1', 'h1' )
+        main.Cluster.active( 0 ).CLI.vplsRemIface( 'VPLS1', 'h1' )
         time.sleep( SLEEP )
         #update master config json
         for network in main.vplsConfig:
@@ -268,23 +256,23 @@
         vpls.verify( main )
 
         main.step( "Clean all vpls configurations" )
-        main.CLIs[ 0 ].vplsClean()
+        main.Cluster.active( 0 ).CLI.vplsClean()
         time.sleep( SLEEP )
         main.vplsConfig = []
         vpls.verify( main )
 
         main.step( "Create a new vpls network" )
         name = "Network1"
-        main.CLIs[ 0 ].vplsCreate( name )
+        main.Cluster.active( 0 ).CLI.vplsCreate( name )
         time.sleep( SLEEP )
         network1 = { 'name': name, 'interfaces': [], 'encapsulation': 'NONE' }
         main.vplsConfig.append( network1 )
         vpls.verify( main )
 
         main.step( "Add interfaces to the network" )
-        main.CLIs[ 0 ].vplsAddIface( name, "h1" )
-        main.CLIs[ 0 ].vplsAddIface( name, "h5" )
-        main.CLIs[ 0 ].vplsAddIface( name, "h4" )
+        main.Cluster.active( 0 ).CLI.vplsAddIface( name, "h1" )
+        main.Cluster.active( 0 ).CLI.vplsAddIface( name, "h5" )
+        main.Cluster.active( 0 ).CLI.vplsAddIface( name, "h4" )
         time.sleep( SLEEP )
         for network in main.vplsConfig:
             if network.get( 'name' ) == name:
@@ -297,7 +285,7 @@
 
         main.step( "Add MPLS encapsulation to a vpls network" )
         encapType = "MPLS"
-        main.CLIs[ 0 ].vplsSetEncap( name, encapType )
+        main.Cluster.active( 0 ).CLI.vplsSetEncap( name, encapType )
         for network in main.vplsConfig:
             if network.get( 'name' ) == name:
                 network[ 'encapsulation' ] = encapType
@@ -306,7 +294,7 @@
 
         main.step( "Change an encapsulation type" )
         encapType = "VLAN"
-        main.CLIs[ 0 ].vplsSetEncap( name, encapType )
+        main.Cluster.active( 0 ).CLI.vplsSetEncap( name, encapType )
         for network in main.vplsConfig:
             if network.get( 'name' ) == name:
                 network[ 'encapsulation' ] = encapType
@@ -315,7 +303,7 @@
 
         main.step( "Remove encapsulation" )
         encapType = "NONE"
-        main.CLIs[ 0 ].vplsSetEncap( name, encapType )
+        main.Cluster.active( 0 ).CLI.vplsSetEncap( name, encapType )
         for network in main.vplsConfig:
             if network.get( 'name' ) == name:
                 network[ 'encapsulation' ] = encapType
@@ -323,7 +311,7 @@
         vpls.verify( main )
 
         main.step( "Clean all vpls configurations" )
-        main.CLIs[ 0 ].vplsClean()
+        main.Cluster.active( 0 ).CLI.vplsClean()
         time.sleep( SLEEP )
         main.vplsConfig = []
         vpls.verify( main )
diff --git a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
index 03e451b..4441c62 100755
--- a/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
+++ b/TestON/tests/USECASE/VPLS/VPLSBasic/VPLSBasic.topo
@@ -1,129 +1,32 @@
 <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>
-                <nodes>3</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.
                 <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> 3 </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>
-
-        <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>
-
-        <ONOSrest1>
-            <host>OC1</host>
-            <port>8181</port>
-            <user>onos</user>
-            <password>rocks</password>
-            <type>OnosRestDriver</type>
-            <connect_order>2</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOSrest1>
-
-        <ONOSrest2>
-            <host>OC2</host>
-            <port>8181</port>
-            <user>onos</user>
-            <password>rocks</password>
-            <type>OnosRestDriver</type>
-            <connect_order>3</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOSrest2>
-
-        <ONOSrest3>
-            <host>OC3</host>
-            <port>8181</port>
-            <user>onos</user>
-            <password>rocks</password>
-            <type>OnosRestDriver</type>
-            <connect_order>4</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOSrest3>
-
+        </ONOScell>
 
         <Mininet1>
             <host>OCN</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>MininetCliDriver</type>
-            <connect_order>7</connect_order>
+            <connect_order>2</connect_order>
             <COMPONENTS>
                 <home>~/mininet/custom/</home>
                 <prompt></prompt>