[ONOS-7756] Start/stop Atomix cluster as part of ONOS cluster setup
Change-Id: Ib2af5e14af9cc59ae9d9cc90b54a91db4914a3a4
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 89dc363..8890871 100755
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -2668,3 +2668,111 @@
except Exception:
main.log.exception( self.name + ": Uncaught exception!" )
main.cleanAndExit()
+
+ def atomixKill( self, nodeIp ):
+ """
+ Calls the command: 'atomix-kill [<node-ip>]'
+ Kills the Atomix instance running on the specified node
+ """
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( self.prompt )
+ self.handle.sendline( "atomix-kill " + str( nodeIp ) )
+ i = self.handle.expect( [
+ self.prompt,
+ "No\sroute\sto\shost",
+ "password:",
+ pexpect.TIMEOUT ], timeout=60 )
+
+ if i == 0:
+ main.log.info( "Atomix instance " + str( nodeIp ) + " was killed" )
+ return main.TRUE
+ elif i == 1:
+ main.log.info( "No route to host" )
+ return main.FALSE
+ elif i == 2:
+ main.log.info( "Passwordless login for host: " + str( nodeIp ) + " not configured" )
+ return main.FALSE
+ else:
+ main.log.info( "Atomix instance was not killed" )
+ return main.FALSE
+
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanAndExit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanAndExit()
+
+ def atomixUninstall( self, nodeIp="" ):
+ """
+ Calls the command: 'atomix-uninstall'
+ Uninstalls Atomix from the designated node, stopping if needed
+ """
+ try:
+ self.handle.sendline( "" )
+ self.handle.expect( self.prompt, timeout=180 )
+ self.handle.sendline( "atomix-uninstall " + str( nodeIp ) )
+ self.handle.expect( self.prompt, timeout=180 )
+ main.log.info( "Atomix " + nodeIp + " was uninstalled" )
+ # onos-uninstall command does not return any text
+ return main.TRUE
+ except pexpect.TIMEOUT:
+ main.log.exception( self.name + ": Timeout in atomixUninstall" )
+ self.handle.send( "\x03" ) # Control-C
+ self.handle.expect( self.prompt )
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanAndExit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanAndExit()
+
+ def atomixInstall( self, options="", node="" ):
+ """
+ Installs Atomix on the designated nodes.
+ Returns: main.TRUE on success and main.FALSE on failure
+ """
+ try:
+ if options:
+ self.handle.sendline( "atomix-install " + options + " " + node )
+ else:
+ self.handle.sendline( "atomix-install " + node )
+ self.handle.expect( "atomix-install " )
+ i = self.handle.expect( [ "Network\sis\sunreachable",
+ "is already installed",
+ "saved",
+ self.prompt,
+ pexpect.TIMEOUT ], timeout=180 )
+ if i == 0:
+ # can't reach ONOS node
+ main.log.warn( "Network is unreachable" )
+ self.handle.expect( self.prompt )
+ return main.FALSE
+ elif i == 1:
+ # same bits are already on Atomix node
+ main.log.info( "Atomix is already installed on " + node )
+ self.handle.expect( self.prompt )
+ return main.TRUE
+ elif i == 2 or i == 3:
+ main.log.info( "Atomix was installed on " + node )
+ self.handle.expect( self.prompt )
+ return main.TRUE
+ elif i == 4:
+ # timeout
+ main.log.info( "Installation of Atomix on " + node + " timed out" )
+ self.handle.expect( self.prompt )
+ main.log.warn( self.handle.before )
+ self.handle.send( "\x03" ) # Control-C
+ self.handle.expect( self.prompt )
+ return main.FALSE
+ except pexpect.EOF:
+ main.log.error( self.name + ": EOF exception found" )
+ main.log.error( self.name + ": " + self.handle.before )
+ main.cleanAndExit()
+ except Exception:
+ main.log.exception( self.name + ": Uncaught exception!" )
+ main.cleanAndExit()