Пример #1
0
 def on_get(self, req, resp, tenant_id, job_id):
     job = Job.get_job(job_id)
     if job:
         resp.body = self.format_response_body(job.as_dict())
     else:
         msg = 'Cannot find job: {job_id}'.format(job_id=job_id)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Пример #2
0
    def on_head(self, req, resp, tenant_id, job_id):
        job = Job.get_job(job_id)
        job_ex = JobExecution.build_job_from_dict(job.as_dict())

        if job:
            # TODO(jmv): Figure out scheduling of jobs
            JobExecution.save_job(job_ex)
            job.run_numbers.append(job_ex.run_number)
            Job.update_job(job)
            job = Job.get_job(job_id)

            execute_job.delay(job.id)
            resp.status = falcon.HTTP_200
        else:
            msg = 'Cannot find job: {job_id}'.format(job_id=job_id)
            resp.status = falcon.HTTP_404
            resp.body = json.dumps({'description': msg})
Пример #3
0
 def on_get(self, req, resp, tenant_id, job_id):
     job = Job.get_job(job_id)
     if job:
         resp.body = self.format_response_body(job.as_dict())
     else:
         msg = 'Cannot find job: {job_id}'.format(job_id=job_id)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Пример #4
0
    def on_head(self, req, resp, tenant_id, job_id):
        job = Job.get_job(job_id)
        job_ex = JobExecution.build_job_from_dict(job.as_dict())

        if job:
            # TODO(jmv): Figure out scheduling of jobs
            JobExecution.save_job(job_ex)
            job.run_numbers.append(job_ex.run_number)
            Job.update_job(job)
            job = Job.get_job(job_id)

            execute_job.delay(job.id)
            resp.status = falcon.HTTP_200
        else:
            msg = 'Cannot find job: {job_id}'.format(job_id=job_id)
            resp.status = falcon.HTTP_404
            resp.body = json.dumps({'description': msg})
Пример #5
0
 def on_head(self, req, resp, tenant_id, job_id):
     job = Job.get_job(job_id)
     if job:
         # TODO(jmv): Figure out scheduling of jobs
         execute_job.delay(job.id)
         resp.status = falcon.HTTP_200
     else:
         msg = 'Cannot find job: {job_id}'.format(job_id=job_id)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Пример #6
0
def execute_job(job_id):
    job = Job.get_job(job_id)
    if not job:
        return

    for action in job.actions:
        plugin = get_action_plugin(ACTION_PLUGINS, action.action_type)

        if plugin:
            plugin.execute_action(job, action)
        else:
            print('Failed to execute action: {0}'.format(action.action_type))
Пример #7
0
def execute_job(job_id, run_number):
    job = Job.get_job(job_id)
    if not job:
        return

    job_execution = JobExecution.get_job(run_number)

    for action in job.actions:
        plugin = get_action_plugin(ACTION_PLUGINS, action.action_type)

        if plugin:
            plugin.execute_action(job, action)
        else:
            job_execution.status = 'error'
            JobExecution.update_job(job_execution)
            print('Failed to execute action: {0}'.format(action.action_type))

    if job_execution.status == 'in-progress':
        job_execution.status = 'complete'
        JobExecution.update_job(job_execution)
Пример #8
0
def execute_job(job_id, run_number):
    job = Job.get_job(job_id)
    if not job:
        return

    job_execution = JobExecution.get_job(run_number)

    for action in job.actions:
        plugin = get_action_plugin(ACTION_PLUGINS, action.action_type)

        if plugin:
            plugin.execute_action(job, action)
        else:
            job_execution.status = 'error'
            JobExecution.update_job(job_execution)
            print('Failed to execute action: {0}'.format(action.action_type))

    if job_execution.status == 'in-progress':
        job_execution.status = 'complete'
        JobExecution.update_job(job_execution)
Пример #9
0
        def can_get_a_job(self):
            retrieved_job = Job.get_job(self.job.id, handler=self.handler)

            expect(len(self.handler.get_document.calls)).to.equal(1)
            expect(retrieved_job.id).to.equal(self.job.id)
Пример #10
0
        def can_get_a_job(self):
            retrieved_job = Job.get_job(self.job.id, handler=self.handler)

            expect(len(self.handler.get_document.calls)).to.equal(1)
            expect(retrieved_job.id).to.equal(self.job.id)