Added getOnosIPfromCell() to onosdriver
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 7abbcc6..9ea663c 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 me 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()