mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): public cloud sku create (#24229)
This commit is contained in:
@@ -320,22 +320,6 @@ func (self *SServerSkuManager) ValidateCreateData(ctx context.Context, userCred
|
||||
region, _ = zone.GetRegion()
|
||||
}
|
||||
|
||||
if input.CpuCoreCount < 1 || input.CpuCoreCount > options.Options.SkuMaxCpuCount {
|
||||
return input, httperrors.NewOutOfRangeError("cpu_core_count should be range of 1~%d", options.Options.SkuMaxCpuCount)
|
||||
}
|
||||
|
||||
if input.MemorySizeMB < 512 || input.MemorySizeMB > 1024*options.Options.SkuMaxMemSize {
|
||||
return input, httperrors.NewOutOfRangeError("memory_size_mb, shoud be range of 512~%d", 1024*options.Options.SkuMaxMemSize)
|
||||
}
|
||||
|
||||
if len(input.InstanceTypeCategory) == 0 {
|
||||
input.InstanceTypeCategory = api.SkuCategoryGeneralPurpose
|
||||
}
|
||||
|
||||
if !utils.IsInStringArray(input.InstanceTypeCategory, api.SKU_FAMILIES) {
|
||||
return input, httperrors.NewInputParameterError("instance_type_category shoud be one of %s", api.SKU_FAMILIES)
|
||||
}
|
||||
|
||||
if input.Enabled == nil {
|
||||
enabled := true
|
||||
input.Enabled = &enabled
|
||||
@@ -346,14 +330,41 @@ func (self *SServerSkuManager) ValidateCreateData(ctx context.Context, userCred
|
||||
if region != nil {
|
||||
input.Provider = region.Provider
|
||||
}
|
||||
|
||||
if input.Provider == api.CLOUD_PROVIDER_ONECLOUD {
|
||||
input.CloudregionId = api.DEFAULT_REGION_ID
|
||||
} else if utils.IsInStringArray(input.Provider, api.PRIVATE_CLOUD_PROVIDERS) {
|
||||
input.Status = api.SkuStatusCreating
|
||||
}
|
||||
|
||||
input.LocalCategory = input.InstanceTypeCategory
|
||||
input.InstanceTypeFamily = api.InstanceFamilies[input.InstanceTypeCategory]
|
||||
if !utils.IsInStringArray(input.Provider, api.PUBLIC_CLOUD_PROVIDERS) {
|
||||
if input.CpuCoreCount < 1 || input.CpuCoreCount > options.Options.SkuMaxCpuCount {
|
||||
return input, httperrors.NewOutOfRangeError("cpu_core_count should be range of 1~%d", options.Options.SkuMaxCpuCount)
|
||||
}
|
||||
|
||||
if input.MemorySizeMB < 512 || input.MemorySizeMB > 1024*options.Options.SkuMaxMemSize {
|
||||
return input, httperrors.NewOutOfRangeError("memory_size_mb, shoud be range of 512~%d", 1024*options.Options.SkuMaxMemSize)
|
||||
}
|
||||
|
||||
if len(input.InstanceTypeCategory) == 0 {
|
||||
input.InstanceTypeCategory = api.SkuCategoryGeneralPurpose
|
||||
}
|
||||
|
||||
if !utils.IsInStringArray(input.InstanceTypeCategory, api.SKU_FAMILIES) {
|
||||
return input, httperrors.NewInputParameterError("instance_type_category shoud be one of %s", api.SKU_FAMILIES)
|
||||
}
|
||||
|
||||
input.LocalCategory = input.InstanceTypeCategory
|
||||
input.InstanceTypeFamily = api.InstanceFamilies[input.InstanceTypeCategory]
|
||||
}
|
||||
|
||||
if len(input.LocalCategory) == 0 {
|
||||
input.LocalCategory = input.InstanceTypeCategory
|
||||
}
|
||||
|
||||
if len(input.InstanceTypeFamily) == 0 {
|
||||
input.InstanceTypeFamily = api.InstanceFamilies[input.InstanceTypeCategory]
|
||||
}
|
||||
|
||||
var err error
|
||||
if len(input.Name) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user