Esempio n. 1
0
def print_docker_status(format):
    from localstack import config
    from localstack.utils import docker_utils
    from localstack.utils.bootstrap import (
        get_docker_image_details,
        get_main_container_ip,
        get_main_container_name,
        get_server_version,
    )

    img = get_docker_image_details()
    cont_name = config.MAIN_CONTAINER_NAME
    running = docker_utils.DOCKER_CLIENT.is_container_running(cont_name)
    status = DockerStatus(
        runtime_version=get_server_version(),
        image_tag=img["tag"],
        image_id=img["id"],
        image_created=img["created"],
        running=running,
    )
    if running:
        status["container_name"] = get_main_container_name()
        status["container_ip"] = get_main_container_ip()

    if format == "dict":
        console.print(status)
    if format == "table":
        print_docker_status_table(status)
    if format == "json":
        console.print(json.dumps(status))
    if format == "plain":
        for key, value in status.items():
            console.print(f"{key}={value}")
Esempio n. 2
0
def print_status():
    print('Base version:\t\t%s' % get_server_version())
    img = get_docker_image_details()
    print('Docker image:\t\tTag %s, ID %s, Created %s' % (img['tag'], img['id'], img['created']))
    cont_name = config.MAIN_CONTAINER_NAME
    running = docker_container_running(cont_name)
    cont_status = 'stopped'
    if running:
        cont_status = 'running (name: "%s", IP: %s)' % (get_main_container_name(), get_main_container_ip())
    print('Container status:\t%s' % cont_status)
Esempio n. 3
0
def print_status():
    print("Base version:\t\t%s" % get_server_version())
    img = get_docker_image_details()
    print("Docker image:\t\tTag %s, ID %s, Created %s" %
          (img["tag"], img["id"], img["created"]))
    cont_name = config.MAIN_CONTAINER_NAME
    running = docker_container_running(cont_name)
    cont_status = "stopped"
    if running:
        cont_status = 'running (name: "%s", IP: %s)' % (
            get_main_container_name(),
            get_main_container_ip(),
        )
    print("Container status:\t%s" % cont_status)
Esempio n. 4
0
def print_docker_status():
    from rich.table import Table

    from localstack import config
    from localstack.utils import docker_utils
    from localstack.utils.bootstrap import (
        get_docker_image_details,
        get_main_container_ip,
        get_main_container_name,
        get_server_version,
    )

    grid = Table(show_header=False)
    grid.add_column()
    grid.add_column()

    # version
    grid.add_row("Runtime version", "[bold]%s[/bold]" % get_server_version())

    # image
    img = get_docker_image_details()
    grid.add_row(
        "Docker image", "tag: %s, id: %s, :calendar: %s" %
        (img["tag"], img["id"], img["created"]))

    # container
    cont_name = config.MAIN_CONTAINER_NAME
    running = docker_utils.DOCKER_CLIENT.is_container_running(cont_name)
    cont_status = "[bold][red]:heavy_multiplication_x: stopped"
    if running:
        cont_status = '[bold][green]:heavy_check_mark: running[/green][/bold] (name: "[italic]%s[/italic]", IP: %s)' % (
            get_main_container_name(),
            get_main_container_ip(),
        )
    grid.add_row("Runtime status", cont_status)

    console.print(grid)