def handle(self): provisioners = self.kqueen_request('provisioner', 'list', fnkwargs={'all_namespaces': True}) _, provisioners, _ = sanitize_resource_metadata(session, [], provisioners) provisioners.sort(key=lambda k: (k['_namespace'], k['created_at'], k['name'])) data = { 'response': 200, 'body': render_template('manager/partial/provisioner_table.html', provisioners=provisioners) } return jsonify(data)
def handle(self, page): supported_filters = { 'name': 'provisioner_name', 'engine': 'provisioner_engine' } sorting = { 'sortby': 'sort_provisioners_by', 'order': 'provisioners_order' } try: provisioners = self.kqueen_request( 'provisioner', 'list', fnkwargs={ 'all_namespaces': True, 'page': page, 'per_page': self.objects_per_page, 'filters': { k: request.args.get(v, '') for k, v in supported_filters.items() }, 'sort': {k: request.args.get(v, '') for k, v in sorting.items()} }) except Exception as e: return handle_exception_for_ajax(e) if provisioners is None: return jsonify({'session_expired': True}) provisioner_pages = get_pages_count(provisioners['total'], self.objects_per_page) _, provisioners = sanitize_resource_metadata(session, [], provisioners['items']) provisioners.sort(key=lambda k: k['_namespace']) data = { 'response': 200, 'body': render_template('manager/partial/provisioner_table.html', provisioners=provisioners, provisioner_pages=provisioner_pages, current_provisioner_page=page, form_page_ranges=form_page_ranges) } return jsonify(data)