jtriley / StarCluster

StarCluster is an open source cluster-computing toolkit for Amazon's Elastic Compute Cloud (EC2).
http://star.mit.edu/cluster
GNU Lesser General Public License v3.0
582 stars 308 forks source link

[Request] Get hostname from starcluster #299

Open syoyo opened 11 years ago

syoyo commented 11 years ago

I am trying to combine starcluster + rsync.

rsync needs remote hostname, but it seems starcluster doesn't have handy command to get hostname only from running cluster.

Currently, I am using following shell script to extract master's hostname from listclusters command, but this is not a robust way.

$ cat grab_hostname.sh
#!/bin/sh

starcluster -r us-west-2 listclusters | grep master | sed -e 's/.*master.*\(ec2-.*\)/\1/g' > hostname
# Starcluster info
$ starcluster -r us-west-2 listclusters
---------------------------------------------------------
oregon_devcluster (security group: @sc-oregon_devcluster)
---------------------------------------------------------
Launch time: 2013-10-01 20:54:55
Uptime: 0 days, 01:00:41
Zone: us-west-2b
Keypair: lte-render-ec2
EBS volumes: N/A
Spot requests: 1 active
Cluster nodes:
     master running i-a983579e ec2-MASTER.us-west-2.compute.amazonaws.com
    node001 running i-63574e57 ec2-NODE001.us-west-2.compute.amazonaws.com (spot sir-XXXXXXX)
Total nodes: 2

# Get hostname
$ ./grab_hostname.sh
$ cat hostname
ec2-MASTER.us-west-2.compute.amazonaws.com

# Do rsync
$ rsync -avz -e "ssh -i ~/.ssh/id_rsa" sgeadmin@`cat hostname`:~/ ./

I'd like to request startcluster will have sub command something like this

$ starcluster listclusters -hostname master
ec2-MASTER.us-west-2.compute.amazonaws.com
ajmazurie commented 10 years ago

syoyo, I wrote a small shell script that does exactly what you describe; it is available at https://gist.github.com/ajmazurie/5212be25bdd1cead8f9b

Let me know if you find it useful. Best, Aurelien