Refactored SCPFmaxIntents
    - Use Retry to set up apps, more stability
    - Fixed driver function, getTotalFlowsNum to get total ADDED flows
    - Only wirte the Total ADDED flows to database (we write all flows
      include PENDING_ADD before)

Change-Id: I1c05f27dcf621c14143a406d71b66adc6409f87e
diff --git a/.gitignore b/.gitignore
index 5b80f94..ae9e171 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 .*.sw?
 TestON/logs/*
 *.pyc
+.DS_Store
+._.DS_Store
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 16f2208..f77ad8f 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -2197,20 +2197,19 @@
             main.cleanup()
             main.exit()
 
-    def getTotalFlowsNum( self ):
+    def getTotalFlowsNum( self, timeout=60 ):
         """
         Description:
-            Get the total number of flows, include every states.
+            Get the number of ADDED flows.
         Return:
-            The number of flows
+            The number of ADDED flows
         """
         try:
-            cmd = "summary -j"
-            response = self.sendline( cmd )
+            cmd = "flows -s|grep ADDED|wc -l"
+            response = self.sendline( cmd, timeout=timeout )
             if response == None:
                 return  -1
-            response = json.loads( response )
-            return int( response.get("flows") )
+            return int( response )
         except TypeError:
             main.log.exception( self.name + ": Object not as expected" )
             return None
diff --git a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
index b4c5ac3..c543d8c 100644
--- a/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
+++ b/TestON/tests/SCPFmaxIntents/SCPFmaxIntents.py
@@ -214,10 +214,13 @@
             Setting up null-provider
         """
         import json
-
         # Activate apps
         main.step("Activating null-provider")
-        appStatus = main.CLIs[0].activateApp('org.onosproject.null')
+        appStatus = utilities.retry( main.CLIs[0].activateApp,
+                                     main.FALSE,
+                                     ['org.onosproject.null'],
+                                     sleep=main.verifySleep,
+                                     attempts=main.verifyAttempts )
         utilities.assert_equals( expect=main.TRUE,
                                  actual=appStatus,
                                  onpass="Successfully activated null-provider",
@@ -225,12 +228,26 @@
 
         # Setup the null-provider
         main.step("Configuring null-provider")
-        cfgStatus = main.ONOSbench.onosCfgSet( main.ONOSip[0],
-                'org.onosproject.provider.nil.NullProviders', 'deviceCount 3' )
-        cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0],
-                'org.onosproject.provider.nil.NullProviders', 'topoShape reroute' )
-        cfgStatus = cfgStatus and main.ONOSbench.onosCfgSet( main.ONOSip[0],
-                'org.onosproject.provider.nil.NullProviders', 'enabled true' )
+        cfgStatus = utilities.retry( main.ONOSbench.onosCfgSet,
+                                     main.FALSE,
+                                     [ main.ONOSip[0],
+                                      'org.onosproject.provider.nil.NullProviders', 'deviceCount 3'],
+                                     sleep=main.verifySleep,
+                                     attempts = main.verifyAttempts )
+        cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
+                                                   main.FALSE,
+                                                   [ main.ONOSip[0],
+                                                     'org.onosproject.provider.nil.NullProviders', 'topoShape reroute'],
+                                                   sleep=main.verifySleep,
+                                                   attempts = main.verifyAttempts )
+
+        cfgStatus = cfgStatus and utilities.retry( main.ONOSbench.onosCfgSet,
+                                                   main.FALSE,
+                                                   [ main.ONOSip[0],
+                                                     'org.onosproject.provider.nil.NullProviders', 'enabled true'],
+                                                   sleep=main.verifySleep,
+                                                   attempts = main.verifyAttempts )
+
 
         utilities.assert_equals( expect=main.TRUE,
                                  actual=cfgStatus,
@@ -459,7 +476,9 @@
                                  onpass = "Successfully pushed and verified intents",
                                  onfail = "Failed to push and verify intents" )
         currIntents = main.ONOScli1.getTotalIntentsNum()
-        currFlows = main.ONOScli1.getTotalFlowsNum()
+        currFlows = main.ONOScli1.getTotalFlowsNum( timeout = main.timeout )
+        main.log.info( "Total Intents Installed: {}".format( currIntents ) )
+        main.log.info( "Total Flows ADDED: {}".format( currFlows ) )
 
         main.log.info("Writing results to DB file")
         with open(main.dbFileName, "a") as dbFile: