Documentation ¶
Index ¶
- Constants
- func AddQuotaHandler(manager *SQuotaBaseManager, prefix string, app *appsrv.Application)
- func AddUsages(ctx context.Context, userCred mcclient.TokenCredential, usages []db.IUsage)
- func CancelPendingUsage(ctx context.Context, userCred mcclient.TokenCredential, localUsage IQuota, ...) error
- func CancelUsages(ctx context.Context, userCred mcclient.TokenCredential, usages []db.IUsage)
- func CheckSetPendingQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error
- func Exceed(used, request, quota int) bool
- func GetQuotaCount(ctx context.Context, request IQuota, pendingKeys IQuotaKeys) (int, error)
- func IsBaseDomainQuotaKeys(k IQuotaKeys) bool
- func IsBaseProjectQuotaKeys(k IQuotaKeys) bool
- func KeyName(prefix, name string) string
- func LockQuota(ctx context.Context, manager IQuotaManager, quota IQuota)
- func LockQuotaKeys(ctx context.Context, manager IQuotaManager, keys IQuotaKeys)
- func NonNegative(val int) int
- func QuotaKeyString(k IQuotaKeys) string
- func QuotaKeyWeight(k IQuotaKeys) uint64
- func Register(manager IQuotaManager)
- func ReleaseQuota(ctx context.Context, manager IQuotaManager, quota IQuota)
- func ReleaseQuotaKeys(ctx context.Context, manager IQuotaManager, keys IQuotaKeys)
- type IQuota
- type IQuotaKeys
- type IQuotaManager
- type IQuotaStore
- type SBaseDomainQuotaDetailKeys
- type SBaseDomainQuotaKeys
- type SBaseProjectQuotaDetailKeys
- type SBaseProjectQuotaKeys
- type SBaseQuotaQueryInput
- type SBaseQuotaSetInput
- type SCloudResourceBaseKeys
- type SCloudResourceDetailBaseKeys
- type SCloudResourceDetailKeys
- type SCloudResourceKeys
- type SDBQuotaStore
- type SDomainRegionalCloudResourceDetailKeys
- type SDomainRegionalCloudResourceKeys
- type SOutOfQuotaError
- type SOutOfQuotaErrors
- type SQuotaBase
- type SQuotaBaseManager
- func (manager *SQuotaBaseManager) AddQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error
- func (manager *SQuotaBaseManager) CalculateQuotaUsages(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)
- func (manager *SQuotaBaseManager) DeleteAllQuotas(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error
- func (manager *SQuotaBaseManager) DeleteQuota(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error
- func (manager *SQuotaBaseManager) FetchIdNames(ctx context.Context, idMap map[string]map[string]string) (map[string]map[string]string, error)
- func (manager *SQuotaBaseManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error)
- func (manager *SQuotaBaseManager) GetChildrenQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
- func (manager *SQuotaBaseManager) GetIQuotaManager() IQuotaManager
- func (manager *SQuotaBaseManager) GetParentQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
- func (manager *SQuotaBaseManager) GetPendingUsages(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
- func (manager *SQuotaBaseManager) GetQuota(ctx context.Context, keys IQuotaKeys, quota IQuota) error
- func (manager *SQuotaBaseManager) InitializeData() error
- func (manager *SQuotaBaseManager) PostUsageJob(keys IQuotaKeys, usageChan chan IQuota, realTime bool)
- func (manager *SQuotaBaseManager) ResourceScope() rbacscope.TRbacScope
- func (manager *SQuotaBaseManager) SetQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error
- func (manager *SQuotaBaseManager) SubQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error
- type SRegionalBaseKeys
- type SRegionalCloudResourceDetailBaseKeys
- type SRegionalCloudResourceDetailKeys
- type SRegionalCloudResourceKeys
- type SZonalCloudResourceDetailKeys
- type SZonalCloudResourceKeys
- type TQuotaKeysRelation
- type TQuotaList
Constants ¶
View Source
const ( QUOTA_ACTION_ADD = "add" QUOTA_ACTION_SUB = "sub" QUOTA_ACTION_RESET = "reset" QUOTA_ACTION_REPLACE = "replace" QUOTA_ACTION_UPDATE = "update" QUOTA_ACTION_DELETE = "delete" )
View Source
const ( QuotaKeysContain = TQuotaKeysRelation("contain") QuotaKeysBelong = TQuotaKeysRelation("belong") QuotaKeysEqual = TQuotaKeysRelation("equal") QuotaKeysExclude = TQuotaKeysRelation("exclude") )
View Source
const (
APP_CONTEXT_KEY_PENDINGUSAGES = appctx.AppContextKey("pendingusages")
)
View Source
const (
METADATA_KEY = "quota"
)
Variables ¶
This section is empty.
Functions ¶
func AddQuotaHandler ¶
func AddQuotaHandler(manager *SQuotaBaseManager, prefix string, app *appsrv.Application)
func CancelPendingUsage ¶
func CancelUsages ¶
func CheckSetPendingQuota ¶
func GetQuotaCount ¶
func IsBaseDomainQuotaKeys ¶
func IsBaseDomainQuotaKeys(k IQuotaKeys) bool
func IsBaseProjectQuotaKeys ¶
func IsBaseProjectQuotaKeys(k IQuotaKeys) bool
func LockQuotaKeys ¶
func LockQuotaKeys(ctx context.Context, manager IQuotaManager, keys IQuotaKeys)
func NonNegative ¶
func QuotaKeyString ¶
func QuotaKeyString(k IQuotaKeys) string
func QuotaKeyWeight ¶
func QuotaKeyWeight(k IQuotaKeys) uint64
func Register ¶
func Register(manager IQuotaManager)
func ReleaseQuota ¶
func ReleaseQuota(ctx context.Context, manager IQuotaManager, quota IQuota)
func ReleaseQuotaKeys ¶
func ReleaseQuotaKeys(ctx context.Context, manager IQuotaManager, keys IQuotaKeys)
Types ¶
type IQuota ¶
type IQuota interface { db.IUsage GetKeys() IQuotaKeys SetKeys(IQuotaKeys) FetchSystemQuota() // FetchUsage(ctx context.Context) error Update(quota IQuota) Add(quota IQuota) Sub(quota IQuota) Allocable(quota IQuota) int ResetNegative() Exceed(request IQuota, quota IQuota) error // IsEmpty() bool ToJSON(prefix string) jsonutils.JSONObject }
type IQuotaKeys ¶
type IQuotaKeys interface { Fields() []string Values() []string Compare(IQuotaKeys) int OwnerId() mcclient.IIdentityProvider Scope() rbacscope.TRbacScope }
type IQuotaManager ¶
type IQuotaStore ¶
type IQuotaStore interface { object.IObject GetQuota(ctx context.Context, keys IQuotaKeys, quota IQuota) error GetChildrenQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error) GetParentQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error) SetQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error AddQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error SubQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error DeleteQuota(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error DeleteAllQuotas(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error }
type SBaseDomainQuotaDetailKeys ¶
type SBaseDomainQuotaDetailKeys struct { // 配额适用的项目的域名称 Domain string `json:"domain"` }
type SBaseDomainQuotaKeys ¶
type SBaseDomainQuotaKeys struct { // 配额适用的域ID DomainId string `width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"domain_id"` }
func OwnerIdDomainQuotaKeys ¶
func OwnerIdDomainQuotaKeys(ownerId mcclient.IIdentityProvider) SBaseDomainQuotaKeys
func (SBaseDomainQuotaKeys) Compare ¶
func (k1 SBaseDomainQuotaKeys) Compare(ik IQuotaKeys) int
func (SBaseDomainQuotaKeys) Fields ¶
func (k SBaseDomainQuotaKeys) Fields() []string
func (SBaseDomainQuotaKeys) OwnerId ¶
func (k SBaseDomainQuotaKeys) OwnerId() mcclient.IIdentityProvider
func (SBaseDomainQuotaKeys) Scope ¶
func (k SBaseDomainQuotaKeys) Scope() rbacscope.TRbacScope
func (SBaseDomainQuotaKeys) Values ¶
func (k SBaseDomainQuotaKeys) Values() []string
type SBaseProjectQuotaDetailKeys ¶
type SBaseProjectQuotaDetailKeys struct { SBaseDomainQuotaDetailKeys // 配额适用的项目名称 Project string `json:"project"` }
type SBaseProjectQuotaKeys ¶
type SBaseProjectQuotaKeys struct { SBaseDomainQuotaKeys // 配额适用的项目ID ProjectId string `name:"tenant_id" width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"project_id"` }
func OwnerIdProjectQuotaKeys ¶
func OwnerIdProjectQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) SBaseProjectQuotaKeys
func (SBaseProjectQuotaKeys) Compare ¶
func (k1 SBaseProjectQuotaKeys) Compare(ik IQuotaKeys) int
func (SBaseProjectQuotaKeys) Fields ¶
func (k SBaseProjectQuotaKeys) Fields() []string
func (SBaseProjectQuotaKeys) OwnerId ¶
func (k SBaseProjectQuotaKeys) OwnerId() mcclient.IIdentityProvider
func (SBaseProjectQuotaKeys) Scope ¶
func (k SBaseProjectQuotaKeys) Scope() rbacscope.TRbacScope
func (SBaseProjectQuotaKeys) Values ¶
func (k SBaseProjectQuotaKeys) Values() []string
type SBaseQuotaQueryInput ¶
type SBaseQuotaSetInput ¶
type SBaseQuotaSetInput struct { // 设置配额操作 // // | action | 说明 | // |---------|-------------------------------------------| // | add | 增量增加配额 | // | sub | 增量减少配额 | // | reset | 重置所有配额为0 | // | replace | 替换所有配额,对于不存在的配额项,设置为0 | // | update | 更新存在的配额 | // | delete | 删除配额 | // Action string `json:"action"` }
type SCloudResourceBaseKeys ¶
type SCloudResourceBaseKeys struct { // 配额适用的平台名称,参考List接口的平台列表 Provider string `width:"32" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"provider"` // 配额适用的品牌名称,参考List接口的品牌列表 Brand string `width:"32" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"brand"` // 配额适用的云环境,参考List接口的云环境列表 CloudEnv string `width:"32" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"cloud_env"` // 配额适用的云账号ID AccountId string `width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"account_id"` // 配额适用的云订阅ID ManagerId string `width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"manager_id"` }
func (SCloudResourceBaseKeys) Fields ¶
func (k SCloudResourceBaseKeys) Fields() []string
func (SCloudResourceBaseKeys) Values ¶
func (k SCloudResourceBaseKeys) Values() []string
type SCloudResourceDetailKeys ¶
type SCloudResourceDetailKeys struct { SBaseProjectQuotaDetailKeys SCloudResourceDetailBaseKeys }
type SCloudResourceKeys ¶
type SCloudResourceKeys struct { SBaseProjectQuotaKeys SCloudResourceBaseKeys }
func (SCloudResourceKeys) Compare ¶
func (k1 SCloudResourceKeys) Compare(ik IQuotaKeys) int
func (SCloudResourceKeys) Fields ¶
func (k SCloudResourceKeys) Fields() []string
func (SCloudResourceKeys) Values ¶
func (k SCloudResourceKeys) Values() []string
type SDBQuotaStore ¶
type SDBQuotaStore struct { }
func (*SDBQuotaStore) GetQuota ¶
func (store *SDBQuotaStore) GetQuota(ctx context.Context, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, quota IQuota) error
type SDomainRegionalCloudResourceDetailKeys ¶
type SDomainRegionalCloudResourceDetailKeys struct { SBaseDomainQuotaDetailKeys SCloudResourceDetailBaseKeys SRegionalCloudResourceDetailBaseKeys }
type SDomainRegionalCloudResourceKeys ¶
type SDomainRegionalCloudResourceKeys struct { SBaseDomainQuotaKeys SCloudResourceBaseKeys SRegionalBaseKeys }
func (SDomainRegionalCloudResourceKeys) Compare ¶
func (k1 SDomainRegionalCloudResourceKeys) Compare(ik IQuotaKeys) int
func (SDomainRegionalCloudResourceKeys) Fields ¶
func (k SDomainRegionalCloudResourceKeys) Fields() []string
func (SDomainRegionalCloudResourceKeys) Values ¶
func (k SDomainRegionalCloudResourceKeys) Values() []string
type SOutOfQuotaError ¶
type SOutOfQuotaError struct {
// contains filtered or unexported fields
}
func (*SOutOfQuotaError) Cause ¶
func (e *SOutOfQuotaError) Cause() error
func (*SOutOfQuotaError) Error ¶
func (e *SOutOfQuotaError) Error() string
type SOutOfQuotaErrors ¶
type SOutOfQuotaErrors struct {
// contains filtered or unexported fields
}
func NewOutOfQuotaError ¶
func NewOutOfQuotaError() *SOutOfQuotaErrors
func (*SOutOfQuotaErrors) Cause ¶
func (es *SOutOfQuotaErrors) Cause() error
func (*SOutOfQuotaErrors) Error ¶
func (es *SOutOfQuotaErrors) Error() string
func (*SOutOfQuotaErrors) IsError ¶
func (es *SOutOfQuotaErrors) IsError() bool
type SQuotaBase ¶
type SQuotaBase struct {
db.SResourceBase
}
type SQuotaBaseManager ¶
type SQuotaBaseManager struct { db.SResourceBaseManager // contains filtered or unexported fields }
func NewQuotaBaseManager ¶
func NewQuotaBaseManager(model interface{}, scope rbacscope.TRbacScope, tableName string, pendingStore IQuotaStore, usageStore IQuotaStore, keyword, keywordPlural string) SQuotaBaseManager
func NewQuotaUsageManager ¶
func NewQuotaUsageManager(model interface{}, scope rbacscope.TRbacScope, tableName string, keyword, keywordPlural string) SQuotaBaseManager
func (*SQuotaBaseManager) AddQuota ¶
func (manager *SQuotaBaseManager) AddQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error
func (*SQuotaBaseManager) CalculateQuotaUsages ¶
func (manager *SQuotaBaseManager) CalculateQuotaUsages(ctx context.Context, userCred mcclient.TokenCredential, isStart bool)
func (*SQuotaBaseManager) DeleteAllQuotas ¶
func (manager *SQuotaBaseManager) DeleteAllQuotas(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error
func (*SQuotaBaseManager) DeleteQuota ¶
func (manager *SQuotaBaseManager) DeleteQuota(ctx context.Context, userCred mcclient.TokenCredential, keys IQuotaKeys) error
func (*SQuotaBaseManager) FetchIdNames ¶
func (*SQuotaBaseManager) FetchOwnerId ¶
func (manager *SQuotaBaseManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error)
func (*SQuotaBaseManager) GetChildrenQuotas ¶
func (manager *SQuotaBaseManager) GetChildrenQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
func (*SQuotaBaseManager) GetIQuotaManager ¶
func (manager *SQuotaBaseManager) GetIQuotaManager() IQuotaManager
func (*SQuotaBaseManager) GetParentQuotas ¶
func (manager *SQuotaBaseManager) GetParentQuotas(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
func (*SQuotaBaseManager) GetPendingUsages ¶
func (manager *SQuotaBaseManager) GetPendingUsages(ctx context.Context, keys IQuotaKeys) ([]IQuota, error)
func (*SQuotaBaseManager) GetQuota ¶
func (manager *SQuotaBaseManager) GetQuota(ctx context.Context, keys IQuotaKeys, quota IQuota) error
func (*SQuotaBaseManager) InitializeData ¶
func (manager *SQuotaBaseManager) InitializeData() error
func (*SQuotaBaseManager) PostUsageJob ¶
func (manager *SQuotaBaseManager) PostUsageJob(keys IQuotaKeys, usageChan chan IQuota, realTime bool)
func (*SQuotaBaseManager) ResourceScope ¶
func (manager *SQuotaBaseManager) ResourceScope() rbacscope.TRbacScope
func (*SQuotaBaseManager) SetQuota ¶
func (manager *SQuotaBaseManager) SetQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error
func (*SQuotaBaseManager) SubQuota ¶
func (manager *SQuotaBaseManager) SubQuota(ctx context.Context, userCred mcclient.TokenCredential, diff IQuota) error
type SRegionalBaseKeys ¶
type SRegionalBaseKeys struct { // 配额适用的区域ID RegionId string `width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"region_id"` }
type SRegionalCloudResourceDetailBaseKeys ¶
type SRegionalCloudResourceDetailBaseKeys struct { // 配额适用的区域名称 Region string `json:"region"` }
type SRegionalCloudResourceDetailKeys ¶
type SRegionalCloudResourceDetailKeys struct { SCloudResourceDetailKeys SRegionalCloudResourceDetailBaseKeys }
type SRegionalCloudResourceKeys ¶
type SRegionalCloudResourceKeys struct { SCloudResourceKeys SRegionalBaseKeys }
func (SRegionalCloudResourceKeys) Compare ¶
func (k1 SRegionalCloudResourceKeys) Compare(ik IQuotaKeys) int
func (SRegionalCloudResourceKeys) Fields ¶
func (k SRegionalCloudResourceKeys) Fields() []string
func (SRegionalCloudResourceKeys) Values ¶
func (k SRegionalCloudResourceKeys) Values() []string
type SZonalCloudResourceDetailKeys ¶
type SZonalCloudResourceDetailKeys struct { SRegionalCloudResourceDetailKeys // 配额适用的可用区名称 Zone string `json:"zone"` }
type SZonalCloudResourceKeys ¶
type SZonalCloudResourceKeys struct { SRegionalCloudResourceKeys // 配额适用的可用区ID ZoneId string `width:"64" charset:"ascii" nullable:"false" primary:"true" list:"user" json:"zone_id"` }
func (SZonalCloudResourceKeys) Compare ¶
func (k1 SZonalCloudResourceKeys) Compare(ik IQuotaKeys) int
func (SZonalCloudResourceKeys) Fields ¶
func (k SZonalCloudResourceKeys) Fields() []string
func (SZonalCloudResourceKeys) Values ¶
func (k SZonalCloudResourceKeys) Values() []string
type TQuotaKeysRelation ¶
type TQuotaKeysRelation string
type TQuotaList ¶
type TQuotaList []IQuota
func (TQuotaList) Len ¶
func (a TQuotaList) Len() int
func (TQuotaList) Less ¶
func (a TQuotaList) Less(i, j int) bool
func (TQuotaList) Swap ¶
func (a TQuotaList) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.