Refactor IntentRerouteLatency test
    - Refactor IntentRerouteLatency and IntentRerouteLatWithFOBJ test
    - Using driver function to handle ONOS
    - Improve algorithm, fix a calculation bug

Change-Id: I994295e0be361f99899c223cf90db70dd22cfb8c
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 61c38b7..7e31e82 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -849,7 +849,7 @@
             main.cleanup()
             main.exit()
 
-    def links( self, jsonFormat=True ):
+    def links( self, jsonFormat=True, timeout=30 ):
         """
         Lists all core links
         Optional argument:
@@ -859,7 +859,7 @@
             cmdStr = "links"
             if jsonFormat:
                 cmdStr += " -j"
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert "Command not found:" not in handle, handle
             return handle
         except AssertionError:
@@ -1866,7 +1866,7 @@
             main.cleanup()
             main.exit()
 
-    def removeAllIntents( self, purge=False, sync=False, app='org.onosproject.cli' ):
+    def removeAllIntents( self, purge=False, sync=False, app='org.onosproject.cli', timeout=30 ):
         """
         Description:
             Remove all the intents
@@ -1885,7 +1885,7 @@
                 cmdStr += " -s"
 
             cmdStr += " " + app
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert "Command not found:" not in handle, handle
             if re.search( "Error", handle ):
                 main.log.error( "Error in removing intent" )
@@ -4377,7 +4377,7 @@
             main.cleanup()
             main.exit()
 
-    def summary( self, jsonFormat=True ):
+    def summary( self, jsonFormat=True, timeout=30 ):
         """
         Description: Execute summary command in onos
         Returns: json object ( summary -j ), returns main.FALSE if there is
@@ -4388,7 +4388,7 @@
             cmdStr = "summary"
             if jsonFormat:
                 cmdStr += " -j"
-            handle = self.sendline( cmdStr )
+            handle = self.sendline( cmdStr, timeout=timeout )
             assert handle is not None, "Error in sendline"
             assert "Command not found:" not in handle, handle
             assert "Error:" not in handle, handle
@@ -4749,7 +4749,7 @@
             main.cleanup()
             main.exit()
 
-    def link( self, begin, end, state ):
+    def link( self, begin, end, state, timeout=30, showResponse=True ):
         '''
         Description:
             Bring link down or up in the null-provider.
@@ -4762,7 +4762,7 @@
         '''
         try:
             cmd =  "null-link null:{} null:{} {}".format( begin, end, state )
-            response = self.sendline( cmd, showResponse=True )
+            response = self.sendline( cmd, showResponse=showResponse, timeout=timeout )
             assert response is not None, "Error in sendline"
             assert "Command not found:" not in response, response
             if "Error" in response or "Failure" in response:
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 1abf258..7f59be8 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1664,6 +1664,8 @@
                 "stop/waiting",
                 "Not Running ...",
                 pexpect.TIMEOUT ], timeout=120 )
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
 
             if i == 0 or i == 1:
                 main.log.info( "ONOS is running" )