def quota_defaults(mgr_or_client, **kwargs): quota_client = _g_quotas_client(mgr_or_client) tenant_id = kwargs.pop('tenant', None) if tenant_id is None: tenant_id = keys.tenant_get_by_name(mgr_or_client, 'admin')['id'] quota = quota_client.show_default_quota_set(tenant_id) quota = quota['quota_set'] if 'quota_set' in quota else quota return quota
def quota_update(mgr_or_client, tenant_id, **kwargs): quota_client = _g_quotas_client(mgr_or_client) try: tenant_id = keys.tenant_get_by_name(mgr_or_client, tenant_id) ['id'] except Exception: pass quota = quota_client.update_quota_set(tenant_id, **kwargs) quota = quota['quota_set'] if 'quota_set' in quota else quota return quota
def quota_show(mgr_or_client, **kwargs): quota_client = _g_quotas_client(mgr_or_client) tenant_id = kwargs.pop('tenant', 'admin') try: tenant_id = keys.tenant_get_by_name(mgr_or_client, tenant_id) ['id'] except Exception: pass quotas = quota_client.show_quota_set(tenant_id, **kwargs) quotas = quotas['quota_set'] if 'quota_set' in quotas else quotas return quotas
def quota_delete(mgr_or_client, **kwargs): quota_client = _g_quotas_client(mgr_or_client) tenant_id = kwargs.pop('tenant', None) if tenant_id is None: raise Exception("error: argument --tenant is required.") try: tenant_id = keys.tenant_get_by_name(mgr_or_client, tenant_id) ['id'] except Exception: pass quota = quota_client.delete_quota_set(tenant_id) quota = quota['quota_set'] if 'quota_set' in quota else quota return quota