예제 #1
0
파일: director.py 프로젝트: heuermh/eggo
def web_proxy(region, stack_name):
    ec2_conn = create_ec2_connection(region)
    manager_instance = get_manager_instance(ec2_conn, stack_name)
    master_instance = get_master_instance(ec2_conn, stack_name)
    worker_instances = get_worker_instances(ec2_conn, stack_name)

    tunnels = []
    ts = '{0:<22}{1:<17}{2:<17}{3:<7}localhost:{4}'
    print(ts.format('name', 'public', 'private', 'remote', 'local'))

    # CM
    tunnels.append(non_blocking_tunnel(manager_instance.ip_address,
                                       manager_instance.private_ip_address,
                                       7180, 7180, 'ec2-user',
                                       get_ec2_private_key_file()))
    print(ts.format(
        'CM WebUI', manager_instance.ip_address,
        manager_instance.private_ip_address, 7180, 7180))

    # YARN RM
    tunnels.append(non_blocking_tunnel(master_instance.ip_address,
                                       master_instance.private_ip_address,
                                       8088, 8088, 'ec2-user',
                                       get_ec2_private_key_file()))
    print(ts.format(
        'YARN RM', master_instance.ip_address,
        master_instance.private_ip_address, 8088, 8088))

    # YARN JobHistory
    tunnels.append(non_blocking_tunnel(master_instance.ip_address,
                                       master_instance.private_ip_address,
                                       19888, 19888, 'ec2-user',
                                       get_ec2_private_key_file()))
    print(ts.format(
        'YARN JobHistory', master_instance.ip_address,
        master_instance.private_ip_address, 19888, 19888))

    try:
        # block on an arbitrary ssh tunnel
        tunnels[-1].wait()
    finally:
        for tunnel in tunnels:
            tunnel.terminate()
예제 #2
0
파일: util.py 프로젝트: ryan-williams/eggo
def non_blocking_tunnel(instance, remote_port, local_port=None, user='******',
                        private_key=None):
    if local_port is None:
        local_port = remote_port
    if private_key is None:
        private_key = get_ec2_private_key_file()
    p = Popen('ssh -nNT -i {private_key} -o UserKnownHostsFile=/dev/null '
              '-o StrictHostKeyChecking=no -L {local}:{private_ip}:{remote} '
              '{user}@{public_ip}'.format(
                  private_key=private_key, public_ip=instance.ip_address,
                  private_ip=instance.private_ip_address, user=user,
                  local=local_port, remote=remote_port),
              shell=True)
    return p
예제 #3
0
파일: director.py 프로젝트: heuermh/eggo
def install_private_key():
    put(get_ec2_private_key_file(), 'id.pem')
    run('chmod 600 id.pem')
예제 #4
0
파일: director.py 프로젝트: heuermh/eggo
def cm_tunnel_ctx(manager_instance):
    # shortcut fn returns a context object that sets up a tunnel on
    # localhost:64999
    return tunnel_ctx(manager_instance.ip_address,
                      manager_instance.private_ip_address, 7180, 64999,
                      'ec2-user', get_ec2_private_key_file())
예제 #5
0
파일: director.py 프로젝트: heuermh/eggo
from cm_api.api_client import ApiResource

from eggo.error import EggoError
from eggo.config import (
    get_aws_access_key_id, get_aws_secret_access_key, get_ec2_key_pair,
    get_ec2_private_key_file)
from eggo.aws import (
    create_cf_connection, create_cf_stack, get_subnet_id, delete_stack,
    get_security_group_id, create_ec2_connection, get_tagged_instances,
    wait_for_instance_state)
from eggo.util import non_blocking_tunnel, tunnel_ctx
from eggo.operations import generate_eggo_env_vars


env.user = '******'
env.key_filename = get_ec2_private_key_file()


def cm_tunnel_ctx(manager_instance):
    # shortcut fn returns a context object that sets up a tunnel on
    # localhost:64999
    return tunnel_ctx(manager_instance.ip_address,
                      manager_instance.private_ip_address, 7180, 64999,
                      'ec2-user', get_ec2_private_key_file())


def install_private_key():
    put(get_ec2_private_key_file(), 'id.pem')
    run('chmod 600 id.pem')

예제 #6
0
def install_private_key():
    put(get_ec2_private_key_file(), "id.pem")
    run("chmod 600 id.pem")