From 45d5ed5b96ccfa1b93dee2af7cffa9bd6aef8883 Mon Sep 17 00:00:00 2001 From: ioito Date: Thu, 21 Dec 2023 20:54:39 +0800 Subject: [PATCH] fix(region): add disk preallocation for guest info --- pkg/apis/compute/guests.go | 37 +++++++++++++++-------------- pkg/compute/models/guest_queries.go | 1 + 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkg/apis/compute/guests.go b/pkg/apis/compute/guests.go index 2a8c8904e80..02ce0452118 100644 --- a/pkg/apis/compute/guests.go +++ b/pkg/apis/compute/guests.go @@ -345,24 +345,25 @@ func (self ServerDetails) GetMetricPairs() map[string]string { // GuestDiskInfo describe the information of disk on the guest. type GuestDiskInfo struct { - Id string `json:"id"` - Name string `json:"name"` - FsFormat string `json:"fs,omitempty"` - DiskType string `json:"disk_type"` - Index int8 `json:"index"` - BootIndex int8 `json:"boot_index"` - SizeMb int `json:"size"` - DiskFormat string `json:"disk_format"` - Driver string `json:"driver"` - CacheMode string `json:"cache_mode"` - AioMode string `json:"aio_mode"` - MediumType string `json:"medium_type"` - StorageType string `json:"storage_type"` - Iops int `json:"iops"` - Bps int `json:"bps"` - ImageId string `json:"image_id,omitempty"` - Image string `json:"image,omitemtpy"` - StorageId string `json:"storage_id"` + Id string `json:"id"` + Name string `json:"name"` + FsFormat string `json:"fs,omitempty"` + DiskType string `json:"disk_type"` + Index int8 `json:"index"` + BootIndex int8 `json:"boot_index"` + SizeMb int `json:"size"` + DiskFormat string `json:"disk_format"` + Driver string `json:"driver"` + CacheMode string `json:"cache_mode"` + AioMode string `json:"aio_mode"` + MediumType string `json:"medium_type"` + StorageType string `json:"storage_type"` + Iops int `json:"iops"` + Bps int `json:"bps"` + ImageId string `json:"image_id,omitempty"` + Image string `json:"image,omitemtpy"` + StorageId string `json:"storage_id"` + Preallocation string `json:"preallocation"` } func (self GuestDiskInfo) ShortDesc() string { diff --git a/pkg/compute/models/guest_queries.go b/pkg/compute/models/guest_queries.go index b62cb08330d..75c24d5c89c 100644 --- a/pkg/compute/models/guest_queries.go +++ b/pkg/compute/models/guest_queries.go @@ -320,6 +320,7 @@ func fetchGuestDisksInfo(guestIds []string) map[string][]api.GuestDiskInfo { guestdisks.Field("guest_id"), guestdisks.Field("boot_index"), disks.Field("storage_id"), + disks.Field("preallocation"), ) q = q.Join(guestdisks, sqlchemy.Equals(guestdisks.Field("disk_id"), disks.Field("id"))) q = q.Join(storages, sqlchemy.Equals(disks.Field("storage_id"), storages.Field("id")))