Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index cf9029c..5580cc1 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -151,7 +151,17 @@
 
             #Wait for onos start (-w) and enter onos cli
             self.handle.sendline("onos -w "+str(ONOS_ip))
-            self.handle.expect("onos>", timeout = 60)
+            i = self.handle.expect([
+                    "onos>",
+                    pexpect.TIMEOUT],timeout=60)
+
+            if i == 0:
+                main.log.info(str(ONOS_ip)+" CLI Started successfully")
+                return main.TRUE
+            else:
+                main.log.error("Connection to CLI "+\
+                        str(ONOS_ip)+" timeout")
+                return main.FALSE
 
         except pexpect.EOF:
             main.log.error(self.name + ": EOF exception found")
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index f22f064..b94001b 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -411,7 +411,9 @@
         temp_directory = "/tmp/"
         #Create the cell file in the directory for writing (w+)
         cell_file = open(temp_directory+file_name , 'w+')
-        
+       
+        comment = ""
+        comment_string = "#"+ comment
         #Feature string is hardcoded environment variables
         #That you may wish to use by default on startup.
         #Note that you  may not want certain features listed
@@ -430,24 +432,24 @@
         #Omit last element of list to format for NIC
         temp_list = temp_list[:-1]
         #Structure the nic string ip
-        nic_addr = ".".join(temp_list) + ".*\n"
+        nic_addr = ".".join(temp_list) + ".*"
         onos_nic_string = "export ONOS_NIC="+nic_addr
 
         try:
             #Start writing to file
-            cell_file.write(core_feature_string + "\n")
-            cell_file.write(onos_nic_string) 
-            cell_file.write(mn_string +"'"+ mn_ip_addrs +"'"+ "\n") 
+            cell_file.write(onos_nic_string + "\n") 
 
             for arg in onos_ip_addrs:
                 #For each argument in onos_ip_addrs, write to file
                 #Output should look like the following:
-                #   export OC1='10.128.20.11'
-                #   export OC2='10.128.20.12'
+                #   export OC1="10.128.20.11"
+                #   export OC2="10.128.20.12"
                 cell_file.write(onos_string + str(temp_count) +
-                        "=" + "'" + arg + "'" + "\n" )
+                        "=" + "\"" + arg + "\"" + "\n" )
                 temp_count = temp_count + 1
             
+            cell_file.write(mn_string +"\""+ mn_ip_addrs +"\""+ "\n") 
+            cell_file.write(core_feature_string + "\n")
             cell_file.close()
 
             #We use os.system to send the command to TestON cluster
@@ -996,7 +998,7 @@
         self.handle.expect("\$")
         self.handle.sendline("")
         self.handle.sendline("tshark -i "+str(interface)+
-                " -t e | grep --line-buffered \""+str(grep)+"\" > "+directory+" &")
+                " -t e | grep --line-buffered \""+str(grep)+"\" >"+directory+" &")
         self.handle.sendline("\r")
         self.handle.expect("Capturing on")
         self.handle.sendline("\r")
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index 463ec02..8f6d644 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -27,7 +27,7 @@
     </MN>
 
     <BENCH>
-        <ip>10.128.20.10</ip>
+        <ip>10.128.174.10</ip>
     </BENCH>
 
     <TEST>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index eb49669..b722974 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -17,6 +17,8 @@
         '''
         ONOS startup sequence
         '''
+        import time
+    
         cell_name = main.params['ENV']['cellName']
 
         git_pull = main.params['GIT']['autoPull']
@@ -57,20 +59,31 @@
         package_result = main.ONOSbench.onos_package()
 
         main.step("Installing ONOS package")
-        install_result = main.ONOSbench.onos_install()
+        install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
+        install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
+        install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
 
-        main.step("Starting ONOS service")
-        start_result = main.ONOSbench.onos_start(ONOS1_ip)
+        #NOTE: This step may be unnecessary
+        #main.step("Starting ONOS service")
+        #start_result = main.ONOSbench.onos_start(ONOS1_ip)
 
         main.step("Set cell for ONOS cli env")
         main.ONOS1cli.set_cell(cell_name)
         main.ONOS2cli.set_cell(cell_name)
         main.ONOS3cli.set_cell(cell_name)
 
+        time.sleep(10)
+
         main.step("Start onos cli")
-        main.ONOS1cli.start_onos_cli(ONOS1_ip)
-        main.ONOS2cli.start_onos_cli(ONOS2_ip)
-        main.ONOS3cli.start_onos_cli(ONOS3_ip)
+        cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+        cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
+        cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
+
+        if not (cli1 and cli2 and cli3):
+            main.log.info("Attempting to start cli again")
+            cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
+            cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
+            cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
 
         main.step("Enable metrics feature")
         main.ONOS1cli.feature_install("onos-app-metrics-topology")
@@ -81,7 +94,8 @@
                 actual= cell_file_result and cell_apply_result and\
                         verify_cell_result and checkout_result and\
                         pull_result and mvn_result and\
-                        install_result and start_result,
+                        install1_result and install2_result and\
+                        install3_result,
                 onpass="ONOS started successfully",
                 onfail="Failed to start ONOS")
 
@@ -206,11 +220,6 @@
             json_str_1 = main.ONOS1cli.topology_events_metrics()
             json_str_2 = main.ONOS2cli.topology_events_metrics()
             json_str_3 = main.ONOS3cli.topology_events_metrics()
-    
-            #TESTING:
-            main.log.info(json_str_1)
-            main.log.info(json_str_2)
-            main.log.info(json_str_3)
 
             json_obj_1 = json.loads(json_str_1)
             json_obj_2 = json.loads(json_str_2)
@@ -222,9 +231,16 @@
 
             #TODO:
             #Parse json object for timestamp
-            topo_timestamp_1 = 0
-            topo_timestamp_2 = 0
-            topo_timestamp_3 = 0
+            topo_timestamp_1 = \
+                    json_obj_1['lastTopologyEventTimestamp']['value'] 
+            topo_timestamp_2 = \
+                    json_obj_2['lastTopologyEventTimestamp']['value'] 
+            topo_timestamp_3 = \
+                    json_obj_3['lastTopologyEventTimestamp']['value'] 
+
+            main.log.info(topo_timestamp_1)
+            main.log.info(topo_timestamp_2)
+            main.log.info(topo_timestamp_3)
 
             #ONOS processing latency
             delta_of_1 = int(topo_timestamp_1) - int(t0_ofp)
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.topo b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
index 9ff8136..9e928a6 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.topo
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.topo
@@ -2,7 +2,7 @@
     <COMPONENT>
         
         <ONOSbench>
-            <host>10.128.20.10</host>
+            <host>10.128.174.10</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosDriver</type>
@@ -11,7 +11,7 @@
         </ONOSbench>
 
         <ONOS1cli>
-            <host>10.128.20.10</host>
+            <host>10.128.174.10</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
@@ -20,7 +20,7 @@
         </ONOS1cli>
 
         <ONOS2cli>
-            <host>10.128.20.10</host>
+            <host>10.128.174.10</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>
@@ -29,7 +29,7 @@
         </ONOS2cli>
         
         <ONOS3cli>
-            <host>10.128.20.10</host>
+            <host>10.128.174.10</host>
             <user>admin</user>
             <password>onos_test</password>
             <type>OnosCliDriver</type>