Skip to content

Commit a2052a4

Browse files
nchammasrxin
authored andcommitted
[SPARK-2065] give launched instances names
This update resolves [SPARK-2065](https://issues.apache.org/jira/browse/SPARK-2065). It 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. Author: Nicholas Chammas <[email protected]> Author: nchammas <[email protected]> Closes #1043 from nchammas/master and squashes the following commits: 69f6e22 [Nicholas Chammas] PEP8 fixes 2627247 [Nicholas Chammas] broke up lines before they hit 100 chars 6544b7e [Nicholas Chammas] [SPARK-2065] give launched instances names 69da6cf [nchammas] Merge pull request #1 from apache/master
1 parent c48b622 commit a2052a4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ec2/spark_ec2.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ def get_spark_shark_version(opts):
200200
sys.exit(1)
201201
return (version, spark_shark_map[version])
202202

203+
203204
# Attempt to resolve an appropriate AMI given the architecture and
204205
# region of the request.
205206
def get_spark_ami(opts):
@@ -418,6 +419,16 @@ def launch_cluster(conn, opts, cluster_name):
418419
master_nodes = master_res.instances
419420
print "Launched master in %s, regid = %s" % (zone, master_res.id)
420421

422+
# Give the instances descriptive names
423+
for master in master_nodes:
424+
master.add_tag(
425+
key='Name',
426+
value='spark-{cn}-master-{iid}'.format(cn=cluster_name, iid=master.id))
427+
for slave in slave_nodes:
428+
slave.add_tag(
429+
key='Name',
430+
value='spark-{cn}-slave-{iid}'.format(cn=cluster_name, iid=slave.id))
431+
421432
# Return all the instances
422433
return (master_nodes, slave_nodes)
423434

0 commit comments

Comments
 (0)