예제 #1
0
파일: test_jobs.py 프로젝트: komawar/qonos
 def test_update_heartbeat(self):
     request = unit_test_utils.get_fake_request(method='PUT')
     body = {'heartbeat': '2012-11-16T18:41:43Z'}
     self.controller.update_heartbeat(request, self.job_1['id'], body)
     expected = timeutils.normalize_time(
         timeutils.parse_isotime(body['heartbeat']))
     actual = db_api.job_get_by_id(self.job_1['id'])['updated_at']
     self.assertEqual(actual, expected)
예제 #2
0
파일: schedules.py 프로젝트: komawar/qonos
    def _get_list_filter_args(self, request):
        filter_args = {}
        if request.params.get('next_run_after') is not None:
            next_run_after = request.params['next_run_after']
            next_run_after = timeutils.parse_isotime(next_run_after)
            next_run_after = timeutils.normalize_time(next_run_after)
            filter_args['next_run_after'] = next_run_after

        if request.params.get('next_run_before') is not None:
            next_run_before = request.params['next_run_before']
            next_run_before = timeutils.parse_isotime(next_run_before)
            next_run_before = timeutils.normalize_time(next_run_before)
            filter_args['next_run_before'] = next_run_before

        if request.params.get('tenant_id') is not None:
            filter_args['tenant_id'] = request.params['tenant_id']

        if request.params.get('instance_id') is not None:
            filter_args['instance_id'] = request.params['instance_id']

        return filter_args
예제 #3
0
파일: jobs.py 프로젝트: komawar/qonos
    def update_heartbeat(self, request, job_id, body):
        updated_at = body.get("heartbeat")
        if not updated_at:
            raise webob.exc.HTTPBadRequest()

        try:
            updated_at = timeutils.parse_isotime(updated_at)
        except ValueError:
            msg = _("Must supply a timestamp in valid format.")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        updated_at = timeutils.normalize_time(updated_at)

        try:
            self.db_api.job_update(job_id, {"updated_at": updated_at})
        except exception.NotFound:
            msg = _("Job %s could not be found.") % job_id
            raise webob.exc.HTTPNotFound(explanation=msg)
예제 #4
0
파일: jobs.py 프로젝트: isethi/qonos
    def update_status(self, request, job_id, body):
        status = body.get('status')
        if not status:
            raise webob.exc.HTTPBadRequest()

        values = {'status': status['status'].upper()}
        if 'timeout' in status:
            timeout = timeutils.parse_isotime(status['timeout'])
            values['timeout'] = timeutils.normalize_time(timeout)

        job = None
        try:
            job = self.db_api.job_update(job_id, values)
        except exception.NotFound:
            msg = _('Job %s could not be found.') % job_id
            raise webob.exc.HTTPNotFound(explanation=msg)

        if status['status'].upper() == 'ERROR':
            values = self._get_error_values(status, job)
            self.db_api.job_fault_create(values)

        return {'status': {'status': job['status'],
                           'timeout': job['timeout']}}