Beispiel #1
0
 def on_get(self, req, resp, tenant_id, job_id, run_number):
     job_execution = JobExecution.get_job(run_number)
     JobExecution.save_job(job_execution)
     if job_execution:
         resp.body = self.format_response_body(job_execution.as_dict())
     else:
         msg = 'Cannot find run number: {id}'.format(id=run_number)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Beispiel #2
0
 def on_get(self, req, resp, tenant_id, job_id, run_number):
     job_execution = JobExecution.get_job(run_number)
     JobExecution.save_job(job_execution)
     if job_execution:
         resp.body = self.format_response_body(job_execution.as_dict())
     else:
         msg = 'Cannot find run number: {id}'.format(id=run_number)
         resp.status = falcon.HTTP_404
         resp.body = json.dumps({'description': msg})
Beispiel #3
0
        def can_deserialize_from_a_dictionary(self):
            job_ex = JobExecution.build_job_from_dict(self.job_dict)

            expect(job_ex.job_id).to.equal(self.job_dict['id'])
            expect(job_ex.tenant_id).to.equal(self.job_dict['tenant_id'])
            expect(job_ex.run_number).to.equal(self.job_dict['run_number'])
            expect(job_ex.status).to.equal('in-progress')
Beispiel #4
0
 def before_all(self):
     self.job_ex = JobExecution(
         tenant_id='123',
         job_id='1001',
         run_number='2012',
         status='in-progress'
     )
        def can_deserialize_from_a_dictionary(self):
            job_ex = JobExecution.build_job_from_dict(self.job_dict)

            expect(job_ex.job_id).to.equal(self.job_dict['id'])
            expect(job_ex.tenant_id).to.equal(self.job_dict['tenant_id'])
            expect(job_ex.run_number).to.equal(self.job_dict['run_number'])
            expect(job_ex.status).to.equal('in-progress')
Beispiel #6
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})
Beispiel #7
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})
Beispiel #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)
Beispiel #9
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)
Beispiel #10
0
    class Serialization(Spec):
        def before_all(self):
            self.job_ex = JobExecution(tenant_id='123',
                                       job_id='1001',
                                       run_number='2012',
                                       status='in-progress')

        def can_serialize_to_a_dictionary(self):
            job_dict = self.job_ex.as_dict()

            expect(job_dict['id']).to.equal(self.job_ex.job_id)
            expect(job_dict['tenant_id']).to.equal(self.job_ex.tenant_id)
            expect(job_dict['run_number']).to.equal(self.job_ex.run_number)
            expect(job_dict['status']).to.equal(self.job_ex.status)
Beispiel #11
0
    class Serialization(Spec):
        def before_all(self):
            self.job_ex = JobExecution(
                tenant_id='123',
                job_id='1001',
                run_number='2012',
                status='in-progress'
            )

        def can_serialize_to_a_dictionary(self):
            job_dict = self.job_ex.as_dict()

            expect(job_dict['id']).to.equal(self.job_ex.job_id)
            expect(job_dict['tenant_id']).to.equal(self.job_ex.tenant_id)
            expect(job_dict['run_number']).to.equal(self.job_ex.run_number)
            expect(job_dict['status']).to.equal(self.job_ex.status)
Beispiel #12
0
 def before_all(self):
     self.job_ex = JobExecution(tenant_id='123',
                                job_id='1001',
                                run_number='2012',
                                status='in-progress')
Beispiel #13
0
 def can_delete(self):
     JobExecution.delete_job(self.job_ex.run_number,
                             handler=self.handler)
     expect(len(self.handler.delete_document.calls)).to.equal(1)
Beispiel #14
0
        def can_get_a_job_execution(self):
            retrieved_job = JobExecution.get_job(self.job_ex.run_number,
                                                 handler=self.handler)

            expect(len(self.handler.get_document.calls)).to.equal(1)
            expect(retrieved_job.run_number).to.equal(self.job_ex.run_number)
Beispiel #15
0
        def can_get_a_job_execution(self):
            retrieved_job = JobExecution.get_job(self.job_ex.run_number,
                                                 handler=self.handler)

            expect(len(self.handler.get_document.calls)).to.equal(1)
            expect(retrieved_job.run_number).to.equal(self.job_ex.run_number)
Beispiel #16
0
 def can_save(self):
     JobExecution.save_job(self.job_ex, handler=self.handler)
     expect(len(self.handler.insert_document.calls)).to.equal(1)
Beispiel #17
0
 def before_all(self):
     self.job_dict = example_job_dict
     self.job_ex = JobExecution.build_job_from_dict(self.job_dict)
Beispiel #18
0
 def before_all(self):
     self.job_dict = example_job_dict
     self.job_ex = JobExecution.build_job_from_dict(self.job_dict)
Beispiel #19
0
 def can_update(self):
     JobExecution.update_job(self.job_ex, handler=self.handler)
     expect(len(self.handler.update_document.calls)).to.equal(1)
Beispiel #20
0
 def can_save(self):
     JobExecution.save_job(self.job_ex, handler=self.handler)
     expect(len(self.handler.insert_document.calls)).to.equal(1)
Beispiel #21
0
 def can_delete(self):
     JobExecution.delete_job(self.job_ex.run_number,
                             handler=self.handler)
     expect(len(self.handler.delete_document.calls)).to.equal(1)
Beispiel #22
0
 def can_update(self):
     JobExecution.update_job(self.job_ex, handler=self.handler)
     expect(len(self.handler.update_document.calls)).to.equal(1)