mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-02 03:22:59 +00:00
fix(vm): fix incorrect disk interface ref when reading VM info from PVE (#365)
Fix a minor bug in `vmGetDiskDeviceObjects(...)` that was discovered during investigation of #360.
This commit is contained in:
parent
a546a82928
commit
de3935d462
@ -516,8 +516,9 @@ func getDiskInfo(resp *vms.GetResponseData, d *schema.ResourceData) map[string]*
|
||||
v.FileID = &fileID
|
||||
}
|
||||
}
|
||||
|
||||
v.Interface = &k
|
||||
// defensive copy of the loop variable
|
||||
iface := k
|
||||
v.Interface = &iface
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1679,9 +1679,9 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
return diag.FromErr(e)
|
||||
}
|
||||
|
||||
allDiskInfo := getDiskInfo(vmConfig, d)
|
||||
allDiskInfo := getDiskInfo(vmConfig, d) // from the cloned VM
|
||||
|
||||
diskDeviceObjects, e := vmGetDiskDeviceObjects(d, nil)
|
||||
diskDeviceObjects, e := vmGetDiskDeviceObjects(d, nil) // from the resource config
|
||||
if e != nil {
|
||||
return diag.FromErr(e)
|
||||
}
|
||||
@ -1691,29 +1691,33 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
|
||||
diskInterface := diskBlock[mkResourceVirtualEnvironmentVMDiskInterface].(string)
|
||||
dataStoreID := diskBlock[mkResourceVirtualEnvironmentVMDiskDatastoreID].(string)
|
||||
diskSize := diskBlock[mkResourceVirtualEnvironmentVMDiskSize].(int)
|
||||
prefix := diskDigitPrefix(diskInterface)
|
||||
|
||||
currentDiskInfo := allDiskInfo[diskInterface]
|
||||
configuredDiskInfo := diskDeviceObjects[prefix][diskInterface]
|
||||
|
||||
if currentDiskInfo == nil {
|
||||
diskUpdateBody := &vms.UpdateRequestBody{}
|
||||
prefix := diskDigitPrefix(diskInterface)
|
||||
|
||||
switch prefix {
|
||||
case "virtio":
|
||||
if diskUpdateBody.VirtualIODevices == nil {
|
||||
diskUpdateBody.VirtualIODevices = vms.CustomStorageDevices{}
|
||||
}
|
||||
diskUpdateBody.VirtualIODevices[diskInterface] = diskDeviceObjects[prefix][diskInterface]
|
||||
|
||||
diskUpdateBody.VirtualIODevices[diskInterface] = configuredDiskInfo
|
||||
case "sata":
|
||||
if diskUpdateBody.SATADevices == nil {
|
||||
diskUpdateBody.SATADevices = vms.CustomStorageDevices{}
|
||||
}
|
||||
diskUpdateBody.SATADevices[diskInterface] = diskDeviceObjects[prefix][diskInterface]
|
||||
|
||||
diskUpdateBody.SATADevices[diskInterface] = configuredDiskInfo
|
||||
case "scsi":
|
||||
if diskUpdateBody.SCSIDevices == nil {
|
||||
diskUpdateBody.SCSIDevices = vms.CustomStorageDevices{}
|
||||
}
|
||||
diskUpdateBody.SCSIDevices[diskInterface] = diskDeviceObjects[prefix][diskInterface]
|
||||
|
||||
diskUpdateBody.SCSIDevices[diskInterface] = configuredDiskInfo
|
||||
}
|
||||
|
||||
e = vmAPI.UpdateVM(ctx, diskUpdateBody)
|
||||
|
Loading…
Reference in New Issue
Block a user