Skip to content

Commit 00a2dbd

Browse files
committed
Allow rebooting slaves.
(cherry picked from commit 9aaad3c) Signed-off-by: Reynold Xin <rxin@apache.org>
1 parent da33acb commit 00a2dbd

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ec2/spark_ec2.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class UsageError(Exception):
5252
def parse_args():
5353
parser = OptionParser(
5454
usage="spark-ec2 [options] <action> <cluster_name>"
55-
+ "\n\n<action> can be: launch, destroy, login, stop, start, get-master",
55+
+ "\n\n<action> can be: launch, destroy, login, stop, start, get-master, reboot-slaves",
5656
add_help_option=False)
5757
parser.add_option(
5858
"-h", "--help", action="help",
@@ -950,6 +950,20 @@ def real_main():
950950
subprocess.check_call(
951951
ssh_command(opts) + proxy_opt + ['-t', '-t', "%s@%s" % (opts.user, master)])
952952

953+
elif action == "reboot-slaves":
954+
response = raw_input(
955+
"Are you sure you want to reboot the cluster " +
956+
cluster_name + " slaves?\n" +
957+
"Reboot cluster slaves " + cluster_name + " (y/N): ")
958+
if response == "y":
959+
(master_nodes, slave_nodes) = get_existing_cluster(
960+
conn, opts, cluster_name, die_on_error=False)
961+
print "Rebooting slaves..."
962+
for inst in slave_nodes:
963+
if inst.state not in ["shutting-down", "terminated"]:
964+
print "Rebooting " + inst.id
965+
inst.reboot()
966+
953967
elif action == "get-master":
954968
(master_nodes, slave_nodes) = get_existing_cluster(conn, opts, cluster_name)
955969
print master_nodes[0].public_dns_name

0 commit comments

Comments
 (0)