Update checkIntentState function in onosclidriver
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index b7e96a1..d3ca4dd 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -98,10 +98,18 @@
 
     def startNet( self, topoFile='', args='', mnCmd='', timeout=120 ):
         """
-        Starts Mininet accepts a topology(.py) file and/or an optional
-        argument ,to start the mininet, as a parameter.
-        Returns main.TRUE if the mininet starts successfully and
-                main.FALSE otherwise
+        Description:
+            Starts Mininet accepts a topology(.py) file and/or an optional
+            argument, to start the mininet, as a parameter.
+            Can also send regular mininet command to load up desired topology.
+            Eg. Pass in a string 'sudo mn --topo=tree,3,3' to mnCmd
+        Options:
+            topoFile = file path for topology file (.py)
+            args = extra option added when starting the topology from the file
+            mnCmd = Mininet command use to start topology
+        Returns:
+                main.TRUE if the mininet starts successfully, main.FALSE
+                otherwise
         """
         if self.handle:
             # make sure old networks are cleaned up
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 1d57271..a0ed6e4 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1734,47 +1734,60 @@
             main.cleanup()
             main.exit()
 
-    def checkIntentState( self, intentsId, expectedState = 'INSTALLED' ):
+    def checkIntentState( self, intentsId, expectedState='INSTALLED' ):
         """
         Description:
             Check intents state
         Required:
             intentsId - List of intents ID to be checked
         Optional:
-            expectedState - Check this expected state of each intents state
-                            in the list. Defaults to INSTALLED
+            expectedState - Check the expected state(s) of each intents
+                            state in the list.
+                            *NOTE: You can pass in a list of expected state,
+                            Eg: expectedState = [ 'INSTALLED' , 'INSTALLING' ]
         Return:
-            Returns main.TRUE only if all intent are the same as expectedState,
-            , otherwise,returns main.FALSE.
+            Returns main.TRUE only if all intent are the same as expected states
+            , otherwise, returns main.FALSE.
         """
         try:
             # Generating a dictionary: intent id as a key and state as value
+            returnValue = main.TRUE
             intentsDict = self.getIntentState( intentsId )
+
             #print "len of intentsDict ", str( len( intentsDict ) )
             if len( intentsId ) != len( intentsDict ):
                 main.log.info( self.name + "There is something wrong " +
                                "getting intents state" )
                 return main.FALSE
-            returnValue = main.TRUE
-            for intents in intentsDict:
-                if intents.get( 'state' ) != expectedState:
-                    if intents.get( 'state' ) == "INSTALLING":
+
+            if isinstance( expectedState, types.StringType ):
+                for intents in intentsDict:
+                    if intents.get( 'state' ) != expectedState:
                         main.log.debug( self.name + " : Intent ID - " +
                                         intents.get( 'id' ) +
-                                        " is in INSTALLING state" )
-                        returnValue = main.TRUE
-                    else:
-                        main.log.info( self.name + " : Intent ID - " +
-                                       intents.get( 'id' ) +
-                                       " actual state = " +
-                                       intents.get( 'state' )
-                                       + " does not equal expected state = "
-                                       + expectedState )
+                                        " actual state = " +
+                                        intents.get( 'state' )
+                                        + " does not equal expected state = "
+                                        + expectedState )
                         returnValue = main.FALSE
+
+            elif isinstance( expectedState, types.ListType ):
+                for intents in intentsDict:
+                    if not any( state == intents.get( 'state' ) for state in
+                                expectedState ):
+                        main.log.debug( self.name + " : Intent ID - " +
+                                        intents.get( 'id' ) +
+                                        " actual state = " +
+                                        intents.get( 'state' ) +
+                                        " does not equal expected states = "
+                                        + str( expectedState ) )
+                        returnValue = main.FALSE
+
             if returnValue == main.TRUE:
                 main.log.info( self.name + ": All " +
                                str( len( intentsDict ) ) +
-                               " intents are in " + expectedState + " state")
+                               " intents are in " + str( expectedState ) +
+                               " state" )
             return returnValue
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
diff --git a/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
index 3ceb24b..75e586f 100644
--- a/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
+++ b/TestON/tests/FuncIntent/Dependency/FuncIntentFunction.py
@@ -1008,19 +1008,39 @@
     return statusResult
 
 def checkIntentState( main, intentsId ):
+    """
+        This function will check intent state to make sure all the intents
+        are in INSTALLED state
+    """
 
     intentResult = main.TRUE
     results = []
 
     main.log.info( itemName + ": Checking intents state" )
+    # First check of intents
     for i in range( main.numCtrls ):
-        intentResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
-        results.append( intentResult )
+        tempResult = main.CLIs[ i ].checkIntentState( intentsId=intentsId )
+        results.append( tempResult )
+
+    expectedState = [ 'INSTALLED', 'INSTALLING' ]
 
     if all( result == main.TRUE for result in results ):
         main.log.info( itemName + ": Intents are installed correctly" )
     else:
-        main.log.error( itemName + ": Intents are NOT installed correctly" )
+        # Wait for at least 5 second before checking the intents again
+        time.sleep( 5 )
+        results = []
+        # Second check of intents since some of the intents may be in
+        # INSTALLING state, they should be in INSTALLED at this time
+        for i in range( main.numCtrls ):
+            tempResult = main.CLIs[ i ].checkIntentState(
+                                                        intentsId=intentsId )
+            results.append( tempResult )
+        if all( result == main.TRUE for result in results ):
+            main.log.info( itemName + ": Intents are installed correctly" )
+        else:
+            main.log.error( itemName + ": Intents are NOT installed correctly" )
+            intentResult = main.FALSE
 
     return intentResult
 
diff --git a/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py b/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
index 121a6dc..d4d3392 100644
--- a/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
+++ b/TestON/tests/FuncTopo/Dependency/FuncTopoFunction.py
@@ -48,6 +48,9 @@
     testTopoResult = startResult and topoObjectResult and \
                      compareTopoResult and getHostsResult
 
+    # Restart ONOS to clear hosts test new mininet topology
+    restartResult = restartONOS( main )
+
     return testTopoResult
 
 def startNewTopology( main, topoFile='', args='', mnCmd='', clean=True ):
@@ -250,3 +253,51 @@
     print main.hostsData
 
     return getDataResult
+
+def restartONOS( main ):
+    """
+    Description:
+        Stop and start ONOS that clears hosts,devices etc. in order to test
+        new mininet topology
+    Return:
+        Retruns main.TRUE for a successful restart, main.FALSE otherwise.
+    """
+    stopResult = []
+    startResult = []
+    restartResult = main.TRUE
+
+    main.log.info( main.topoName + ": Stopping ONOS cluster" )
+    for node in main.nodes:
+        startResult.append( main.ONOSbench.onosStop( nodeIp=node.ip_address ) )
+
+    if all( result == main.TRUE for result in stopResult ):
+        main.log.info( main.topoName + ": Successfully stopped ONOS cluster" )
+    else:
+        restartResult = main.FALSE
+        main.log.error( main.topoName + ": Failed to stop ONOS cluster" )
+
+    time.sleep( 15 )
+
+    main.log.info( main.topoName + ": Starting ONOS cluster" )
+    for node in main.nodes:
+        startResult.append( main.ONOSbench.onosStart( nodeIp=node.ip_address ) )
+
+    if all( result == main.TRUE for result in startResult ):
+        main.log.info( main.topoName + ": Successfully start ONOS cluster" )
+    else:
+        restartResult = main.FALSE
+        main.log.error( main.topoName + ": Failed to start ONOS cluster" )
+
+    # Start ONOS CLIs again
+    main.log.info( main.topoName + ": Starting ONOS CLI" )
+    cliResult = main.TRUE
+    for i in range( main.numCtrls ):
+        cliResult = cliResult and \
+                    main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
+
+    time.sleep( 15 )
+
+    return restartResult
+
+
+
diff --git a/TestON/tests/FuncTopo/FuncTopo.py b/TestON/tests/FuncTopo/FuncTopo.py
index eefdb39..829c582 100644
--- a/TestON/tests/FuncTopo/FuncTopo.py
+++ b/TestON/tests/FuncTopo/FuncTopo.py
@@ -178,7 +178,7 @@
         cliResult = main.TRUE
         for i in range( main.numCtrls ):
             cliResult = cliResult and \
-                        main.CLIs[i].startOnosCli( main.ONOSip[ i ] )
+                        main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] )
         stepResult = cliResult
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
@@ -201,13 +201,27 @@
             Test topology discovery
         """
         main.case( "Topology discovery test" )
+
+        main.topoName = "TREE3-3"
+        stepResult = main.TRUE
+        main.step( "Tree 3-3 topology" )
+        mnCmd = "mn --topo=tree,3,3 --controller=remote,ip=$OC1 --mac"
+        stepResult = main.wrapper.testTopology( main,
+                                                mnCmd=mnCmd,
+                                                clean=False )
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=stepResult,
+                                 onpass="Tree 3-3 topology successful",
+                                 onfail="Tree 3-3 topology failed" )
+
         main.step( "Torus 5-5 topology" )
         main.topoName = "TORUS5-5"
         mnCmd = "mn --topo=torus,5,5 --controller=remote,ip=$OC1 --mac"
         stepResult = main.wrapper.testTopology( main,
                                                 mnCmd=mnCmd,
-                                                clean=False)
+                                                clean=True )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=stepResult,
                                  onpass="Torus 5-5 topology successful",
                                  onfail="Torus 5-5 topology failed" )
+