Example #1
0
def swarm_up_slaves(args):
    logging.info("Bringing up {0} swarm slaves".format(args.num_slaves))

    _validate_dirs(args)

    cfg = get_config(args.config)

    master_ip_address = get_master_ip_address(cfg)

    security_group = get_security_group_from_role(cfg, DEFAULT_SLAVE_ROLE_NAME)

    if not master_ip_address:
        raise Exception("Unable to start slaves without a master. Please "
                        "bring up a master first.")

    for i in xrange(args.num_slaves):
        pool.apply_async(create_slave, (cfg, security_group))

    pool.close()
    pool.join()

    _wait_for_slave_reservations(cfg, args.num_slaves)

    update_master_security_group(cfg)
    _update_role_defs(get_slave_reservations(cfg), 'slave')
    env.user = cfg.get('fabric', 'user', None)
    env.key_filename = cfg.get('fabric', 'key_filename', None)
    env.parallel = True

    execute(_bootstrap_slave, args.directory, master_ip_address)
    _disconnect_fabric()
Example #2
0
def swarm_up_slaves(args):
    logging.info("Bringing up {0} swarm slaves".format(args.num_slaves))

    _validate_dirs(args)

    cfg = get_config(args.config)

    master_ip_address = get_master_ip_address(cfg)

    if not master_ip_address:
        raise Exception("Unable to start slaves without a master. Please "
                        "bring up a master first.")

    for i in xrange(args.num_slaves):
        pool.apply_async(create_slave, (cfg,))

    pool.close()
    pool.join()

    update_master_security_group(cfg)

    # TODO: Hack for now, should check for ssh-ability
    time.sleep(5)

    _update_role_defs(get_slave_reservations(cfg), 'slave')
    env.user = cfg.get('fabric', 'user', None)
    env.key_filename = cfg.get('fabric', 'key_filename', None)
    env.parallel = True

    execute(_bootstrap_slave, args.directory, master_ip_address)
    _disconnect_fabric()
Example #3
0
def swarm_up_slaves(args):
    logging.info("Bringing up {0} swarm slaves".format(args.num_slaves))

    _validate_dirs(args)

    cfg = get_config(args.config)

    master_ip_address = get_master_ip_address(cfg)

    if not master_ip_address:
        raise Exception("Unable to start slaves without a master. Please "
                        "bring up a master first.")

    for i in xrange(args.num_slaves):
        pool.apply_async(create_slave, (cfg, ))

    pool.close()
    pool.join()

    update_master_security_group(cfg)

    # TODO: Hack for now, should check for ssh-ability
    time.sleep(5)

    _update_role_defs(get_slave_reservations(cfg), 'slave')
    env.user = cfg.get('fabric', 'user', None)
    env.key_filename = cfg.get('fabric', 'key_filename', None)
    env.parallel = True

    execute(_bootstrap_slave, args.directory, master_ip_address)
    _disconnect_fabric()
Example #4
0
def swarm_up_slaves(args):
    logging.info("Bringing up {0} swarm slaves".format(args.num_slaves))

    _validate_dirs(args)

    cfg = get_config(args.config)

    master_ip_address = get_master_ip_address(cfg)

    security_group = get_security_group_from_role(cfg, DEFAULT_SLAVE_ROLE_NAME)

    if not master_ip_address:
        raise Exception("Unable to start slaves without a master. Please "
                        "bring up a master first.")

    for i in xrange(args.num_slaves):
        pool.apply_async(create_slave, (cfg, security_group))

    pool.close()
    pool.join()

    _wait_for_slave_reservations(cfg, args.num_slaves)

    update_master_security_group(cfg)
    _update_role_defs(get_slave_reservations(cfg), 'slave')
    env.user = cfg.get('fabric', 'user', None)
    env.key_filename = cfg.get('fabric', 'key_filename', None)
    env.parallel = True

    execute(_bootstrap_slave, args.directory, master_ip_address)
    _disconnect_fabric()
Example #5
0
def _wait_for_slave_reservations(
        cfg, reservations_num, max_tries=30, sleep_interval=5):
    tries = 0
    online_hosts = []
    while True:
        if (len(online_hosts) == reservations_num):
            logging.info("All {0} hosts are online".format(reservations_num))
            break
        if tries > max_tries:
            logging.warning(
                "Timeout. Only {0} of {1} hosts came online.".format(
                    len(online_hosts), reservations_num))
            break
        reservations = get_slave_reservations(cfg)
        for reservation in reservations:
            ip_address = reservation.instances[0].ip_address
            if ip_address not in online_hosts and can_ssh(ip_address):
                online_hosts.append(ip_address)
                logging.info("Host {0} is now ssh-able.".format(ip_address))
        tries += 1
        time.sleep(sleep_interval)
Example #6
0
def _wait_for_slave_reservations(cfg,
                                 reservations_num,
                                 max_tries=30,
                                 sleep_interval=5):
    tries = 0
    online_hosts = []
    while True:
        if (len(online_hosts) == reservations_num):
            logging.info("All {0} hosts are online".format(reservations_num))
            break
        if tries > max_tries:
            logging.warning(
                "Timeout. Only {0} of {1} hosts came online.".format(
                    len(online_hosts), reservations_num))
            break
        reservations = get_slave_reservations(cfg)
        for reservation in reservations:
            ip_address = reservation.instances[0].ip_address
            if ip_address not in online_hosts and can_ssh(ip_address):
                online_hosts.append(ip_address)
                logging.info("Host {0} is now ssh-able.".format(ip_address))
        tries += 1
        time.sleep(sleep_interval)