You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by kl...@apache.org on 2018/10/18 16:13:43 UTC

[mesos] branch master updated: Added 'task exec' subcommand to new CLI.

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


The following commit(s) were added to refs/heads/master by this push:
     new 7f36ebc  Added 'task exec' subcommand to new CLI.
7f36ebc is described below

commit 7f36ebc1775398a43b2aa3a81bb647fb296b8313
Author: Armand Grillet <ar...@outlook.com>
AuthorDate: Thu Oct 11 15:12:32 2018 +0200

    Added 'task exec' subcommand to new CLI.
    
    This subcommand launches a process inside a Mesos task container.
    
    Review: https://reviews.apache.org/r/69003
---
 src/python/cli_new/lib/cli/plugins/task/main.py | 31 +++++++++++++++++++++++++
 1 file changed, 31 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 8a4a859..546ad00 100644
--- a/src/python/cli_new/lib/cli/plugins/task/main.py
+++ b/src/python/cli_new/lib/cli/plugins/task/main.py
@@ -23,6 +23,8 @@ from cli.mesos import get_tasks
 from cli.plugins import PluginBase
 from cli.util import Table
 
+from cli.mesos import TaskIO
+
 PLUGIN_NAME = "task"
 PLUGIN_CLASS = "Task"
 
@@ -37,6 +39,15 @@ class Task(PluginBase):
     """
 
     COMMANDS = {
+        "exec": {
+            "arguments": ['<task-id>', '<command>', '[<args>...]'],
+            "flags": {
+                "-i --interactive" : "interactive [default: False]",
+                "-t --tty": "tty [default: False]"
+            },
+            "short_help": "Execute commands in a task's container",
+            "long_help": "Execute commands in a task's container"
+        },
         "list": {
             "arguments": [],
             "flags": {},
@@ -45,6 +56,26 @@ class Task(PluginBase):
         }
     }
 
+    def exec(self, argv):
+        """
+        Launch a process inside a task's container.
+        """
+        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.exec(argv["<command>"],
+                     argv["<args>"],
+                     argv["--interactive"],
+                     argv["--tty"])
+
+        # TODO(ArmandGrillet): We should not return 0 here but
+        # whatever the result of `<command> [<args>...]` was.
+        return 0
+
     def list(self, argv):
         """
         List the tasks running in a cluster by checking the /tasks endpoint.