Skip to content

Commit

Permalink
Merge pull request #994 from xserrat/add-protection-property-in-resou…
Browse files Browse the repository at this point in the history
…rce-vm-qemu

Feature: Add `protection` property to the `resource_vm_qemu`
  • Loading branch information
Tinyblargon authored Apr 24, 2024
2 parents 9e39250 + 39d863b commit 67954af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The following arguments are supported in the top level resource block.
| `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. |
| `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. |
Expand Down
1 change: 1 addition & 0 deletions examples/pxe_example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -838,6 +844,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),
Expand Down Expand Up @@ -1114,6 +1121,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),
Expand Down Expand Up @@ -1427,6 +1435,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)
Expand Down

0 comments on commit 67954af

Please sign in to comment.