Merge pull request #11098 from ioito/automated-cherry-pick-of-#11097-upstream-release-3.7

Automated cherry pick of #11097: fix(region): allow update sku status
This commit is contained in:
Zexi Li
2021-05-13 20:27:35 +08:00
committed by GitHub
2 changed files with 9 additions and 7 deletions
+7
View File
@@ -140,6 +140,13 @@ type ServerSkuDetails struct {
type ServerSkuUpdateInput struct {
apis.EnabledStatusStandaloneResourceBaseUpdateInput
// 预付费状态
// default: available
PrepaidStatus string `json:"prepaid_status"`
// 后付费状态
// default: available
PostpaidStatus string `json:"postpaid_status"`
InstanceTypeFamily string `json:"instance_type_family"`
InstanceTypeCategory string `json:"instance_type_category"`
+2 -7
View File
@@ -85,8 +85,8 @@ type SServerSku struct {
InstanceTypeCategory string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"admin_optional" update:"admin"` // 通用型
LocalCategory string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"admin_optional" update:"admin" default:""` // 记录本地分类
PrepaidStatus string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"admin_optional" default:"available"` // 预付费资源状态 available|soldout
PostpaidStatus string `width:"32" charset:"utf8" nullable:"true" list:"user" create:"admin_optional" default:"available"` // 按需付费资源状态 available|soldout
PrepaidStatus string `width:"32" charset:"utf8" nullable:"true" list:"user" update:"admin" create:"admin_optional" default:"available"` // 预付费资源状态 available|soldout
PostpaidStatus string `width:"32" charset:"utf8" nullable:"true" list:"user" update:"admin" create:"admin_optional" default:"available"` // 按需付费资源状态 available|soldout
CpuArch string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"admin_optional" update:"admin"` // CPU 架构 x86|xarm
CpuCoreCount int `nullable:"false" list:"user" create:"admin_required"`
@@ -629,11 +629,6 @@ func (self *SServerSku) AllowUpdateItem(ctx context.Context, userCred mcclient.T
}
func (self *SServerSku) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ServerSkuUpdateInput) (api.ServerSkuUpdateInput, error) {
// 目前不允许改sku信息
if !inWhiteList(self.Provider) {
return input, httperrors.NewForbiddenError("can not update instance_type for public cloud %s", self.Provider)
}
if len(input.Name) > 0 {
return input, httperrors.NewUnsupportOperationError("Cannot change server sku name")
}