Migrate Get Requests invocations(libraries)
[integration/test.git] / tools / clustering / cluster-deployer / restart.py
1 #!/usr/bin/env 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(
16     "--rootdir",
17     default="/root",
18     help="the root directory on the remote host where the distribution is deployed",
19     required=True,
20 )
21 parser.add_argument(
22     "--hosts",
23     default="",
24     help="a comma separated list of host names or ip addresses",
25     required=True,
26 )
27 parser.add_argument(
28     "--clean",
29     action="store_true",
30     default=False,
31     help="clean the persistent data for the current deployment",
32 )
33 parser.add_argument(
34     "--user", default="root", help="the SSH username for the remote host(s)"
35 )
36 parser.add_argument(
37     "--password", default="Ecp123", help="the SSH password for the remote host(s)"
38 )
39 args = parser.parse_args()
40
41
42 def main():
43     hosts = args.hosts.split(",")
44     for x in range(0, len(hosts)):
45         # Connect to the remote host and start doing operations
46         remote = RemoteHost(hosts[x], args.user, args.password, args.rootdir)
47         remote.kill_controller()
48         if args.clean:
49             remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/*journal")
50             remote.exec_cmd("rm -rf " + args.rootdir + "/deploy/current/odl/snapshots")
51         remote.start_controller(args.rootdir + "/deploy/current")
52
53
54 main()