Example #1
0
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})
Example #2
0
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})
Example #3
0
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
    })
Example #4
0
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})
Example #5
0
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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
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)
Example #11
0
 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}
Example #12
0
 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
     }