You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by cf...@apache.org on 2022/01/13 19:44:41 UTC
[mesos] branch master updated: ADD: task inspect function.
This is an automated email from the ASF dual-hosted git repository.
cfnatali 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 97d9a40 ADD: task inspect function.
97d9a40 is described below
commit 97d9a4063332aae3825d78de71611657e05cf5e2
Author: Andreas Peters <ap...@aventer.biz>
AuthorDate: Tue Nov 30 21:16:15 2021 +0100
ADD: task inspect function.
UPDATE: code refactor.
FIX: revoke accidental changes.
---
src/python/cli_new/lib/cli/plugins/task/main.py | 37 ++++++++++++++++++++-----
1 file changed, 30 insertions(+), 7 deletions(-)
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 d223746..b43d7cc 100644
--- a/src/python/cli_new/lib/cli/plugins/task/main.py
+++ b/src/python/cli_new/lib/cli/plugins/task/main.py
@@ -18,6 +18,8 @@
The task plugin.
"""
+import json
+
from cli.exceptions import CLIException
from cli.mesos import get_tasks
from cli.plugins import PluginBase
@@ -65,7 +67,13 @@ class Task(PluginBase):
},
"short_help": "List all running tasks in a Mesos cluster",
"long_help": "List all running tasks in a Mesos cluster"
- }
+ },
+ "inspect": {
+ "arguments": ['<task_id>'],
+ "flags": {},
+ "short_help": "Return low-level information on the task",
+ "long_help": "Return low-level information on the task"
+ }
}
def attach(self, argv):
@@ -75,12 +83,11 @@ class Task(PluginBase):
"""
try:
master = self.config.master()
- config = self.config
except Exception as exception:
raise CLIException("Unable to get leading master address: {error}"
.format(error=exception))
- task_io = TaskIO(master, config, argv["<task-id>"])
+ task_io = TaskIO(master, self.config, argv["<task-id>"])
return task_io.attach(argv["--no-stdin"])
@@ -90,12 +97,11 @@ class Task(PluginBase):
"""
try:
master = self.config.master()
- config = self.config
except Exception as exception:
raise CLIException("Unable to get leading master address: {error}"
.format(error=exception))
- task_io = TaskIO(master, config, argv["<task-id>"])
+ task_io = TaskIO(master, self.config, argv["<task-id>"])
return task_io.exec(argv["<command>"],
argv["<args>"],
argv["--interactive"],
@@ -108,13 +114,12 @@ class Task(PluginBase):
# pylint: disable=unused-argument
try:
master = self.config.master()
- config = self.config
except Exception as exception:
raise CLIException("Unable to get leading master address: {error}"
.format(error=exception))
try:
- tasks = get_tasks(master, config)
+ tasks = get_tasks(master, self.config)
except Exception as exception:
raise CLIException("Unable to get tasks from leading"
" master '{master}': {error}"
@@ -143,3 +148,21 @@ class Task(PluginBase):
.format(error=exception))
print(str(table))
+
+ def inspect(self, argv):
+ """
+ Show the low-level information on the task.
+ """
+ try:
+ master = self.config.master()
+ except Exception as exception:
+ raise CLIException("Unable to get leading master address: {error}"
+ .format(error=exception))
+
+ data = get_tasks(master, self.config)
+ for task in data:
+ if task["id"] != argv["<task_id>"]:
+ continue
+
+ print(json.dumps(task, indent=4))
+