コード例 #1
0
ファイル: quotas.py プロジェクト: NZtechpapa/expert-system
def get_default_quota_data(request, disabled_quotas=None, tenant_id=None):
    quotasets = []
    if not tenant_id:
        tenant_id = request.user.tenant_id
    if disabled_quotas is None:
        disabled_quotas = get_disabled_quotas(request)

    if NOVA_QUOTA_FIELDS - disabled_quotas:
        quotasets.append(nova.default_quota_get(request, tenant_id))

    if CINDER_QUOTA_FIELDS - disabled_quotas:
        try:
            quotasets.append(cinder.default_quota_get(request, tenant_id))
        except cinder.cinder_exception.ClientException:
            disabled_quotas.update(CINDER_QUOTA_FIELDS)
            msg = _("Unable to retrieve volume quota information.")
            exceptions.handle(request, msg)

    if NEUTRON_QUOTA_FIELDS - disabled_quotas:
        # TODO(jpichon): There is no API to access the Neutron default quotas
        # (LP#1204956). For now, use the values from the current project.
        try:
            quotasets.append(
                neutron.tenant_quota_get(request, tenant_id=tenant_id))
        except Exception:
            disabled_quotas.update(NEUTRON_QUOTA_FIELDS)
            msg = _('Unable to retrieve Neutron quota information.')
            exceptions.handle(request, msg)

    qs = base.QuotaSet()
    for quota in itertools.chain(*quotasets):
        if quota.name not in disabled_quotas and quota.name in QUOTA_FIELDS:
            qs[quota.name] = quota.limit
    return qs
コード例 #2
0
def _get_quota_data(request,
                    tenant_mode=True,
                    disabled_quotas=None,
                    tenant_id=None):
    quotasets = []
    if not tenant_id:
        tenant_id = request.user.tenant_id
    if disabled_quotas is None:
        disabled_quotas = get_disabled_quotas(request)

    qs = base.QuotaSet()

    if NOVA_QUOTA_FIELDS - disabled_quotas:
        if tenant_mode:
            quotasets.append(nova.tenant_quota_get(request, tenant_id))
        else:
            quotasets.append(nova.default_quota_get(request, tenant_id))

    if CINDER_QUOTA_FIELDS - disabled_quotas:
        try:
            if tenant_mode:
                quotasets.append(cinder.tenant_quota_get(request, tenant_id))
            else:
                quotasets.append(cinder.default_quota_get(request, tenant_id))
        except cinder.cinder_exception.ClientException:
            disabled_quotas.update(CINDER_QUOTA_FIELDS)
            msg = _("Unable to retrieve volume limit information.")
            exceptions.handle(request, msg)

    for quota in itertools.chain(*quotasets):
        if quota.name not in disabled_quotas:
            qs[quota.name] = quota.limit
    return qs
コード例 #3
0
ファイル: quotas.py プロジェクト: infraredgirl/horizon
def _get_quota_data(request, tenant_mode=True, disabled_quotas=None,
                    tenant_id=None):
    quotasets = []
    if not tenant_id:
        tenant_id = request.user.tenant_id
    if disabled_quotas is None:
        disabled_quotas = get_disabled_quotas(request)

    qs = base.QuotaSet()

    if NOVA_QUOTA_FIELDS - disabled_quotas:
        if tenant_mode:
            quotasets.append(nova.tenant_quota_get(request, tenant_id))
        else:
            quotasets.append(nova.default_quota_get(request, tenant_id))

    if CINDER_QUOTA_FIELDS - disabled_quotas:
        try:
            if tenant_mode:
                quotasets.append(cinder.tenant_quota_get(request, tenant_id))
            else:
                quotasets.append(cinder.default_quota_get(request, tenant_id))
        except cinder.cinder_exception.ClientException:
            disabled_quotas.update(CINDER_QUOTA_FIELDS)
            msg = _("Unable to retrieve volume limit information.")
            exceptions.handle(request, msg)

    for quota in itertools.chain(*quotasets):
        if quota.name not in disabled_quotas:
            qs[quota.name] = quota.limit
    return qs
コード例 #4
0
ファイル: workflows.py プロジェクト: tomascribb10/horizon
 def prepare_action_context(self, request, context):
     try:
         quota_defaults = nova.default_quota_get(request,
                                                 request.user.tenant_id)
         for field in quotas.NOVA_QUOTA_FIELDS:
             context[field] = quota_defaults.get(field).limit
     except Exception:
         exceptions.handle(request,
                           _('Unable to retrieve default compute quotas.'))
     return context
コード例 #5
0
ファイル: workflows.py プロジェクト: CCI-MOC/horizon
 def prepare_action_context(self, request, context):
     try:
         quota_defaults = nova.default_quota_get(request,
                                                 request.user.tenant_id)
         for field in quotas.NOVA_QUOTA_FIELDS:
             context[field] = quota_defaults.get(field).limit
     except Exception:
         exceptions.handle(request,
                           _('Unable to retrieve default compute quotas.'))
     return context
コード例 #6
0
def _get_quota_data(request,
                    tenant_mode=True,
                    disabled_quotas=None,
                    tenant_id=None):
    quotasets = []
    if not tenant_id:
        tenant_id = request.user.tenant_id
    if disabled_quotas is None:
        disabled_quotas = get_disabled_quotas(request)

    qs = base.QuotaSet()

    if 'instances' not in disabled_quotas:
        if tenant_mode:
            quotasets.append(nova.tenant_quota_get(request, tenant_id))
        else:
            quotasets.append(nova.default_quota_get(request, tenant_id))

    if 'volumes' not in disabled_quotas:
        try:
            if tenant_mode:
                quotasets.append(cinder.tenant_quota_get(request, tenant_id))
            else:
                quotasets.append(cinder.default_quota_get(request, tenant_id))
        except cinder.cinder_exception.ClientException:
            disabled_quotas.update(CINDER_QUOTA_FIELDS)
            msg = _("Unable to retrieve volume limit information.")
            exceptions.handle(request, msg)

    #mj - add the tenant_quota info from neutron - this is replaced in Queens
    if 'network' not in disabled_quotas:
        try:
            if tenant_mode:
                quotasets.append(
                    neutron.tenant_quota_get(request, tenant_id=tenant_id))
            else:
                quotasets.append(neutron.default_quota_get(request, tenant_id))

        except Exception:
            disabled_quotas.update(NEUTRON_QUOTA_FIELDS)
            msg = _('Unable to retrieve Neutron quota information.')

    for quota in itertools.chain(*quotasets):
        if quota.name not in disabled_quotas:
            qs[quota.name] = quota.limit
    return qs
コード例 #7
0
def get_default_quota_data(request, disabled_quotas=None, tenant_id=None):
    quotasets = []
    if not tenant_id:
        tenant_id = request.user.tenant_id
    if disabled_quotas is None:
        disabled_quotas = get_disabled_quotas(request)

    if NOVA_QUOTA_FIELDS - disabled_quotas:
        try:
            quotasets.append(nova.default_quota_get(request, tenant_id))
        except Exception:
            disabled_quotas.update(NOVA_QUOTA_FIELDS)
            msg = _('Unable to retrieve Nova quota information.')
            exceptions.handle(request, msg)

    if CINDER_QUOTA_FIELDS - disabled_quotas:
        try:
            quotasets.append(cinder.default_quota_get(request, tenant_id))
        except cinder.cinder_exception.ClientException:
            disabled_quotas.update(CINDER_QUOTA_FIELDS)
            msg = _("Unable to retrieve volume quota information.")
            exceptions.handle(request, msg)

    if NEUTRON_QUOTA_FIELDS - disabled_quotas:
        try:
            quotasets.append(neutron.default_quota_get(request,
                                                       tenant_id=tenant_id))
        except Exception:
            disabled_quotas.update(NEUTRON_QUOTA_FIELDS)
            msg = _('Unable to retrieve Neutron quota information.')
            exceptions.handle(request, msg)

    qs = base.QuotaSet()
    for quota in itertools.chain(*quotasets):
        if quota.name not in disabled_quotas and quota.name in QUOTA_FIELDS:
            qs[quota.name] = quota.limit
    return qs