Skip to content

Commit 6544b7e

Browse files
committed
[SPARK-2065] give launched instances names
This update gives launched EC2 instances descriptive names by using instance tags. Launched instances now show up in the EC2 console with these names. I used `format()` with named parameters, which I believe is the recommended practice for string formatting in Python, but which doesn’t seem to be used elsewhere in the script.
1 parent 69da6cf commit 6544b7e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ec2/spark_ec2.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ def launch_cluster(conn, opts, cluster_name):
418418
master_nodes = master_res.instances
419419
print "Launched master in %s, regid = %s" % (zone, master_res.id)
420420

421+
# Give the instances descriptive names
422+
for master in master_nodes:
423+
master.add_tag(key='Name', value='spark-{cn}-master-{iid}'.format(cn=cluster_name, iid=master.id))
424+
for slave in slave_nodes:
425+
slave.add_tag(key='Name', value='spark-{cn}-slave-{iid}'.format(cn=cluster_name, iid=slave.id))
426+
421427
# Return all the instances
422428
return (master_nodes, slave_nodes)
423429

0 commit comments

Comments
 (0)