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})
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})
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})
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))
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)
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)