Added testcase to balance ownership of switches to FUNCintent and
FUNCintentRest
Added new cli-driver function to remove all intents

Change-Id: If5ae4760f25fbc3334dc9dab8d0c5faf8defd088
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index fad5ce5..ba2b37c 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1744,6 +1744,48 @@
             main.cleanup()
             main.exit()
 
+    def removeAllIntents( self, purge=False, sync=False, app='org.onosproject.cli' ):
+        """
+        Description:
+            Remove all the intents
+        Optional args:-
+            -s or --sync: Waits for the removal before returning
+            -p or --purge: Purge the intent from the store after removal
+        Returns:
+            Returns main.TRUE if all intents are removed, otherwise returns
+            main.FALSE; Returns None for exception
+        """
+        try:
+            cmdStr = "remove-intent"
+            if purge:
+                cmdStr += " -p"
+            if sync:
+                cmdStr += " -s"
+
+            cmdStr += " " + app
+            handle = self.sendline( cmdStr )
+            assert "Command not found:" not in handle, handle
+            if re.search( "Error", handle ):
+                main.log.error( "Error in removing intent" )
+                return main.FALSE
+            else:
+                return main.TRUE
+        except AssertionError:
+            main.log.exception( "" )
+            return None
+        except TypeError:
+            main.log.exception( self.name + ": Object not as expected" )
+            return None
+        except pexpect.EOF:
+            main.log.error( self.name + ": EOF exception found" )
+            main.log.error( self.name + ":    " + self.handle.before )
+            main.cleanup()
+            main.exit()
+        except Exception:
+            main.log.exception( self.name + ": Uncaught exception!" )
+            main.cleanup()
+            main.exit()
+
     def purgeWithdrawnIntents( self ):
         """
         Purges all WITHDRAWN Intents
diff --git a/TestON/tests/FUNCintent/FUNCintent.params b/TestON/tests/FUNCintent/FUNCintent.params
index d19a45d..26ee48d 100644
--- a/TestON/tests/FUNCintent/FUNCintent.params
+++ b/TestON/tests/FUNCintent/FUNCintent.params
@@ -9,8 +9,9 @@
     # 12 - Assign switch to controller
     # 13 - Create Scapy Components
     # 14 - Discover hosts with Mininet Pingall
-    $ 15 - Discover hosts with Scapy arping ( only discovers scapy hosts )
-    # 16 - Stop Mininet
+    # 15 - Discover hosts with Scapy arping ( only discovers scapy hosts )
+    # 16 - Balance ownership of switches
+    # 17 - Stop Mininet
     # 1000 - Test host intents
     # 2000 - Test point intents
     # 3000 - Test single to multi point intents
@@ -18,7 +19,7 @@
     # 5000 - Test host mobility
     # 6000 - Test Multi Point intent End Point Failure
 
-    <testcases>1,[2,10,12,13,15,1000,2000,3000,4000,5000,6000,16]*2,[2,11,12,13,15,1000,2000,3000,4000,5000,6000,16]*2</testcases>
+    <testcases>1,[2,10,12,13,15,16,1000,2000,3000,4000,5000,6000,17]*2,[2,11,12,13,15,16,1000,2000,3000,4000,5000,6000,17]*2</testcases>
 
     <SCALE>
         <size>1,3,1,3</size>
@@ -66,4 +67,4 @@
         <dstPort>5001</dstPort>
     </SDNIP>
 
-</PARAMS>
+</PARAMS>
\ No newline at end of file
diff --git a/TestON/tests/FUNCintent/FUNCintent.py b/TestON/tests/FUNCintent/FUNCintent.py
index e1660f1..ba4e8dd 100644
--- a/TestON/tests/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNCintent/FUNCintent.py
@@ -140,8 +140,6 @@
         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" )
@@ -157,6 +155,7 @@
                                  actual=stepResult,
                                  onpass="Successfully uninstalled ONOS package",
                                  onfail="Failed to uninstall ONOS package" )
+        time.sleep( main.startUpSleep )
 
         for i in range( main.maxNodes ):
             main.ONOSbench.onosDie( main.ONOSip[ i ] )
@@ -540,6 +539,21 @@
 
     def CASE16( self, main ):
         """
+            Balance Masters
+        """
+        main.case( "Balance mastership of switches" )
+        main.step( "Balancing mastership of switches" )
+
+        balanceResult = main.FALSE
+        balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully balanced mastership of switches",
+                                 onfail="Failed to balance mastership of switches" )
+
+    def CASE17( self, main ):
+        """
             Stop mininet and remove scapy host
         """
         main.log.report( "Stop Mininet and Scapy" )
@@ -625,6 +639,7 @@
         host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
         host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='IPV4',
                                               onosNode='0',
@@ -640,6 +655,8 @@
                                               sw1='s5',
                                               sw2='s2',
                                               expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -651,6 +668,7 @@
         host1 = { "name":"h3","id":"00:00:00:00:00:03/-1" }
         host2 = { "name":"h11","id":"00:00:00:00:00:0B/-1 "}
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='DUALSTACK',
                                               onosNode='0',
@@ -678,6 +696,7 @@
         host1 = { "name":"h1" }
         host2 = { "name":"h11" }
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='DUALSTACK2',
                                               onosNode='0',
@@ -694,6 +713,8 @@
                                               sw1='s5',
                                               sw2='s2',
                                               expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -705,6 +726,7 @@
         host1 = { "name":"h1" }
         host2 = { "name":"h3" }
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='1HOP',
                                               onosNode='0',
@@ -721,6 +743,8 @@
                                               sw1='s5',
                                               sw2='s2',
                                               expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -732,6 +756,7 @@
         host1 = { "name":"h4","id":"00:00:00:00:00:04/100" }
         host2 = { "name":"h12","id":"00:00:00:00:00:0C/100 "}
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='VLAN1',
                                               onosNode='0',
@@ -748,6 +773,8 @@
                                               sw1='s5',
                                               sw2='s2',
                                               expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -759,6 +786,7 @@
         host1 = { "name":"h13" }
         host2 = { "name":"h20" }
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='VLAN2',
                                               onosNode='0',
@@ -775,6 +803,8 @@
                                               sw1='s5',
                                               sw2='s2',
                                               expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -844,6 +874,8 @@
         recipients = [
             { "name":"h9","device":"of:0000000000000006/1" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="NOOPTION",
@@ -860,6 +892,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -875,6 +909,8 @@
         recipients = [
             { "name":"h9","device":"of:0000000000000006/1","mac":"00:00:00:00:00:09" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="IPV4",
@@ -892,6 +928,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -905,6 +943,8 @@
         recipients = [
             { "name":"h9","device":"of:0000000000000006/1" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="IPV4_2",
@@ -922,6 +962,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -942,7 +984,8 @@
         # Uneccessary, not including this in the selectors
         tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ]
         tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ]
-
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="SDNIP-ICMP",
@@ -963,6 +1006,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1008,6 +1053,8 @@
         recipients = [
             { "name":"h11","device":"of:0000000000000006/3","mac":"00:00:00:00:00:0B" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="DUALSTACK1",
@@ -1025,6 +1072,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1039,6 +1088,8 @@
         recipients = [
             { "name":"h21","device":"of:0000000000000007/5","mac":"00:00:00:00:00:15" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="DUALSTACK1",
@@ -1070,6 +1121,8 @@
         recipients = [
             { "name":"h3","device":"of:0000000000000005/3","mac":"00:00:00:00:00:03" }
         ]
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installPointIntent(
                                        main,
                                        name="1HOP IPV4",
@@ -1087,6 +1140,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1143,6 +1198,7 @@
         badSenders=[ { "name":"h9" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h17" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="NOOPTION",
@@ -1163,6 +1219,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1181,6 +1239,7 @@
         badSenders=[ { "name":"h9" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h17" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4",
@@ -1202,6 +1261,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1220,6 +1281,7 @@
         badSenders=[ { "name":"h9" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h17" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4_2",
@@ -1241,6 +1303,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1259,6 +1323,7 @@
         badSenders=[ { "name":"h13" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h21" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4",
@@ -1280,6 +1345,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1336,6 +1403,7 @@
         badSenders=[ { "name":"h17" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h9" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="NOOPTION",
@@ -1356,6 +1424,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1374,6 +1444,7 @@
         badSenders=[ { "name":"h17" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h9" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="IPV4",
@@ -1395,6 +1466,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1413,6 +1486,7 @@
         badSenders=[ { "name":"h17" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h9" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="IPV4_2",
@@ -1434,6 +1508,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1452,6 +1528,7 @@
         badSenders=[ { "name":"h12" } ]  # Senders that are not in the intent
         badRecipients=[ { "name":"h20" } ]  # Recipients that are not in the intent
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="VLAN",
@@ -1473,6 +1550,8 @@
                                          sw1="s5",
                                          sw2="s2",
                                          expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1523,7 +1602,8 @@
         main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n"
         host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
         host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
-
+        testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installHostIntent( main,
                                               name='IPV4 Mobility IPV4',
                                               onosNode='0',
@@ -1539,6 +1619,8 @@
                                                   sw1="s6",
                                                   sw2="s2",
                                                   expectedLink=18 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1573,6 +1655,7 @@
         ]
         isolatedRecipients = []
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="NOOPTION",
@@ -1597,6 +1680,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1618,6 +1703,7 @@
         ]
         isolatedRecipients = []
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="IPV4",
@@ -1643,6 +1729,9 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
                                  onpass=main.assertReturnString,
@@ -1663,6 +1752,7 @@
         ]
         isolatedRecipients = []
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="IPV4_2",
@@ -1688,6 +1778,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1709,6 +1801,7 @@
         ]
         isolatedRecipients = []
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installMultiToSingleIntent(
                                          main,
                                          name="VLAN",
@@ -1734,6 +1827,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1755,6 +1850,7 @@
             { "name":"h24" }
         ]
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="NOOPTION",
@@ -1779,6 +1875,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1800,6 +1898,7 @@
             { "name":"h24" }
         ]
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4",
@@ -1825,6 +1924,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1846,6 +1947,7 @@
             { "name":"h24" }
         ]
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4_2",
@@ -1871,6 +1973,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
@@ -1892,6 +1996,7 @@
             { "name":"h20" }
         ]
         testResult = main.FALSE
+        installResult = main.FALSE
         installResult = main.intentFunction.installSingleToMultiIntent(
                                          main,
                                          name="IPV4",
@@ -1917,6 +2022,8 @@
                                          sw5="s3",
                                          expectedLink1=16,
                                          expectedLink2=14 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=testResult,
diff --git a/TestON/tests/FUNCintentRest/FUNCintentRest.params b/TestON/tests/FUNCintentRest/FUNCintentRest.params
index 94339b4..07a5cff 100644
--- a/TestON/tests/FUNCintentRest/FUNCintentRest.params
+++ b/TestON/tests/FUNCintentRest/FUNCintentRest.params
@@ -10,14 +10,15 @@
     # 13 - Create Scapy Components
     # 14 - Discover all hosts and Create a dictionary of hosts information
     # 15 - Discover hosts with scapy arping ( only discovers scapy hosts )
-    # 16 - Stop Mininet
+    # 16 - Balance ownership of switches
+    # 17 - Stop Mininet
     # 1000 - Test host intents
     # 2000 - Test point intents
     # 3000 - Test single to multi point intents
     # 4000 - Test multi to single point intents
     # 5000 - Test host mobility
 
-    <testcases>1,[2,10,12,13,15,1000,2000,5000,16]*2,[2,11,12,13,15,1000,2000,5000,16]*2</testcases>
+    <testcases>1,[2,10,12,13,15,16,1000,2000,5000,17]*2,[2,11,12,13,15,16,1000,2000,5000,17]*2</testcases>
 
     <SCALE>
         <size>1,3,1,3</size>
diff --git a/TestON/tests/FUNCintentRest/FUNCintentRest.py b/TestON/tests/FUNCintentRest/FUNCintentRest.py
index ede3459..1a32bc1 100644
--- a/TestON/tests/FUNCintentRest/FUNCintentRest.py
+++ b/TestON/tests/FUNCintentRest/FUNCintentRest.py
@@ -167,6 +167,7 @@
                        " before initiating environment setup" )
 
         time.sleep( main.startUpSleep )
+
         main.step( "Uninstalling ONOS package" )
         onosUninstallResult = main.TRUE
         for ip in main.ONOSip:
@@ -178,6 +179,8 @@
                                  onpass="Successfully uninstalled ONOS package",
                                  onfail="Failed to uninstall ONOS package" )
 
+        time.sleep( main.startUpSleep )
+
         for i in range( main.maxNodes ):
             main.ONOSbench.onosDie( main.ONOSip[ i ] )
 
@@ -653,6 +656,21 @@
 
     def CASE16( self, main ):
         """
+            Balance Masters
+        """
+        main.case( "Balance mastership of switches" )
+        main.step( "Balancing mastership of switches" )
+
+        balanceResult = main.FALSE
+        balanceResult = utilities.retry( f=main.CLIs2[ 0 ].balanceMasters, retValue=main.FALSE, args=[] )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Successfully balanced mastership of switches",
+                                 onfail="Failed to balance mastership of switches" )
+
+    def CASE17( self, main ):
+        """
             Stop mininet and remove scapy hosts
         """
         main.log.report( "Stop Mininet and Scapy" )