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