mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-05 21:43:59 +00:00
Add acpi argument to VM resource
This commit is contained in:
parent
f75082bf2c
commit
073030965a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
ENHANCEMENTS:
|
ENHANCEMENTS:
|
||||||
|
|
||||||
|
* resource/virtual_environment_vm: Add `acpi` argument
|
||||||
* resource/virtual_environment_vm: Add `cpu.flags`, `cpu.type` and `cpu.units` arguments
|
* resource/virtual_environment_vm: Add `cpu.flags`, `cpu.type` and `cpu.units` arguments
|
||||||
* resource/virtual_environment_vm: Add `tablet_device` argument
|
* resource/virtual_environment_vm: Add `tablet_device` argument
|
||||||
* resource/virtual_environment_vm: Add `vga` argument
|
* resource/virtual_environment_vm: Add `vga` argument
|
||||||
|
@ -332,6 +332,7 @@ This resource doesn't expose any additional attributes.
|
|||||||
##### VM (proxmox_virtual_environment_vm)
|
##### VM (proxmox_virtual_environment_vm)
|
||||||
|
|
||||||
###### Arguments
|
###### Arguments
|
||||||
|
* `acpi` - (Optional) Whether to enable ACPI (defaults to `true`)
|
||||||
* `agent` - (Optional) The QEMU agent configuration
|
* `agent` - (Optional) The QEMU agent configuration
|
||||||
* `enabled` - (Optional) Whether to enable the QEMU agent (defaults to `false`)
|
* `enabled` - (Optional) Whether to enable the QEMU agent (defaults to `false`)
|
||||||
* `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent (defaults to `false`)
|
* `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent (defaults to `false`)
|
||||||
|
@ -16,6 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
dvResourceVirtualEnvironmentVMACPI = true
|
||||||
dvResourceVirtualEnvironmentVMAgentEnabled = false
|
dvResourceVirtualEnvironmentVMAgentEnabled = false
|
||||||
dvResourceVirtualEnvironmentVMAgentTrim = false
|
dvResourceVirtualEnvironmentVMAgentTrim = false
|
||||||
dvResourceVirtualEnvironmentVMAgentType = "virtio"
|
dvResourceVirtualEnvironmentVMAgentType = "virtio"
|
||||||
@ -59,6 +60,7 @@ const (
|
|||||||
dvResourceVirtualEnvironmentVMVGAType = "std"
|
dvResourceVirtualEnvironmentVMVGAType = "std"
|
||||||
dvResourceVirtualEnvironmentVMVMID = -1
|
dvResourceVirtualEnvironmentVMVMID = -1
|
||||||
|
|
||||||
|
mkResourceVirtualEnvironmentVMACPI = "acpi"
|
||||||
mkResourceVirtualEnvironmentVMAgent = "agent"
|
mkResourceVirtualEnvironmentVMAgent = "agent"
|
||||||
mkResourceVirtualEnvironmentVMAgentEnabled = "enabled"
|
mkResourceVirtualEnvironmentVMAgentEnabled = "enabled"
|
||||||
mkResourceVirtualEnvironmentVMAgentTrim = "trim"
|
mkResourceVirtualEnvironmentVMAgentTrim = "trim"
|
||||||
@ -132,6 +134,12 @@ const (
|
|||||||
func resourceVirtualEnvironmentVM() *schema.Resource {
|
func resourceVirtualEnvironmentVM() *schema.Resource {
|
||||||
return &schema.Resource{
|
return &schema.Resource{
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
mkResourceVirtualEnvironmentVMACPI: {
|
||||||
|
Type: schema.TypeBool,
|
||||||
|
Description: "Whether to enable ACPI",
|
||||||
|
Optional: true,
|
||||||
|
Default: dvResourceVirtualEnvironmentVMACPI,
|
||||||
|
},
|
||||||
mkResourceVirtualEnvironmentVMAgent: &schema.Schema{
|
mkResourceVirtualEnvironmentVMAgent: &schema.Schema{
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Description: "The QEMU agent configuration",
|
Description: "The QEMU agent configuration",
|
||||||
@ -784,6 +792,8 @@ func resourceVirtualEnvironmentVMCreate(d *schema.ResourceData, m interface{}) e
|
|||||||
|
|
||||||
resource := resourceVirtualEnvironmentVM()
|
resource := resourceVirtualEnvironmentVM()
|
||||||
|
|
||||||
|
acpi := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
|
||||||
|
|
||||||
agentBlock, err := getSchemaBlock(resource, d, m, []string{mkResourceVirtualEnvironmentVMAgent}, 0, true)
|
agentBlock, err := getSchemaBlock(resource, d, m, []string{mkResourceVirtualEnvironmentVMAgent}, 0, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -922,6 +932,7 @@ func resourceVirtualEnvironmentVMCreate(d *schema.ResourceData, m interface{}) e
|
|||||||
scsiHardware := "virtio-scsi-pci"
|
scsiHardware := "virtio-scsi-pci"
|
||||||
|
|
||||||
body := &proxmox.VirtualEnvironmentVMCreateRequestBody{
|
body := &proxmox.VirtualEnvironmentVMCreateRequestBody{
|
||||||
|
ACPI: &acpi,
|
||||||
Agent: &proxmox.CustomAgent{
|
Agent: &proxmox.CustomAgent{
|
||||||
Enabled: &agentEnabled,
|
Enabled: &agentEnabled,
|
||||||
TrimClonedDisks: &agentTrim,
|
TrimClonedDisks: &agentTrim,
|
||||||
@ -1399,6 +1410,31 @@ func resourceVirtualEnvironmentVMRead(d *schema.ResourceData, m interface{}) err
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compare some primitive arguments to the values stored in the state.
|
||||||
|
if vmConfig.ACPI != nil {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMACPI, bool(*vmConfig.ACPI))
|
||||||
|
} else {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMACPI, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if vmConfig.Description != nil {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMDescription, *vmConfig.Description)
|
||||||
|
} else {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMDescription, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if vmConfig.KeyboardLayout != nil {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMKeyboardLayout, *vmConfig.KeyboardLayout)
|
||||||
|
} else {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMKeyboardLayout, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
if vmConfig.TabletDeviceEnabled != nil {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMTabletDevice, bool(*vmConfig.TabletDeviceEnabled))
|
||||||
|
} else {
|
||||||
|
d.Set(mkResourceVirtualEnvironmentVMTabletDevice, false)
|
||||||
|
}
|
||||||
|
|
||||||
// Compare the agent configuration to the one stored in the state.
|
// Compare the agent configuration to the one stored in the state.
|
||||||
if vmConfig.Agent != nil {
|
if vmConfig.Agent != nil {
|
||||||
agent := map[string]interface{}{}
|
agent := map[string]interface{}{}
|
||||||
@ -1647,25 +1683,6 @@ func resourceVirtualEnvironmentVMRead(d *schema.ResourceData, m interface{}) err
|
|||||||
d.Set(mkResourceVirtualEnvironmentVMCPU, []interface{}{cpu})
|
d.Set(mkResourceVirtualEnvironmentVMCPU, []interface{}{cpu})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare some primitive arguments to the values stored in the state.
|
|
||||||
if vmConfig.Description != nil {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMDescription, *vmConfig.Description)
|
|
||||||
} else {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMDescription, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if vmConfig.KeyboardLayout != nil {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMKeyboardLayout, *vmConfig.KeyboardLayout)
|
|
||||||
} else {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMKeyboardLayout, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
if vmConfig.TabletDeviceEnabled != nil {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMTabletDevice, bool(*vmConfig.TabletDeviceEnabled))
|
|
||||||
} else {
|
|
||||||
d.Set(mkResourceVirtualEnvironmentVMTabletDevice, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare the disks to those stored in the state.
|
// Compare the disks to those stored in the state.
|
||||||
currentDiskList := d.Get(mkResourceVirtualEnvironmentVMDisk).([]interface{})
|
currentDiskList := d.Get(mkResourceVirtualEnvironmentVMDisk).([]interface{})
|
||||||
|
|
||||||
@ -2027,6 +2044,7 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the new primitive configuration values.
|
// Prepare the new primitive configuration values.
|
||||||
|
acpi := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
|
||||||
delete := []string{}
|
delete := []string{}
|
||||||
description := d.Get(mkResourceVirtualEnvironmentVMDescription).(string)
|
description := d.Get(mkResourceVirtualEnvironmentVMDescription).(string)
|
||||||
keyboardLayout := d.Get(mkResourceVirtualEnvironmentVMKeyboardLayout).(string)
|
keyboardLayout := d.Get(mkResourceVirtualEnvironmentVMKeyboardLayout).(string)
|
||||||
@ -2034,6 +2052,8 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
|||||||
osType := d.Get(mkResourceVirtualEnvironmentVMOSType).(string)
|
osType := d.Get(mkResourceVirtualEnvironmentVMOSType).(string)
|
||||||
tabletDevice := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
|
tabletDevice := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
|
||||||
|
|
||||||
|
body.ACPI = &acpi
|
||||||
|
|
||||||
if description != "" {
|
if description != "" {
|
||||||
body.Description = &description
|
body.Description = &description
|
||||||
}
|
}
|
||||||
@ -2047,7 +2067,8 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
|||||||
body.OSType = &osType
|
body.OSType = &osType
|
||||||
body.TabletDeviceEnabled = &tabletDevice
|
body.TabletDeviceEnabled = &tabletDevice
|
||||||
|
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentVMKeyboardLayout) ||
|
if d.HasChange(mkResourceVirtualEnvironmentVMACPI) ||
|
||||||
|
d.HasChange(mkResourceVirtualEnvironmentVMKeyboardLayout) ||
|
||||||
d.HasChange(mkResourceVirtualEnvironmentVMOSType) ||
|
d.HasChange(mkResourceVirtualEnvironmentVMOSType) ||
|
||||||
d.HasChange(mkResourceVirtualEnvironmentVMTabletDevice) {
|
d.HasChange(mkResourceVirtualEnvironmentVMTabletDevice) {
|
||||||
rebootRequired = true
|
rebootRequired = true
|
||||||
|
@ -28,6 +28,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
testOptionalArguments(t, s, []string{
|
testOptionalArguments(t, s, []string{
|
||||||
|
mkResourceVirtualEnvironmentVMACPI,
|
||||||
mkResourceVirtualEnvironmentVMCDROM,
|
mkResourceVirtualEnvironmentVMCDROM,
|
||||||
mkResourceVirtualEnvironmentVMCloudInit,
|
mkResourceVirtualEnvironmentVMCloudInit,
|
||||||
mkResourceVirtualEnvironmentVMCPU,
|
mkResourceVirtualEnvironmentVMCPU,
|
||||||
@ -52,6 +53,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
testSchemaValueTypes(t, s, []string{
|
testSchemaValueTypes(t, s, []string{
|
||||||
|
mkResourceVirtualEnvironmentVMACPI,
|
||||||
mkResourceVirtualEnvironmentVMCDROM,
|
mkResourceVirtualEnvironmentVMCDROM,
|
||||||
mkResourceVirtualEnvironmentVMCloudInit,
|
mkResourceVirtualEnvironmentVMCloudInit,
|
||||||
mkResourceVirtualEnvironmentVMCPU,
|
mkResourceVirtualEnvironmentVMCPU,
|
||||||
@ -71,6 +73,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMTabletDevice,
|
mkResourceVirtualEnvironmentVMTabletDevice,
|
||||||
mkResourceVirtualEnvironmentVMVMID,
|
mkResourceVirtualEnvironmentVMVMID,
|
||||||
}, []schema.ValueType{
|
}, []schema.ValueType{
|
||||||
|
schema.TypeBool,
|
||||||
schema.TypeList,
|
schema.TypeList,
|
||||||
schema.TypeList,
|
schema.TypeList,
|
||||||
schema.TypeList,
|
schema.TypeList,
|
||||||
|
Loading…
Reference in New Issue
Block a user