Skip to content

Commit

Permalink
Merge branch 'master' into #1106
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyblargon authored Nov 19, 2024
2 parents 40832ec + 2b3985e commit 0c58b70
Show file tree
Hide file tree
Showing 30 changed files with 3,622 additions and 3,012 deletions.
34 changes: 16 additions & 18 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,22 @@ provider "proxmox" {

The following arguments are supported in the provider block:

- `pm_api_url` - (Required; or use environment variable `PM_API_URL`) This is the target Proxmox API endpoint.
- `pm_user` - (Optional; or use environment variable `PM_USER`) The user, remember to include the authentication realm
such as myuser@pam or myuser@pve.
- `pm_password` - (Optional; sensitive; or use environment variable `PM_PASS`) The password.
- `pm_api_token_id` - (Optional; or use environment variable `PM_API_TOKEN_ID`) This is
an [API token](https://pve.proxmox.com/pve-docs/pveum-plain.html) you have previously created for a specific user.
- `pm_api_token_secret` - (Optional; or use environment variable `PM_API_TOKEN_SECRET`) This uuid is only
available when the token was initially created.
- `pm_otp` - (Optional; or use environment variable `PM_OTP`) The 2FA OTP code.
- `pm_tls_insecure` - (Optional) Disable TLS verification while connecting to the proxmox server.
- `pm_parallel` - (Optional; defaults to 4) Allowed simultaneous Proxmox processes (e.g. creating resources).
- `pm_log_enable` - (Optional; defaults to false) Enable debug logging, see the section below for logging details.
- `pm_log_levels` - (Optional) A map of log sources and levels.
- `pm_log_file` - (Optional; defaults to "terraform-plugin-proxmox.log") If logging is enabled, the log file the
provider will write logs to.
- `pm_timeout` - (Optional; defaults to 300) Timeout value (seconds) for proxmox API calls.
- `pm_debug` - (Optional; defaults to false) Enable verbose output in proxmox-api-go
- `pm_proxy_server` - (Optional; defaults to nil) Send provider api call to a proxy server for easy debugging
| Argument | environment variable | Type | Default Value | Description |
| --------------------- | -------------------- | -------- | ------------------------------ | ----------- |
| `pm_api_url` | `PM_API_URL` | `string` | | **Required** This is the target Proxmox API endpoint. |
| `pm_user` | `PM_USER` | `string` | | The user, remember to include the authentication realm such as myuser@pam or myuser@pve. |
| `pm_password` | `PM_PASS` | `string` | | **Sensitive** The password. |
| `pm_api_token_id` | `PM_API_TOKEN_ID` | `string` | | This is an [API token](https://pve.proxmox.com/pve-docs/pveum-plain.html) you have previously created for a specific user. |
| `pm_api_token_secret` | `PM_API_TOKEN` | `string` | | **Sensitive** This uuid is only available when the token was initially created. |
| `pm_otp` | `PM_OTP` | `string` | | The 2FA OTP code. |
| `pm_tls_insecure` | | `bool` | `true` | Disable TLS verification while connecting to the proxmox server. |
| `pm_parallel` | | `uint` | `1` | Allowed simultaneous Proxmox processes (e.g. creating resources). Setting this greater than 1 is currently not recommended when using dynamic guest id allocation. |
| `pm_log_enable` | | `bool` | `false` | Enable debug logging, see the section below for logging details. |
| `pm_log_levels` | | `map` | | A map of log sources and levels. |
| `pm_log_file` | | `string` | `terraform-plugin-proxmox.log` | The log file the provider will write logs to. |
| `pm_timeout` | | `uint` | `300` | Timeout value (seconds) for proxmox API calls. |
| `pm_debug` | | `bool` | `false` | Enable verbose output in proxmox-api-go. |
| `pm_proxy_server` | | `string` | | Send provider api call to a proxy server for easy debugging. |

Additionally, one can set the `PM_OTP_PROMPT` environment variable to prompt for OTP 2FA code (if required).

Expand Down
91 changes: 82 additions & 9 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ The following arguments are supported in the top level resource block.
| `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 exclusive with `pxe` modes. |
| `clone` | `str` | | The base VM name from which to clone to create the new VM. Note that `clone` is mutually exclusive with `clone_id` and `pxe` modes. |
| `clone_id` | `int` | | The base VM id from which to clone to create the new VM. Note that `clone_id` is mutually exclusive with `clone` and `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. |
Expand Down Expand Up @@ -138,7 +139,7 @@ The following arguments are supported in the top level resource block.
| `searchdomain` | `str` | | Sets default DNS search domain suffix. |
| `nameserver` | `str` | | Sets default DNS server for guest. |
| `sshkeys` | `str` | | Newline delimited list of SSH public keys to add to authorized keys file for the cloud-init user. |
| `ipconfig0` | `str` | `''` | The first IP address to assign to the guest. Format: `[gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]`. When `os_type` is `cloud-init` not setting `ip=` is equivalent to `skip_ipv4` == `true` and `ip6=` to `skip_ipv4` == `true` .|
| `ipconfig0` | `str` | `''` | The first IP address to assign to the guest. Format: `[gw=<GatewayIPv4>] [,gw6=<GatewayIPv6>] [,ip=<IPv4Format/CIDR>] [,ip6=<IPv6Format/CIDR>]`. When `os_type` is `cloud-init` not setting `ip=` is equivalent to `skip_ipv4` == `true` and `ip6=` to `skip_ipv6` == `true` .|
| `ipconfig1` to `ipconfig15` | `str` | | The second IP address to assign to the guest. Same format as `ipconfig0`. |
| `automatic_reboot` | `bool` | `true` | Automatically reboot the VM when parameter changes require this. If disabled the provider will emit a warning when the VM needs to be rebooted. |
| `skip_ipv4` | `bool` | `false` | Tells proxmox that acquiring an IPv4 address from the qemu guest agent isn't required, it will still return an ipv4 address if it could obtain one. Useful for reducing retries in environments without ipv4.|
Expand Down Expand Up @@ -560,17 +561,89 @@ details.

### USB Block

The `usb` block is used to configure USB devices. It may be specified multiple times. The order in which the
blocks are specified determines the ID for each net device. i.e. The first `usb` block will become `usb0`, the
second will be `usb1` etc...
The `usb` block is used to configure USB devices. It may be specified multiple times. When no `device_id`, `mapping_id`, or `port_id` is specified, it will be a `spice` device.
In order to have a normal diff put the `usb` blocks in alphanumeric order based on the value of `id`.
Don't need it in a module? Use the [USBs](#usbs-block) instead.

See the [docs about USB passthrough](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_usb_passthrough) for more
details.

| Argument | Type | Default Value | Description |
| -------- | ------ | ------------- | ------------------------------------------------------------------------------------------------------------------- |
| `host` | `str` | | **Required** USB device host. This can either be done via the vendor- and product-id, or via the host bus and port. |
| `usb3` | `bool` | `false` | Specifies whether if given host option is a USB3 device or port. |
| Argument | Type | Default Value | Description |
| ------------ | -------- | ------------- | ----------- |
| `id` | `int` | | **Required** The ID of the USB device. Must be unique, and between `0-4`. |
| `device_id` | `string` | | The USB device ID, mutually exclusive with `mapping_id` and `port_id`. |
| `mapping_id` | `string` | | The USB mapping ID, mutually exclusive with `device_id` and `port_id`. |
| `port_id` | `string` | | The USB port ID, mutually exclusive with `device_id` and `mapping_id`. |
| `usb3` | `bool` | `false` | Specifies whether the USB device or port is USB3. |

### USBs Block

The `usbs` block is used to configure USB devices.
There are four types of USB devices `device`, `mapping`, `port`, and `spice`. Configuration for these sub types can be found in their respective chapters:

* `device`: [USBs.x.Device Block](#usbsxdevice-block).
* `mapping`: [USBs.x.Mapping Block](#usbsxmapping-block).
* `port`: [USBs.x.Port Block](#usbsxport-block).
* `spice`: [USBs.x.Spice Block](#usbsxspice-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>
usbs {
usb0 {
device {
device_id = "e0bc:40a9"
usb3 = true
}
}
usb1 {
mapping {
mapping_id = "mapped-device"
usb3 = true
}
}
usb2 {
port {
port_id = "1-1"
usb3 = true
}
}
usb4 {
spice {
usb3 = true
}
}
}
}
```

### USBs.x.Device Block

| Argument | Type | Default Value | Description |
| ----------- | -------- | ------------- | ----------- |
| `device_id` | `string` | | **Required** The USB device ID, mutually exclusive with `mapping_id` and `port_id`. |
| `usb3` | `bool` | `false` | Specifies whether the USB device or port is USB3. |

### USBs.x.Mapping Block

| Argument | Type | Default Value | Description |
| ------------ | -------- | ------------- | ----------- |
| `mapping_id` | `string` | | **Required** The USB mapping ID, mutually exclusive with `device_id` and `port_id`. |
| `usb3` | `bool` | `false` | Specifies whether the USB device or port is USB3. |

### USBs.x.Port Block

| Argument | Type | Default Value | Description |
| --------- | -------- | ------------- | ----------- |
| `port_id` | `string` | | **Required** The USB port ID, mutually exclusive with `device_id` and `mapping_id`. |
| `usb3` | `bool` | `false` | Specifies whether the USB device or port is USB3. |

### USBs.x.Spice Block

| Argument | Type | Default Value | Description |
| -------- | ------ | ------------- | ----------- |
| `usb3` | `bool` | `false` | Specifies whether the USB device or port is USB3. |

## SMBIOS Block

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.21
toolchain go1.21.0

require (
github.com/Telmate/proxmox-api-go v0.0.0-20241028065640-b38644dd6993
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a
github.com/google/uuid v1.6.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/rs/zerolog v1.32.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0

)
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton h1:HKz85FwoXx86kVtTvFke7rgHvq/HoloSUvW5semjFWs=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/Telmate/proxmox-api-go v0.0.0-20241028065640-b38644dd6993 h1:HOkpCRbJXYt/dFecrbp6rs7hVaJjADHMXDVA07Kpewg=
github.com/Telmate/proxmox-api-go v0.0.0-20241028065640-b38644dd6993/go.mod h1:Gu6n6vEn1hlyFUkjrvU+X1fdgaSXLoM9HKYYJqy1fsY=
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a h1:HLnjs22IoYtL3QBkOXiABuQhfg6WDJGbENV6+lzPgtQ=
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a/go.mod h1:Gu6n6vEn1hlyFUkjrvU+X1fdgaSXLoM9HKYYJqy1fsY=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down Expand Up @@ -132,8 +132,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
Expand Down
7 changes: 7 additions & 0 deletions proxmox/Internal/errormsg/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package errorMSG

const (
Uint string = "expected type of %s to be a positive number (uint)"
Float string = "expected type of %s to be a float"
String string = "expected type of %s to be string"
)
11 changes: 11 additions & 0 deletions proxmox/Internal/resource/guest/qemu/disk/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package disk

import "github.com/hashicorp/terraform-plugin-sdk/v2/diag"

func errorDiskSlotDuplicate(slot string) diag.Diagnostics {
return diag.Diagnostics{
{
Severity: diag.Error,
Summary: "duplicate disk slot",
Detail: "disk slot " + slot + " is already defined"}}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
package proxmox
package disk

import (
"strconv"

pveAPI "github.com/Telmate/proxmox-api-go/proxmox"
)

func default_format(rawFormat string) pveAPI.QemuDiskFormat {
if rawFormat == "" {
return pveAPI.QemuDiskFormat("raw")
}
return pveAPI.QemuDiskFormat(rawFormat)
}

const (
kibibyte int64 = 1
mebibyte int64 = 1024
Expand Down
Loading

0 comments on commit 0c58b70

Please sign in to comment.