updates
diff --git a/TestON/tests/IntentRerouteLat/IntentRerouteLat.params b/TestON/tests/IntentRerouteLat/IntentRerouteLat.params
index 27af1f2..99a03c0 100644
--- a/TestON/tests/IntentRerouteLat/IntentRerouteLat.params
+++ b/TestON/tests/IntentRerouteLat/IntentRerouteLat.params
@@ -1,27 +1,28 @@
 <PARAMS>
 
-    <testcases>1,2</testcases>
+    <testcases>1,2,1,2,1,2,1,2</testcases>
 
-    <SCALE>1</SCALE>
+    <SCALE>1,3,5,7</SCALE>
     <availableNodes>7</availableNodes>
  
     <ENV>
         <cellName>intentRerouteCell</cellName>
-        <cellApps>null,intentperf,metrics</cellApps>
-        <scale1switches>8</scale1switches>
-        <scale3switches>2,2,3</scale3switches>
-        <scale5switches>2,2,1,1,1</scale5switches>
-        <scale7switches>1,1,1,1,1,1,1</scale7switches>
-    
+        <cellApps>drivers,null,intentperf,metrics</cellApps>
     </ENV>
 
     <TEST>
         <skipCleanInstall>yes</skipCleanInstall>
-        <warmUp>1</warmUp>
+        <warmUp>2</warmUp>
         <sampleSize>2</sampleSize>                     
         <wait></wait>
-        <intents>1,10</intents>                       #list format, will be split on ','
-        <debug>True</debug>                          
+        <intents>1000</intents>                       #list format, will be split on ','
+        <debug>True</debug>     
+       
+        <s1>1,1,1,1,1,1,1,1</s1>
+        <s3>2,2,1,1,3,3,3,1</s3>
+        <s5>2,2,1,1,3,4,5,3</s5>
+        <s7>2,3,1,1,5,6,7,4</s7>
+
     </TEST>
 
     <METRICS>
diff --git a/TestON/tests/IntentRerouteLat/IntentRerouteLat.py b/TestON/tests/IntentRerouteLat/IntentRerouteLat.py
index 84d5c03..f824a5c 100644
--- a/TestON/tests/IntentRerouteLat/IntentRerouteLat.py
+++ b/TestON/tests/IntentRerouteLat/IntentRerouteLat.py
@@ -79,9 +79,6 @@
         clusterCount = int(scale[0])
         scale.remove(scale[0])       
        
-        switchParams = ("scale" + str(clusterCount) + "switches")
-        switchCount = (main.params[ 'ENV' ][ switchParams ]).split(",")
-
         #kill off all onos processes 
         main.log.step("Safety check, killing all ONOS processes")
         main.log.step("before initiating enviornment setup")
@@ -105,15 +102,6 @@
         main.step( "Set Cell" )
         main.ONOSbench.setCell(cellName)
         
-        if clusterCount == 1:
-            temp = "one"
-        if clusterCount == 3:
-            temp = "three"
-        if clusterCount == 5:
-            temp = "five"
-        if clusterCount == 7:
-            temp = "seven"
-
         main.step( "Creating ONOS package" )
         packageResult = main.ONOSbench.onosPackage()  
 
@@ -134,7 +122,10 @@
             if not isup:
                 main.log.report( "ONOS " + str(node) + " didn't start!" )
         main.log.info("Startup sequence complete")
-     
+    
+        deviceMastership = (main.params[ 'TEST' ][ "s" + str(clusterCount) ]).split(",")
+        print("Device mastership list: " + str(deviceMastership))
+
         main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders deviceCount 8 " """)
         main.ONOSbench.handle.expect(":~")
         print repr(main.ONOSbench.handle.before)
@@ -143,53 +134,49 @@
         main.ONOSbench.handle.expect(":~")
         print repr(main.ONOSbench.handle.before)
         time.sleep(3)
-        main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled true" """)
-        main.ONOSbench.handle.expect(":~")
-        print repr(main.ONOSbench.handle.before) 
 
-        while True: 
+        time.sleep(10)
+
+        once = True
+        for attempt in range(0,10): 
             main.ONOSbench.handle.sendline("onos $OC1 summary")
             main.ONOSbench.handle.expect(":~")
             x = main.ONOSbench.handle.before
-            if "devices=8" in x:
+            main.log.info("Initial setup. ONOS summary response: \n" + x + "\n")
+
+            if "devices=8" in x and "links=16," in x: 
                 break
-            else:   
+            else:                
+                if once == False:
+                    main.log.error("Null provider start failed, retrying..")
+                once = False
                 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled false" """)
                 main.ONOSbench.handle.expect(":~")
                 time.sleep(3)
                 main.ONOSbench.handle.sendline("""onos $OC1 "cfg set org.onosproject.provider.nil.NullProviders enabled true" """)
                 main.ONOSbench.handle.expect(":~")
-                main.log.error("Null provider start failed, retrying..") 
-                time.sleep(8)
+                time.sleep(8) 
 
-        main.ONOSbench.handle.sendline("""onos $OC1 "null-simulation start" """)
-        main.ONOSbench.handle.expect(":~")
-        print main.ONOSbench.handle.before
-        time.sleep(10)
-        main.ONOSbench.handle.sendline("""onos $OC1 "balance-masters" """)
-        main.ONOSbench.handle.expect(":~")
-        
-        temp = 1 
-        for node in range(1, clusterCount + 1): 
-            for switch in range (0, int(switchCount[node-1])): 
-                cmd = ("""onos $OC1 "device-role null:000000000000000""" + str(temp) + " " + ONOSIp[node] + """ master" """)
+        index = 1
+        for node in deviceMastership:
+            for attempt in range(0,10):
+                cmd = ( "onos $OC" + node + """ "device-role null:000000000000000""" + str(index) + " " + ONOSIp[int(node)]  + """ master" """)
+                main.log.info("assigning mastership of device " + str(index) + " to node " + node + ": \n " + cmd + "\n")
                 main.ONOSbench.handle.sendline(cmd)
-                main.log.info( cmd ) 
                 main.ONOSbench.handle.expect(":~")
-                temp += 1
+                time.sleep(4)
+                
+                cmd = ( "onos $OC" + node + " roles|grep 00000" + str(index)) 
+                main.log.info(cmd) 
+                main.ONOSbench.handle.sendline(cmd)
+                main.ONOSbench.handle.expect(":~")
+                check = main.ONOSbench.handle.before
+                main.log.info("CHECK:\n" + check)
+                if ("master=" + ONOSIp[int(node)]) in check:
+                    break
+            index += 1
 
 
-        #    cmd = ( """onos $OC1 "device-role null:0000000000000008 10.128.5.52 master" """)
-        #if clusterCount == 7: 
-        #    cmd = ( """onos $OC1 "device-role null:0000000000000008 10.128.5.53 master" """)
-            
-        #main.ONOSbench.handle.sendline(cmd)
-        #main.log.info( cmd )
-        #main.ONOSbench.handle.expect(":~")
-
-        #print "sleeping"
-        #time.sleep(120)
-
     def CASE2( self, main ):
          
         import time
@@ -226,7 +213,7 @@
             debug = False
 
         ingress = "null:0000000000000001"
-        egress = "null:0000000000000008"
+        egress = "null:0000000000000007"
 
         for intents in intentsList:
             main.log.report("Intent Batch size: " + str(intents) + "\n      ")
@@ -236,7 +223,7 @@
                 if run > warmUp:
                     main.log.info("Starting test iteration " + str(run-warmUp))
 
-                cmd = """onos $OC1 push-test-intents -i" """
+                cmd = """onos $OC1 "push-test-intents -i """
                 cmd += ingress + "/0 "
                 cmd += egress + "/0 "
                 cmd += str(intents) +""" 1" """
@@ -253,10 +240,10 @@
                     main.ONOSbench.handle.sendline("onos $OC1 summary")
                     main.ONOSbench.handle.expect(":~")
                     linkCheck = main.ONOSbench.handle.before
-                    if ("flows=16,") in linkCheck:
+                    if ("links=16,") in linkCheck and ("flows=" + str(intents*7) + ","):
                         break
                     if i == 39:
-                        main.log.error("Flow count incorrect, data invalid."+ linkCheck)
+                        main.log.error("Flow/link count incorrect, data invalid."+ linkCheck)
 
 
                 #collect timestamp from link cut
@@ -270,7 +257,8 @@
                     time.sleep(2)
                     main.ONOSbench.handle.expect(":~")
                     raw = main.ONOSbench.handle.before
-                    if "NullLinkProvider" in raw and "links=14" in raw:
+                    #if "NullLinkProvider" in raw and "links=14" in raw:
+                    if "links=14" in raw:
                         break
                     if i >= 9:
                         main.log.error("Expected output not being recieved... continuing")
@@ -292,22 +280,27 @@
                     main.ONOSbench.handle.sendline("onos $OC1 summary")
                     main.ONOSbench.handle.expect(":~")
                     linkCheck = main.ONOSbench.handle.before
-                    if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
+                    #if "links=" + str(7*intents)+ "," in linkCheck and ("flows=" + str(7*intents) + ",") in linkCheck:
+                    if "links=14," in linkCheck and ("flows=" + str(8*intents) + ",") in linkCheck:
                         break
                     if i == 39:
                         main.log.error("Link or flow count incorrect, data invalid." + linkCheck)
+                
+                time.sleep(5) #trying to avoid negative values 
 
                 #intents events metrics installed timestamp
                 IEMtimestamps = [0]*(clusterCount + 1)
                 installedTemp = [0]*(clusterCount + 1)
                 for node in range(1, clusterCount +1):
-                    cmd = "onos $OC" + str(node) + " intents-events-metrics|grep Timestamp"
+                    cmd = "onos $OC" + str(node) + """ "intents-events-metrics"|grep Timestamp """
                     raw = ""
-                    while "Timestamp" not in raw:
+                    while "epoch)" not in raw:
                         main.ONOSbench.handle.sendline(cmd)
                         main.ONOSbench.handle.expect(":~")
                         raw = main.ONOSbench.handle.before
 
+                    print(raw)
+
                     intentsTimestamps = {}
                     rawTimestamps = raw.splitlines()
                     for line in rawTimestamps:
@@ -398,13 +391,16 @@
             average = numpy.average(latTemp)
             stdDev = numpy.std(latTemp)
 
+            average = numpy.multiply(average, 1000)
+            stdDev = numpy.multiply(stdDev, 1000)
+
             main.log.report("Scale: " + str(clusterCount) + "  \tIntent batch: " + str(intents))
             main.log.report("Latency average:................" + str(average))
             main.log.report("Latency standard deviation:....." + str(stdDev))
             main.log.report("Mode of last node to respond:..." + str(nodeMode))
             main.log.report("________________________________________________________")
 
-            resultsDB = open("IntentRerouteLatDB", "w+")
+            resultsDB = open("IntentRerouteLatDB", "a")
             resultsDB.write("'" + commit + "',") 
             resultsDB.write(str(clusterCount) + ",")
             resultsDB.write(str(intents) + ",")