Exemple #1
0
def main(args):
    ec2_conf = get_ec2_conf()
    conn = get_conn()
    if args.submit:
        info(
            'waiting for spot instance requests to be fulfilled, you can cancel by ctrl+c ...'
        )
        try:
            rid_tag, requests = submit_request(conn, ec2_conf, args.masters)
        except (KeyboardInterrupt, RequestFailedError) as e:
            error(e)
            exit(1)
        info('spot instance requests fulfilled')
        instance_id_to_tag_ip = {}
        info('getting instance IPs...')
        for r in requests:
            instance_id = r.instance_id
            info('waiting for ip to be allocated to the machine')
            ip = conn.get_only_instances([instance_id])[0].ip_address
            while ip is None:
                time.sleep(1)
                ip = conn.get_only_instances([instance_id])[0].ip_address
            instance_id_to_tag_ip[instance_id] = (rid_tag[r.id], ip)
        info('mocking vagrant info under .vagrant...')
        mock_vagrant_info(instance_id_to_tag_ip)
        info('creation of spot instances done')
        info('waiting for ssh to be available...')
        wait_for_ssh([ip for tag, ip in instance_id_to_tag_ip.values()])
        info('ssh for all instances are ready')
    elif args.cancel:
        cancel_request(conn)
Exemple #2
0
def main(args):
    ec2_conf = get_ec2_conf()
    conn = get_conn()
    if args.submit:
        info('waiting for spot instance requests to be fulfilled, you can cancel by ctrl+c ...')
        try:
            requests = submit_request(conn, ec2_conf)
        except (KeyboardInterrupt, RequestFailedError) as e:
            error(e)
            exit(1)
        info('spot instance requests fulfilled')
        instance_id_to_tag_ip = {}
        rid_tag = request_id_to_tag(requests)
        info('getting instance IPs...')
        for r in requests:
            instance_id = r.instance_id
            info('waiting for ip to be allocated to the machine')
            ip = conn.get_only_instances([instance_id])[0].ip_address
            while ip is None:
                time.sleep(1)
                ip = conn.get_only_instances([instance_id])[0].ip_address
            instance_id_to_tag_ip[instance_id] = (rid_tag[r.id], ip)
        info('mocking vagrant info under .vagrant...')
        mock_vagrant_info(instance_id_to_tag_ip)
        info('creation of spot instances done')
        info('waiting for ssh to be available...')
        wait_for_ssh([ip for tag, ip in instance_id_to_tag_ip.values()])
        info('ssh for all instances are ready')
    elif args.cancel:
        cancel_request(conn)
Exemple #3
0
def is_ssh_ready(host):
    s = subprocess.Popen([
        'ssh', '-o', 'StrictHostKeyChecking=no', '-o',
        'UserKnownHostsFile=/dev/null', '-o', 'ConnectTimeout=30', '-i',
        os.path.expanduser(get_ec2_conf()['Key_Path']),
        '%s@%s' % ('ec2-user', host), 'true'
    ],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.STDOUT)
    s.communicate()
    return s.returncode == 0
Exemple #4
0
def is_ssh_ready(host):
    s = subprocess.Popen(['ssh', 
        '-o', 'StrictHostKeyChecking=no', 
        '-o', 'UserKnownHostsFile=/dev/null',
        '-o', 'ConnectTimeout=30',
        '-i', os.path.expanduser(get_ec2_conf()['Key_Path']),
        '%s@%s' % ('ec2-user', host),
        'true'], 
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT)
    s.communicate()
    return s.returncode == 0
Exemple #5
0
def add_tag(host):
    return '{}-{}'.format(get_ec2_conf()['Tag'], host)
Exemple #6
0
def add_tag(host):
    return '{}-{}'.format(get_ec2_conf()['Tag'], host)