From 811f01752079503e11bb28a0318de893eec99919 Mon Sep 17 00:00:00 2001 From: Serge Date: Thu, 25 May 2023 01:14:32 +0300 Subject: [PATCH] add disk parameters serial and wwn (#767) --- docs/resources/vm_qemu.md | 4 +++- proxmox/resource_vm_qemu.go | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/resources/vm_qemu.md b/docs/resources/vm_qemu.md index f0fa5517..863a75be 100644 --- a/docs/resources/vm_qemu.md +++ b/docs/resources/vm_qemu.md @@ -218,7 +218,7 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h | `ssd` | `int` | `0` | Whether to expose this drive as an SSD, rather than a rotational hard disk. | | `discard` | `str` | | Controls whether to pass discard/trim requests to the underlying storage. Only effective when the underlying storage supports thin provisioning. There are other caveats too, see the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more info. | | `aio` | `str` | | AIO type to use. Options: `io_uring`, `native`, `threads`. | -| `mbps` | `int` | `0` | Maximum r/w speed in megabytes per second. `0` means unlimited. +| `mbps` | `int` | `0` | Maximum r/w speed in megabytes per second. `0` means unlimited. | `mbps_rd` | `int` | `0` | Maximum read speed in megabytes per second. `0` means unlimited. | | `mbps_rd_max` | `int` | `0` | Maximum read speed in megabytes per second. `0` means unlimited. | | `mbps_wr` | `int` | `0` | Maximum write speed in megabytes per second. `0` means unlimited. | @@ -232,6 +232,8 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h | `iops_wr` | `int` | `0` | Maximum write I/O in operations per second. `0` means unlimited. | | `iops_wr_max` | `int` | `0` | Maximum unthrottled write I/O pool in operations per second. `0` means unlimited. | | `iops_wr_max_length` | `int` | `0` | Maximum length of write I/O bursts in seconds. `0` means unlimited. | +| `serial` | `str` | | The drive’s reported serial number, url-encoded, up to 20 bytes long. | +| `wwn` | `str` | | The drive’s worldwide name, encoded as 16 bytes hex string, prefixed by 0x. | | `file` | `str` | | The filename portion of the path to the drive’s backing volume. You shouldn't need to specify this, use the `storage` parameter instead. | | `media` | `str` | `"disk"` | The drive’s media type. Options: `cdrom`, `disk`. | | `volume` | `str` | | The full path to the drive’s backing volume including the storage pool name. You shouldn't need to specify this, use the `storage` parameter instead. | diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index 951d0228..3238f258 100755 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -561,6 +561,18 @@ func resourceVmQemu() *schema.Resource { Optional: true, Default: 0, }, + "serial": { + Type: schema.TypeString, + Optional: true, + Default: "", + ValidateFunc: validation.StringLenBetween(0, 20), + }, + "wwn": { + Type: schema.TypeString, + Optional: true, + Default: "", + ValidateFunc: validation.StringMatch(regexp.MustCompile(`^0x[A-Fa-f0-9]+$`), "The drive’s worldwide name, encoded as 16 bytes hex string, prefixed by 0x."), + }, // Misc "file": { Type: schema.TypeString, @@ -1448,6 +1460,12 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte if oldValues[i].(map[string]interface{})["size"] != newValues[i].(map[string]interface{})["size"] { d.Set("reboot_required", true) } + if oldValues[i].(map[string]interface{})["serial"] != newValues[i].(map[string]interface{})["serial"] { + d.Set("reboot_required", true) + } + if oldValues[i].(map[string]interface{})["wwn"] != newValues[i].(map[string]interface{})["wwn"] { + d.Set("reboot_required", true) + } // these paramater changes only require reboot if disk hotplug is disabled if !strings.Contains(d.Get("hotplug").(string), "disk") { if oldValues[i].(map[string]interface{})["type"] != newValues[i].(map[string]interface{})["type"] {