This is an automated email from the ASF dual-hosted git repository. klueska pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 2d563794bc82a2cc799cdf2171fc47742fb573d1 Author: Armand Grillet <armand.gril...@outlook.com> AuthorDate: Fri Oct 19 12:47:59 2018 +0200 Added 'task attach' subcommand to new CLI. Review: https://reviews.apache.org/r/69105/ --- src/python/cli_new/lib/cli/plugins/task/main.py | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/python/cli_new/lib/cli/plugins/task/main.py b/src/python/cli_new/lib/cli/plugins/task/main.py index 546ad00..5866a23 100644 --- a/src/python/cli_new/lib/cli/plugins/task/main.py +++ b/src/python/cli_new/lib/cli/plugins/task/main.py @@ -39,6 +39,16 @@ class Task(PluginBase): """ COMMANDS = { + "attach": { + "arguments": ['<task-id>'], + "flags": { + "--no-stdin": "do not attach a stdin [default: False]" + }, + "short_help": "Attach the CLI to the stdio of a running task", + "long_help": """ + Attach the CLI to the stdio of a running task + To detach type the sequence CTRL-p CTRL-q.""" + }, "exec": { "arguments": ['<task-id>', '<command>', '[<args>...]'], "flags": { @@ -56,6 +66,22 @@ class Task(PluginBase): } } + def attach(self, argv): + """ + Attach the stdin/stdout/stderr of the CLI to the + STDIN/STDOUT/STDERR of a running task. + """ + try: + master = self.config.master() + except Exception as exception: + raise CLIException("Unable to get leading master address: {error}" + .format(error=exception)) + + task_io = TaskIO(master, argv["<task-id>"]) + task_io.attach(argv["--no-stdin"]) + return 0 + + def exec(self, argv): """ Launch a process inside a task's container.