mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 19:12:59 +00:00
Continued work on VM resource
This commit is contained in:
parent
b039380f2a
commit
8d458e1a31
@ -1784,7 +1784,20 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
||||
return err
|
||||
}
|
||||
|
||||
body := &proxmox.VirtualEnvironmentVMUpdateRequestBody{}
|
||||
body := &proxmox.VirtualEnvironmentVMUpdateRequestBody{
|
||||
IDEDevices: proxmox.CustomStorageDevices{
|
||||
proxmox.CustomStorageDevice{
|
||||
Enabled: false,
|
||||
},
|
||||
proxmox.CustomStorageDevice{
|
||||
Enabled: false,
|
||||
},
|
||||
proxmox.CustomStorageDevice{
|
||||
Enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
resource := resourceVirtualEnvironmentVM()
|
||||
|
||||
// Retrieve the entire configuration as we need to process certain values.
|
||||
@ -1833,6 +1846,59 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
// Prepare the new CDROM configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMCDROM) {
|
||||
cdromBlock, err := getSchemaBlock(resource, d, m, []string{mkResourceVirtualEnvironmentVMCDROM}, 0, true)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cdromEnabled := cdromBlock[mkResourceVirtualEnvironmentVMCDROMEnabled].(bool)
|
||||
cdromFileID := cdromBlock[mkResourceVirtualEnvironmentVMCDROMFileID].(string)
|
||||
|
||||
if cdromFileID == "" {
|
||||
cdromFileID = "cdrom"
|
||||
}
|
||||
|
||||
cdromMedia := "cdrom"
|
||||
|
||||
body.IDEDevices[2] = proxmox.CustomStorageDevice{
|
||||
Enabled: cdromEnabled,
|
||||
FileVolume: cdromFileID,
|
||||
Media: &cdromMedia,
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare the new cloud-init configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMCloudInit) {
|
||||
cloudInitConfig, err := resourceVirtualEnvironmentVMGetCloudConfig(d, m)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
body.CloudInitConfig = cloudInitConfig
|
||||
|
||||
if body.CloudInitConfig != nil {
|
||||
cdromMedia := "cdrom"
|
||||
|
||||
body.IDEDevices[2] = proxmox.CustomStorageDevice{
|
||||
Enabled: true,
|
||||
FileVolume: "local-lvm:cloudinit",
|
||||
Media: &cdromMedia,
|
||||
}
|
||||
|
||||
if vmConfig.IDEDevice2 != nil {
|
||||
if strings.Contains(vmConfig.IDEDevice2.FileVolume, fmt.Sprintf("vm-%d-cloudinit", vmID)) {
|
||||
body.IDEDevices[2].Enabled = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
// Prepare the new CPU configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMCPU) {
|
||||
cpuBlock, err := getSchemaBlock(resource, d, m, []string{mkResourceVirtualEnvironmentVMCPU}, 0, true)
|
||||
@ -1860,19 +1926,6 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
// Prepare the new cloud-init configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMCloudInit) {
|
||||
cloudInitConfig, err := resourceVirtualEnvironmentVMGetCloudConfig(d, m)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
body.CloudInitConfig = cloudInitConfig
|
||||
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
// Prepare the new disk device configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMDisk) {
|
||||
diskDeviceObjects, err := resourceVirtualEnvironmentVMGetDiskDeviceObjects(d, m)
|
||||
|
Loading…
Reference in New Issue
Block a user