Skip to content

Commit c653df8

Browse files
committed
fix(region): guestdisk list add auto_reset column
1 parent d606c9d commit c653df8

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

pkg/apis/compute/disk.go

+2
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ type DiskUpdateInput struct {
254254

255255
// 磁盘类型
256256
DiskType string `json:"disk_type"`
257+
// 关机自动重置
258+
AutoReset *bool `json:"auto_reset"`
257259
}
258260

259261
type DiskSaveInput struct {

pkg/apis/compute/guest_disk.go

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ type GuestDiskDetails struct {
3434
// 磁盘类型
3535
// example: data
3636
DiskType string `json:"disk_type"`
37+
// 关机自动重置
38+
AutoReset bool `json:"auto_reset"`
3739
// 介质类型
3840
// example: ssd
3941
MediumType string `json:"medium_type"`

pkg/compute/models/disks.go

+6
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ func (self *SDisk) ValidateUpdateData(ctx context.Context, userCred mcclient.Tok
439439
}
440440
}
441441

442+
if input.AutoReset != nil && *input.AutoReset != self.AutoReset {
443+
if guest := self.GetGuest(); guest != nil && guest.Status != api.VM_READY {
444+
return input, httperrors.NewBadRequestError("Can't set disk auto_reset on guest status %s", guest.Status)
445+
}
446+
}
447+
442448
storage, _ := self.GetStorage()
443449
if storage == nil {
444450
return input, httperrors.NewNotFoundError("failed to find storage for disk %s", self.Name)

pkg/compute/models/guestdisks.go

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ func (manager *SGuestdiskManager) FetchCustomizeColumns(
131131
rows[i].Status = disk.Status
132132
rows[i].DiskSize = disk.DiskSize
133133
rows[i].DiskType = disk.DiskType
134+
rows[i].AutoReset = disk.AutoReset
134135
storage, _ := disk.GetStorage()
135136
if storage != nil {
136137
rows[i].StorageType = storage.StorageType

0 commit comments

Comments
 (0)