Improve MaxIntents Tests
    - Add two functions on driver, getTotalIntentsNum and getTotalFlowsNum
    - Fixed currIntents and currFlows is 0 after tests
    - Fixed the bug of writing database

Change-Id: I6e0d40be89234edbb8c41d68587ab0c059b2d47e
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 002fc17..ebe600e 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1992,9 +1992,9 @@
             # get total and installed number, see if they are match
             allState = response.get( 'all' )
             if allState.get('total') == allState.get('installed'):
-                main.log.info( 'successful verified Intents' )
+                main.log.info( 'Total Intents: {}   Installed Intents: {}'.format( allState.get('total'), allState.get('installed') ) )
                 return main.TRUE
-            main.log.info( 'Verified Intents failed Excepte intetnes: {} installed intents: {}'.format(allState.get('total'), allState.get('installed')))
+            main.log.info( 'Verified Intents failed Excepte intetnes: {} installed intents: {}'.format( allState.get('total'), allState.get('installed') ) )
             return main.FALSE
 
         except TypeError:
@@ -2147,6 +2147,60 @@
             main.cleanup()
             main.exit()
 
+    def getTotalFlowsNum( self ):
+        """
+        Description:
+            Get the total number of flows, include every states.
+        Return:
+            The number of flows
+        """
+        try:
+            cmd = "summary -j"
+            response = self.sendline( cmd )
+            if response == None:
+                return  -1
+            response = json.loads( response )
+            return int( response.get("flows") )
+        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 getTotalIntentsNum( self ):
+        """
+        Description:
+            Get the total number of intents, include every states.
+        Return:
+            The number of intents
+        """
+        try:
+            cmd = "summary -j"
+            response = self.sendline( cmd )
+            if response == None:
+                return  -1
+            response = json.loads( response )
+            return int( response.get("intents") )
+        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 intentsEventsMetrics( self, jsonFormat=True ):
         """
         Description:Returns topology metrics
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
index 4c92d74..b4c5ac3 100644
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
@@ -169,6 +169,10 @@
             temp += "'" + nic + "',"
             temp += str(main.numCtrls) + ","
             temp += "'" + node + "1" + "'"
+            temp += ",0"
+            temp += ",0"
+            temp += ",0"
+            temp += ",0"
             dbFile.write(temp)
 
     def CASE2( self, main ):
@@ -454,11 +458,15 @@
                                  actual = intentVerify,
                                  onpass = "Successfully pushed and verified intents",
                                  onfail = "Failed to push and verify intents" )
+        currIntents = main.ONOScli1.getTotalIntentsNum()
+        currFlows = main.ONOScli1.getTotalFlowsNum()
 
         main.log.info("Writing results to DB file")
         with open(main.dbFileName, "a") as dbFile:
             temp = "," + str(currIntents)
             temp += "," + str(currFlows)
+            temp += ",0"
+            temp += ",0\n"
             dbFile.write(temp)
 
         if main.switchType == "of:":