from boto_util import BotoUtil import argparse if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('region', help='Region') parser.add_argument('instance_name', help='InstanceName') args = parser.parse_args() BUtil = BotoUtil(args.region) dns_tup, cluster_name = BUtil.get_ec2_instances(args.instance_name) for dns in dns_tup: print dns print "Cluster name: {}".format(cluster_name) BUtil.write_dns(cluster_name, dns_tup)
#!/usr/local/bin/python import argparse import json from boto_util import BotoUtil, InstanceConfig if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('template_path', help='path to instance template') args = parser.parse_args() with open(args.template_path) as json_file: params = json.load(json_file) BUtil = BotoUtil(params['region']) IConf = InstanceConfig(params) if IConf.is_valid(): BUtil.launch_instances(IConf)
import argparse from boto_util import BotoUtil, remove_cluster_info, write_dns, copy_pem if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('region', help='Region') parser.add_argument('cluster_name', help='Cluster Name') parser.add_argument('new_tag_name', help='New Cluster Name') args = parser.parse_args() BUtil = BotoUtil(args.region) BUtil.retag_cluster(args.cluster_name, args.new_tag_name) cluster_info = BUtil.fetch_instances(args.new_tag_name) if cluster_info is not None: dns_tup = cluster_info[0] cluster_name = cluster_info[1] key_name = cluster_info[2] for idx, dns in enumerate(dns_tup): if idx == 0: print "{} NODE: Hostname:{}, Public DNS:{}".format( "MASTER", dns[0], dns[1]) else: print "{} NODE: Hostname:{}, Public DNS:{}".format( "WORKER", dns[0], dns[1]) print "Cluster name: {}".format(cluster_name)
parser.add_argument('purchase_type', help='define on demand or spot') parser.add_argument('region', help='region for instances to spin up') parser.add_argument('az', help='avaliability zone for the instance to spin up') parser.add_argument('instance_name', help='instance name to tag each instance') parser.add_argument('pem_key_name', help='region specific pem key name to associate instances with') parser.add_argument('num_instances', help='number of instances to spin up') parser.add_argument('security_groups', help='array of security group names') parser.add_argument('instance_type', help='type of instances to spin up') parser.add_argument('volume_size', help='size in GB of default EBS volume') parser.add_argument('price', help='bid price of spot instance') parser.add_argument('image', help='region specific ami to use') args = parser.parse_args() BUtil = BotoUtil(args.region) IConf = InstanceConfig(purchase_type=args.purchase_type, region=args.region, az=args.az, image=args.image, price=args.price, num_instances=args.num_instances, key_name=args.pem_key_name, security_groups=[args.security_groups], instance_type=args.instance_type, tag_name=args.instance_name, vol_size=args.volume_size) BUtil.create_ec2(IConf) dns_tup, cluster_name = BUtil.get_ec2_instances(args.instance_name)
import argparse from boto_util import BotoUtil, remove_cluster_info, write_dns, copy_pem if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("region", help="Region") parser.add_argument("cluster_name", help="Cluster Name") parser.add_argument("new_tag_name", help="New Cluster Name") args = parser.parse_args() BUtil = BotoUtil(args.region) BUtil.retag_cluster(args.cluster_name, args.new_tag_name) cluster_info = BUtil.fetch_instances(args.new_tag_name) if cluster_info is not None: dns_tup = cluster_info[0] cluster_name = cluster_info[1] key_name = cluster_info[2] for idx, dns in enumerate(dns_tup): if idx == 0: print "{} NODE: Hostname:{}, Public DNS:{}".format("MASTER", dns[0], dns[1]) else: print "{} NODE: Hostname:{}, Public DNS:{}".format("WORKER", dns[0], dns[1]) print "Cluster name: {}".format(cluster_name) write_dns(cluster_name, dns_tup)
#!/usr/local/bin/python import argparse from boto_util import BotoUtil if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('region', help='region to search for instances') parser.add_argument('public_dns', nargs='+', help='list of all the public DNSs') args = parser.parse_args() BUtil = BotoUtil(args.region) public_dns_list = args.public_dns ips = [".".join(dns.split('.')[0].split('-')[1:]) for dns in public_dns_list] BUtil.terminate_cluster(ips)
#!/usr/local/bin/python import argparse from boto_util import BotoUtil if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('region', help='region to search for instances') parser.add_argument('public_dns', nargs='+', help='list of all the public DNSs') args = parser.parse_args() BUtil = BotoUtil(args.region) public_dns_list = args.public_dns ips = [ ".".join(dns.split('.')[0].split('-')[1:]) for dns in public_dns_list ] BUtil.terminate_cluster(ips)
import argparse from boto_util import BotoUtil, remove_cluster_info, write_dns, copy_pem if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('region', help='Region') parser.add_argument('cluster_name', help='Cluster Name') args = parser.parse_args() BUtil = BotoUtil(args.region) remove_cluster_info(args.cluster_name) cluster_info = BUtil.fetch_instances(args.cluster_name) if cluster_info is not None: dns_tup = cluster_info[0] cluster_name = cluster_info[1] key_name = cluster_info[2] for idx, dns in enumerate(dns_tup): if idx == 0: print "{} NODE: Hostname:{}, Public DNS:{}".format("MASTER", dns[0], dns[1]) else: print "{} NODE: Hostname:{}, Public DNS:{}".format("WORKER", dns[0], dns[1]) print "Cluster name: {}".format(cluster_name) write_dns(cluster_name, dns_tup) copy_pem(cluster_name, key_name) else:
#!/usr/local/bin/python import argparse import json from boto_util import BotoUtil, InstanceConfig if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("template_path", help="path to instance template") args = parser.parse_args() with open(args.template_path) as json_file: params = json.load(json_file) BUtil = BotoUtil(params["region"]) IConf = InstanceConfig(params) if IConf.is_valid(): BUtil.launch_instances(IConf)