Skip to content

Commit

Permalink
Add scripts to print master hostnames and copy progress
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaram committed Aug 16, 2013
1 parent baaeeeb commit 6ac1cc4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions check-copy-progess.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# Usage
# check-copy-progress <private_key_path> <file-with-hostnames>

pssh -i -x "-i $1" -l root -h $2 '~/ephemeral-hdfs/bin/hadoop fs -dus /'
2 changes: 2 additions & 0 deletions get-masters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
PYTHONPATH="./third_party/boto-2.4.1.zip/boto-2.4.1:$PYTHONPATH" python get_masters.py $@
37 changes: 37 additions & 0 deletions get_masters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function
import json
import urllib2
import boto
from optparse import OptionParser
from boto import *

def is_active(instance):
return (instance.state in ['pending', 'running', 'stopping', 'stopped'])

def main():
parser = OptionParser(usage="get_masters [cluster_prefix]",
add_help_option=True)
(opts, args) = parser.parse_args()
if len(args) != 1:
get_cluster_masters()
else:
get_cluster_masters(args[0])

def get_cluster_masters(prefix=""):
conn = connect_ec2()
res = conn.get_all_instances()
# master reservations have only one node
masters = [i for i in res if len(i.instances) == 1]
master_instances = [m.instances[0] for m in masters if is_active(m.instances[0])]

name_host = [(m.tags['cluster'], m.public_dns_name) for m in master_instances]

for (name, host) in name_host:
if prefix in name:
print(name + " " + host)

if __name__ == "__main__":
main()

0 comments on commit 6ac1cc4

Please sign in to comment.