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 2017/09/26 14:44:28 UTC
mesos git commit: Added CLI utility function to get agent address.
Repository: mesos
Updated Branches:
refs/heads/master ebc277c32 -> d1a430886
Added CLI utility function to get agent address.
This will be used by future plugins.
Review: https://reviews.apache.org/r/62573/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d1a43088
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d1a43088
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d1a43088
Branch: refs/heads/master
Commit: d1a430886feac2b79afc6c1a8af05ea2046d9761
Parents: ebc277c
Author: Armand Grillet <ag...@mesosphere.io>
Authored: Tue Sep 26 16:43:42 2017 +0200
Committer: Kevin Klues <kl...@gmail.com>
Committed: Tue Sep 26 16:43:42 2017 +0200
----------------------------------------------------------------------
src/python/cli_new/lib/cli/util.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d1a43088/src/python/cli_new/lib/cli/util.py
----------------------------------------------------------------------
diff --git a/src/python/cli_new/lib/cli/util.py b/src/python/cli_new/lib/cli/util.py
index a9803d1..dd109c0 100644
--- a/src/python/cli_new/lib/cli/util.py
+++ b/src/python/cli_new/lib/cli/util.py
@@ -25,6 +25,8 @@ import re
import socket
import textwrap
+import cli.http as http
+
from cli.exceptions import CLIException
@@ -184,6 +186,24 @@ 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