fix(region): guestdisk list add auto reset column (#22346)

This commit is contained in:
wanyaoqi
2025-03-26 15:07:13 +08:00
committed by GitHub
parent 2ff5f9331f
commit 4edc483209
6 changed files with 13 additions and 0 deletions
+2
View File
@@ -261,6 +261,8 @@ type DiskUpdateInput struct {
// 磁盘类型
DiskType string `json:"disk_type"`
// 关机自动重置
AutoReset *bool `json:"auto_reset"`
}
type DiskSaveInput struct {
+2
View File
@@ -34,6 +34,8 @@ type GuestDiskDetails struct {
// 磁盘类型
// example: data
DiskType string `json:"disk_type"`
// 关机自动重置
AutoReset bool `json:"auto_reset"`
// 介质类型
// example: ssd
MediumType string `json:"medium_type"`
+1
View File
@@ -359,6 +359,7 @@ type GuestDiskInfo struct {
Driver string `json:"driver"`
CacheMode string `json:"cache_mode"`
AioMode string `json:"aio_mode"`
AutoReset bool `json:"auto_reset"`
MediumType string `json:"medium_type"`
StorageType string `json:"storage_type"`
Iops int `json:"iops"`
+6
View File
@@ -432,6 +432,12 @@ func (self *SDisk) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok
}
}
if input.AutoReset != nil && *input.AutoReset != self.AutoReset {
if guest := self.GetGuest(); guest != nil && guest.Status != api.VM_READY {
return input, httperrors.NewBadRequestError("Can't set disk auto_reset on guest status %s", guest.Status)
}
}
storage, _ := self.GetStorage()
if storage == nil {
return input, httperrors.NewNotFoundError("failed to find storage for disk %s", self.Name)
+1
View File
@@ -379,6 +379,7 @@ func fetchGuestDisksInfo(guestIds []string) map[string][]api.GuestDiskInfo {
guestdisks.Field("driver"),
guestdisks.Field("cache_mode"),
guestdisks.Field("aio_mode"),
disks.Field("auto_reset"),
storages.Field("medium_type"),
storages.Field("storage_type"),
guestdisks.Field("iops"),
+1
View File
@@ -147,6 +147,7 @@ func (manager *SGuestdiskManager) FetchCustomizeColumns(
rows[i].Status = disk.Status
rows[i].DiskSize = disk.DiskSize
rows[i].DiskType = disk.DiskType
rows[i].AutoReset = disk.AutoReset
storage, _ := disk.GetStorage()
if storage != nil {
rows[i].StorageType = storage.StorageType