fix(region): allow reset huawei system disk

This commit is contained in:
TangBin
2020-11-25 18:06:41 +08:00
parent 319a7ab2a2
commit 332f752ae3
+7 -1
View File
@@ -59,7 +59,13 @@ func (self *SHuaweiHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb
func (self *SHuaweiHostDriver) ValidateResetDisk(ctx context.Context, userCred mcclient.TokenCredential, disk *models.SDisk, snapshot *models.SSnapshot, guests []models.SGuest, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
if len(guests) >= 1 {
return nil, httperrors.NewBadRequestError("Disk must be dettached")
if disk.DiskType == api.DISK_TYPE_SYS {
if g := disk.GetGuest(); g != nil && g.Status != api.VM_READY {
return nil, httperrors.NewBadRequestError("Server must in status ready")
}
} else {
return nil, httperrors.NewBadRequestError("Disk must be dettached")
}
}
return data, nil
}