reconnect onos cli when disconnected
Change-Id: I6ecd3180ab8f9a19e5a2f07cb062e8c8fadc4248
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 9b0a375..47c7d66 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -224,6 +224,7 @@
Note: karafTimeout is left as str so that this could be read
and passed to startOnosCli from PARAMS file as str.
"""
+ self.onosIp = ONOSIp
try:
self.handle.sendline( "" )
x = self.handle.expect( [
@@ -303,9 +304,19 @@
self.handle.sendline( "" )
i = self.handle.expect( [ "onos>", "\$", pexpect.TIMEOUT ] )
if i == 1:
- main.log.error( self.name + ": onos cli session closed." )
- main.cleanup()
- main.exit()
+ main.log.error( self.name + ": onos cli session closed. ")
+ if self.onosIp:
+ main.log.warn( "Trying to reconnect " + self.onosIp )
+ reconnectResult = self.startOnosCli( self.onosIp )
+ if reconnectResult:
+ main.log.info( self.name + ": onos cli session reconnected." )
+ else:
+ main.log.error( self.name + ": reconnection failed." )
+ main.cleanup()
+ main.exit()
+ else:
+ main.cleanup()
+ main.exit()
if i == 2:
self.handle.sendline( "" )
self.handle.expect( "onos>" )