Пример #1
0
    def get_status(self):
        """Fetch summary hardware resource usage for the scheduler framework.

        :returns: Node resource usage information.
        :rtype: dict
        """
        master_dict = {
            'is_online': False,
            'hostname': None,
            'port': 0,
        }
        sched_dict = {
            'is_online': False,
            'is_paused': False,
            'hostname': None,
        }
        res_dict = None

        try:
            # Set the master info
            sched = self.get_master()
            master_dict['hostname'] = sched.master_hostname
            master_dict['port'] = sched.master_port

            # Set the scheduler framework info
            sched_info = mesos_api.get_scheduler(sched.master_hostname,
                                                 sched.master_port)
            sched_dict['is_online'] = sched_info.is_online
            sched_dict[
                'is_paused'] = sched.is_paused  # Note this must be pulled from the database
            sched_dict['hostname'] = sched_info.hostname

            # Master is online if the API above succeeded
            master_dict['is_online'] = True

            # Set the cluster resource info
            res_dict = sched_info.to_dict()['resources']
        except Scheduler.DoesNotExist:
            logger.exception('Unable to find master scheduler')
        except MesosError:
            logger.exception('Failed to query master info')

        status_dict = {
            'master': master_dict,
            'scheduler': sched_dict,
            'queue_depth': Queue.objects.all().count(),
        }
        if res_dict:
            status_dict['resources'] = res_dict
        return status_dict
Пример #2
0
    def get_status(self):
        '''Fetch summary hardware resource usage for the scheduler framework.

        :returns: Node resource usage information.
        :rtype: dict
        '''
        master_dict = {
            'is_online': False,
            'hostname': None,
            'port': 0,
        }
        sched_dict = {
            'is_online': False,
            'is_paused': False,
            'hostname': None,
        }
        res_dict = None

        try:
            # Set the master info
            sched = self.get_master()
            master_dict['hostname'] = sched.master_hostname
            master_dict['port'] = sched.master_port

            # Set the scheduler framework info
            sched_info = mesos_api.get_scheduler(sched.master_hostname, sched.master_port)
            sched_dict['is_online'] = sched_info.is_online
            sched_dict['is_paused'] = sched.is_paused  # Note this must be pulled from the database
            sched_dict['hostname'] = sched_info.hostname

            # Master is online if the API above succeeded
            master_dict['is_online'] = True

            # Set the cluster resource info
            res_dict = sched_info.to_dict()['resources']
        except Scheduler.DoesNotExist:
            logger.exception('Unable to find master scheduler')
        except MesosError:
            logger.exception('Failed to query master info')

        status_dict = {
            'master': master_dict,
            'scheduler': sched_dict,
            'queue_depth': Queue.objects.all().count(),
        }
        if res_dict:
            status_dict['resources'] = res_dict
        return status_dict