コード例 #1
0
ファイル: spot_request.py プロジェクト: zjureel/alluxio
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)
コード例 #2
0
ファイル: spot_request.py プロジェクト: JoeChien23/tachyon
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)