Merge pull request #140 from opennetworkinglab/OnosCHO

Added new getOnosIPfromCell to onosdriver and updated CHO scripts
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 7256294..fca8f22 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1624,7 +1624,7 @@
             main.cleanup()
             main.exit()
 
-    def purgeIntents( self ):
+    def purgeWithdrawnIntents( self ):
         """
         Purges all WITHDRAWN Intents
         """
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 7abbcc6..5de8e2e 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -2258,3 +2258,46 @@
         if len(exceptions) > 0: 
             main.log.info(msg3)
         main.log.info("===============================================================\n")
+
+    def getOnosIPfromCell(self):
+        '''
+            Returns the ONOS node names and their IP addresses as defined in the cell and applied to shell environment
+			Example output return: [['OC1', '10.128.40.41'], ['OC2', '10.128.40.42'], ['OC3', '10.128.40.43']]
+        ''' 
+        import re
+        try:
+            # Clean handle by sending empty and expecting $
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            self.handle.sendline( "cell" )
+            self.handle.expect( "\$" )
+            handleBefore = self.handle.before
+            handleAfter = self.handle.after
+            # Get the rest of the handle
+            self.handle.sendline( "" )
+            self.handle.expect( "\$" )
+            handleMore = self.handle.before
+            ipList = []
+            cellOutput = handleBefore + handleAfter + handleMore
+            cellOutput = cellOutput.replace("\r\r","")
+            cellOutput = cellOutput.splitlines()
+            for i in range( len(cellOutput) ):
+                if( re.match( "OC", cellOutput[i] ) ):
+                    if( re.match( "OCI", cellOutput[i] ) or re.match( "OCN", cellOutput[i] ) ):
+                        continue
+                    else:
+                        onosIP = cellOutput[i].split("=")
+						# below step could be changed to return only IP if node name is not needed.
+                        ipList.append(onosIP)
+            return ipList
+        except pexpect.ExceptionPexpect as e:
+            main.log.error( self.name + ": Pexpect exception found of type " +
+                            str( type( e ) ) )
+            main.log.error ( e.get_trace() )
+            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()
diff --git a/TestON/tests/OnosCHO/OnosCHO.params b/TestON/tests/OnosCHO/OnosCHO.params
index 398ee96..6240fdb 100644
--- a/TestON/tests/OnosCHO/OnosCHO.params
+++ b/TestON/tests/OnosCHO/OnosCHO.params
@@ -18,7 +18,7 @@
     </ENV>
     <GIT>         
         #autoPull 'on' or 'off'
-        <autoPull>off</autoPull>
+        <autoPull>on</autoPull>
         <branch>master</branch>
     </GIT>
     <TOPO1>
diff --git a/TestON/tests/OnosCHO/OnosCHO.py b/TestON/tests/OnosCHO/OnosCHO.py
index 1bd0696..8c58d04 100644
--- a/TestON/tests/OnosCHO/OnosCHO.py
+++ b/TestON/tests/OnosCHO/OnosCHO.py
@@ -494,10 +494,9 @@
                     ( numOnosDevices , numOnosLinks ) )
             main.log.info("Topology does not match, exiting CHO test...")
             topoResult = main.FALSE
-            
-            #time.sleep(300)
-            #main.cleanup()
-            #main.exit()
+            # It's better exit here from running the test            
+            main.cleanup()
+            main.exit()
 
         # just returning TRUE for now as this one just collects data
         case3Result = topoResult
@@ -2257,18 +2256,7 @@
                     main.log.info("Time for removing host intents: %2f seconds" %(time2-time1))
                     time.sleep(10)
                     main.log.info("Purging WITHDRAWN Intents")
-                    purgeResult  = main.TRUE
-                    for i in range( int( main.numCtrls) ):
-                        t = main.Thread( target=main.CLIs[i].purgeIntents,
-                             threadID=main.threadID,
-                             name="purgeIntents",
-                             args=[ ] )
-                        pool.append(t)
-                        t.start()
-                        main.threadID = main.threadID + 1
-                    for t in pool:
-                        t.join()
-                        purgeResult = purgeResult and t.result        
+                    purgeResult  = main.ONOScli2.purgeIntents()
                 else:
                     time.sleep(10)
                     if len( main.ONOScli1.intents()):