From 08568e3600caa2ddcc6535367d8e576b331f5235 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Mon, 16 Sep 2024 16:54:59 +1000 Subject: [PATCH] log more info about disk additions --- server/handler/vmModify.go | 8 ++++++++ server/models/models.go | 42 +++++++++++++++++++++++++++++++------- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/server/handler/vmModify.go b/server/handler/vmModify.go index 4c63260..a580a2a 100644 --- a/server/handler/vmModify.go +++ b/server/handler/vmModify.go @@ -204,6 +204,14 @@ func (h *Handler) calculateNewDiskSize(event models.CloudEventReceived) float64 // Calculate the total disk allocated in GB for _, device := range vmObject.Vm.Config.Hardware.Device { if disk, ok := device.(*types.VirtualDisk); ok { + + // Print the filename of the backing device + if backing, ok := disk.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok { + h.Logger.Debug("Adding disk", "size_bytes", disk.CapacityInBytes, "backing_file", backing.FileName) + } else { + h.Logger.Debug("Adding disk, unknown backing type", "size_bytes", disk.CapacityInBytes) + } + diskSize += float64(disk.CapacityInBytes / 1024 / 1024 / 1024) // Convert from bytes to GB } } diff --git a/server/models/models.go b/server/models/models.go index 8ba38ac..282c731 100644 --- a/server/models/models.go +++ b/server/models/models.go @@ -68,6 +68,7 @@ type ConfigChangesReceived struct { Modified string `json:"modified"` } +// This probably needs more fields added so not in use yet type ConfigSpec struct { AlternateGuestName string `json:"AlternateGuestName"` Annotation string `json:"Annotation"` @@ -86,6 +87,12 @@ type ConfigSpec struct { Backing any `json:"Backing"` Device struct { Backing struct { + Port struct { + ConnectionCookie int `json:"ConnectionCookie"` + PortKey string `json:"PortKey"` + PortgroupKey string `json:"PortgroupKey"` + SwitchUUID string `json:"SwitchUuid"` + } `json:"Port"` BackingObjectID string `json:"BackingObjectId"` ChangeID string `json:"ChangeId"` ContentID string `json:"ContentId"` @@ -108,17 +115,39 @@ type ConfigSpec struct { UUID string `json:"Uuid"` WriteThrough any `json:"WriteThrough"` } `json:"Backing"` - CapacityInBytes int `json:"CapacityInBytes"` - CapacityInKB int `json:"CapacityInKB"` - Connectable any `json:"Connectable"` - ControllerKey int `json:"ControllerKey"` - DeviceInfo any `json:"DeviceInfo"` + CapacityInBytes int `json:"CapacityInBytes"` + CapacityInKB int `json:"CapacityInKB"` + Connectable struct { + AllowGuestControl bool `json:"AllowGuestControl"` + Connected bool `json:"Connected"` + MigrateConnect string `json:"MigrateConnect"` + StartConnected bool `json:"StartConnected"` + Status string `json:"Status"` + } `json:"Connectable"` + ControllerKey int `json:"ControllerKey"` + DeviceInfo struct { + Label string `json:"Label"` + Summary string `json:"Summary"` + } `json:"DeviceInfo"` + ExternalID string `json:"ExternalId"` + MacAddress string `json:"MacAddress"` + ResourceAllocation struct { + Limit int `json:"Limit"` + Reservation int `json:"Reservation"` + Share struct { + Level string `json:"Level"` + Shares int `json:"Shares"` + } `json:"Share"` + } `json:"ResourceAllocation"` + SlotInfo any `json:"SlotInfo"` + UnitNumber int `json:"UnitNumber"` + UptCompatibilityEnabled bool `json:"UptCompatibilityEnabled"` + WakeOnLanEnabled bool `json:"WakeOnLanEnabled"` DiskObjectID string `json:"DiskObjectId"` Iofilter any `json:"Iofilter"` Key int `json:"Key"` NativeUnmanagedLinkedClone any `json:"NativeUnmanagedLinkedClone"` Shares any `json:"Shares"` - SlotInfo any `json:"SlotInfo"` StorageIOAllocation struct { Limit int `json:"Limit"` Reservation any `json:"Reservation"` @@ -127,7 +156,6 @@ type ConfigSpec struct { Shares int `json:"Shares"` } `json:"Shares"` } `json:"StorageIOAllocation"` - UnitNumber int `json:"UnitNumber"` VDiskID any `json:"VDiskId"` VFlashCacheConfigInfo any `json:"VFlashCacheConfigInfo"` } `json:"Device"`