mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 18:42:58 +00:00
fix(provider): maxint for storage and vms (#694)
* fix(provider): use int64 for vm and disk storage Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de> * revert changes for memory Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de> * revert changes for memory Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de> * fix test Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> * fix int -> int64 conversion for disk size Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de> Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
74ddd82550
commit
5fe6892724
@ -37,13 +37,13 @@ type ResourcesListResponseData struct {
|
||||
CgroupMode int `json:"cgroup-mode,omitempty"`
|
||||
Content int `json:"content,omitempty"`
|
||||
CPU float64 `json:"cpu,omitempty"`
|
||||
Disk int `json:"disk,omitempty"`
|
||||
Disk int64 `json:"disk,omitempty"`
|
||||
HaState string `json:"hastate,omitempty"`
|
||||
Level string `json:"level,omitempty"`
|
||||
MaxCPU float64 `json:"maxcpu,omitempty"`
|
||||
MaxDisk int `json:"maxdisk,omitempty"`
|
||||
MaxMem int `json:"maxmem,omitempty"`
|
||||
Mem int `json:"mem,omitempty"`
|
||||
MaxDisk int64 `json:"maxdisk,omitempty"`
|
||||
MaxMem int64 `json:"maxmem,omitempty"`
|
||||
Mem int64 `json:"mem,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
NodeName string `json:"node,omitempty"`
|
||||
PluginType string `json:"plugintype,omitempty"`
|
||||
|
@ -184,7 +184,6 @@ type CustomStorageDevice struct {
|
||||
Interface *string
|
||||
ID *string
|
||||
FileID *string
|
||||
SizeInt *int
|
||||
}
|
||||
|
||||
// PathInDatastore returns path part of FileVolume or nil if it is not yet allocated.
|
||||
@ -433,11 +432,11 @@ type GetResponseData struct {
|
||||
CPULimit *types.CustomInt `json:"cpulimit,omitempty"`
|
||||
CPUSockets *int `json:"sockets,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty"`
|
||||
DedicatedMemory *int64 `json:"memory,omitempty"`
|
||||
DeletionProtection *types.CustomBool `json:"protection,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
EFIDisk *CustomEFIDisk `json:"efidisk0,omitempty"`
|
||||
FloatingMemory *int `json:"balloon,omitempty"`
|
||||
FloatingMemory *int64 `json:"balloon,omitempty"`
|
||||
FloatingMemoryShares *int `json:"shares,omitempty"`
|
||||
Freeze *types.CustomBool `json:"freeze,omitempty"`
|
||||
HookScript *string `json:"hookscript,omitempty"`
|
||||
@ -555,11 +554,11 @@ type GetStatusResponseData struct {
|
||||
AgentEnabled *types.CustomBool `json:"agent,omitempty"`
|
||||
CPUCount *float64 `json:"cpus,omitempty"`
|
||||
Lock *string `json:"lock,omitempty"`
|
||||
MemoryAllocation *int `json:"maxmem,omitempty"`
|
||||
MemoryAllocation *int64 `json:"maxmem,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
PID *int `json:"pid,omitempty"`
|
||||
QMPStatus *string `json:"qmpstatus,omitempty"`
|
||||
RootDiskSize *int `json:"maxdisk,omitempty"`
|
||||
RootDiskSize *int64 `json:"maxdisk,omitempty"`
|
||||
SpiceSupport *types.CustomBool `json:"spice,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Tags *string `json:"tags,omitempty"`
|
||||
|
@ -28,17 +28,17 @@ func (r DiskSize) String() string {
|
||||
}
|
||||
|
||||
// InMegabytes returns the disk size in megabytes.
|
||||
func (r DiskSize) InMegabytes() int {
|
||||
return int(int64(r) / 1024 / 1024)
|
||||
func (r DiskSize) InMegabytes() int64 {
|
||||
return int64(r) / 1024 / 1024
|
||||
}
|
||||
|
||||
// InGigabytes returns the disk size in gigabytes.
|
||||
func (r DiskSize) InGigabytes() int {
|
||||
return int(int64(r) / 1024 / 1024 / 1024)
|
||||
func (r DiskSize) InGigabytes() int64 {
|
||||
return int64(r) / 1024 / 1024 / 1024
|
||||
}
|
||||
|
||||
// DiskSizeFromGigabytes creates a DiskSize from gigabytes.
|
||||
func DiskSizeFromGigabytes(size int) DiskSize {
|
||||
func DiskSizeFromGigabytes(size int64) DiskSize {
|
||||
return DiskSize(size * 1024 * 1024 * 1024)
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func TestToFromGigabytes(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
size int
|
||||
size int64
|
||||
want string
|
||||
}{
|
||||
{"handle 0 size", 0, "0"},
|
||||
|
@ -2154,7 +2154,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
diskBlock := disk[i].(map[string]interface{})
|
||||
diskInterface := diskBlock[mkResourceVirtualEnvironmentVMDiskInterface].(string)
|
||||
dataStoreID := diskBlock[mkResourceVirtualEnvironmentVMDiskDatastoreID].(string)
|
||||
diskSize := diskBlock[mkResourceVirtualEnvironmentVMDiskSize].(int)
|
||||
diskSize := int64(diskBlock[mkResourceVirtualEnvironmentVMDiskSize].(int))
|
||||
prefix := diskDigitPrefix(diskInterface)
|
||||
|
||||
currentDiskInfo := allDiskInfo[diskInterface]
|
||||
@ -3120,9 +3120,8 @@ func vmGetDiskDeviceObjects(
|
||||
diskDevice.Interface = &diskInterface
|
||||
diskDevice.Format = &fileFormat
|
||||
diskDevice.FileID = &fileID
|
||||
diskSize := types.DiskSizeFromGigabytes(size)
|
||||
diskSize := types.DiskSizeFromGigabytes(int64(size))
|
||||
diskDevice.Size = &diskSize
|
||||
diskDevice.SizeInt = &size
|
||||
diskDevice.IOThread = &ioThread
|
||||
diskDevice.Discard = &discard
|
||||
diskDevice.Cache = &cache
|
||||
@ -3229,9 +3228,7 @@ func vmGetEfiDiskAsStorageDevice(d *schema.ResourceData, disk []interface{}) (*v
|
||||
return nil, fmt.Errorf("invalid efi disk type: %s", err.Error())
|
||||
}
|
||||
|
||||
sizeInt := ds.InMegabytes()
|
||||
storageDevice.Size = &ds
|
||||
storageDevice.SizeInt = &sizeInt
|
||||
}
|
||||
}
|
||||
|
||||
@ -5790,7 +5787,7 @@ func vmUpdateDiskLocationAndSize(
|
||||
}
|
||||
}
|
||||
|
||||
if *oldDisk.SizeInt < *diskNewEntries[prefix][oldKey].SizeInt {
|
||||
if *oldDisk.Size < *diskNewEntries[prefix][oldKey].Size {
|
||||
if oldDisk.IsOwnedBy(vmID) {
|
||||
diskResizeBodies = append(
|
||||
diskResizeBodies,
|
||||
|
Loading…
Reference in New Issue
Block a user