def index(request): quotas = api.admin_api(request).quota_sets.get(True)._info quotas['ram'] = int(quotas['ram']) / 100 quotas.pop('id') return shortcuts.render(request, 'syspanel/quotas/index.html', {'quotas': quotas})
def quotas(request, tenant_id): for f in (UpdateQuotas,): form, handled = f.maybe_handle(request) if handled: return handled quotas = api.admin_api(request).quota_sets.get(tenant_id) quota_set = { 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, 'injected_file_content_bytes': quotas.injected_file_content_bytes, 'volumes': quotas.volumes, 'gigabytes': quotas.gigabytes, 'ram': int(quotas.ram), 'floating_ips': quotas.floating_ips, 'instances': quotas.instances, 'injected_files': quotas.injected_files, 'cores': quotas.cores, } form = UpdateQuotas(initial=quota_set) return shortcuts.render(request, 'syspanel/tenants/quotas.html', { 'form': form, 'tenant_id': tenant_id, 'quotas': quotas})
def quotas(request, tenant_id): for f in (UpdateQuotas, ): form, handled = f.maybe_handle(request) if handled: return handled quotas = api.admin_api(request).quota_sets.get(tenant_id) quota_set = { 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, 'injected_file_content_bytes': quotas.injected_file_content_bytes, 'volumes': quotas.volumes, 'gigabytes': quotas.gigabytes, 'ram': int(quotas.ram), 'floating_ips': quotas.floating_ips, 'instances': quotas.instances, 'injected_files': quotas.injected_files, 'cores': quotas.cores, } form = UpdateQuotas(initial=quota_set) return shortcuts.render(request, 'syspanel/tenants/quotas.html', { 'form': form, 'tenant_id': tenant_id, 'quotas': quotas })
def index(request): quotas = api.admin_api(request).quota_sets.get(True)._info quotas['ram'] = int(quotas['ram']) / 100 quotas.pop('id') return shortcuts.render(request, 'syspanel/quotas/index.html', { 'quotas': quotas})
def index(request): try: quotas = api.admin_api(request).quota_sets.get(True)._info quotas['ram'] = int(quotas['ram']) / 100 quotas.pop('id') except Exception, e: quotas = None LOG.exception('Exception while getting quota info') messages.error(request, _('Unable to get quota info: %s') % e.message)
def handle(self, request, data): try: api.admin_api(request).quota_sets.update(data['tenant_id'], metadata_items=data['metadata_items'], injected_file_content_bytes=data['injected_file_content_bytes'], volumes=data['volumes'], gigabytes=data['gigabytes'], ram=int(data['ram']), floating_ips=data['floating_ips'], instances=data['instances'], injected_files=data['injected_files'], cores=data['cores'], ) messages.success(request, _('Quotas for %s were successfully updated.') % data['tenant_id']) except api_exceptions.ApiException, e: messages.error(request, _('Unable to update quotas: %s') % e.message)
def get_data(self): try: quotas = api.admin_api(self.request).quota_sets.get(True)._info quotas['ram'] = int(quotas['ram']) quotas.pop('id') data = [api.nova.Quota(key, val) for key, val in quotas.items()] except Exception, e: data = [] LOG.exception('Exception while getting quota info') messages.error(self.request, _('Unable to get quota info: %s') % e)
def index(request): try: quotas = api.admin_api(request).quota_sets.get(True)._info quotas['ram'] = int(quotas['ram']) / 100 quotas.pop('id') except Exception, e: quotas = None LOG.exception('Exception while getting quota info') if not hasattr(e, 'message'): e.message = str(e) messages.error(request, _('Unable to get quota info: %s') % e.message)
def get_initial(self): admin_api = api.admin_api(self.request) quotas = admin_api.quota_sets.get(self.kwargs['tenant_id']) return { 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, 'injected_file_content_bytes': quotas.injected_file_content_bytes, 'volumes': quotas.volumes, 'gigabytes': quotas.gigabytes, 'ram': int(quotas.ram), 'floating_ips': quotas.floating_ips, 'instances': quotas.instances, 'injected_files': quotas.injected_files, 'cores': quotas.cores}
def get_initial(self): admin_api = api.admin_api(self.request) quotas = admin_api.quota_sets.get(self.kwargs['tenant_id']) return { 'tenant_id': quotas.id, 'metadata_items': quotas.metadata_items, 'injected_file_content_bytes': quotas.injected_file_content_bytes, 'volumes': quotas.volumes, 'gigabytes': quotas.gigabytes, 'ram': int(quotas.ram), 'floating_ips': quotas.floating_ips, 'instances': quotas.instances, 'injected_files': quotas.injected_files, 'cores': quotas.cores }