コード例 #1
0
ファイル: views.py プロジェクト: termie/horizon
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})
コード例 #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})
コード例 #3
0
ファイル: views.py プロジェクト: termie/horizon
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
    })
コード例 #4
0
ファイル: views.py プロジェクト: BillTheBest/horizon
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})
コード例 #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)
コード例 #6
0
ファイル: forms.py プロジェクト: katzj/horizon
 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)
コード例 #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)
コード例 #8
0
ファイル: views.py プロジェクト: ehazlett/horizon
 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)
コード例 #9
0
ファイル: views.py プロジェクト: ehazlett/horizon
 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)
コード例 #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)
コード例 #11
0
ファイル: views.py プロジェクト: griddynamics/horizon
 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}
コード例 #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
     }