示例#1
0
def start_instances(args):
    assert args.num_instances > 0
    ssh_keyname = get_ssh_keyname(args.ssh_keyname)
    open_public_port = args.open_public_port or ssh_keyname is None
    if ssh_keyname is None and not args.yes_all:
        response = raw_input(
            "You are launching instances without specifying an ssh key-pair name.\n"
            "You will not be able to log into the launched instances.\n"
            "You can specify a key-pair using the --ssh-keyname option.\n"
            "Do you want to continue without a keypair (Y/n)? "
            )
        if response not in ('Y', 'y'):
            return

    launcher = Launcher(region=get_region(args.ec2_region),
                        vpc_id=args.vpc_id,
                        subnet_id=args.subnet_id,
                        security_group_id=args.security_group_id,
                        instance_type=args.instance_type,
                        open_public_port=open_public_port)

    status_printer = StatusPrinter()
    print "Launching ufora manager instance:"
    manager = launcher.launch_manager(ssh_keyname,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    status_printer.done()

    print "Ufora manager instance started:\n"
    print_instance(manager, 'manager')
    print ""
    if not args.open_public_port:
        print "To tunnel Ufora's HTTP port (30000) over ssh, run the following command:"
        print "    ssh -i <ssh_key_file> -L 30000:localhost:30000 ubuntu@%s\n" % manager.ip_address

    workers = []
    if args.num_instances > 1:
        print "Launching worker instance(s):"
        workers = launcher.launch_workers(args.num_instances-1,
                                          ssh_keyname,
                                          manager.id,
                                          args.spot_price,
                                          callback=status_printer.on_status)
        status_printer.done()
        print "Worker instance(s) started:"

    for worker in workers:
        print_instance(worker, 'worker')

    print "Waiting for Ufora services:"
    if launcher.wait_for_services([manager] + workers, callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()
示例#2
0
def start_instances(args):
    assert args.num_instances > 0
    ssh_keyname = get_ssh_keyname(args.ssh_keyname)
    open_public_port = args.open_public_port or ssh_keyname is None
    if ssh_keyname is None and not args.yes_all:
        response = raw_input(
            "You are launching instances without specifying an ssh key-pair name.\n"
            "You will not be able to log into the launched instances.\n"
            "You can specify a key-pair using the --ssh-keyname option.\n"
            "Do you want to continue without a keypair (Y/n)? ")
        if response not in ('Y', 'y'):
            return

    launcher = Launcher(region=get_region(args.ec2_region),
                        vpc_id=args.vpc_id,
                        subnet_id=args.subnet_id,
                        security_group_id=args.security_group_id,
                        instance_type=args.instance_type,
                        open_public_port=open_public_port)

    status_printer = StatusPrinter()
    print "Launching ufora manager instance:"
    manager = launcher.launch_manager(ssh_keyname,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    status_printer.done()

    print "Ufora manager instance started:\n"
    print_instance(manager, 'manager')
    print ""
    if not args.open_public_port:
        print "To tunnel Ufora's HTTP port (30000) over ssh, run the following command:"
        print "    ssh -i <ssh_key_file> -L 30000:localhost:30000 ubuntu@%s\n" % manager.ip_address

    workers = []
    if args.num_instances > 1:
        print "Launching worker instance(s):"
        workers = launcher.launch_workers(args.num_instances - 1,
                                          ssh_keyname,
                                          manager.id,
                                          args.spot_price,
                                          callback=status_printer.on_status)
        status_printer.done()
        print "Worker instance(s) started:"

    for worker in workers:
        print_instance(worker, 'worker')

    print "Waiting for Ufora services:"
    if launcher.wait_for_services([manager] + workers,
                                  callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()
示例#3
0
def add_instances(args):
    launcher = Launcher(**launcher_args(args))
    manager = [
        i for i in running_or_pending_instances(launcher.get_reservations())
        if 'manager' in i.tags.get('Name', '')
    ]
    if len(manager) > 1:
        print "There is more than one Manager instance. Can't add workers.", \
            "Managers:"
        for m in manager:
            print_instance(m)
        return 1
    elif len(manager) == 0:
        print "No manager instances are running. Can't add workers."
        return 1

    if args.num_instances < 1:
        print "--num-instances must be greater or equal to 1."
        return 1

    manager = manager[0]
    launcher.vpc_id = manager.vpc_id
    launcher.subnet_id = manager.subnet_id
    launcher.instance_type = manager.instance_type
    launcher.security_group_id = manager.groups[0].id

    print "Launching worker instance(s):"
    status_printer = StatusPrinter()
    workers = launcher.launch_workers(args.num_instances,
                                      manager.key_name,
                                      manager.id,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    status_printer.done()

    print "Workers started:"
    for worker in workers:
        print_instance(worker, 'worker')

    print ""
    print "Waiting for services:"
    if launcher.wait_for_services(workers, callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()
示例#4
0
def add_instances(args):
    launcher = Launcher(**launcher_args(args))
    manager = [i for i in running_or_pending_instances(launcher.get_reservations())
               if 'manager' in i.tags.get('Name', '')]
    if len(manager) > 1:
        print "There is more than one Manager instance. Can't add workers.", \
            "Managers:"
        for m in manager:
            print_instance(m)
        return 1
    elif len(manager) == 0:
        print "No manager instances are running. Can't add workers."
        return 1

    if args.num_instances < 1:
        print "--num-instances must be greater or equal to 1."
        return 1

    manager = manager[0]
    launcher.vpc_id = manager.vpc_id
    launcher.subnet_id = manager.subnet_id
    launcher.instance_type = manager.instance_type
    launcher.security_group_id = manager.groups[0].id

    print "Launching worker instance(s):"
    status_printer = StatusPrinter()
    workers = launcher.launch_workers(args.num_instances,
                                      manager.key_name,
                                      manager.id,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    status_printer.done()

    print "Workers started:"
    for worker in workers:
        print_instance(worker, 'worker')

    print ""
    print "Waiting for services:"
    if launcher.wait_for_services(workers, callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()
示例#5
0
def start_instances(args):
    assert args.num_instances > 0
    ssh_keyname = get_ssh_keyname(args.ssh_keyname)
    open_public_port = args.open_public_port or ssh_keyname is None
    if ssh_keyname is None and not args.yes_all:
        response = raw_input(
            "You are launching instances without specifying an ssh key-pair name.\n"
            "You will not be able to log into the launched instances.\n"
            "You can specify a key-pair using the --ssh-keyname option.\n"
            "Do you want to continue without a keypair (Y/n)? "
            )
        if response not in ('Y', 'y'):
            return

    if args.name is None:
        args.name = 'pyfora'
        print '--name argument was not specified. Using default name: ' + args.name

    launcher = Launcher(instance_type=args.instance_type,
                        open_public_port=open_public_port,
                        commit_to_build=args.commit,
                        vpc_id=args.vpc_id,
                        subnet_id=args.subnet_id,
                        security_group_id=args.security_group_id,
                        **launcher_args(args))

    status_printer = StatusPrinter()
    print "Launching manager instance:"
    manager = launcher.launch_manager(ssh_keyname,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    if not manager:
        status_printer.failed()
        list_instances(args)
        return
    status_printer.done()

    print "Manager instance started:\n"
    print_instance(manager, 'manager')
    print ""
    if not args.open_public_port:
        print "To tunnel the pyfora HTTP port (30000) over ssh, run the following command:"
        print "    ssh -i <ssh_key_file> -L 30000:localhost:30000 ubuntu@%s\n" % manager.ip_address

    workers = []
    if args.num_instances > 1:
        print "Launching worker instance(s):"
        workers = launcher.launch_workers(args.num_instances-1,
                                          ssh_keyname,
                                          manager.id,
                                          args.spot_price,
                                          callback=status_printer.on_status)
        if not workers:
            status_printer.failed()
            print "Workers could not be launched."
            list_instances(args)
        else:
            status_printer.done()
            print "Worker instance(s) started:"

            for worker in workers:
                print_instance(worker, 'worker')

    print "Waiting for services:"
    if launcher.wait_for_services([manager] + workers, callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()
示例#6
0
def start_instances(args):
    assert args.num_instances > 0
    ssh_keyname = get_ssh_keyname(args.ssh_keyname)
    open_public_port = args.open_public_port or ssh_keyname is None
    if ssh_keyname is None and not args.yes_all:
        response = raw_input(
            "You are launching instances without specifying an ssh key-pair name.\n"
            "You will not be able to log into the launched instances.\n"
            "You can specify a key-pair using the --ssh-keyname option.\n"
            "Do you want to continue without a keypair (Y/n)? ")
        if response not in ('Y', 'y'):
            return

    if args.name is None:
        args.name = 'pyfora'
        print '--name argument was not specified. Using default name: ' + args.name

    launcher = Launcher(instance_type=args.instance_type,
                        open_public_port=open_public_port,
                        commit_to_build=args.commit,
                        vpc_id=args.vpc_id,
                        subnet_id=args.subnet_id,
                        security_group_id=args.security_group_id,
                        **launcher_args(args))

    status_printer = StatusPrinter()
    print "Launching manager instance:"
    manager = launcher.launch_manager(ssh_keyname,
                                      args.spot_price,
                                      callback=status_printer.on_status)
    if not manager:
        status_printer.failed()
        list_instances(args)
        return
    status_printer.done()

    print "Manager instance started:\n"
    print_instance(manager, 'manager')
    print ""
    if not args.open_public_port:
        print "To tunnel the pyfora HTTP port (30000) over ssh, run the following command:"
        print "    ssh -i <ssh_key_file> -L 30000:localhost:30000 ubuntu@%s\n" % manager.ip_address

    workers = []
    if args.num_instances > 1:
        print "Launching worker instance(s):"
        workers = launcher.launch_workers(args.num_instances - 1,
                                          ssh_keyname,
                                          manager.id,
                                          args.spot_price,
                                          callback=status_printer.on_status)
        if not workers:
            status_printer.failed()
            print "Workers could not be launched."
            list_instances(args)
        else:
            status_printer.done()
            print "Worker instance(s) started:"

            for worker in workers:
                print_instance(worker, 'worker')

    print "Waiting for services:"
    if launcher.wait_for_services([manager] + workers,
                                  callback=status_printer.on_status):
        status_printer.done()
    else:
        status_printer.failed()