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 aa98a49  Moved `get_agent_address` from `util.py` to `mesos.py` in new 
CLI.
aa98a49 is described below

commit aa98a4918eab5c46383d352aee16e0b8ed4e2b13
Author: Armand Grillet <agril...@mesosphere.io>
AuthorDate: Mon Oct 8 09:33:07 2018 -0400

    Moved `get_agent_address` from `util.py` to `mesos.py` in new CLI.
    
    Review: https://reviews.apache.org/r/68950/
---
 src/python/cli_new/lib/cli/mesos.py | 19 +++++++++++++++++++
 src/python/cli_new/lib/cli/util.py  | 20 --------------------
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/python/cli_new/lib/cli/mesos.py 
b/src/python/cli_new/lib/cli/mesos.py
index 068d694..7cf84bc 100644
--- a/src/python/cli_new/lib/cli/mesos.py
+++ b/src/python/cli_new/lib/cli/mesos.py
@@ -22,6 +22,24 @@ from cli import http
 from cli.exceptions import CLIException
 
 
+def get_agent_address(agent_id, master):
+    """
+    Given a master and an agent id, return the agent address
+    by checking the /slaves endpoint of the master.
+    """
+    try:
+        agents = http.get_json(master, "slaves")["slaves"]
+    except Exception as exception:
+        raise CLIException("Could not open '/slaves'"
+                           " endpoint at '{addr}': {error}"
+                           .format(addr=master,
+                                   error=exception))
+    for agent in agents:
+        if agent["id"] == agent_id:
+            return agent["pid"].split("@")[1]
+    raise CLIException("Unable to find agent '{id}'".format(id=agent_id))
+
+
 def get_agents(master):
     """
     Get the agents in a Mesos cluster.
@@ -44,6 +62,7 @@ def get_agents(master):
 
     return data[key]
 
+
 def get_tasks(master):
     """
     Get the tasks in a Mesos cluster.
diff --git a/src/python/cli_new/lib/cli/util.py 
b/src/python/cli_new/lib/cli/util.py
index 7cec7e4..e79268d 100644
--- a/src/python/cli_new/lib/cli/util.py
+++ b/src/python/cli_new/lib/cli/util.py
@@ -28,8 +28,6 @@ import textwrap
 
 from kazoo.client import KazooClient
 
-from cli import http
-
 from cli.exceptions import CLIException
 
 
@@ -186,24 +184,6 @@ def verify_address_format(address):
         raise CLIException("The port '{port}' is not valid")
 
 
-def get_agent_address(agent_id, master):
-    """
-    Given a master and an agent id, return the agent address
-    by checking the /slaves endpoint of the master.
-    """
-    try:
-        agents = http.get_json(master, "slaves")["slaves"]
-    except Exception as exception:
-        raise CLIException("Could not open '/slaves'"
-                           " endpoint at '{addr}': {error}"
-                           .format(addr=master,
-                                   error=exception))
-    for agent in agents:
-        if agent["id"] == agent_id:
-            return agent["pid"].split("@")[1]
-    raise CLIException("Unable to find agent '{id}'".format(id=agent_id))
-
-
 def join_plugin_paths(settings, config):
     """
     Return all the plugin paths combined

Reply via email to