def create(app_options, argv): """\ Create a new cluster. Usage: gilliam [options] create Options: --region REGION What EC2 region to use [default: eu-west-1] -k KEY, --key-pair KEY What key-pair to use -i PATH, --identity PATH SSH key identity Environment variables: AWS_EC2_SSH_KEY_FILE Same as --identity PATH. """ cluster_name = app_options.get('--cluster') or 'gilliam' options = docopt(create.__doc__, argv=argv) opts = ec2.Options( region=options['--region'], key_pair=options['--key-pair'], ssh_key_file=options.get('--identity', os.getenv( 'AWS_EC2_SSH_KEY_FILE')) ) conn = ec2.connect(opts) cluster = ec2.Cluster.create(conn, opts, cluster_name) cluster.setup(conn) cluster.scale(conn, 1)
def scale(app_options, argv): """\ Scale the number of executors for a cluster. Usage: gilliam [options] scale <COUNT> Options: --region REGION What EC2 region to use [default: eu-west-1] """ cluster_name = app_options.get('--cluster') or 'gilliam' options = docopt(scale.__doc__, argv=argv) opts = ec2.Options( region=options['--region'], ) conn = ec2.connect(opts) cluster = ec2.Cluster.get(conn, opts, cluster_name) if cluster is None: sys.exit("cannot find a %s cluster" % (cluster_name,)) cluster.scale(conn, int(options['<COUNT>']))
def destroy(app_options, argv): """\ Create a new cluster. Usage: gilliam [options] destroy Options: --region REGION What EC2 region to use [default: eu-west-1] Environment variables: AWS_EC2_SSH_KEY_FILE Same as --identity PATH. """ cluster_name = app_options.get('--cluster') or 'gilliam' options = docopt(destroy.__doc__, argv=argv) opts = ec2.Options( region=options['--region'], ) conn = ec2.connect(opts) cluster = ec2.Cluster.get(conn, opts, cluster_name) if cluster is None: sys.exit("Cannot find a Gilliam cluster") cluster.destroy(conn)