From 3c209df49756666577a02a08ac6adfc40de56935 Mon Sep 17 00:00:00 2001 From: Xavier Serrat Bordas Date: Wed, 24 Apr 2024 07:58:37 +0200 Subject: [PATCH] Add `protection` property to the `resource_vm_qemu` --- docs/resources/vm_qemu.md | 7 ++++--- examples/pxe_example.tf | 1 + proxmox/resource_vm_qemu.go | 9 +++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/resources/vm_qemu.md b/docs/resources/vm_qemu.md index f83d86e9..0ea303ee 100644 --- a/docs/resources/vm_qemu.md +++ b/docs/resources/vm_qemu.md @@ -98,14 +98,15 @@ The following arguments are supported in the top level resource block. | `bios` | `str` | `"seabios"` | The BIOS to use, options are `seabios` or `ovmf` for UEFI. | | `onboot` | `bool` | `false` | Whether to have the VM startup after the PVE node starts. | | `startup` | `string` | `""` | The [startup and shutdown behaviour](https://pve.proxmox.com/pve-docs/pve-admin-guide.html#pct_startup_and_shutdown) | -| `vm_state` | `string` | `"running"` | The desired state of the VM, options are `running`, `stopped` and `started`. Do note that `started` will only start the vm on creation and won't fully manage the power state unlike `running` and `stopped` do.| +| `vm_state` | `string` | `"running"` | The desired state of the VM, options are `running`, `stopped` and `started`. Do note that `started` will only start the vm on creation and won't fully manage the power state unlike `running` and `stopped` do. | | `oncreate` | `bool` | `true` | Whether to have the VM startup after the VM is created (deprecated, use `vm_state` instead) | +| `protection` | `bool` | `false` | Enable/disable the VM protection from being removed. The default value of `false` indicates the VM is removable. | | `tablet` | `bool` | `true` | Enable/disable the USB tablet device. This device is usually needed to allow absolute mouse positioning with VNC. | | `boot` | `str` | | The boot order for the VM. For example: `order=scsi0;ide2;net0`. The deprecated `legacy=` syntax is no longer supported. See the `boot` option in the [Proxmox manual](https://pve.proxmox.com/wiki/Manual:_qm.conf#_options) for more information. | | `bootdisk` | `str` | | Enable booting from specified disk. You shouldn't need to change it under most circumstances. | | `agent` | `int` | `0` | Set to `1` to enable the QEMU Guest Agent. Note, you must run the [`qemu-guest-agent`](https://pve.proxmox.com/wiki/Qemu-guest-agent) daemon in the guest for this to have any effect. | -| `pxe` | `bool` | `false` | If set to `true`, enable PXE boot of the VM. Also requires a `boot` order be set with Network included (eg `boot = "order=scsi0;net0"`). Note that `pxe` is mutually exclusive with `clone` modes.| -| `clone` | `str` | | The base VM from which to clone to create the new VM. Note that `clone` is mutually exclussive with `pxe` modes.| +| `pxe` | `bool` | `false` | If set to `true`, enable PXE boot of the VM. Also requires a `boot` order be set with Network included (eg `boot = "order=scsi0;net0"`). Note that `pxe` is mutually exclusive with `clone` modes. | +| `clone` | `str` | | The base VM from which to clone to create the new VM. Note that `clone` is mutually exclussive with `pxe` modes. | | `full_clone` | `bool` | `true` | Set to `true` to create a full clone, or `false` to create a linked clone. See the [docs about cloning](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_copy_and_clone) for more info. Only applies when `clone` is set. | | `hastate` | `str` | | Requested HA state for the resource. One of "started", "stopped", "enabled", "disabled", or "ignored". See the [docs about HA](https://pve.proxmox.com/pve-docs/chapter-ha-manager.html#ha_manager_resource_config) for more info. | | `hagroup` | `str` | | The HA group identifier the resource belongs to (requires `hastate` to be set!). See the [docs about HA](https://pve.proxmox.com/pve-docs/chapter-ha-manager.html#ha_manager_resource_config) for more info. | diff --git a/examples/pxe_example.tf b/examples/pxe_example.tf index f5ba26cd..fbcaee0d 100644 --- a/examples/pxe_example.tf +++ b/examples/pxe_example.tf @@ -45,6 +45,7 @@ resource "proxmox_vm_qemu" "pxe-example" { qemu_os = "l26" scsihw = "virtio-scsi-pci" sockets = 1 + protection = false tablet = true target_node = "test" vcpus = 0 diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index e2470443..6f26c9c1 100755 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -147,6 +147,12 @@ func resourceVmQemu() *schema.Resource { // Default: "", Description: "Startup order of the VM", }, + "protection": { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Protect VM from being removed", + }, "tablet": { Type: schema.TypeBool, Optional: true, @@ -832,6 +838,7 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte Bios: d.Get("bios").(string), Onboot: BoolPointer(d.Get("onboot").(bool)), Startup: d.Get("startup").(string), + Protection: BoolPointer(d.Get("protection").(bool)), Tablet: BoolPointer(d.Get("tablet").(bool)), Boot: d.Get("boot").(string), BootDisk: d.Get("bootdisk").(string), @@ -1108,6 +1115,7 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte Bios: d.Get("bios").(string), Onboot: BoolPointer(d.Get("onboot").(bool)), Startup: d.Get("startup").(string), + Protection: BoolPointer(d.Get("protection").(bool)), Tablet: BoolPointer(d.Get("tablet").(bool)), Boot: d.Get("boot").(string), BootDisk: d.Get("bootdisk").(string), @@ -1421,6 +1429,7 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("bios", config.Bios) d.Set("onboot", config.Onboot) d.Set("startup", config.Startup) + d.Set("protection", config.Protection) d.Set("tablet", config.Tablet) d.Set("boot", config.Boot) d.Set("bootdisk", config.BootDisk)