Update Cluster Driver

Change-Id: I8a3a57e19637ff210548e57d41178e6f194cf694
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
index 5e26932..48b0a66 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.py
@@ -53,7 +53,8 @@
         swResult = main.TRUE
         for i in range ( 1, int( main.params['config']['switchNum'] ) + 1 ):
             sw = "sw%s" % ( i )
-            swResult = swResult and main.Mininet.assignSwController( sw, main.ONOSip[ 0 ] )
+            swResult = swResult and \
+                       main.Mininet.assignSwController( sw, main.Cluster.active( 0 ).ipAddress )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=swResult,
                                  onpass="Successfully connect all switches to ONOS",
@@ -63,9 +64,10 @@
             main.exit()
 
         main.step( "Set up tunnel from Mininet node to onos node" )
-        forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.ONOSip[ 0 ] )
+        forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', main.Cluster.active( 0 ).ipAddress )
         command = 'ssh -nNT -o "PasswordAuthentication no" \
-        -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, main.ONOSip[ 0 ] )
+        -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % \
+                  ( forwarding1, main.Cluster.active( 0 ).ipAddress )
 
         tunnelResult = main.TRUE
         tunnelResult = main.Mininet.node( "root", command )
@@ -110,20 +112,20 @@
         time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
 
         main.log.info( "Get links in the network" )
-        summaryResult = main.ONOScli1.summary()
+        summaryResult = main.Cluster.active( 0 ).CLI.summary()
         linkNum = json.loads( summaryResult )[ "links" ]
-        listResult = main.ONOScli1.links( jsonFormat=False )
+        listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
         main.log.info( listResult )
         if linkNum < 100:
             main.log.error( "Link number is wrong!" )
             time.sleep( int( main.params['timers']['TopoDiscovery'] ) )
-            listResult = main.ONOScli1.links( jsonFormat=False )
+            listResult = main.Cluster.active( 0 ).CLI.links( jsonFormat=False )
             main.log.info( listResult )
             main.cleanup()
             main.exit()
 
         main.step( "Activate sdn-ip application" )
-        activeSDNIPresult = main.ONOScli1.activateApp( "org.onosproject.sdnip" )
+        activeSDNIPresult = main.Cluster.active( 0 ).CLI.activateApp( "org.onosproject.sdnip" )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=activeSDNIPresult,
                                  onpass="Activate SDN-IP succeeded",
@@ -292,7 +294,7 @@
             main.exit()
 
         main.step( "Check whether all flow status are ADDED" )
-        flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+        flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
                                      main.FALSE,
                                      kwargs={'isPENDING':False},
                                      attempts=10 )
@@ -318,7 +320,7 @@
             onpass="Starting switch succeeded!",
             onfail="Starting switch failed!" )
 
-        result2 = main.Mininet.assignSwController( "sw32", main.ONOSip[ 0 ] )
+        result2 = main.Mininet.assignSwController( "sw32", main.Cluster.active( 0 ).ipAddress )
         utilities.assertEquals( \
             expect=main.TRUE,
             actual=result2,
@@ -336,7 +338,7 @@
             main.exit()
 
         main.step( "Check whether all flow status are ADDED" )
-        flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+        flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
                                      main.FALSE,
                                      kwargs={'isPENDING':False},
                                      attempts=10 )
@@ -388,7 +390,7 @@
             main.exit()
 
         main.step( "Check whether all flow status are ADDED" )
-        flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+        flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
                                      main.FALSE,
                                      kwargs={'isPENDING':False},
                                      attempts=10 )
@@ -425,7 +427,7 @@
         utilities.assertEquals( expect=main.TRUE, actual=result1,
                                 onpass="Starting switch succeeded!",
                                 onfail="Starting switch failed!" )
-        result2 = main.Mininet.assignSwController( "sw11", main.ONOSip[ 0 ] )
+        result2 = main.Mininet.assignSwController( "sw11", main.Cluster.active( 0 ).ipAddress )
         utilities.assertEquals( expect=main.TRUE, actual=result2,
                                 onpass="Connect switch to ONOS succeeded!",
                                 onfail="Connect switch to ONOS failed!" )
@@ -444,7 +446,7 @@
             main.exit()
 
         main.step( "Check whether all flow status are ADDED" )
-        flowCheck = utilities.retry( main.ONOScli1.checkFlowsState,
+        flowCheck = utilities.retry( main.Cluster.active( 0 ).CLI.checkFlowsState,
                                      main.FALSE,
                                      kwargs={'isPENDING':False},
                                      attempts=10 )
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
index 9f2ed34..680f6bc 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/USECASE_SdnipFunction.topo
@@ -1,47 +1,32 @@
 <TOPOLOGY>
     <COMPONENT>
 
-        <ONOSbench>
-            <host>127.0.0.1</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>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOSbench>
-
-        <ONOScli1>
-            <host>127.0.0.1</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> 1 </nodes>  # number of nodes in the cluster
             </COMPONENTS>
-        </ONOScli1>
-
-        <ONOS1>
-            <host>OC1</host>
-            <user>sdn</user>
-            <password>rocks</password>
-            <type>OnosDriver</type>
-            <connect_order>3</connect_order>
-            <COMPONENTS>
-                <prompt></prompt>
-            </COMPONENTS>
-        </ONOS1>
+        </ONOScell>
 
         <QuaggaCliSpeaker1>
             <host>127.0.0.1</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>QuaggaCliDriver</type>
-            <connect_order>4</connect_order>
+            <connect_order>2</connect_order>
             <COMPONENTS>
                 <prompt></prompt>
             </COMPONENTS>
@@ -52,7 +37,7 @@
             <user>sdn</user>
             <password>rocks</password>
             <type>MininetCliDriver</type>
-            <connect_order>5</connect_order>
+            <connect_order>3</connect_order>
             <COMPONENTS>
                 <home>~/Mininet/mininet/custom/</home>
                 <prompt></prompt>
diff --git a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
index b62780a..85b732d 100644
--- a/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
+++ b/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/Functions.py
@@ -27,10 +27,10 @@
     main.log.info( routeNumExpected )
     main.log.info( "Route number from ONOS CLI:" )
 
-    routeNumActual = main.ONOScli1.ipv4RouteNumber()
+    routeNumActual = main.Cluster.active( 0 ).CLI.ipv4RouteNumber()
     if routeNumActual != routeNumExpected:
         time.sleep( wait )
-        routeNumActual = main.ONOScli1.ipv4RouteNumber()
+        routeNumActual = main.Cluster.active( 0 ).CLI.ipv4RouteNumber()
     main.log.info( routeNumActual )
     utilities.assertEquals( \
         expect = routeNumExpected, actual = routeNumActual,
@@ -41,8 +41,8 @@
     import time
     main.step( "Check M2S intents installed" )
     wait = int( main.params['timers']['PathAvailable'] )
-    jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
-                                       TYPE = "multiPointToSinglePoint" )
+    jsonResult = main.Cluster.active( 0 ).CLI.intents( jsonFormat = True, summary = True,
+                                                       TYPE = "multiPointToSinglePoint" )
     try:
         intentNumActual = jsonResult['installed']
     except TypeError as e:
@@ -50,8 +50,8 @@
         main.log.error( e )
     if intentNumActual != intentNumExpected:
         time.sleep( wait )
-        jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
-                                           TYPE = "multiPointToSinglePoint" )
+        jsonResult = main.Cluster.active( 0 ).CLI.intents( jsonFormat = True, summary = True,
+                                                           TYPE = "multiPointToSinglePoint" )
         try:
             intentNumActual = jsonResult['installed']
         except TypeError as e:
@@ -68,8 +68,8 @@
     import time
     main.step( "Check P2P intents installed" )
     wait = int( main.params['timers']['PathAvailable'] )
-    jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
-                                       TYPE = "pointToPoint" )
+    jsonResult = main.Cluster.active( 0 ).CLI.intents( jsonFormat = True, summary = True,
+                                                       TYPE = "pointToPoint" )
     try:
         intentNumActual = jsonResult['installed']
     except TypeError as e:
@@ -78,8 +78,8 @@
 
     if intentNumActual != intentNumExpected:
         time.sleep( wait )
-        jsonResult = main.ONOScli1.intents( jsonFormat = True, summary = True,
-                                           TYPE = "pointToPoint" )
+        jsonResult = main.Cluster.active( 0 ).CLI.intents( jsonFormat = True, summary = True,
+                                                           TYPE = "pointToPoint" )
         try:
             intentNumActual = jsonResult['installed']
         except TypeError as e: