mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #691 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-qcloud-sysdisk-size-validate to release/2.3.0
* commit '7d97609cdd71942688fbda9ee2787bccc79fa739': 加入腾讯云系统盘大小验证信息
This commit is contained in:
@@ -96,6 +96,24 @@ func (self *SQcloudGuestDriver) ValidateCreateData(ctx context.Context, userCred
|
||||
if data.Contains("net.0") && data.Contains("net.1") {
|
||||
return nil, httperrors.NewInputParameterError("cannot support more than 1 nic")
|
||||
}
|
||||
sysDisk := models.SDiskConfig{}
|
||||
if err := data.Unmarshal(&sysDisk, "disk.0"); err != nil {
|
||||
return nil, fmt.Errorf("Missing system disk information")
|
||||
}
|
||||
switch sysDisk.Backend {
|
||||
case models.STORAGE_CLOUD_BASIC, models.STORAGE_CLOUD_SSD:
|
||||
if sysDisk.SizeMb < 50*10024 || sysDisk.SizeMb > 500*1024 {
|
||||
return nil, fmt.Errorf("The %s system disk size must be in the range of 50 ~ 500GB", sysDisk.Backend)
|
||||
}
|
||||
case models.STORAGE_CLOUD_PREMIUM:
|
||||
if sysDisk.SizeMb < 50*1024 || sysDisk.SizeMb > 1024*1024 {
|
||||
return nil, fmt.Errorf("The %s system disk size must be in the range of 50 ~ 1024GB", sysDisk.Backend)
|
||||
}
|
||||
default:
|
||||
if sysDisk.SizeMb < 50*1024 {
|
||||
return nil, fmt.Errorf("The system disk must be greater than or equal to 50GB")
|
||||
}
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user