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/17 11:28:04 UTC
[mesos] branch master updated: Added `get_container_id` to util
functions for the 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 e9dc095 Added `get_container_id` to util functions for the new CLI.
e9dc095 is described below
commit e9dc09516f2becad5e746c2410997ba9658eca70
Author: Armand Grillet <ag...@mesosphere.io>
AuthorDate: Wed Oct 17 07:07:59 2018 -0400
Added `get_container_id` to util functions for the new CLI.
In a future commit, this function will be used by the `TaskIO` object to
know which container to use in order to run `task attach` and `task
exec.`.
Review: https://reviews.apache.org/r/69007/
---
src/python/cli_new/lib/cli/mesos.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/src/python/cli_new/lib/cli/mesos.py b/src/python/cli_new/lib/cli/mesos.py
index 26556c5..cab02f6 100644
--- a/src/python/cli_new/lib/cli/mesos.py
+++ b/src/python/cli_new/lib/cli/mesos.py
@@ -63,6 +63,35 @@ def get_agents(master):
return data[key]
+def get_container_id(task):
+ """
+ Get the container ID of a task.
+ """
+
+ if 'statuses' not in task:
+ raise CLIException("Unable to obtain status information for task")
+
+ statuses = task['statuses']
+ if not statuses:
+ raise CLIException("No status updates available for task")
+
+ # It doesn't matter which status we use to get the `container_id`, if the
+ # `container_id` has been set for the task, all statuses will contain it.
+ if not 'container_status' in statuses[0]:
+ raise CLIException("Task status does not contain container information")
+
+ container_status = statuses[0]['container_status']
+ if 'container_id' in container_status:
+ container_id = container_status['container_id']
+ if 'value' in container_id:
+ return container_id
+
+ raise CLIException(
+ "No container found for the specified task."
+ " It might still be spinning up."
+ " Please try again.")
+
+
def get_tasks(master):
"""
Get the tasks in a Mesos cluster.