mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-04 21:14:05 +00:00
fix(vm): fix CloudInit datastore change support (#509)
The datastore update support introduced in #486 only worked if the CloudInit interface was also changed at the same time. This commit fixes the problem. Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
98ae6a8d8f
commit
73c1294979
@ -5270,7 +5270,17 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
tflog.Debug(ctx, fmt.Sprintf("CloudInit must be moved from %s to %s", existingInterface, initializationInterface))
|
||||
}
|
||||
|
||||
if mustMove || d.HasChange(mkResourceVirtualEnvironmentVMInitializationDatastoreID) || existingInterface == "" {
|
||||
oldInit, _ := d.GetChange(mkResourceVirtualEnvironmentVMInitialization)
|
||||
oldInitBlock := oldInit.([]interface{})[0].(map[string]interface{})
|
||||
prevDatastoreID := oldInitBlock[mkResourceVirtualEnvironmentVMInitializationDatastoreID].(string)
|
||||
|
||||
mustChangeDatastore := prevDatastoreID != initializationDatastoreID
|
||||
if mustChangeDatastore {
|
||||
tflog.Debug(ctx, fmt.Sprintf("CloudInit must be moved from datastore %s to datastore %s",
|
||||
prevDatastoreID, initializationDatastoreID))
|
||||
}
|
||||
|
||||
if mustMove || mustChangeDatastore || existingInterface == "" {
|
||||
// CloudInit must be moved, either from a device to another or from a datastore
|
||||
// to another (or both). This requires the VM to be stopped.
|
||||
if err := vmShutdown(ctx, vmAPI, d); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user