예제 #1
0
def run(
    ctx: click.core.Context,
    cluster_id: str,
    node_args: Tuple[str],
    sync_dir: Tuple[Path],
    dcos_login_uname: str,
    dcos_login_pw: str,
    test_env: bool,
    node: Tuple[str],
    env: Dict[str, str],
    transport: Transport,
) -> None:
    """
    Run an arbitrary command on a node or multiple nodes.

    To use special characters such as single quotes in your command, wrap the
    whole command in double quotes.
    """
    check_cluster_id_exists(
        new_cluster_id=cluster_id,
        existing_cluster_ids=existing_cluster_ids(),
    )

    cluster_containers = ClusterContainers(
        cluster_id=cluster_id,
        transport=transport,
    )
    cluster = cluster_containers.cluster

    for dcos_checkout_dir in sync_dir:
        sync_code_to_masters(
            cluster=cluster,
            dcos_checkout_dir=dcos_checkout_dir,
            sudo=False,
        )

    inspect_command_name = command_path(
        sibling_ctx=ctx,
        command=inspect_cluster,
    )

    hosts = get_nodes(
        cluster_id=cluster_id,
        cluster_representation=cluster_containers,
        node_references=node,
        inspect_command_name=inspect_command_name,
    )

    for host in hosts:
        run_command(
            args=list(node_args),
            cluster=cluster,
            host=host,
            use_test_env=test_env,
            dcos_login_uname=dcos_login_uname,
            dcos_login_pw=dcos_login_pw,
            env=env,
            transport=transport,
        )
예제 #2
0
def send_file(
    ctx: click.core.Context,
    cluster_id: str,
    node: Tuple[str],
    transport: Transport,
    source: str,
    destination: str,
) -> None:
    """
    Send a file to a node or multiple nodes.
    """
    check_cluster_id_exists(
        new_cluster_id=cluster_id,
        existing_cluster_ids=existing_cluster_ids(),
    )

    cluster_containers = ClusterContainers(
        cluster_id=cluster_id,
        transport=transport,
    )

    inspect_command_name = command_path(
        sibling_ctx=ctx,
        command=inspect_cluster,
    )

    hosts = get_nodes(
        cluster_id=cluster_id,
        cluster_representation=cluster_containers,
        node_references=node,
        inspect_command_name=inspect_command_name,
    )

    for host in hosts:
        host.send_file(
            local_path=Path(source),
            remote_path=Path(destination),
            transport=transport,
            sudo=False,
        )
예제 #3
0
def send_file(
    ctx: click.core.Context,
    cluster_id: str,
    node: Tuple[str],
    source: Path,
    destination: Path,
) -> None:
    """
    Send a file to a node or multiple nodes.
    """
    check_cluster_id_exists(
        new_cluster_id=cluster_id,
        existing_cluster_ids=existing_cluster_ids(),
    )

    cluster_vms = ClusterVMs(cluster_id=cluster_id)

    inspect_command_name = command_path(
        sibling_ctx=ctx,
        command=inspect_cluster,
    )

    hosts = get_nodes(
        cluster_id=cluster_id,
        cluster_representation=cluster_vms,
        node_references=node,
        inspect_command_name=inspect_command_name,
    )

    for host in hosts:
        host.send_file(
            local_path=source,
            remote_path=destination,
            transport=Transport.SSH,
            sudo=True,
        )