コード例 #1
0
ファイル: workers.py プロジェクト: isethi/qonos
 def list(self, request):
     params = self._get_request_params(request)
     try:
         params = utils.get_pagination_limit(params)
     except exception.Invalid as e:
         raise webob.exc.HTTPBadRequest(explanation=str(e))
     try:
         workers = self.db_api.worker_get_all(params=params)
     except exception.NotFound:
         raise webob.exc.HTTPNotFound()
     [utils.serialize_datetimes(worker) for worker in workers]
     return {'workers': workers}
コード例 #2
0
ファイル: workers.py プロジェクト: cp16net/qonos
 def list(self, request):
     params = self._get_request_params(request)
     try:
         params = utils.get_pagination_limit(params)
     except exception.Invalid as e:
         raise webob.exc.HTTPBadRequest(explanation=str(e))
     try:
         workers = self.db_api.worker_get_all(params=params)
     except exception.NotFound:
         raise webob.exc.HTTPNotFound()
     [utils.serialize_datetimes(worker) for worker in workers]
     return {'workers': workers}
コード例 #3
0
ファイル: jobs.py プロジェクト: pperezrubio/qonos
    def list(self, request):
        params = self._get_request_params(request)
        try:
            params = utils.get_pagination_limit(params)
        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=str(e))
        try:
            jobs = self.db_api.job_get_all(params)
        except exception.NotFound:
            raise webob.exc.HTTPNotFound()

        for job in jobs:
            utils.serialize_datetimes(job)
            api_utils.serialize_job_metadata(job)
        return {'jobs': jobs}
コード例 #4
0
ファイル: schedules.py プロジェクト: isethi/qonos
 def list(self, request):
     filter_args = self._get_request_params(request)
     try:
         filter_args = utils.get_pagination_limit(filter_args)
     except exception.Invalid as e:
         raise webob.exc.HTTPBadRequest(explanation=str(e))
     try:
         schedules = self.db_api.schedule_get_all(filter_args=filter_args)
         if len(schedules) != 0 and len(schedules) == filter_args['limit']:
             next_page = '/v1/schedules?marker=%s' % schedules[-1].get('id')
         else:
             next_page = None
     except exception.NotFound:
         msg = _('The specified marker could not be found')
         raise webob.exc.HTTPNotFound(explanation=msg)
     for sched in schedules:
         utils.serialize_datetimes(sched),
         api_utils.serialize_schedule_metadata(sched)
     links = [{'rel': 'next', 'href': next_page}]
     return {'schedules': schedules, 'schedules_links': links}
コード例 #5
0
ファイル: schedules.py プロジェクト: cp16net/qonos
 def list(self, request):
     filter_args = self._get_request_params(request)
     try:
         filter_args = utils.get_pagination_limit(filter_args)
         limit = filter_args['limit']
     except exception.Invalid as e:
         raise webob.exc.HTTPBadRequest(explanation=str(e))
     try:
         schedules = self.db_api.schedule_get_all(filter_args=filter_args)
         if len(schedules) != 0 and len(schedules) == limit:
             next_page = '/v1/schedules?marker=%s' % schedules[-1].get('id')
         else:
             next_page = None
     except exception.NotFound:
         msg = _('The specified marker could not be found')
         raise webob.exc.HTTPNotFound(explanation=msg)
     for sched in schedules:
         utils.serialize_datetimes(sched),
         api_utils.serialize_schedule_metadata(sched)
     links = [{'rel': 'next', 'href': next_page}]
     return {'schedules': schedules, 'schedules_links': links}
コード例 #6
0
ファイル: jobs.py プロジェクト: broble/qonos
    def list(self, request):
        params = request.params.copy()

        try:
            params = utils.get_pagination_limit(params)
        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=str(e))

        if 'status' in params:
            params['status'] = str(params['status']).upper()

        if 'timeout' in params:
            timeout = timeutils.parse_isotime(params['timeout'])
            params['timeout'] = timeutils.normalize_time(timeout)

        if 'hard_timeout' in params:
            hard_timeout = timeutils.parse_isotime(params['hard_timeout'])
            params['hard_timeout'] = timeutils.normalize_time(hard_timeout)

        try:
            jobs = self.db_api.job_get_all(params)
        except exception.NotFound:
            raise webob.exc.HTTPNotFound()

        limit = params.get('limit')
        if len(jobs) != 0 and len(jobs) == limit:
            next_page = '/v1/jobs?marker=%s' % jobs[-1].get('id')
        else:
            next_page = None

        for job in jobs:
            utils.serialize_datetimes(job)
            api_utils.serialize_job_metadata(job)

        links = [{'rel': 'next', 'href': next_page}]
        return {'jobs': jobs, 'jobs_links': links}
コード例 #7
0
ファイル: jobs.py プロジェクト: clefelhocz/qonos
    def list(self, request):
        params = request.params.copy()

        try:
            params = utils.get_pagination_limit(params)
        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=str(e))

        if 'status' in params:
            params['status'] = str(params['status']).upper()

        if 'timeout' in params:
            timeout = timeutils.parse_isotime(params['timeout'])
            params['timeout'] = timeutils.normalize_time(timeout)

        if 'hard_timeout' in params:
            hard_timeout = timeutils.parse_isotime(params['hard_timeout'])
            params['hard_timeout'] = timeutils.normalize_time(hard_timeout)

        try:
            jobs = self.db_api.job_get_all(params)
        except exception.NotFound:
            raise webob.exc.HTTPNotFound()

        limit = params.get('limit')
        if len(jobs) != 0 and len(jobs) == limit:
            next_page = '/v1/jobs?marker=%s' % jobs[-1].get('id')
        else:
            next_page = None

        for job in jobs:
            utils.serialize_datetimes(job)
            api_utils.serialize_job_metadata(job)

        links = [{'rel': 'next', 'href': next_page}]
        return {'jobs': jobs, 'jobs_links': links}
コード例 #8
0
ファイル: test_validate_limit.py プロジェクト: cp16net/qonos
 def test_list_limit(self):
     limit = utils.get_pagination_limit({'limit': '1'})
     one = 1
     self.assertEqual({'limit': one}, limit)
コード例 #9
0
 def test_list_limit(self):
     limit = utils.get_pagination_limit({"limit": "1"})
     one = 1
     self.assertEqual({"limit": one}, limit)