cf-natali commented on a change in pull request #409:
URL: https://github.com/apache/mesos/pull/409#discussion_r713338428
##########
File path: src/python/cli_new/lib/cli/http.py
##########
@@ -64,13 +64,11 @@ def read_endpoint(addr, endpoint, config, query=None):
.format(url=url, error=str(exception)))
-def get_json(addr, endpoint, config, condition=None, query=None):
+def get_json(addr, endpoint, config, query=None):
Review comment:
So interestingly the only call site which seems to pass 4 arguments to
`get_json` is this:
https://github.com/apache/mesos/blob/c66aaf47768aa0e5b66ee9d830f634f4dd682c43/src/python/cli_new/lib/cli/tests/base.py#L280
However it's apparently passing a `timeout` argument, which doesn't seem to
be accepted here.
Looking at `git blame`, I think you might have broken it here:
https://github.com/apache/mesos/commit/c66aaf47768aa0e5b66ee9d830f634f4dd682c43#diff-1b933ba1cadd6e125668ca2646e6376b740919e25e905142108f9cc324bafb4a
As you can see you removed the `timeout` parameter from `get_json` but the
test still uses it.
So I have two questions:
- have you run the tests, or do you know how to run them?
- we should probably fix the test as well
##########
File path: src/python/cli_new/lib/cli/mesos.py
##########
@@ -68,6 +63,37 @@ def get_agents(master, config):
"""
endpoint = "slaves"
key = "slaves"
+ return get_key_endpoint(key, endpoint, master, config)
+
+def get_framework_address(framework_id, master, config):
+ """
+ Given a master and an framework id, return the framework address
+ by checking the /master/frameworks endpoint of the master.
+ """
+ frameworks = get_frameworks(master, config)
+
+ for framework in frameworks:
+ if framework["id"] == framework_id:
+ return framework["webui_url"]
+ # pylint: disable=line-too-long
+ raise CLIException("Unable to find framework
'{id}'".format(id=framework_id))
+
+
+def get_frameworks(master, config):
+ """
+ Get the frameworks in a Mesos cluster.
+ """
+
+ endpoint = "master/frameworks/"
+ key = "frameworks"
+ return get_key_endpoint(key, endpoint, master, config)
+
+
+def get_key_endpoint(key, endpoint, master, config):
+ """
+ Get the json key of the given endpoint
+ """
+
Review comment:
Nit: no need for newline.
##########
File path: src/python/cli_new/lib/cli/mesos.py
##########
@@ -68,6 +63,37 @@ def get_agents(master, config):
"""
endpoint = "slaves"
key = "slaves"
+ return get_key_endpoint(key, endpoint, master, config)
+
+def get_framework_address(framework_id, master, config):
+ """
+ Given a master and an framework id, return the framework address
+ by checking the /master/frameworks endpoint of the master.
+ """
+ frameworks = get_frameworks(master, config)
+
+ for framework in frameworks:
+ if framework["id"] == framework_id:
+ return framework["webui_url"]
+ # pylint: disable=line-too-long
+ raise CLIException("Unable to find framework
'{id}'".format(id=framework_id))
+
+
+def get_frameworks(master, config):
+ """
+ Get the frameworks in a Mesos cluster.
+ """
+
Review comment:
Nit: no need for newline.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]