mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-24 04:18:33 +00:00
Add tablet_device argument to VM resource
This commit is contained in:
parent
9ea1cdba2c
commit
8a06e287b3
@ -2,7 +2,9 @@
|
||||
|
||||
ENHANCEMENTS:
|
||||
|
||||
resource/virtual_environment_vm: Add `cpu.flags`, `cpu.type`, `cpu.units` and `vga` 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 `vga` argument
|
||||
|
||||
## 0.1.0
|
||||
|
||||
|
@ -478,6 +478,7 @@ This resource doesn't expose any additional attributes.
|
||||
* `wxp` - Windows XP
|
||||
* `pool_id` - (Optional) The ID of a pool to assign the virtual machine to
|
||||
* `started` - (Optional) Whether to start the virtual machine (defaults to `true`)
|
||||
* `tablet_device` - (Optional) Whether to enable the USB tablet device (defaults to `true`)
|
||||
* `vga` - (Optional) The VGA configuration
|
||||
* `enabled` - (Optional) Whether to enable the VGA device (defaults to `true`)
|
||||
* `memory` - (Optional) The VGA memory in megabytes (defaults to `16`)
|
||||
|
@ -23,11 +23,15 @@ resource "proxmox_virtual_environment_vm" "example" {
|
||||
user_data_file_id = "${proxmox_virtual_environment_file.cloud_config.id}"
|
||||
}
|
||||
|
||||
description = "Managed by Terraform"
|
||||
|
||||
disk {
|
||||
datastore_id = "${element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local-lvm"))}"
|
||||
file_id = "${proxmox_virtual_environment_file.ubuntu_cloud_image.id}"
|
||||
}
|
||||
|
||||
name = "terraform-provider-proxmox-example"
|
||||
|
||||
network_device {}
|
||||
|
||||
node_name = "${data.proxmox_virtual_environment_nodes.example.names[0]}"
|
||||
|
@ -53,6 +53,7 @@ const (
|
||||
dvResourceVirtualEnvironmentVMOSType = "other"
|
||||
dvResourceVirtualEnvironmentVMPoolID = ""
|
||||
dvResourceVirtualEnvironmentVMStarted = true
|
||||
dvResourceVirtualEnvironmentVMTabletDevice = true
|
||||
dvResourceVirtualEnvironmentVMVGAEnabled = true
|
||||
dvResourceVirtualEnvironmentVMVGAMemory = 16
|
||||
dvResourceVirtualEnvironmentVMVGAType = "std"
|
||||
@ -120,6 +121,7 @@ const (
|
||||
mkResourceVirtualEnvironmentVMOSType = "os_type"
|
||||
mkResourceVirtualEnvironmentVMPoolID = "pool_id"
|
||||
mkResourceVirtualEnvironmentVMStarted = "started"
|
||||
mkResourceVirtualEnvironmentVMTabletDevice = "tablet_device"
|
||||
mkResourceVirtualEnvironmentVMVGA = "vga"
|
||||
mkResourceVirtualEnvironmentVMVGAEnabled = "enabled"
|
||||
mkResourceVirtualEnvironmentVMVGAMemory = "memory"
|
||||
@ -707,6 +709,12 @@ func resourceVirtualEnvironmentVM() *schema.Resource {
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentVMStarted,
|
||||
},
|
||||
mkResourceVirtualEnvironmentVMTabletDevice: {
|
||||
Type: schema.TypeBool,
|
||||
Description: "Whether to enable the USB tablet device",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentVMTabletDevice,
|
||||
},
|
||||
mkResourceVirtualEnvironmentVMVGA: &schema.Schema{
|
||||
Type: schema.TypeList,
|
||||
Description: "The VGA configuration",
|
||||
@ -853,6 +861,7 @@ func resourceVirtualEnvironmentVMCreate(d *schema.ResourceData, m interface{}) e
|
||||
osType := d.Get(mkResourceVirtualEnvironmentVMOSType).(string)
|
||||
poolID := d.Get(mkResourceVirtualEnvironmentVMPoolID).(string)
|
||||
started := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMStarted).(bool))
|
||||
tabletDevice := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
|
||||
|
||||
vgaDevice, err := resourceVirtualEnvironmentVMGetVGADeviceObject(d, m)
|
||||
|
||||
@ -911,7 +920,6 @@ func resourceVirtualEnvironmentVMCreate(d *schema.ResourceData, m interface{}) e
|
||||
}
|
||||
|
||||
scsiHardware := "virtio-scsi-pci"
|
||||
tabletDeviceEnabled := proxmox.CustomBool(true)
|
||||
|
||||
body := &proxmox.VirtualEnvironmentVMCreateRequestBody{
|
||||
Agent: &proxmox.CustomAgent{
|
||||
@ -941,7 +949,7 @@ func resourceVirtualEnvironmentVMCreate(d *schema.ResourceData, m interface{}) e
|
||||
SerialDevices: []string{"socket"},
|
||||
SharedMemory: memorySharedObject,
|
||||
StartOnBoot: &started,
|
||||
TabletDeviceEnabled: &tabletDeviceEnabled,
|
||||
TabletDeviceEnabled: &tabletDevice,
|
||||
VGADevice: vgaDevice,
|
||||
VMID: &vmID,
|
||||
}
|
||||
@ -1639,7 +1647,7 @@ func resourceVirtualEnvironmentVMRead(d *schema.ResourceData, m interface{}) err
|
||||
d.Set(mkResourceVirtualEnvironmentVMCPU, []interface{}{cpu})
|
||||
}
|
||||
|
||||
// Compare the description and keyboard layout to the values stored in the state.
|
||||
// Compare some primitive arguments to the values stored in the state.
|
||||
if vmConfig.Description != nil {
|
||||
d.Set(mkResourceVirtualEnvironmentVMDescription, *vmConfig.Description)
|
||||
} else {
|
||||
@ -1652,6 +1660,12 @@ func resourceVirtualEnvironmentVMRead(d *schema.ResourceData, m interface{}) err
|
||||
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.
|
||||
currentDiskList := d.Get(mkResourceVirtualEnvironmentVMDisk).([]interface{})
|
||||
|
||||
@ -2018,6 +2032,7 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
||||
keyboardLayout := d.Get(mkResourceVirtualEnvironmentVMKeyboardLayout).(string)
|
||||
name := d.Get(mkResourceVirtualEnvironmentVMName).(string)
|
||||
osType := d.Get(mkResourceVirtualEnvironmentVMOSType).(string)
|
||||
tabletDevice := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
|
||||
|
||||
if description != "" {
|
||||
body.Description = &description
|
||||
@ -2030,6 +2045,13 @@ func resourceVirtualEnvironmentVMUpdate(d *schema.ResourceData, m interface{}) e
|
||||
}
|
||||
|
||||
body.OSType = &osType
|
||||
body.TabletDeviceEnabled = &tabletDevice
|
||||
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMKeyboardLayout) ||
|
||||
d.HasChange(mkResourceVirtualEnvironmentVMOSType) ||
|
||||
d.HasChange(mkResourceVirtualEnvironmentVMTabletDevice) {
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
// Prepare the new agent configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMAgent) {
|
||||
|
@ -40,6 +40,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentVMOSType,
|
||||
mkResourceVirtualEnvironmentVMPoolID,
|
||||
mkResourceVirtualEnvironmentVMStarted,
|
||||
mkResourceVirtualEnvironmentVMTabletDevice,
|
||||
mkResourceVirtualEnvironmentVMVMID,
|
||||
})
|
||||
|
||||
@ -67,6 +68,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentVMOSType,
|
||||
mkResourceVirtualEnvironmentVMPoolID,
|
||||
mkResourceVirtualEnvironmentVMStarted,
|
||||
mkResourceVirtualEnvironmentVMTabletDevice,
|
||||
mkResourceVirtualEnvironmentVMVMID,
|
||||
}, []schema.ValueType{
|
||||
schema.TypeList,
|
||||
@ -85,6 +87,7 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
||||
schema.TypeString,
|
||||
schema.TypeString,
|
||||
schema.TypeBool,
|
||||
schema.TypeBool,
|
||||
schema.TypeInt,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user