Ejemplo n.º 1
0
def builder_start_cmd(args):
    instance = BuilderInstance.instance()
    if instance.status() == 'stopped':
        print("Starting builder instance...")
        instance.start()
        for i in range(60):
            if instance.status() == 'running':
                break
            time.sleep(1)
        else:
            raise RuntimeError("Unable to start instance, still in state: {}".format(instance.status()))
    for i in range(60):
        try:
            r = exec_remote(instance, ["echo", "hello"])
            if r.strip() == "hello":
                break
        except Exception as e:
            print("Still waiting for SSH: got: {}".format(e))
            pass
        time.sleep(1)
    else:
        raise RuntimeError("Unable to get SSH access")
    res = exec_remote(instance, ["bash", "-c", "cd compiler-explorer-image && git pull && sudo ./setup-builder.sh"])
    print(res)
    print("Builder started OK")
Ejemplo n.º 2
0
Archivo: ce.py Proyecto: iCodeIN/infra
def builder_start_cmd(_):
    instance = BuilderInstance.instance()
    if instance.status() == 'stopped':
        print("Starting builder instance...")
        instance.start()
        for _ in range(60):
            if instance.status() == 'running':
                break
            time.sleep(1)
        else:
            raise RuntimeError(
                "Unable to start instance, still in state: {}".format(
                    instance.status()))
    for _ in range(60):
        try:
            r = exec_remote(instance, ["echo", "hello"])
            if r.strip() == "hello":
                break
        except subprocess.CalledProcessError as e:
            print("Still waiting for SSH: got: {}".format(e))
        time.sleep(1)
    else:
        raise RuntimeError("Unable to get SSH access")
    res = exec_remote(instance, [
        "bash", "-c", "cd infra && git pull && sudo ./setup-builder-startup.sh"
    ])
    print(res)
    print("Builder started OK")
Ejemplo n.º 3
0
def builder_status_cmd(args):
    print("Builder status: {}".format(BuilderInstance.instance().status()))
Ejemplo n.º 4
0
def builder_stop_cmd(args):
    BuilderInstance.instance().stop()
Ejemplo n.º 5
0
def builder_exec_cmd(args):
    instance = BuilderInstance.instance()
    exec_remote_to_stdout(instance, args['remote_cmd'])
Ejemplo n.º 6
0
def builder_login_cmd(args):
    instance = BuilderInstance.instance()
    run_remote_shell(args, instance)
Ejemplo n.º 7
0
def builder_status():
    """Get the builder status (running or otherwise)."""
    print("Builder status: {}".format(BuilderInstance.instance().status()))
Ejemplo n.º 8
0
def builder_stop():
    """Stop the builder instance."""
    BuilderInstance.instance().stop()
Ejemplo n.º 9
0
def builder_exec(remote_cmd: Sequence[str]):
    """Execute REMOTE_CMD on the builder instance."""
    instance = BuilderInstance.instance()
    exec_remote_to_stdout(instance, remote_cmd)
Ejemplo n.º 10
0
def builder_login():
    """Log in to the builder machine."""
    instance = BuilderInstance.instance()
    run_remote_shell(instance)