コード例 #1
0
ファイル: test_derex.py プロジェクト: sshyran/derex.runner
def test_get_exposed_container_names(monkeypatch):
    from derex.runner import docker_utils

    response = {
        "derex_services_minio_1": {
            "NetworkSettings": {
                "Networks": {
                    "derex": {
                        "Aliases": ["minio.localhost.derex"],
                        "IPAddress": "172.11.0.12",
                    }
                }
            }
        },
        "derex-themes_lms_1": {
            "NetworkSettings": {
                "Networks": {
                    "derex": {
                        "Aliases": ["studio.derex-themes.localhost.derex"],
                        "IPAddress": "172.11.0.12",
                    }
                }
            }
        },
    }
    monkeypatch.setattr(docker_utils, "get_running_containers",
                        lambda: response)
    result = docker_utils.get_exposed_container_names()

    assert result[0][0] == "http://minio.localhost"
    assert result[1][0] == "http://studio.derex-themes.localhost"
コード例 #2
0
ファイル: __init__.py プロジェクト: everton137/derex.runner
def derex(ctx):
    """Derex directs edX: commands to manage an Open edX installation
    """
    # Optimize --help and bash completion by importing
    from derex.runner.project import Project

    try:
        ctx.obj = Project()
    except ProjectNotFound:
        pass
    except Exception as ex:
        logger.error("\n".join(map(str, ex.args)))
        sys.exit(1)

    if ctx.invoked_subcommand:
        return

    click.echo(derex.get_help(ctx) + "\n")

    from derex.runner.docker_utils import get_exposed_container_names

    container_names = get_exposed_container_names()
    if not container_names:
        return

    console = Console()
    table = Table(
        title="[bold green]These containers are running and exposing an HTTP server on port 80",
        box=box.SIMPLE,
    )
    table.add_column("Name")
    for container in container_names:
        container = (f"[bold]{container[0]}",) + container[1:]
        table.add_row(*container)
    console.print(table)