mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
fix(region): allow delete server sku (#23693)
This commit is contained in:
@@ -193,11 +193,6 @@ func sliceToJsonObject(items []int) jsonutils.JSONObject {
|
||||
return ret
|
||||
}
|
||||
|
||||
func inWhiteList(provider string) bool {
|
||||
// 私有云套餐也允许更新删除
|
||||
return provider == api.CLOUD_PROVIDER_ONECLOUD || utils.IsInStringArray(provider, api.PRIVATE_CLOUD_PROVIDERS)
|
||||
}
|
||||
|
||||
func genInstanceType(family string, cpu, memMb int64) (string, error) {
|
||||
if cpu <= 0 {
|
||||
return "", fmt.Errorf("cpu_core_count should great than zero")
|
||||
@@ -679,9 +674,10 @@ func (self *SServerSku) ValidateDeleteCondition(ctx context.Context, info *api.S
|
||||
return httperrors.NewNotEmptyError("now allow to delete inuse instance_type.please remove related servers first: %s", self.Name)
|
||||
}
|
||||
|
||||
if !inWhiteList(self.Provider) {
|
||||
if !options.Options.EnableDeletePublicCloudSku && utils.IsInStringArray(self.Provider, api.PUBLIC_CLOUD_PROVIDERS) {
|
||||
return httperrors.NewForbiddenError("not allow to delete public cloud instance_type: %s", self.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,7 @@ type ComputeOptions struct {
|
||||
ServerSkuSyncIntervalMinutes int `default:"60" help:"Interval to sync public cloud server skus, defualt is 1 hour"`
|
||||
SkuBatchSync int `default:"5" help:"How many skus can be sync in a batch"`
|
||||
|
||||
EnableDeletePublicCloudSku bool `help:"Enable delete public cloud sku" default:"true"`
|
||||
// sku sync
|
||||
SyncSkusDay int `default:"1" help:"Days auto sync skus data, default 1 day"`
|
||||
SyncSkusHour int `default:"3" help:"What hour start sync skus, default 03:00"`
|
||||
|
||||
Reference in New Issue
Block a user