BUG 2276 : Add a script to restart a cluster
[integration.git] / test / tools / cluster-deployer / restart.py
1 # #!/usr/local/bin/python
2
3 # This script restarts the cluster nodes. It can optionally cleanup the persistent data.
4 # --------------------------------------------------------------------------------------
5
6 # This script takes a list of hosts as parameter
7 #
8
9 # -------------------------------------------------------------------------------------------------------------
10
11 import argparse
12 from remote_host import RemoteHost
13
14 parser = argparse.ArgumentParser(description='Cluster Restart')
15 parser.add_argument("--rootdir", default="/root", help="the root directory on the remote host where the distribution is deployed", required=True)
16 parser.add_argument("--hosts", default="", help="a comma separated list of host names or ip addresses", required=True)
17 parser.add_argument("--clean", action="store_true", default=False, help="clean the persistent data for the current deployment")
18 parser.add_argument("--user", default="root", help="the SSH username for the remote host(s)")
19 parser.add_argument("--password", default="Ecp123", help="the SSH password for the remote host(s)")
20 args = parser.parse_args()
21
22
23 def main():
24     hosts = args.hosts.split(",")
25     for x in range(0, len(hosts)):
26         # Connect to the remote host and start doing operations
27         remote = RemoteHost(hosts[x], args.user, args.password, args.rootdir)
28         remote.kill_controller()
29         if(args.clean):
30             remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/journal")
31             remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/snapshots")
32         remote.start_controller(args.rootdir + "/deploy/current")
33
34 main()