You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by GitBox <gi...@apache.org> on 2021/11/04 22:06:34 UTC

[GitHub] [mesos] cf-natali commented on a change in pull request #413: ADD: framework plugin for the mesos-cli.

cf-natali commented on a change in pull request #413:
URL: https://github.com/apache/mesos/pull/413#discussion_r743235991



##########
File path: src/python/cli_new/lib/cli/plugins/framework/main.py
##########
@@ -0,0 +1,120 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+The framework plugin.
+"""
+
+import json
+
+from cli.exceptions import CLIException
+from cli.mesos import get_frameworks
+from cli.plugins import PluginBase
+from cli.util import Table
+
+
+PLUGIN_NAME = "framework"
+PLUGIN_CLASS = "Framework"
+
+VERSION = "v0.1.0"
+
+SHORT_HELP = "Interacts with the Mesos Frameworks"
+
+
+class Framework(PluginBase):
+    """
+    The framework plugin.
+    """
+
+    COMMANDS = {
+        "list": {
+            "arguments": [],
+            "flags": {
+                "-a --all": "list also non active frameworks"
+            },
+            "short_help": "List the Mesos frameworks.",
+            "long_help": "List information about the Mesos frameworks."
+        },
+        "inspect": {
+            "arguments": ['<framework_id>'],
+            "flags": {},
+            "short_help": "Return low-level information of the framework.",
+            "long_help": "Return low-level information of the framework."
+        }
+    }
+
+    def list(self, argv):
+        """
+        Show a list of running M3s frameworks
+        """
+
+        try:
+            master = self.config.master()
+            config = self.config
+        except Exception as exception:
+            raise CLIException("Unable to get leading master address: {error}"
+                               .format(error=exception))
+
+        data = get_frameworks(master, config)
+        try:

Review comment:
       Yes, better to remove it then!

##########
File path: src/python/cli_new/lib/cli/plugins/framework/main.py
##########
@@ -0,0 +1,120 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+The framework plugin.
+"""
+
+import json
+
+from cli.exceptions import CLIException
+from cli.mesos import get_frameworks
+from cli.plugins import PluginBase
+from cli.util import Table
+
+
+PLUGIN_NAME = "framework"
+PLUGIN_CLASS = "Framework"
+
+VERSION = "v0.1.0"
+
+SHORT_HELP = "Interacts with the Mesos Frameworks"
+
+
+class Framework(PluginBase):
+    """
+    The framework plugin.
+    """
+
+    COMMANDS = {
+        "list": {
+            "arguments": [],
+            "flags": {
+                "-a --all": "list also non active frameworks"
+            },
+            "short_help": "List the Mesos frameworks.",
+            "long_help": "List information about the Mesos frameworks."
+        },
+        "inspect": {
+            "arguments": ['<framework_id>'],
+            "flags": {},
+            "short_help": "Return low-level information of the framework.",
+            "long_help": "Return low-level information of the framework."
+        }
+    }
+
+    def list(self, argv):
+        """
+        Show a list of running M3s frameworks
+        """
+
+        try:
+            master = self.config.master()
+            config = self.config
+        except Exception as exception:
+            raise CLIException("Unable to get leading master address: {error}"
+                               .format(error=exception))
+
+        data = get_frameworks(master, config)
+        try:
+            table = Table(["ID", "Active", "Hostname", "Name"])
+            for framework in data:
+                if (not argv["--all"] and framework["active"] is not True):
+                    continue
+
+                active = "False"
+                if framework["active"]:
+                    active = "True"
+
+                table.add_row([framework["id"],
+                               active,
+                               framework["hostname"],
+                               framework["name"]])
+        except Exception as exception:
+            raise CLIException("Unable to build table of frameworks: {error}"
+                               .format(error=exception))
+
+        print(str(table))
+
+    def inspect(self, argv):
+        """
+        Show the low-level information of the framework.
+        """
+
+        try:
+            master = self.config.master()
+            config = self.config
+        except Exception as exception:
+            raise CLIException("Unable to get leading master address: {error}"
+                               .format(error=exception))
+
+        data = get_frameworks(master, config)
+        try:

Review comment:
       OK :).




-- 
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: reviews-unsubscribe@mesos.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org