示例#1
0
    def list(self, argv):
        """
        List the tasks running in a cluster by checking the /tasks endpoint.
        """
        # pylint: disable=unused-argument
        try:
            master = self.config.master()
        except Exception as exception:
            raise CLIException(
                "Unable to get leading master address: {error}".format(
                    error=exception))

        try:
            tasks = get_tasks(master)
        except Exception as exception:
            raise CLIException("Unable to get tasks from leading"
                               " master '{master}': {error}".format(
                                   master=master, error=exception))

        if not tasks:
            print("There are no tasks running in the cluster.")
            return

        try:
            table = Table(["Task ID", "Framework ID", "Executor ID"])
            for task in tasks:
                table.add_row(
                    [task["id"], task["framework_id"], task["executor_id"]])
        except Exception as exception:
            raise CLIException(
                "Unable to build table of tasks: {error}".format(
                    error=exception))

        print(str(table))
示例#2
0
文件: main.py 项目: wwjiang007/mesos
    def inspect(self, argv):
        """
        Show the low-level information on the task.
        """
        try:
            master = self.config.master()
        except Exception as exception:
            raise CLIException(
                "Unable to get leading master address: {error}".format(
                    error=exception))

        data = get_tasks(master, self.config)
        for task in data:
            if task["id"] != argv["<task_id>"]:
                continue

            print(json.dumps(task, indent=4))
示例#3
0
文件: main.py 项目: wwjiang007/mesos
    def list(self, argv):
        """
        List the tasks running in a cluster by checking the /tasks endpoint.
        """
        # pylint: disable=unused-argument
        try:
            master = self.config.master()
        except Exception as exception:
            raise CLIException(
                "Unable to get leading master address: {error}".format(
                    error=exception))

        try:
            tasks = get_tasks(master, self.config)
        except Exception as exception:
            raise CLIException("Unable to get tasks from leading"
                               " master '{master}': {error}".format(
                                   master=master, error=exception))

        if not tasks:
            print("There are no tasks running in the cluster.")
            return

        try:
            table = Table(["ID", "State", "Framework ID", "Executor ID"])
            for task in tasks:
                task_state = "UNKNOWN"
                if task["statuses"]:
                    task_state = task["statuses"][-1]["state"]

                if not argv["--all"] and task_state != "TASK_RUNNING":
                    continue

                table.add_row([
                    task["id"], task_state, task["framework_id"],
                    task["executor_id"]
                ])
        except Exception as exception:
            raise CLIException(
                "Unable to build table of tasks: {error}".format(
                    error=exception))

        print(str(table))
示例#4
0
    def list(self, argv):
        """
        List the tasks running in a cluster by checking the /tasks endpoint.
        """
        # pylint: disable=unused-argument
        try:
            master = self.config.master()
        except Exception as exception:
            raise CLIException("Unable to get leading master address: {error}"
                               .format(error=exception))

        try:
            tasks = get_tasks(master)
        except Exception as exception:
            raise CLIException("Unable to get tasks from leading"
                               " master '{master}': {error}"
                               .format(master=master, error=exception))

        if not tasks:
            print("There are no tasks running in the cluster.")
            return

        try:
            table = Table(["ID", "State", "Framework ID", "Executor ID"])
            for task in tasks:
                task_state = "UNKNOWN"
                if task["statuses"]:
                    task_state = task["statuses"][-1]["state"]

                if not argv["--all"] and task_state != "TASK_RUNNING":
                    continue

                table.add_row([task["id"],
                               task_state,
                               task["framework_id"],
                               task["executor_id"]])
        except Exception as exception:
            raise CLIException("Unable to build table of tasks: {error}"
                               .format(error=exception))

        print(str(table))