Пример #1
0
    def get_job_status(job_id):
        """
        Returns the job status or None if the job doesn't exist
        @param job_id: job id string to check in canonical uuid format
        @return: a celery.states.state object or None
        """
        job_status = None

        job_id_bytes = apimethods.utils.get_bytes_from_uuid(job_id)
        job_status = db_get_job_status(job_id_bytes)
        if job_status:
            return pickle.loads(job_status.info)
        else:
            return job_status
Пример #2
0
    def get_job_status(job_id):
        """
        Returns the job status or None if the job doesn't exist
        @param job_id: job id string to check in canonical uuid format
        @return: a celery.states.state object or None
        """
        job_status = None

        job_id_bytes = apimethods.utils.get_bytes_from_uuid(job_id)
        job_status = db_get_job_status(job_id_bytes)
        if job_status:
            return pickle.loads(job_status.info)
        else:
            return job_status
Пример #3
0
    def get_job_status(job_id):
        """
        Returns the job status or None if the job doesn't exist
        @param job_id: job id string to check in canonical uuid format
        @return: a celery.states.state object or None
        """
        job_status = None

        job_id_bytes = apimethods.utils.get_bytes_from_uuid(job_id)
        job_status = db_get_job_status(job_id_bytes)
        if job_status:
            return pickle.loads(job_status.info)
        else:
            # Maybe it's not in the database yet. Let's inspect celery queues.
            job_status = is_task_in_celery(job_id)
            # When the task is stored in the database it is stored with the following formant
            #              {u'retries': 0,
            #              u'expires': None,
            #              u'uuid': u'e8e2a4ce-bc09-47f8-9ce8-6d3798acc2eb',
            #              u'clock': 49,
            #              u'timestamp':
            #              1441353908.687852,
            #              u'args': u"[u'DF08B5C7521111E5A4AE000C295288BF', u'5DADB3A8662F91844C62172498696BB1', u'192.168.2.213', u'crosa', u'alien4ever!', u'bosquewin2008.alienvault.com', u'001']",
            #              u'eta': None,
            #              u'kwargs': u'{}',
            #              'type': u'task-received',
            #              u'hostname': u'w1.VirtualUSMAllInOneLite',
            #              u'name': u'celerymethods.jobs.ossec_win_deploy.ossec_win_deploy'}
            # And when the task is obtained from the inspect, the task has the following format.
            # We use the type
            #             {u'hostname': u'w1.VirtualUSMAllInOneLite',
            #              u'time_start': 1441354117.651205,
            #              u'name': u'celerymethods.jobs.ossec_win_deploy.ossec_win_deploy',
            #              u'delivery_info': {u'routing_key': u'celery', u'exchange': u'celery'},
            #              u'args': u"[u'DF08B5C7521111E5A4AE000C295288BF', u'5DADB3A8662F91844C62172498696BB1', u'192.168.2.213', u'crosa', u'alien4ever!', u'bosquewin2008.alienvault.com', u'001']",
            #              u'acknowledged': True,
            #              u'kwargs': u'{}', u'id': u'720d8fdb-9c2a-4be7-8889-5244d8c980df',
            #              u'worker_pid': 14330}
            if job_status is not None:
                job_status['type'] = "task-received"
            return job_status