mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-06-30 02:31:10 +00:00
chore: lint and reformat the code (#204)
* chore: reformat code * chore: add commitlint config * reformat README.md * add linter config * lint & reformat docs * go linter: only new issues * fix some linting errors * more reformatting * disable linter warning for some duplicated code
This commit is contained in:
parent
dd9ffe190c
commit
bf9e31ecfc
3
.github/workflows/golangci-lint.yml
vendored
3
.github/workflows/golangci-lint.yml
vendored
@ -21,4 +21,5 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.50
|
||||
version: v1.50.1
|
||||
only-new-issues: true
|
||||
|
90
.golangci.yml
Normal file
90
.golangci.yml
Normal file
@ -0,0 +1,90 @@
|
||||
# v1.50.1
|
||||
run:
|
||||
deadline: 5m
|
||||
issues:
|
||||
new-from-rev: 9101977dc81f64db077b9a1eda2fe401359854c9
|
||||
# Maximum issues count per one linter. Set to 0 to disable.
|
||||
# Default is 50.
|
||||
max-issues-per-linter: 0
|
||||
# Maximum count of issues with the same text. Set to 0 to disable.
|
||||
# Default is 3.
|
||||
max-same-issues: 0
|
||||
exclude-rules:
|
||||
# Exclude duplicate code and function length and complexity checking in test
|
||||
# files (due to common repeats and long functions in test code)
|
||||
- path: _(test|gen)\.go
|
||||
linters:
|
||||
- cyclop
|
||||
- dupl
|
||||
- gocognit
|
||||
- funlen
|
||||
- lll
|
||||
- path: _types\.go
|
||||
linters:
|
||||
- lll
|
||||
linters-settings:
|
||||
nolintlint:
|
||||
# Disable to ensure that nolint directives don't have a leading space.
|
||||
# Default is true.
|
||||
allow-leading-space: false
|
||||
exhaustive:
|
||||
default-signifies-exhaustive: true
|
||||
govet:
|
||||
check-shadowing: true
|
||||
cyclop:
|
||||
max-complexity: 25
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 150
|
||||
goconst:
|
||||
min-len: 10
|
||||
min-occurrences: 4
|
||||
funlen:
|
||||
lines: 80
|
||||
statements: 60
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
# deprecated
|
||||
- gocyclo
|
||||
- interfacer
|
||||
- scopelint
|
||||
- maligned
|
||||
- golint
|
||||
- deadcode
|
||||
- ifshort
|
||||
- varcheck
|
||||
- structcheck
|
||||
# require massive refactoring
|
||||
- forcetypeassert
|
||||
- govet
|
||||
- funlen
|
||||
- gocognit
|
||||
- cyclop
|
||||
#
|
||||
- containedctx
|
||||
- decorder
|
||||
- execinquery
|
||||
- exhaustivestruct
|
||||
- exhaustruct
|
||||
- gci
|
||||
- gochecknoinits
|
||||
- godot
|
||||
- godox
|
||||
- goerr113
|
||||
- goheader
|
||||
- gomnd
|
||||
- gomodguard
|
||||
- grouper
|
||||
- ireturn
|
||||
- maintidx
|
||||
- nlreturn
|
||||
- nonamedreturns
|
||||
- nosnakecase
|
||||
- tagliatelle
|
||||
- testpackage
|
||||
- thelper
|
||||
- varnamelen
|
||||
- wsl
|
||||
fast: false
|
62
README.md
62
README.md
@ -1,3 +1,5 @@
|
||||
# Terraform Provider for Proxmox
|
||||
|
||||
[](https://goreportcard.com/report/github.com/bpg/terraform-provider-proxmox)
|
||||
[](http://godoc.org/github.com/bpg/terraform-provider-proxmox)
|
||||
[](https://github.com/bpg/terraform-provider-proxmox/releases/latest)
|
||||
@ -6,62 +8,69 @@
|
||||
[](https://www.conventionalcommits.org/en/v1.0.0/#specification)
|
||||
[](https://www.buymeacoffee.com/bpgca)
|
||||
|
||||
# Terraform Provider for Proxmox
|
||||
A Terraform Provider which adds support for Proxmox solutions.
|
||||
|
||||
This repository is a fork of https://github.com/danitso/terraform-provider-proxmox with several critical fixes to unblock
|
||||
VM deployment in Proxmox v7.0, and a few other enhancements.
|
||||
This repository is a fork of <https://github.com/danitso/terraform-provider-proxmox>
|
||||
with several critical fixes to unblock VM deployment in Proxmox v7.0, and several
|
||||
other enhancements.
|
||||
|
||||
## Compatibility Matrix
|
||||
|
||||
| Proxmox version | Provider version |
|
||||
|-----------------|--------------------------|
|
||||
| 6.x | \<= 0.4.4 |
|
||||
| 7.x | 0.4.x \> 0.4.4 <br>0.5.x |
|
||||
| Proxmox version | Provider version |
|
||||
| --------------- | ---------------- |
|
||||
| 6.x | \<= 0.4.4 |
|
||||
| 7.x | \>= 0.4.5 |
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Terraform](https://www.terraform.io/downloads.html) 1.1+
|
||||
- [Go](https://golang.org/doc/install) 1.18+ (to build the provider plugin)
|
||||
- [GoReleaser](https://goreleaser.com/install/) v1.10+ (to build the provider plugin)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Building the provider](#building-the-provider)
|
||||
- [Using the provider](#using-the-provider)
|
||||
- [Testing the provider](#testing-the-provider)
|
||||
- [Known issues](#known-issues)
|
||||
|
||||
## Building the provider
|
||||
|
||||
- Clone the repository to `$GOPATH/src/github.com/bpg/terraform-provider-proxmox`:
|
||||
|
||||
```sh
|
||||
$ mkdir -p "${GOPATH}/src/github.com/bpg"
|
||||
$ cd "${GOPATH}/src/github.com/bpg"
|
||||
$ git clone git@github.com:bpg/terraform-provider-proxmox
|
||||
```
|
||||
```sh
|
||||
mkdir -p "${GOPATH}/src/github.com/bpg"
|
||||
cd "${GOPATH}/src/github.com/bpg"
|
||||
git clone git@github.com:bpg/terraform-provider-proxmox
|
||||
```
|
||||
|
||||
- Enter the provider directory and build it:
|
||||
|
||||
```sh
|
||||
$ cd "${GOPATH}/src/github.com/bpg/terraform-provider-proxmox"
|
||||
$ make build
|
||||
```
|
||||
```sh
|
||||
cd "${GOPATH}/src/github.com/bpg/terraform-provider-proxmox"
|
||||
make build
|
||||
```
|
||||
|
||||
## Using the provider
|
||||
|
||||
You can find the latest release and its documentation in the [Terraform Registry](https://registry.terraform.io/providers/bpg/proxmox/latest).
|
||||
|
||||
## Testing the provider
|
||||
|
||||
In order to test the provider, you can simply run `make test`.
|
||||
|
||||
```sh
|
||||
$ make test
|
||||
make test
|
||||
```
|
||||
|
||||
Tests are limited to regression tests, ensuring backwards compatibility.
|
||||
|
||||
## Deploying the example resources
|
||||
|
||||
There are number of TF examples in the `examples` directory, which can be used to deploy a Container, VM, or other Proxmox resources on your test Proxmox cluster.
|
||||
There are number of TF examples in the `examples` directory, which can be used
|
||||
to deploy a Container, VM, or other Proxmox resources on your test Proxmox cluster.
|
||||
The following assumptions are made about the test Proxmox cluster:
|
||||
|
||||
- It has one node named `pve`
|
||||
- The node has local storages named `local` and `local-lvm`
|
||||
|
||||
@ -75,15 +84,17 @@ virtual_environment_endpoint = "https://<your-cluster-endpoint>:8006/"
|
||||
|
||||
Then run `make example` to deploy the example resources.
|
||||
|
||||
|
||||
|
||||
## Known issues
|
||||
|
||||
### Disk images cannot be imported by non-PAM accounts
|
||||
Due to limitations in the Proxmox VE API, certain actions need to be performed using SSH. This requires the use of a PAM account (standard Linux account).
|
||||
|
||||
Due to limitations in the Proxmox VE API, certain actions need to be performed
|
||||
using SSH. This requires the use of a PAM account (standard Linux account).
|
||||
|
||||
### Disk images from VMware cannot be uploaded or imported
|
||||
Proxmox VE is not currently supporting VMware disk images directly. However, you can still use them as disk images by using this workaround:
|
||||
|
||||
Proxmox VE is not currently supporting VMware disk images directly. However, you
|
||||
can still use them as disk images by using this workaround:
|
||||
|
||||
```hcl
|
||||
resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
|
||||
@ -92,7 +103,8 @@ resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
|
||||
node_name = "node-name"
|
||||
|
||||
source_file {
|
||||
# We must override the file extension to bypass the validation code in the Proxmox VE API.
|
||||
# We must override the file extension to bypass the validation code
|
||||
# in the Proxmox VE API.
|
||||
file_name = "vmdk-file-name.img"
|
||||
path = "path-to-vmdk-file"
|
||||
}
|
||||
@ -113,4 +125,6 @@ resource "proxmox_virtual_environment_vm" "example" {
|
||||
```
|
||||
|
||||
### Snippets cannot be uploaded by non-PAM accounts
|
||||
Due to limitations in the Proxmox VE API, certain files need to be uploaded using SFTP. This requires the use of a PAM account (standard Linux account).
|
||||
|
||||
Due to limitations in the Proxmox VE API, certain files need to be uploaded
|
||||
using SFTP. This requires the use of a PAM account (standard Linux account).
|
||||
|
6
commitlint.config.js
Normal file
6
commitlint.config.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: [
|
||||
"@commitlint/config-conventional"
|
||||
],
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ Retrieves information about a specific alias.
|
||||
|
||||
```terraform
|
||||
data "proxmox_virtual_environment_cluster_alias" "local_network" {
|
||||
name = "local_network"
|
||||
name = "local_network"
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -23,4 +23,4 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `alias_ids` - The pool identifiers.
|
||||
- `alias_ids` - The pool identifiers.
|
||||
|
@ -21,16 +21,16 @@ data "proxmox_virtual_environment_datastores" "first_node" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
- `node_name` - (Required) A node name.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `active` - Whether the datastore is active.
|
||||
* `content_types` - The allowed content types.
|
||||
* `datastore_ids` - The datastore identifiers.
|
||||
* `enabled` - Whether the datastore is enabled.
|
||||
* `shared` - Whether the datastore is shared.
|
||||
* `space_available` - The available space in bytes.
|
||||
* `space_total` - The total space in bytes.
|
||||
* `space_used` - The used space in bytes.
|
||||
* `types` - The storage types.
|
||||
- `active` - Whether the datastore is active.
|
||||
- `content_types` - The allowed content types.
|
||||
- `datastore_ids` - The datastore identifiers.
|
||||
- `enabled` - Whether the datastore is enabled.
|
||||
- `shared` - Whether the datastore is shared.
|
||||
- `space_available` - The available space in bytes.
|
||||
- `space_total` - The total space in bytes.
|
||||
- `space_used` - The used space in bytes.
|
||||
- `types` - The storage types.
|
||||
|
@ -21,9 +21,9 @@ data "proxmox_virtual_environment_dns" "first_node" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
- `node_name` - (Required) A node name.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `domain` - The DNS search domain.
|
||||
* `servers` - The DNS servers.
|
||||
- `domain` - The DNS search domain.
|
||||
- `servers` - The DNS servers.
|
||||
|
@ -21,13 +21,13 @@ data "proxmox_virtual_environment_group" "operations_team" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `group_id` - (Required) The group identifier.
|
||||
- `group_id` - (Required) The group identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `acl` - The access control list.
|
||||
* `path` - The path.
|
||||
* `propagate` - Whether to propagate to child paths.
|
||||
* `role_id` - The role identifier.
|
||||
* `comment` - The group comment.
|
||||
* `members` - The group members as a list with `username@realm` entries.
|
||||
- `acl` - The access control list.
|
||||
- `path` - The path.
|
||||
- `propagate` - Whether to propagate to child paths.
|
||||
- `role_id` - The role identifier.
|
||||
- `comment` - The group comment.
|
||||
- `members` - The group members as a list with `username@realm` entries.
|
||||
|
@ -23,5 +23,5 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `comments` - The group comments.
|
||||
* `group_ids` - The group identifiers.
|
||||
- `comments` - The group comments.
|
||||
- `group_ids` - The group identifiers.
|
||||
|
@ -21,11 +21,12 @@ data "proxmox_virtual_environment_hosts" "first_node_host_entries" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
- `node_name` - (Required) A node name.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `addresses` - The IP addresses.
|
||||
* `digest` - The SHA1 digest.
|
||||
* `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
|
||||
* `hostnames` - The hostnames associated with each of the IP addresses.
|
||||
- `addresses` - The IP addresses.
|
||||
- `digest` - The SHA1 digest.
|
||||
- `entries` - The host entries (conversion of `addresses` and `hostnames` into
|
||||
objects).
|
||||
- `hostnames` - The hostnames associated with each of the IP addresses.
|
||||
|
@ -23,12 +23,12 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `cpu_count` - The CPU count for each node.
|
||||
* `cpu_utilization` - The CPU utilization on each node.
|
||||
* `memory_available` - The memory available on each node.
|
||||
* `memory_used` - The memory used on each node.
|
||||
* `names` - The node names.
|
||||
* `online` - Whether a node is online.
|
||||
* `ssl_fingerprints` - The SSL fingerprint for each node.
|
||||
* `support_levels` - The support level for each node.
|
||||
* `uptime` - The uptime in seconds for each node.
|
||||
- `cpu_count` - The CPU count for each node.
|
||||
- `cpu_utilization` - The CPU utilization on each node.
|
||||
- `memory_available` - The memory available on each node.
|
||||
- `memory_used` - The memory used on each node.
|
||||
- `names` - The node names.
|
||||
- `online` - Whether a node is online.
|
||||
- `ssl_fingerprints` - The SSL fingerprint for each node.
|
||||
- `support_levels` - The support level for each node.
|
||||
- `uptime` - The uptime in seconds for each node.
|
||||
|
@ -21,14 +21,14 @@ data "proxmox_virtual_environment_pool" "operations_pool" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `pool_id` - (Required) The pool identifier.
|
||||
- `pool_id` - (Required) The pool identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `comment` - The pool comment.
|
||||
* `members` - The pool members.
|
||||
* `datastore_id` - The datastore identifier.
|
||||
* `id` - The member identifier.
|
||||
* `node_name` - The node name.
|
||||
* `type` - The member type.
|
||||
* `vm_id` - The virtual machine identifier.
|
||||
- `comment` - The pool comment.
|
||||
- `members` - The pool members.
|
||||
- `datastore_id` - The datastore identifier.
|
||||
- `id` - The member identifier.
|
||||
- `node_name` - The node name.
|
||||
- `type` - The member type.
|
||||
- `vm_id` - The virtual machine identifier.
|
||||
|
@ -23,4 +23,4 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `pool_ids` - The pool identifiers.
|
||||
- `pool_ids` - The pool identifiers.
|
||||
|
@ -21,8 +21,8 @@ data "proxmox_virtual_environment_role" "operations_role" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `role_id` - (Required) The role identifier.
|
||||
- `role_id` - (Required) The role identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `privileges` - The role privileges
|
||||
- `privileges` - The role privileges
|
||||
|
@ -23,6 +23,6 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `privileges` - The role privileges.
|
||||
* `role_ids` - The role identifiers.
|
||||
* `special` - Whether the role is special (built-in).
|
||||
- `privileges` - The role privileges.
|
||||
- `role_ids` - The role identifiers.
|
||||
- `special` - Whether the role is special (built-in).
|
||||
|
@ -21,10 +21,10 @@ data "proxmox_virtual_environment_time" "first_node_time" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
- `node_name` - (Required) A node name.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `local_time` - The node's local time.
|
||||
* `time_zone` - The node's time zone.
|
||||
* `utc_time` - The node's local time formatted as UTC.
|
||||
- `local_time` - The node's local time.
|
||||
- `time_zone` - The node's time zone.
|
||||
- `utc_time` - The node's local time formatted as UTC.
|
||||
|
@ -21,19 +21,19 @@ data "proxmox_virtual_environment_user" "operations_user" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `user_id` - (Required) The user identifier.
|
||||
- `user_id` - (Required) The user identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `acl` - The access control list.
|
||||
* `path` - The path.
|
||||
* `propagate` - Whether to propagate to child paths.
|
||||
* `role_id` - The role identifier.
|
||||
* `comment` - The user comment.
|
||||
* `email` - The user's email address.
|
||||
* `enabled` - Whether the user account is enabled.
|
||||
* `expiration_date` - The user account's expiration date (RFC 3339).
|
||||
* `first_name` - The user's first name.
|
||||
* `groups` - The user's groups.
|
||||
* `keys` - The user's keys.
|
||||
* `last_name` - The user's last name.
|
||||
- `acl` - The access control list.
|
||||
- `path` - The path.
|
||||
- `propagate` - Whether to propagate to child paths.
|
||||
- `role_id` - The role identifier.
|
||||
- `comment` - The user comment.
|
||||
- `email` - The user's email address.
|
||||
- `enabled` - Whether the user account is enabled.
|
||||
- `expiration_date` - The user account's expiration date (RFC 3339).
|
||||
- `first_name` - The user's first name.
|
||||
- `groups` - The user's groups.
|
||||
- `keys` - The user's keys.
|
||||
- `last_name` - The user's last name.
|
||||
|
@ -23,12 +23,12 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `comments` - The user comments.
|
||||
* `emails` - The users' email addresses.
|
||||
* `enabled` - Whether a user account is enabled.
|
||||
* `expiration_dates` - The user accounts' expiration dates (RFC 3339).
|
||||
* `first_names` - The users' first names.
|
||||
* `groups` - The users' groups.
|
||||
* `keys` - The users' keys.
|
||||
* `last_names` - The users' last names.
|
||||
* `user_ids` - The user identifiers.
|
||||
- `comments` - The user comments.
|
||||
- `emails` - The users' email addresses.
|
||||
- `enabled` - Whether a user account is enabled.
|
||||
- `expiration_dates` - The user accounts' expiration dates (RFC 3339).
|
||||
- `first_names` - The users' first names.
|
||||
- `groups` - The users' groups.
|
||||
- `keys` - The users' keys.
|
||||
- `last_names` - The users' last names.
|
||||
- `user_ids` - The user identifiers.
|
||||
|
@ -23,7 +23,7 @@ There are no arguments available for this data source.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `keyboard_layout` - The keyboard layout.
|
||||
* `release` - The release number.
|
||||
* `repository_id` - The repository identifier.
|
||||
* `version` - The version string.
|
||||
- `keyboard_layout` - The keyboard layout.
|
||||
- `release` - The release number.
|
||||
- `repository_id` - The repository identifier.
|
||||
- `version` - The version string.
|
||||
|
@ -6,7 +6,10 @@ nav_order: 1
|
||||
|
||||
# Proxmox Provider
|
||||
|
||||
This provider for [Terraform](https://www.terraform.io/) is used for interacting with resources supported by [Proxmox](https://www.proxmox.com/en/). The provider needs to be configured with the proper endpoints and credentials before it can be used.
|
||||
This provider for [Terraform](https://www.terraform.io/) is used for interacting
|
||||
with resources supported by [Proxmox](https://www.proxmox.com/en/). The provider
|
||||
needs to be configured with the proper endpoints and credentials before it can
|
||||
be used.
|
||||
|
||||
Use the navigation to the left to read about the available resources.
|
||||
|
||||
@ -25,16 +28,21 @@ provider "proxmox" {
|
||||
|
||||
## Authentication
|
||||
|
||||
The Proxmox provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below:
|
||||
The Proxmox provider offers a flexible means of providing credentials for
|
||||
authentication. The following methods are supported, in this order, and
|
||||
explained below:
|
||||
|
||||
* Static credentials
|
||||
* Environment variables
|
||||
- Static credentials
|
||||
- Environment variables
|
||||
|
||||
### Static credentials
|
||||
|
||||
> Warning: Hard-coding credentials into any Terraform configuration is not recommended, and risks secret leakage should this file ever be committed to a public version control system.
|
||||
> Warning: Hard-coding credentials into any Terraform configuration is not
|
||||
> recommended, and risks secret leakage should this file ever be committed to a
|
||||
> public version control system.
|
||||
|
||||
Static credentials can be provided by adding a `username` and `password` in-line in the Proxmox provider block:
|
||||
Static credentials can be provided by adding a `username` and `password` in-line
|
||||
in the Proxmox provider block:
|
||||
|
||||
```terraform
|
||||
provider "proxmox" {
|
||||
@ -47,9 +55,11 @@ provider "proxmox" {
|
||||
|
||||
### Environment variables
|
||||
|
||||
You can provide your credentials via the `PROXMOX_VE_USERNAME` and `PROXMOX_VE_PASSWORD`, environment variables, representing your Proxmox username, realm and password, respectively:
|
||||
You can provide your credentials via the `PROXMOX_VE_USERNAME`
|
||||
and `PROXMOX_VE_PASSWORD`, environment variables, representing your Proxmox
|
||||
username, realm and password, respectively:
|
||||
|
||||
```
|
||||
```terraform
|
||||
provider "proxmox" {
|
||||
virtual_environment {}
|
||||
}
|
||||
@ -58,18 +68,28 @@ provider "proxmox" {
|
||||
Usage:
|
||||
|
||||
```sh
|
||||
$ export PROXMOX_VE_USERNAME="username@realm"
|
||||
$ export PROXMOX_VE_PASSWORD="a-strong-password"
|
||||
$ terraform plan
|
||||
export PROXMOX_VE_USERNAME="username@realm"
|
||||
export PROXMOX_VE_PASSWORD="a-strong-password"
|
||||
terraform plan
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
||||
In addition to [generic provider arguments](https://www.terraform.io/docs/configuration/providers.html) (e.g. `alias` and `version`), the following arguments are supported in the Proxmox `provider` block:
|
||||
In addition
|
||||
to [generic provider arguments](https://www.terraform.io/docs/configuration/providers.html) (
|
||||
e.g. `alias` and `version`), the following arguments are supported in the
|
||||
Proxmox `provider` block:
|
||||
|
||||
* `virtual_environment` - (Optional) The Proxmox Virtual Environment configuration.
|
||||
* `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_ENDPOINT`).
|
||||
* `insecure` - (Optional) Whether to skip the TLS verification step (can also be sourced from `PROXMOX_VE_INSECURE`). If omitted, defaults to `false`.
|
||||
* `otp` - (Optional) The one-time password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_OTP`).
|
||||
* `password` - (Required) The password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_PASSWORD`).
|
||||
* `username` - (Required) The username and realm for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_USERNAME`).
|
||||
- `virtual_environment` - (Optional) The Proxmox Virtual Environment
|
||||
configuration.
|
||||
- `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment
|
||||
API (can also be sourced from `PROXMOX_VE_ENDPOINT`).
|
||||
- `insecure` - (Optional) Whether to skip the TLS verification step (can
|
||||
also be sourced from `PROXMOX_VE_INSECURE`). If omitted, defaults
|
||||
to `false`.
|
||||
- `otp` - (Optional) The one-time password for the Proxmox Virtual
|
||||
Environment API (can also be sourced from `PROXMOX_VE_OTP`).
|
||||
- `password` - (Required) The password for the Proxmox Virtual Environment
|
||||
API (can also be sourced from `PROXMOX_VE_PASSWORD`).
|
||||
- `username` - (Required) The username and realm for the Proxmox Virtual
|
||||
Environment API (can also be sourced from `PROXMOX_VE_USERNAME`).
|
||||
|
@ -46,19 +46,19 @@ resource "tls_self_signed_cert" "proxmox_virtual_environment_certificate" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `certificate` - (Required) The PEM encoded certificate.
|
||||
* `certificate_chain` - (Optional) The PEM encoded certificate chain.
|
||||
* `node_name` - (Required) A node name.
|
||||
* `private_key` - (Required) The PEM encoded private key.
|
||||
- `certificate` - (Required) The PEM encoded certificate.
|
||||
- `certificate_chain` - (Optional) The PEM encoded certificate chain.
|
||||
- `node_name` - (Required) A node name.
|
||||
- `private_key` - (Required) The PEM encoded private key.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `expiration_date` - The expiration date (RFC 3339).
|
||||
* `file_name` - The file name.
|
||||
* `issuer` - The issuer.
|
||||
* `public_key_size` - The public key size.
|
||||
* `public_key_type` - The public key type.
|
||||
* `ssl_fingerprint` - The SSL fingerprint.
|
||||
* `start_date` - The start date (RFC 3339).
|
||||
* `subject` - The subject.
|
||||
* `subject_alternative_names` - The subject alternative names.
|
||||
- `expiration_date` - The expiration date (RFC 3339).
|
||||
- `file_name` - The file name.
|
||||
- `issuer` - The issuer.
|
||||
- `public_key_size` - The public key size.
|
||||
- `public_key_type` - The public key type.
|
||||
- `ssl_fingerprint` - The SSL fingerprint.
|
||||
- `start_date` - The start date (RFC 3339).
|
||||
- `subject` - The subject.
|
||||
- `subject_alternative_names` - The subject alternative names.
|
||||
|
@ -16,23 +16,23 @@ We can create aliases to identify an IP address or a network.
|
||||
|
||||
```terraform
|
||||
resource "proxmox_virtual_environment_cluster_alias" "local_network" {
|
||||
name = "local_network"
|
||||
cidr = "192.168.0.0/23"
|
||||
comment = "Managed by Terraform"
|
||||
name = "local_network"
|
||||
cidr = "192.168.0.0/23"
|
||||
comment = "Managed by Terraform"
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_cluster_alias" "ubuntu_vm" {
|
||||
name = "ubuntu"
|
||||
cidr = "192.168.0.1"
|
||||
comment = "Managed by Terraform"
|
||||
name = "ubuntu"
|
||||
cidr = "192.168.0.1"
|
||||
comment = "Managed by Terraform"
|
||||
}
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `name` - (Required) Alias name.
|
||||
* `cidr` - (Required) Network/IP specification in CIDR format.
|
||||
* `comment` - (Optional) Alias comment.
|
||||
- `name` - (Required) Alias name.
|
||||
- `cidr` - (Required) Network/IP specification in CIDR format.
|
||||
- `comment` - (Optional) Alias comment.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -15,35 +15,36 @@ An IPSet allows us to group multiple IP addresses, IP subnets and aliases.
|
||||
|
||||
```terraform
|
||||
resource "proxmox_virtual_environment_cluster_ipset" "ipset" {
|
||||
name = "local_network"
|
||||
comment = "Managed by Terraform"
|
||||
|
||||
cidr {
|
||||
name = "192.168.0.0/23"
|
||||
comment = "Local network 1"
|
||||
}
|
||||
|
||||
cidr {
|
||||
name = "192.168.0.1"
|
||||
comment = "Server 1"
|
||||
nomatch = true
|
||||
}
|
||||
|
||||
cidr {
|
||||
name = "192.168.2.1"
|
||||
comment = "Server 1"
|
||||
}
|
||||
name = "local_network"
|
||||
comment = "Managed by Terraform"
|
||||
|
||||
cidr {
|
||||
name = "192.168.0.0/23"
|
||||
comment = "Local network 1"
|
||||
}
|
||||
|
||||
cidr {
|
||||
name = "192.168.0.1"
|
||||
comment = "Server 1"
|
||||
nomatch = true
|
||||
}
|
||||
|
||||
cidr {
|
||||
name = "192.168.2.1"
|
||||
comment = "Server 1"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `name` - (Required) Alias name.
|
||||
* `comment` - (Optional) Alias comment.
|
||||
* `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
|
||||
* `name` - Network/IP specification in CIDR format.
|
||||
* `comment` - (Optional) Arbitrary string annotation.
|
||||
* `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those were not added to the set.
|
||||
- `name` - (Required) Alias name.
|
||||
- `comment` - (Optional) Alias comment.
|
||||
- `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
|
||||
- `name` - Network/IP specification in CIDR format.
|
||||
- `comment` - (Optional) Arbitrary string annotation.
|
||||
- `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those
|
||||
were not added to the set.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -30,7 +30,9 @@ resource "proxmox_virtual_environment_container" "ubuntu_container" {
|
||||
}
|
||||
|
||||
user_account {
|
||||
keys = [trimspace(tls_private_key.ubuntu_container_key.public_key_openssh)]
|
||||
keys = [
|
||||
trimspace(tls_private_key.ubuntu_container_key.public_key_openssh)
|
||||
]
|
||||
password = random_password.ubuntu_container_password.result
|
||||
}
|
||||
}
|
||||
@ -83,72 +85,89 @@ output "ubuntu_container_public_key" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `clone` - (Optional) The cloning configuration.
|
||||
* `datastore_id` - (Optional) The identifier for the target datastore.
|
||||
* `node_name` - (Optional) The name of the source node (leave blank, if equal to the `node_name` argument).
|
||||
* `vm_id` - (Required) The identifier for the source container.
|
||||
* `console` - (Optional) The console configuration.
|
||||
* `enabled` - (Optional) Whether to enable the console device (defaults to `true`).
|
||||
* `mode` - (Optional) The console mode (defaults to `tty`).
|
||||
* `console` - Console.
|
||||
* `shell` - Shell.
|
||||
* `tty` - TTY.
|
||||
* `tty_count` - (Optional) The number of available TTY (defaults to `2`).
|
||||
* `cpu` - (Optional) The CPU configuration.
|
||||
* `architecture` - (Optional) The CPU architecture (defaults to `amd64`).
|
||||
* `amd64` - x86 (64 bit).
|
||||
* `arm64` - ARM (64-bit).
|
||||
* `armhf` - ARM (32 bit).
|
||||
* `i386` - x86 (32 bit).
|
||||
* `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||
* `units` - (Optional) The CPU units (defaults to `1024`).
|
||||
* `description` - (Optional) The description.
|
||||
* `disk` - (Optional) The disk configuration.
|
||||
* `datastore_id` - (Optional) The identifier for the datastore to create the disk in (defaults to `local`).
|
||||
- `clone` - (Optional) The cloning configuration.
|
||||
- `datastore_id` - (Optional) The identifier for the target datastore.
|
||||
- `node_name` - (Optional) The name of the source node (leave blank, if
|
||||
equal
|
||||
to the `node_name` argument).
|
||||
- `vm_id` - (Required) The identifier for the source container.
|
||||
- `console` - (Optional) The console configuration.
|
||||
- `enabled` - (Optional) Whether to enable the console device (defaults
|
||||
to `true`).
|
||||
- `mode` - (Optional) The console mode (defaults to `tty`).
|
||||
- `console` - Console.
|
||||
- `shell` - Shell.
|
||||
- `tty` - TTY.
|
||||
- `tty_count` - (Optional) The number of available TTY (defaults to `2`).
|
||||
- `cpu` - (Optional) The CPU configuration.
|
||||
- `architecture` - (Optional) The CPU architecture (defaults to `amd64`).
|
||||
- `amd64` - x86 (64 bit).
|
||||
- `arm64` - ARM (64-bit).
|
||||
- `armhf` - ARM (32 bit).
|
||||
- `i386` - x86 (32 bit).
|
||||
- `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||
- `units` - (Optional) The CPU units (defaults to `1024`).
|
||||
- `description` - (Optional) The description.
|
||||
- `disk` - (Optional) The disk configuration.
|
||||
- `datastore_id` - (Optional) The identifier for the datastore to create the
|
||||
disk in (defaults to `local`).
|
||||
* `size` - (Optional) The size of the root filesystem in gigabytes (defaults to `4`). Requires `datastore_id` to be set.
|
||||
* `initialization` - (Optional) The initialization configuration.
|
||||
* `dns` - (Optional) The DNS configuration.
|
||||
* `domain` - (Optional) The DNS search domain.
|
||||
* `server` - (Optional) The DNS server.
|
||||
* `hostname` - (Optional) The hostname.
|
||||
* `ip_config` - (Optional) The IP configuration (one block per network device).
|
||||
* `ipv4` - (Optional) The IPv4 configuration.
|
||||
* `address` - (Optional) The IPv4 address (use `dhcp` for autodiscovery).
|
||||
* `gateway` - (Optional) The IPv4 gateway (must be omitted when `dhcp` is used as the address).
|
||||
* `ipv6` - (Optional) The IPv4 configuration.
|
||||
* `address` - (Optional) The IPv6 address (use `dhcp` for autodiscovery).
|
||||
* `gateway` - (Optional) The IPv6 gateway (must be omitted when `dhcp` is used as the address).
|
||||
* `user_account` - (Optional) The user account configuration.
|
||||
* `keys` - (Optional) The SSH keys for the root account.
|
||||
* `password` - (Optional) The password for the root account.
|
||||
* `memory` - (Optional) The memory configuration.
|
||||
* `dedicated` - (Optional) The dedicated memory in megabytes (defaults to `512`).
|
||||
* `swap` - (Optional) The swap size in megabytes (defaults to `0`).
|
||||
* `network_interface` - (Optional) A network interface (multiple blocks supported).
|
||||
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
||||
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
||||
* `mac_address` - (Optional) The MAC address.
|
||||
* `mtu` - (Optional) Maximum transfer unit of the interface. Cannot be larger than the bridge's MTU.
|
||||
* `name` - (Required) The network interface name.
|
||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||
* `vlan_id` - (Optional) The VLAN identifier.
|
||||
* `node_name` - (Required) The name of the node to assign the container to.
|
||||
* `operating_system` - (Required) The Operating System configuration.
|
||||
* `template_file_id` - (Required) The identifier for an OS template file.
|
||||
* `type` - (Optional) The type (defaults to `unmanaged`).
|
||||
* `alpine` - Alpine.
|
||||
* `archlinux` - Arch Linux.
|
||||
* `centos` - CentOS.
|
||||
* `debian` - Debian.
|
||||
* `fedora` - Fedora.
|
||||
* `gentoo` - Gentoo.
|
||||
* `opensuse` - openSUSE.
|
||||
* `ubuntu` - Ubuntu.
|
||||
* `unmanaged` - Unmanaged.
|
||||
* `pool_id` - (Optional) The identifier for a pool to assign the container to.
|
||||
* `started` - (Optional) Whether to start the container (defaults to `true`).
|
||||
* `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||
* `vm_id` - (Optional) The virtual machine identifier
|
||||
- `initialization` - (Optional) The initialization configuration.
|
||||
- `dns` - (Optional) The DNS configuration.
|
||||
- `domain` - (Optional) The DNS search domain.
|
||||
- `server` - (Optional) The DNS server.
|
||||
- `hostname` - (Optional) The hostname.
|
||||
- `ip_config` - (Optional) The IP configuration (one block per network
|
||||
device).
|
||||
- `ipv4` - (Optional) The IPv4 configuration.
|
||||
- `address` - (Optional) The IPv4 address (use `dhcp` for
|
||||
autodiscovery).
|
||||
- `gateway` - (Optional) The IPv4 gateway (must be omitted
|
||||
when `dhcp` is
|
||||
used as the address).
|
||||
- `ipv6` - (Optional) The IPv4 configuration.
|
||||
- `address` - (Optional) The IPv6 address (use `dhcp` for
|
||||
autodiscovery).
|
||||
- `gateway` - (Optional) The IPv6 gateway (must be omitted
|
||||
when `dhcp` is
|
||||
used as the address).
|
||||
- `user_account` - (Optional) The user account configuration.
|
||||
- `keys` - (Optional) The SSH keys for the root account.
|
||||
- `password` - (Optional) The password for the root account.
|
||||
- `memory` - (Optional) The memory configuration.
|
||||
- `dedicated` - (Optional) The dedicated memory in megabytes (defaults
|
||||
to `512`).
|
||||
- `swap` - (Optional) The swap size in megabytes (defaults to `0`).
|
||||
- `network_interface` - (Optional) A network interface (multiple blocks
|
||||
supported).
|
||||
- `bridge` - (Optional) The name of the network bridge (defaults
|
||||
to `vmbr0`).
|
||||
- `enabled` - (Optional) Whether to enable the network device (defaults
|
||||
to `true`).
|
||||
- `mac_address` - (Optional) The MAC address.
|
||||
- `mtu` - (Optional) Maximum transfer unit of the interface. Cannot be
|
||||
larger
|
||||
than the bridge's MTU.
|
||||
- `name` - (Required) The network interface name.
|
||||
- `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||
- `vlan_id` - (Optional) The VLAN identifier.
|
||||
- `node_name` - (Required) The name of the node to assign the container to.
|
||||
- `operating_system` - (Required) The Operating System configuration.
|
||||
- `template_file_id` - (Required) The identifier for an OS template file.
|
||||
- `type` - (Optional) The type (defaults to `unmanaged`).
|
||||
- `alpine` - Alpine.
|
||||
- `archlinux` - Arch Linux.
|
||||
- `centos` - CentOS.
|
||||
- `debian` - Debian.
|
||||
- `fedora` - Fedora.
|
||||
- `gentoo` - Gentoo.
|
||||
- `opensuse` - openSUSE.
|
||||
- `ubuntu` - Ubuntu.
|
||||
- `unmanaged` - Unmanaged.
|
||||
- `pool_id` - (Optional) The identifier for a pool to assign the container to.
|
||||
- `started` - (Optional) Whether to start the container (defaults to `true`).
|
||||
- `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||
- `vm_id` - (Optional) The virtual machine identifier
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -31,9 +31,9 @@ data "proxmox_virtual_environment_dns" "first_node_dns_configuration" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `domain` - (Required) The DNS search domain.
|
||||
* `node_name` - (Required) A node name.
|
||||
* `servers` - (Optional) The DNS servers.
|
||||
- `domain` - (Required) The DNS search domain.
|
||||
- `node_name` - (Required) A node name.
|
||||
- `servers` - (Optional) The DNS servers.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -58,34 +58,38 @@ EOF
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `content_type` - (Optional) The content type.
|
||||
* `backup`
|
||||
* `iso`
|
||||
* `snippets`
|
||||
* `vztmpl`
|
||||
* `datastore_id` - (Required) The datastore id.
|
||||
* `node_name` - (Required) The node name.
|
||||
* `source_file` - (Optional) The source file (conflicts with `source_raw`).
|
||||
* `checksum` - (Optional) The SHA256 checksum of the source file.
|
||||
* `file_name` - (Optional) The file name to use instead of the source file name.
|
||||
* `insecure` - (Optional) Whether to skip the TLS verification step for HTTPS sources (defaults to `false`).
|
||||
* `path` - (Required) A path to a local file or a URL.
|
||||
* `source_raw` - (Optional) The raw source (conflicts with `source_file`).
|
||||
* `data` - (Required) The raw data.
|
||||
* `file_name` - (Required) The file name.
|
||||
* `resize` - (Optional) The number of bytes to resize the file to.
|
||||
- `content_type` - (Optional) The content type.
|
||||
- `backup`
|
||||
- `iso`
|
||||
- `snippets`
|
||||
- `vztmpl`
|
||||
- `datastore_id` - (Required) The datastore id.
|
||||
- `node_name` - (Required) The node name.
|
||||
- `source_file` - (Optional) The source file (conflicts with `source_raw`).
|
||||
- `checksum` - (Optional) The SHA256 checksum of the source file.
|
||||
- `file_name` - (Optional) The file name to use instead of the source file
|
||||
name.
|
||||
- `insecure` - (Optional) Whether to skip the TLS verification step for
|
||||
HTTPSsources (defaults to `false`).
|
||||
- `path` - (Required) A path to a local file or a URL.
|
||||
- `source_raw` - (Optional) The raw source (conflicts with `source_file`).
|
||||
- `data` - (Required) The raw data.
|
||||
- `file_name` - (Required) The file name.
|
||||
- `resize` - (Optional) The number of bytes to resize the file to.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `file_modification_date` - The file modification date (RFC 3339).
|
||||
* `file_name` - The file name.
|
||||
* `file_size` - The file size in bytes.
|
||||
* `file_tag` - The file tag.
|
||||
- `file_modification_date` - The file modification date (RFC 3339).
|
||||
- `file_name` - The file name.
|
||||
- `file_size` - The file size in bytes.
|
||||
- `file_tag` - The file tag.
|
||||
|
||||
## Important Notes
|
||||
|
||||
The Proxmox VE API endpoint for file uploads does not support chunked transfer encoding, which means that we must first
|
||||
store the source file as a temporary file locally before uploading it.
|
||||
The Proxmox VE API endpoint for file uploads does not support chunked transfer
|
||||
encoding, which means that we must first store the source file as a temporary
|
||||
file locally before uploading it.
|
||||
|
||||
You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space available (twice the size plus overhead
|
||||
because a multipart payload needs to be created as another temporary file).
|
||||
You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space
|
||||
available (twice the size plus overhead because a multipart payload needs to be
|
||||
created as another temporary file).
|
||||
|
@ -22,13 +22,13 @@ resource "proxmox_virtual_environment_group" "operations_team" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `acl` - (Optional) The access control list (multiple blocks supported).
|
||||
* `path` - The path.
|
||||
* `propagate` - Whether to propagate to child paths.
|
||||
* `role_id` - The role identifier.
|
||||
* `comment` - (Optional) The group comment.
|
||||
* `group_id` - (Required) The group identifier.
|
||||
- `acl` - (Optional) The access control list (multiple blocks supported).
|
||||
- `path` - The path.
|
||||
- `propagate` - Whether to propagate to child paths.
|
||||
- `role_id` - The role identifier.
|
||||
- `comment` - (Optional) The group comment.
|
||||
- `group_id` - (Required) The group identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `members` - The group members as a list of `username@realm` entries
|
||||
- `members` - The group members as a list of `username@realm` entries
|
||||
|
@ -30,14 +30,15 @@ resource "proxmox_virtual_environment_hosts" "first_node_host_entries" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
* `entry` - (Required) A host entry (multiple blocks supported).
|
||||
* `address` - (Required) The IP address.
|
||||
* `hostnames` - (Required) The hostnames.
|
||||
- `node_name` - (Required) A node name.
|
||||
- `entry` - (Required) A host entry (multiple blocks supported).
|
||||
- `address` - (Required) The IP address.
|
||||
- `hostnames` - (Required) The hostnames.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `addresses` - The IP addresses.
|
||||
* `digest` - The SHA1 digest.
|
||||
* `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
|
||||
* `hostnames` - The hostnames associated with each of the IP addresses.
|
||||
- `addresses` - The IP addresses.
|
||||
- `digest` - The SHA1 digest.
|
||||
- `entries` - The host entries (conversion of `addresses` and `hostnames` into
|
||||
objects).
|
||||
- `hostnames` - The hostnames associated with each of the IP addresses.
|
||||
|
@ -22,14 +22,14 @@ resource "proxmox_virtual_environment_pool" "operations_pool" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `comment` - (Optional) The pool comment.
|
||||
* `pool_id` - (Required) The pool identifier.
|
||||
- `comment` - (Optional) The pool comment.
|
||||
- `pool_id` - (Required) The pool identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `members` - The pool members.
|
||||
* `datastore_id` - The datastore identifier.
|
||||
* `id` - The member identifier.
|
||||
* `node_name` - The node name.
|
||||
* `type` - The member type.
|
||||
* `vm_id` - The virtual machine identifier.
|
||||
- `members` - The pool members.
|
||||
- `datastore_id` - The datastore identifier.
|
||||
- `id` - The member identifier.
|
||||
- `node_name` - The node name.
|
||||
- `type` - The member type.
|
||||
- `vm_id` - The virtual machine identifier.
|
||||
|
@ -25,8 +25,8 @@ resource "proxmox_virtual_environment_role" "operations_monitoring" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `privileges` - (Required) The role privileges.
|
||||
* `role_id` - (Required) The role identifier.
|
||||
- `privileges` - (Required) The role privileges.
|
||||
- `role_id` - (Required) The role identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -22,10 +22,10 @@ resource "proxmox_virtual_environment_time" "first_node_time" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `node_name` - (Required) A node name.
|
||||
* `time_zone` - (Required) The node's time zone.
|
||||
- `node_name` - (Required) A node name.
|
||||
- `time_zone` - (Required) The node's time zone.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `local_time` - The node's local time.
|
||||
* `utc_time` - The node's local time formatted as UTC.
|
||||
- `local_time` - The node's local time.
|
||||
- `utc_time` - The node's local time formatted as UTC.
|
||||
|
@ -37,20 +37,20 @@ resource "proxmox_virtual_environment_role" "operations_monitoring" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `acl` - (Optional) The access control list (multiple blocks supported).
|
||||
* `path` - The path.
|
||||
* `propagate` - Whether to propagate to child paths.
|
||||
* `role_id` - The role identifier.
|
||||
* `comment` - (Optional) The user comment.
|
||||
* `email` - (Optional) The user's email address.
|
||||
* `enabled` - (Optional) Whether the user account is enabled.
|
||||
* `expiration_date` - (Optional) The user account's expiration date (RFC 3339).
|
||||
* `first_name` - (Optional) The user's first name.
|
||||
* `groups` - (Optional) The user's groups.
|
||||
* `keys` - (Optional) The user's keys.
|
||||
* `last_name` - (Optional) The user's last name.
|
||||
* `password` - (Required) The user's password.
|
||||
* `user_id` - (Required) The user identifier.
|
||||
- `acl` - (Optional) The access control list (multiple blocks supported).
|
||||
- `path` - The path.
|
||||
- `propagate` - Whether to propagate to child paths.
|
||||
- `role_id` - The role identifier.
|
||||
- `comment` - (Optional) The user comment.
|
||||
- `email` - (Optional) The user's email address.
|
||||
- `enabled` - (Optional) Whether the user account is enabled.
|
||||
- `expiration_date` - (Optional) The user account's expiration date (RFC 3339).
|
||||
- `first_name` - (Optional) The user's first name.
|
||||
- `groups` - (Optional) The user's groups.
|
||||
- `keys` - (Optional) The user's keys.
|
||||
- `last_name` - (Optional) The user's last name.
|
||||
- `password` - (Required) The user's password.
|
||||
- `user_id` - (Required) The user identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
|
@ -97,251 +97,339 @@ output "ubuntu_vm_public_key" {
|
||||
|
||||
## Argument Reference
|
||||
|
||||
* `acpi` - (Optional) Whether to enable ACPI (defaults to `true`).
|
||||
* `agent` - (Optional) The QEMU agent configuration.
|
||||
* `enabled` - (Optional) Whether to enable the QEMU agent (defaults to `false`).
|
||||
* `timeout` - (Optional) The maximum amount of time to wait for data from the QEMU agent to become available (
|
||||
defaults to `15m`).
|
||||
* `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent (defaults to `false`).
|
||||
* `type` - (Optional) The QEMU agent interface type (defaults to `virtio`).
|
||||
* `isa` - ISA Serial Port.
|
||||
* `virtio` - VirtIO (paravirtualized).
|
||||
* `audio_device` - (Optional) An audio device.
|
||||
* `device` - (Optional) The device (defaults to `intel-hda`).
|
||||
* `AC97` - Intel 82801AA AC97 Audio.
|
||||
* `ich9-intel-hda` - Intel HD Audio Controller (ich9).
|
||||
* `intel-hda` - Intel HD Audio.
|
||||
* `driver` - (Optional) The driver (defaults to `spice`).
|
||||
* `spice` - Spice.
|
||||
* `enabled` - (Optional) Whether to enable the audio device (defaults to `true`).
|
||||
* `bios` - (Optional) The BIOS implementation (defaults to `seabios`).
|
||||
* `ovmf` - OVMF (UEFI).
|
||||
* `seabios` - SeaBIOS.
|
||||
* `cdrom` - (Optional) The CDROM configuration.
|
||||
* `enabled` - (Optional) Whether to enable the CDROM drive (defaults to `false`).
|
||||
* `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as in the physical drive).
|
||||
* `clone` - (Optional) The cloning configuration.
|
||||
* `datastore_id` - (Optional) The identifier for the target datastore.
|
||||
* `node_name` - (Optional) The name of the source node (leave blank, if equal to the `node_name` argument).
|
||||
* `retries` - (Optional) Number of retries in Proxmox for clone vm. Sometimes Proxmox errors with timeout when
|
||||
creating multiple clones at once.
|
||||
* `vm_id` - (Required) The identifier for the source VM.
|
||||
* `cpu` - (Optional) The CPU configuration.
|
||||
* `architecture` - (Optional) The CPU architecture (defaults to `x86_64`).
|
||||
* `aarch64` - ARM (64 bit).
|
||||
* `x86_64` - x86 (64-bit).
|
||||
* `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||
* `flags` - (Optional) The CPU flags.
|
||||
* `+aes`/`-aes` - Activate AES instruction set for HW acceleration.
|
||||
* `+amd-no-ssb`/`-amd-no-ssb` - Notifies guest OS that host is not vulnerable for Spectre on AMD CPUs.
|
||||
* `+amd-ssbd`/`-amd-ssbd` - Improves Spectre mitigation performance with AMD CPUs, best used with "virt-ssbd".
|
||||
* `+hv-evmcs`/`-hv-evmcs` - Improve performance for nested virtualization (only supported on Intel CPUs).
|
||||
* `+hv-tlbflush`/`-hv-tlbflush` - Improve performance in overcommitted Windows guests (may lead to guest BSOD on
|
||||
old CPUs).
|
||||
* `+ibpb`/`-ibpb` - Allows improved Spectre mitigation on AMD CPUs.
|
||||
* `+md-clear`/`-md-clear` - Required to let the guest OS know if MDS is mitigated correctly.
|
||||
* `+pcid`/`-pcid` - Meltdown fix cost reduction on Westmere, Sandy- and Ivy Bridge Intel CPUs.
|
||||
* `+pdpe1gb`/`-pdpe1gb` - Allows guest OS to use 1 GB size pages, if host HW supports it.
|
||||
* `+spec-ctrl`/`-spec-ctrl` - Allows improved Spectre mitigation with Intel CPUs.
|
||||
* `+ssbd`/`-ssbd` - Protection for "Speculative Store Bypass" for Intel models.
|
||||
* `+virt-ssbd`/`-virt-ssbd` - Basis for "Speculative Store Bypass" protection for AMD models.
|
||||
* `hotplugged` - (Optional) The number of hotplugged vCPUs (defaults to `0`).
|
||||
* `sockets` - (Optional) The number of CPU sockets (defaults to `1`).
|
||||
* `type` - (Optional) The emulated CPU type (defaults to `qemu64`).
|
||||
* `486` - Intel 486.
|
||||
* `Broadwell`/`Broadwell-IBRS`/`Broadwell-noTSX`/`Broadwell-noTSX-IBRS` - Intel Core Processor (Broadwell, 2014)
|
||||
.
|
||||
* `Cascadelake-Server` - Intel Xeon 32xx/42xx/52xx/62xx/82xx/92xx (2019).
|
||||
* `Conroe` - Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006).
|
||||
* `EPYC`/`EPYC-IBPB` - AMD EPYC Processor (2017).
|
||||
* `Haswell`/`Haswell-IBRS`/`Haswell-noTSX`/`Haswell-noTSX-IBRS` - Intel Core Processor (Haswell, 2013).
|
||||
* `IvyBridge`/`IvyBridge-IBRS` - Intel Xeon E3-12xx v2 (Ivy Bridge, 2012).
|
||||
* `KnightsMill` - Intel Xeon Phi 72xx (2017).
|
||||
* `Nehalem`/`Nehalem-IBRS` - Intel Core i7 9xx (Nehalem Class Core i7, 2008).
|
||||
* `Opteron_G1` - AMD Opteron 240 (Gen 1 Class Opteron, 2004).
|
||||
* `Opteron_G2` - AMD Opteron 22xx (Gen 2 Class Opteron, 2006).
|
||||
* `Opteron_G3` - AMD Opteron 23xx (Gen 3 Class Opteron, 2009).
|
||||
* `Opteron_G4` - AMD Opteron 62xx class CPU (2011).
|
||||
* `Opteron_G5` - AMD Opteron 63xx class CPU (2012).
|
||||
* `Penryn` - Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007).
|
||||
* `SandyBridge`/`SandyBridge-IBRS` - Intel Xeon E312xx (Sandy Bridge, 2011).
|
||||
* `Skylake-Client`/`Skylake-Client-IBRS` - Intel Core Processor (Skylake, 2015).
|
||||
* `Skylake-Server`/`Skylake-Server-IBRS` - Intel Xeon Processor (Skylake, 2016).
|
||||
* `Westmere`/`Westmere-IBRS` - Intel Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010).
|
||||
* `athlon` - AMD Athlon.
|
||||
* `core2duo` - Intel Core 2 Duo.
|
||||
* `coreduo` - Intel Core Duo.
|
||||
* `host` - Host pass-through.
|
||||
* `kvm32`/`kvm64` - Common KVM processor (32 & 64 bit variants).
|
||||
* `max` - Maximum amount of features from host CPU.
|
||||
* `pentium` - Intel Pentium (1993).
|
||||
* `pentium2` - Intel Pentium 2 (1997-1999).
|
||||
* `pentium3` - Intel Pentium 3 (1999-2001).
|
||||
* `phenom` - AMD Phenom (2010).
|
||||
* `qemu32`/`qemu64` - QEMU Virtual CPU version 2.5+ (32 & 64 bit variants).
|
||||
* `units` - (Optional) The CPU units (defaults to `1024`).
|
||||
* `description` - (Optional) The description.
|
||||
* `disk` - (Optional) A disk (multiple blocks supported).
|
||||
* `datastore_id` - (Optional) The identifier for the datastore to create the disk in (defaults to `local-lvm`).
|
||||
* `discard` - (Optional) Whether to pass discard/trim requests to the underlying storage. Supported values are `on`/`ignore` (defaults to `ignore`)
|
||||
* `file_format` - (Optional) The file format (defaults to `qcow2`).
|
||||
* `qcow2` - QEMU Disk Image v2.
|
||||
* `raw` - Raw Disk Image.
|
||||
* `vmdk` - VMware Disk Image.
|
||||
* `file_id` - (Optional) The file ID for a disk image (experimental - might cause high CPU utilization during
|
||||
import, especially with large disk images).
|
||||
* `interface` - (Required) The disk interface for Proxmox, currently scsi, sata and virtio are supported.
|
||||
* `iothread` - (Optional) Whether to use iothreads for this disk (defaults to `false`).
|
||||
* `size` - (Optional) The disk size in gigabytes (defaults to `8`).
|
||||
* `speed` - (Optional) The speed limits.
|
||||
* `read` - (Optional) The maximum read speed in megabytes per second.
|
||||
* `read_burstable` - (Optional) The maximum burstable read speed in megabytes per second.
|
||||
* `write` - (Optional) The maximum write speed in megabytes per second.
|
||||
* `write_burstable` - (Optional) The maximum burstable write speed in megabytes per second.
|
||||
* `ssd` - (Optional) Whether to use an SSD emulation option for this disk (defaults to `false`). Note that SSD emulation is not supported on VirtIO Block drives.
|
||||
* `hostpci` - (Optional) A host PCI device mapping (multiple blocks supported).
|
||||
* `device` - (Required) The PCI device name for Proxmox, in form of `hostpciX` where `X` is a sequential number from 0 to 3.
|
||||
* `id` - (Required) The PCI device ID.
|
||||
* `mdev` - (Optional) The mediated device ID to use.
|
||||
* `pcie` - (Optional) Tells Proxmox to use a PCIe or PCI port. Some guests/device combination require PCIe rather than PCI. PCIe is only available for q35 machine types.
|
||||
* `rombar` - (Optional) Makes the firmware ROM visible for the VM (defaults to `true`).
|
||||
* `rom_file` - (Optional) A path to a ROM file for the device to use. This is a relative path under `/usr/share/kvm/`.
|
||||
* `xvga` - (Optional) Marks the PCI(e) device as the primary GPU of the VM. With this enabled the `vga` configuration argument will be ignored.
|
||||
* `initialization` - (Optional) The cloud-init configuration.
|
||||
* `datastore_id` - (Optional) The identifier for the datastore to create the cloud-init disk in (defaults
|
||||
- `acpi` - (Optional) Whether to enable ACPI (defaults to `true`).
|
||||
- `agent` - (Optional) The QEMU agent configuration.
|
||||
- `enabled` - (Optional) Whether to enable the QEMU agent (defaults
|
||||
to `false`).
|
||||
- `timeout` - (Optional) The maximum amount of time to wait for data from
|
||||
the
|
||||
QEMU agent to become available ( defaults to `15m`).
|
||||
- `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent
|
||||
(defaults to `false`).
|
||||
- `type` - (Optional) The QEMU agent interface type (defaults to `virtio`).
|
||||
- `isa` - ISA Serial Port.
|
||||
- `virtio` - VirtIO (paravirtualized).
|
||||
- `audio_device` - (Optional) An audio device.
|
||||
- `device` - (Optional) The device (defaults to `intel-hda`).
|
||||
- `AC97` - Intel 82801AA AC97 Audio.
|
||||
- `ich9-intel-hda` - Intel HD Audio Controller (ich9).
|
||||
- `intel-hda` - Intel HD Audio.
|
||||
- `driver` - (Optional) The driver (defaults to `spice`).
|
||||
- `spice` - Spice.
|
||||
- `enabled` - (Optional) Whether to enable the audio device (defaults
|
||||
to `true`).
|
||||
- `bios` - (Optional) The BIOS implementation (defaults to `seabios`).
|
||||
- `ovmf` - OVMF (UEFI).
|
||||
- `seabios` - SeaBIOS.
|
||||
- `cdrom` - (Optional) The CDROM configuration.
|
||||
- `enabled` - (Optional) Whether to enable the CDROM drive (defaults
|
||||
to `false`).
|
||||
- `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as
|
||||
in
|
||||
the physical drive).
|
||||
- `clone` - (Optional) The cloning configuration.
|
||||
- `datastore_id` - (Optional) The identifier for the target datastore.
|
||||
- `node_name` - (Optional) The name of the source node (leave blank, if
|
||||
equal to the `node_name` argument).
|
||||
- `retries` - (Optional) Number of retries in Proxmox for clone vm.
|
||||
Sometimes Proxmox errors with timeout when creating multiple clones at once.
|
||||
- `vm_id` - (Required) The identifier for the source VM.
|
||||
- `cpu` - (Optional) The CPU configuration.
|
||||
- `architecture` - (Optional) The CPU architecture (defaults to `x86_64`).
|
||||
- `aarch64` - ARM (64 bit).
|
||||
- `x86_64` - x86 (64-bit).
|
||||
- `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||
- `flags` - (Optional) The CPU flags.
|
||||
- `+aes`/`-aes` - Activate AES instruction set for HW acceleration.
|
||||
- `+amd-no-ssb`/`-amd-no-ssb` - Notifies guest OS that host is not
|
||||
vulnerable for Spectre on AMD CPUs.
|
||||
- `+amd-ssbd`/`-amd-ssbd` - Improves Spectre mitigation performance with
|
||||
AMD CPUs, best used with "virt-ssbd".
|
||||
- `+hv-evmcs`/`-hv-evmcs` - Improve performance for nested
|
||||
virtualization (only supported on Intel CPUs).
|
||||
- `+hv-tlbflush`/`-hv-tlbflush` - Improve performance in overcommitted
|
||||
Windows guests (may lead to guest BSOD on old CPUs).
|
||||
- `+ibpb`/`-ibpb` - Allows improved Spectre mitigation on AMD CPUs.
|
||||
- `+md-clear`/`-md-clear` - Required to let the guest OS know if MDS is
|
||||
mitigated correctly.
|
||||
- `+pcid`/`-pcid` - Meltdown fix cost reduction on Westmere, Sandy- and
|
||||
Ivy Bridge Intel CPUs.
|
||||
- `+pdpe1gb`/`-pdpe1gb` - Allows guest OS to use 1 GB size pages, if
|
||||
host HW supports it.
|
||||
- `+spec-ctrl`/`-spec-ctrl` - Allows improved Spectre mitigation with
|
||||
Intel CPUs.
|
||||
- `+ssbd`/`-ssbd` - Protection for "Speculative Store Bypass" for Intel
|
||||
models.
|
||||
- `+virt-ssbd`/`-virt-ssbd` - Basis for "Speculative Store Bypass"
|
||||
protection for AMD models.
|
||||
- `hotplugged` - (Optional) The number of hotplugged vCPUs (defaults
|
||||
to `0`).
|
||||
- `sockets` - (Optional) The number of CPU sockets (defaults to `1`).
|
||||
- `type` - (Optional) The emulated CPU type (defaults to `qemu64`).
|
||||
- `486` - Intel 486.
|
||||
- `Broadwell`/`Broadwell-IBRS`/`Broadwell-noTSX`/`Broadwell-noTSX-IBRS`
|
||||
- Intel Core Processor (Broadwell, 2014).
|
||||
- `Cascadelake-Server` - Intel Xeon 32xx/42xx/52xx/62xx/82xx/92xx (
|
||||
2019).
|
||||
- `Conroe` - Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006).
|
||||
- `EPYC`/`EPYC-IBPB` - AMD EPYC Processor (2017).
|
||||
- `Haswell`/`Haswell-IBRS`/`Haswell-noTSX`/`Haswell-noTSX-IBRS` - Intel
|
||||
Core Processor (Haswell, 2013).
|
||||
- `IvyBridge`/`IvyBridge-IBRS` - Intel Xeon E3-12xx v2 (Ivy Bridge,
|
||||
2012).
|
||||
- `KnightsMill` - Intel Xeon Phi 72xx (2017).
|
||||
- `Nehalem`/`Nehalem-IBRS` - Intel Core i7 9xx (Nehalem Class Core i7,
|
||||
2008).
|
||||
- `Opteron_G1` - AMD Opteron 240 (Gen 1 Class Opteron, 2004).
|
||||
- `Opteron_G2` - AMD Opteron 22xx (Gen 2 Class Opteron, 2006).
|
||||
- `Opteron_G3` - AMD Opteron 23xx (Gen 3 Class Opteron, 2009).
|
||||
- `Opteron_G4` - AMD Opteron 62xx class CPU (2011).
|
||||
- `Opteron_G5` - AMD Opteron 63xx class CPU (2012).
|
||||
- `Penryn` - Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007).
|
||||
- `SandyBridge`/`SandyBridge-IBRS` - Intel Xeon E312xx (Sandy Bridge,
|
||||
2011).
|
||||
- `Skylake-Client`/`Skylake-Client-IBRS` - Intel Core Processor (
|
||||
Skylake, 2015).
|
||||
- `Skylake-Server`/`Skylake-Server-IBRS` - Intel Xeon Processor (
|
||||
Skylake, 2016).
|
||||
- `Westmere`/`Westmere-IBRS` - Intel Westmere E56xx/L56xx/X56xx (
|
||||
Nehalem-C, 2010).
|
||||
- `athlon` - AMD Athlon.
|
||||
- `core2duo` - Intel Core 2 Duo.
|
||||
- `coreduo` - Intel Core Duo.
|
||||
- `host` - Host pass-through.
|
||||
- `kvm32`/`kvm64` - Common KVM processor (32 & 64 bit variants).
|
||||
- `max` - Maximum amount of features from host CPU.
|
||||
- `pentium` - Intel Pentium (1993).
|
||||
- `pentium2` - Intel Pentium 2 (1997-1999).
|
||||
- `pentium3` - Intel Pentium 3 (1999-2001).
|
||||
- `phenom` - AMD Phenom (2010).
|
||||
- `qemu32`/`qemu64` - QEMU Virtual CPU version 2.5+ (32 & 64 bit
|
||||
variants).
|
||||
- `units` - (Optional) The CPU units (defaults to `1024`).
|
||||
- `description` - (Optional) The description.
|
||||
- `disk` - (Optional) A disk (multiple blocks supported).
|
||||
- `datastore_id` - (Optional) The identifier for the datastore to create
|
||||
the disk in (defaults to `local-lvm`).
|
||||
- `discard` - (Optional) Whether to pass discard/trim requests to the
|
||||
underlying storage. Supported values are `on`/`ignore` (defaults
|
||||
to `ignore`).
|
||||
- `file_format` - (Optional) The file format (defaults to `qcow2`).
|
||||
- `qcow2` - QEMU Disk Image v2.
|
||||
- `raw` - Raw Disk Image.
|
||||
- `vmdk` - VMware Disk Image.
|
||||
- `file_id` - (Optional) The file ID for a disk image (experimental -
|
||||
might cause high CPU utilization during import, especially with large
|
||||
disk images).
|
||||
- `interface` - (Required) The disk interface for Proxmox, currently scsi,
|
||||
sata and virtio are supported.
|
||||
- `iothread` - (Optional) Whether to use iothreads for this disk (defaults
|
||||
to `false`).
|
||||
- `size` - (Optional) The disk size in gigabytes (defaults to `8`).
|
||||
- `speed` - (Optional) The speed limits.
|
||||
- `read` - (Optional) The maximum read speed in megabytes per second.
|
||||
- `read_burstable` - (Optional) The maximum burstable read speed in
|
||||
megabytes per second.
|
||||
- `write` - (Optional) The maximum write speed in megabytes per second.
|
||||
- `write_burstable` - (Optional) The maximum burstable write speed in
|
||||
megabytes per second.
|
||||
- `ssd` - (Optional) Whether to use an SSD emulation option for this disk (
|
||||
defaults to `false`). Note that SSD emulation is not supported on VirtIO
|
||||
Block drives.
|
||||
- `hostpci` - (Optional) A host PCI device mapping (multiple blocks supported).
|
||||
- `device` - (Required) The PCI device name for Proxmox, in form
|
||||
of `hostpciX` where `X` is a sequential number from 0 to 3.
|
||||
- `id` - (Required) The PCI device ID.
|
||||
- `mdev` - (Optional) The mediated device ID to use.
|
||||
- `pcie` - (Optional) Tells Proxmox to use a PCIe or PCI port. Some
|
||||
guests/device combination require PCIe rather than PCI. PCIe is only
|
||||
available for q35 machine types.
|
||||
- `rombar` - (Optional) Makes the firmware ROM visible for the VM (defaults
|
||||
to `true`).
|
||||
- `rom_file` - (Optional) A path to a ROM file for the device to use. This
|
||||
is a relative path under `/usr/share/kvm/`.
|
||||
- `xvga` - (Optional) Marks the PCI(e) device as the primary GPU of the VM.
|
||||
With this enabled the `vga` configuration argument will be ignored.
|
||||
- `initialization` - (Optional) The cloud-init configuration.
|
||||
- `datastore_id` - (Optional) The identifier for the datastore to create the
|
||||
cloud-init disk in (defaults
|
||||
to `local-lvm`).
|
||||
* `dns` - (Optional) The DNS configuration.
|
||||
* `domain` - (Optional) The DNS search domain.
|
||||
* `server` - (Optional) The DNS server.
|
||||
* `ip_config` - (Optional) The IP configuration (one block per network device).
|
||||
* `ipv4` - (Optional) The IPv4 configuration.
|
||||
* `address` - (Optional) The IPv4 address (use `dhcp` for autodiscovery).
|
||||
* `gateway` - (Optional) The IPv4 gateway (must be omitted when `dhcp` is used as the address).
|
||||
* `ipv6` - (Optional) The IPv4 configuration.
|
||||
* `address` - (Optional) The IPv6 address (use `dhcp` for autodiscovery).
|
||||
* `gateway` - (Optional) The IPv6 gateway (must be omitted when `dhcp` is used as the address).
|
||||
* `user_account` - (Optional) The user account configuration (conflicts with `user_data_file_id`).
|
||||
* `keys` - (Optional) The SSH keys.
|
||||
* `password` - (Optional) The SSH password.
|
||||
* `username` - (Optional) The SSH username.
|
||||
* `network_data_file_id` - (Optional) The identifier for a file containing network configuration data passed to the
|
||||
- `dns` - (Optional) The DNS configuration.
|
||||
- `domain` - (Optional) The DNS search domain.
|
||||
- `server` - (Optional) The DNS server.
|
||||
- `ip_config` - (Optional) The IP configuration (one block per network
|
||||
device).
|
||||
- `ipv4` - (Optional) The IPv4 configuration.
|
||||
- `address` - (Optional) The IPv4 address (use `dhcp` for
|
||||
autodiscovery).
|
||||
- `gateway` - (Optional) The IPv4 gateway (must be omitted
|
||||
when `dhcp` is used as the address).
|
||||
- `ipv6` - (Optional) The IPv4 configuration.
|
||||
- `address` - (Optional) The IPv6 address (use `dhcp` for
|
||||
autodiscovery).
|
||||
- `gateway` - (Optional) The IPv6 gateway (must be omitted
|
||||
when `dhcp` is used as the address).
|
||||
- `user_account` - (Optional) The user account configuration (conflicts
|
||||
with `user_data_file_id`).
|
||||
- `keys` - (Optional) The SSH keys.
|
||||
- `password` - (Optional) The SSH password.
|
||||
- `username` - (Optional) The SSH username.
|
||||
- `network_data_file_id` - (Optional) The identifier for a file containing
|
||||
network configuration data passed to the
|
||||
VM via cloud-init (conflicts with `ip_config`).
|
||||
* `user_data_file_id` - (Optional) The identifier for a file containing custom user data (conflicts
|
||||
- `user_data_file_id` - (Optional) The identifier for a file containing
|
||||
custom user data (conflicts
|
||||
with `user_account`).
|
||||
* `vendor_data_file_id` - (Optional) The identifier for a file containing all vendor data passed to the VM via cloud-init.
|
||||
* `keyboard_layout` - (Optional) The keyboard layout (defaults to `en-us`).
|
||||
* `da` - Danish.
|
||||
* `de` - German.
|
||||
* `de-ch` - Swiss German.
|
||||
* `en-gb` - British English.
|
||||
* `en-us` - American English.
|
||||
* `es` - Spanish.
|
||||
* `fi` - Finnish.
|
||||
* `fr` - French.
|
||||
* `fr-be` - Belgian French.
|
||||
* `fr-ca` - French Canadian.
|
||||
* `fr-ch` - Swish French.
|
||||
* `hu` - Hungarian.
|
||||
* `is` - Icelandic.
|
||||
* `it` - Italian.
|
||||
* `ja` - Japanese.
|
||||
* `lt` - Lithuanian.
|
||||
* `mk` - Macedonian.
|
||||
* `nl` - Dutch.
|
||||
* `no` - Norwegian.
|
||||
* `pl` - Polish.
|
||||
* `pt` - Portuguese.
|
||||
* `pt-br` - Brazilian Portuguese.
|
||||
* `sl` - Slovenian.
|
||||
* `sv` - Swedish.
|
||||
* `tr` - Turkish.
|
||||
* `kvm_arguments` - (Optional) Arbitrary arguments passed to kvm.
|
||||
- `vendor_data_file_id` - (Optional) The identifier for a file containing
|
||||
all vendor data passed to the VM via cloud-init.
|
||||
- `keyboard_layout` - (Optional) The keyboard layout (defaults to `en-us`).
|
||||
- `da` - Danish.
|
||||
- `de` - German.
|
||||
- `de-ch` - Swiss German.
|
||||
- `en-gb` - British English.
|
||||
- `en-us` - American English.
|
||||
- `es` - Spanish.
|
||||
- `fi` - Finnish.
|
||||
- `fr` - French.
|
||||
- `fr-be` - Belgian French.
|
||||
- `fr-ca` - French Canadian.
|
||||
- `fr-ch` - Swish French.
|
||||
- `hu` - Hungarian.
|
||||
- `is` - Icelandic.
|
||||
- `it` - Italian.
|
||||
- `ja` - Japanese.
|
||||
- `lt` - Lithuanian.
|
||||
- `mk` - Macedonian.
|
||||
- `nl` - Dutch.
|
||||
- `no` - Norwegian.
|
||||
- `pl` - Polish.
|
||||
- `pt` - Portuguese.
|
||||
- `pt-br` - Brazilian Portuguese.
|
||||
- `sl` - Slovenian.
|
||||
- `sv` - Swedish.
|
||||
- `tr` - Turkish.
|
||||
- `kvm_arguments` - (Optional) Arbitrary arguments passed to kvm.
|
||||
* `machine` - (Optional) The VM machine type (defaults to `i440fx`).
|
||||
* `i440fx` - Standard PC (i440FX + PIIX, 1996).
|
||||
* `q35` - Standard PC (Q35 + ICH9, 2009).
|
||||
* `memory` - (Optional) The memory configuration.
|
||||
* `dedicated` - (Optional) The dedicated memory in megabytes (defaults to `512`).
|
||||
* `floating` - (Optional) The floating memory in megabytes (defaults to `0`).
|
||||
* `shared` - (Optional) The shared memory in megabytes (defaults to `0`).
|
||||
* `name` - (Optional) The virtual machine name.
|
||||
* `network_device` - (Optional) A network device (multiple blocks supported).
|
||||
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
||||
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
||||
* `mac_address` - (Optional) The MAC address.
|
||||
* `model` - (Optional) The network device model (defaults to `virtio`).
|
||||
* `e1000` - Intel E1000.
|
||||
* `rtl8139` - Realtek RTL8139.
|
||||
* `virtio` - VirtIO (paravirtualized).
|
||||
* `vmxnet3` - VMware vmxnet3.
|
||||
* `mtu` - (Optional) Force MTU, for VirtIO only. Set to 1 to use the bridge MTU. Cannot be larger than the bridge MTU.
|
||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||
* `vlan_id` - (Optional) The VLAN identifier.
|
||||
* `node_name` - (Required) The name of the node to assign the virtual machine to.
|
||||
* `on_boot` - (Optional) Specifies whether a VM will be started during system boot. (defaults to `true`)
|
||||
* `operating_system` - (Optional) The Operating System configuration.
|
||||
* `type` - (Optional) The type (defaults to `other`).
|
||||
* `l24` - Linux Kernel 2.4.
|
||||
* `l26` - Linux Kernel 2.6 - 5.X.
|
||||
* `other` - Unspecified OS.
|
||||
* `solaris` - OpenIndiania, OpenSolaris og Solaris Kernel.
|
||||
* `w2k` - Windows 2000.
|
||||
* `w2k3` - Windows 2003.
|
||||
* `w2k8` - Windows 2008.
|
||||
* `win7` - Windows 7.
|
||||
* `win8` - Windows 8, 2012 or 2012 R2.
|
||||
* `win10` - Windows 10 or 2016.
|
||||
* `wvista` - Windows Vista.
|
||||
* `wxp` - Windows XP.
|
||||
* `pool_id` - (Optional) The identifier for a pool to assign the virtual machine to.
|
||||
* `reboot` - (Optional) Reboot the VM after initial creation. (defaults to `false`)
|
||||
* `serial_device` - (Optional) A serial device (multiple blocks supported).
|
||||
* `device` - (Optional) The device (defaults to `socket`).
|
||||
* `/dev/*` - A host serial device.
|
||||
* `socket` - A unix socket.
|
||||
* `started` - (Optional) Whether to start the virtual machine (defaults to `true`).
|
||||
* `tablet_device` - (Optional) Whether to enable the USB tablet device (defaults to `true`).
|
||||
* `tags` - (Optional) A list of tags of the VM. This is only meta information (defaults to `[]`). Note: Proxmox always sorts the VM tags. If the list in template is not sorted, then Proxmox will always report a difference on the resource. You may use the `ignore_changes` lifecycle meta-argument to ignore changes to this attribute.
|
||||
* `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||
* `timeout_clone` - (Optional) Timeout for cloning a VM in seconds (defaults to 1800).
|
||||
* `timeout_move_disk` - (Optional) Timeout for moving the disk of a VM in seconds (defaults to 1800).
|
||||
* `timeout_reboot` - (Optional) Timeout for rebooting a VM in seconds (defaults to 1800).
|
||||
* `timeout_shutdown_vm` - (Optional) Timeout for shutting down a VM in seconds (defaults to 1800).
|
||||
* `timeout_start_vm` - (Optional) Timeout for starting a VM in seconds (defaults to 1800).
|
||||
* `timeout_stop_vm` - (Optional) Timeout for stopping a VM in seconds (defaults to 300).
|
||||
* `vga` - (Optional) The VGA configuration.
|
||||
* `enabled` - (Optional) Whether to enable the VGA device (defaults to `true`).
|
||||
* `memory` - (Optional) The VGA memory in megabytes (defaults to `16`).
|
||||
* `type` - (Optional) The VGA type (defaults to `std`).
|
||||
* `cirrus` - Cirrus (deprecated since QEMU 2.2).
|
||||
* `qxl` - SPICE.
|
||||
* `qxl2` - SPICE Dual Monitor.
|
||||
* `qxl3` - SPICE Triple Monitor.
|
||||
* `qxl4` - SPICE Quad Monitor.
|
||||
* `serial0` - Serial Terminal 0.
|
||||
* `serial1` - Serial Terminal 1.
|
||||
* `serial2` - Serial Terminal 2.
|
||||
* `serial3` - Serial Terminal 3.
|
||||
* `std` - Standard VGA.
|
||||
* `virtio` - VirtIO-GPU.
|
||||
* `vmware` - VMware Compatible.
|
||||
* `vm_id` - (Optional) The VM identifier.
|
||||
- `i440fx` - Standard PC (i440FX + PIIX, 1996).
|
||||
- `q35` - Standard PC (Q35 + ICH9, 2009).
|
||||
- `memory` - (Optional) The memory configuration.
|
||||
- `dedicated` - (Optional) The dedicated memory in megabytes (defaults
|
||||
to `512`).
|
||||
- `floating` - (Optional) The floating memory in megabytes (defaults
|
||||
to `0`).
|
||||
- `shared` - (Optional) The shared memory in megabytes (defaults to `0`).
|
||||
- `name` - (Optional) The virtual machine name.
|
||||
- `network_device` - (Optional) A network device (multiple blocks supported).
|
||||
- `bridge` - (Optional) The name of the network bridge (defaults
|
||||
to `vmbr0`).
|
||||
- `enabled` - (Optional) Whether to enable the network device (defaults
|
||||
to `true`).
|
||||
- `mac_address` - (Optional) The MAC address.
|
||||
- `model` - (Optional) The network device model (defaults to `virtio`).
|
||||
- `e1000` - Intel E1000.
|
||||
- `rtl8139` - Realtek RTL8139.
|
||||
- `virtio` - VirtIO (paravirtualized).
|
||||
- `vmxnet3` - VMware vmxnet3.
|
||||
- `mtu` - (Optional) Force MTU, for VirtIO only. Set to 1 to use the bridge
|
||||
MTU. Cannot be larger than the bridge MTU.
|
||||
- `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||
- `vlan_id` - (Optional) The VLAN identifier.
|
||||
- `node_name` - (Required) The name of the node to assign the virtual machine
|
||||
to.
|
||||
- `on_boot` - (Optional) Specifies whether a VM will be started during system
|
||||
boot. (defaults to `true`)
|
||||
- `operating_system` - (Optional) The Operating System configuration.
|
||||
- `type` - (Optional) The type (defaults to `other`).
|
||||
- `l24` - Linux Kernel 2.4.
|
||||
- `l26` - Linux Kernel 2.6 - 5.X.
|
||||
- `other` - Unspecified OS.
|
||||
- `solaris` - OpenIndiania, OpenSolaris og Solaris Kernel.
|
||||
- `w2k` - Windows 2000.
|
||||
- `w2k3` - Windows 2003.
|
||||
- `w2k8` - Windows 2008.
|
||||
- `win7` - Windows 7.
|
||||
- `win8` - Windows 8, 2012 or 2012 R2.
|
||||
- `win10` - Windows 10 or 2016.
|
||||
- `wvista` - Windows Vista.
|
||||
- `wxp` - Windows XP.
|
||||
- `pool_id` - (Optional) The identifier for a pool to assign the virtual machine
|
||||
to.
|
||||
- `reboot` - (Optional) Reboot the VM after initial creation. (defaults
|
||||
to `false`)
|
||||
- `serial_device` - (Optional) A serial device (multiple blocks supported).
|
||||
- `device` - (Optional) The device (defaults to `socket`).
|
||||
- `/dev/*` - A host serial device.
|
||||
- `socket` - A unix socket.
|
||||
- `started` - (Optional) Whether to start the virtual machine (defaults
|
||||
to `true`).
|
||||
- `tablet_device` - (Optional) Whether to enable the USB tablet device (defaults
|
||||
to `true`).
|
||||
- `tags` - (Optional) A list of tags of the VM. This is only meta information (
|
||||
defaults to `[]`). Note: Proxmox always sorts the VM tags. If the list in
|
||||
template is not sorted, then Proxmox will always report a difference on the
|
||||
resource. You may use the `ignore_changes` lifecycle meta-argument to ignore
|
||||
changes to this attribute.
|
||||
- `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||
- `timeout_clone` - (Optional) Timeout for cloning a VM in seconds (defaults to
|
||||
1800).
|
||||
- `timeout_move_disk` - (Optional) Timeout for moving the disk of a VM in
|
||||
seconds (defaults to 1800).
|
||||
- `timeout_reboot` - (Optional) Timeout for rebooting a VM in seconds (defaults
|
||||
to 1800).
|
||||
- `timeout_shutdown_vm` - (Optional) Timeout for shutting down a VM in seconds (
|
||||
defaults to 1800).
|
||||
- `timeout_start_vm` - (Optional) Timeout for starting a VM in seconds (defaults
|
||||
to 1800).
|
||||
- `timeout_stop_vm` - (Optional) Timeout for stopping a VM in seconds (defaults
|
||||
to 300).
|
||||
- `vga` - (Optional) The VGA configuration.
|
||||
- `enabled` - (Optional) Whether to enable the VGA device (defaults
|
||||
to `true`).
|
||||
- `memory` - (Optional) The VGA memory in megabytes (defaults to `16`).
|
||||
- `type` - (Optional) The VGA type (defaults to `std`).
|
||||
- `cirrus` - Cirrus (deprecated since QEMU 2.2).
|
||||
- `qxl` - SPICE.
|
||||
- `qxl2` - SPICE Dual Monitor.
|
||||
- `qxl3` - SPICE Triple Monitor.
|
||||
- `qxl4` - SPICE Quad Monitor.
|
||||
- `serial0` - Serial Terminal 0.
|
||||
- `serial1` - Serial Terminal 1.
|
||||
- `serial2` - Serial Terminal 2.
|
||||
- `serial3` - Serial Terminal 3.
|
||||
- `std` - Standard VGA.
|
||||
- `virtio` - VirtIO-GPU.
|
||||
- `vmware` - VMware Compatible.
|
||||
- `vm_id` - (Optional) The VM identifier.
|
||||
|
||||
## Attribute Reference
|
||||
|
||||
* `ipv4_addresses` - The IPv4 addresses per network interface published by the QEMU agent (empty list
|
||||
when `agent.enabled` is `false`)
|
||||
* `ipv6_addresses` - The IPv6 addresses per network interface published by the QEMU agent (empty list
|
||||
when `agent.enabled` is `false`)
|
||||
* `mac_addresses` - The MAC addresses published by the QEMU agent with fallback to the network device configuration, if
|
||||
the agent is disabled
|
||||
* `network_interface_names` - The network interface names published by the QEMU agent (empty list when `agent.enabled`
|
||||
is `false`)
|
||||
- `ipv4_addresses` - The IPv4 addresses per network interface published by the
|
||||
QEMU agent (empty list when `agent.enabled` is `false`)
|
||||
- `ipv6_addresses` - The IPv6 addresses per network interface published by the
|
||||
QEMU agent (empty list when `agent.enabled` is `false`)
|
||||
- `mac_addresses` - The MAC addresses published by the QEMU agent with fallback
|
||||
to the network device configuration, if the agent is disabled
|
||||
- `network_interface_names` - The network interface names published by the QEMU
|
||||
agent (empty list when `agent.enabled` is `false`)
|
||||
|
||||
## Important Notes
|
||||
|
||||
When cloning an existing virtual machine, whether it's a template or not, the resource will only detect changes to the
|
||||
arguments which are not set to their default values.
|
||||
When cloning an existing virtual machine, whether it's a template or not, the
|
||||
resource will only detect changes to the arguments which are not set to their
|
||||
default values.
|
||||
|
||||
Furthermore, when cloning from one node to a different one, the behavior changes depening on the datastores of the source VM. If at least one non-shared datastore is used, the VM is first cloned to the source node before being migrated to the target node. This circumvents a limitation in the Proxmox clone API.
|
||||
Furthermore, when cloning from one node to a different one, the behavior changes
|
||||
depening on the datastores of the source VM. If at least one non-shared
|
||||
datastore is used, the VM is first cloned to the source node before being
|
||||
migrated to the target node. This circumvents a limitation in the Proxmox clone
|
||||
API.
|
||||
|
||||
**Note:** Because the migration step after the clone tries to preserve the used datastores by their name, it may fail if a datastore used in the source VM is not available on the target node (e.g. `local-lvm` is used on the source node in the VM but no `local-lvm` datastore is availabel on the target node). In this case, it is recommended to set the `datastore_id` argument in the `clone` block to force the migration step to migrate all disks to a specific datastore on the target node. If you need certain disks to be on specific datastores, set the `datastore_id` argument of the disks in the `disks` block to move the disks to the correct datastore after the cloning and migrating succeeded.
|
||||
**Note:** Because the migration step after the clone tries to preserve the used
|
||||
datastores by their name, it may fail if a datastore used in the source VM is
|
||||
not available on the target node (e.g. `local-lvm` is used on the source node in
|
||||
the VM but no `local-lvm` datastore is availabel on the target node). In this
|
||||
case, it is recommended to set the `datastore_id` argument in the `clone` block
|
||||
to force the migration step to migrate all disks to a specific datastore on the
|
||||
target node. If you need certain disks to be on specific datastores, set
|
||||
the `datastore_id` argument of the disks in the `disks` block to move the disks
|
||||
to the correct datastore after the cloning and migrating succeeded.
|
||||
|
@ -63,7 +63,6 @@ func (r *CustomCommaSeparatedList) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -82,7 +81,6 @@ func (r *CustomInt) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
|
||||
i, err := strconv.ParseInt(s, 10, 32)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -104,7 +102,6 @@ func (r *CustomLineBreakSeparatedList) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -130,7 +127,6 @@ func (r *CustomPrivileges) UnmarshalJSON(b []byte) error {
|
||||
var privileges interface{}
|
||||
|
||||
err := json.Unmarshal(b, &privileges)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -167,7 +163,6 @@ func (r CustomTimestamp) MarshalJSON() ([]byte, error) {
|
||||
func (r *CustomTimestamp) UnmarshalJSON(b []byte) error {
|
||||
s := string(b)
|
||||
i, err := strconv.ParseInt(s, 10, 64)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -11,10 +11,11 @@ import (
|
||||
)
|
||||
|
||||
// GetACL retrieves the access control list.
|
||||
func (c *VirtualEnvironmentClient) GetACL(ctx context.Context) ([]*VirtualEnvironmentACLGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetACL(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentACLGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentACLGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "access/acl", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -31,6 +32,9 @@ func (c *VirtualEnvironmentClient) GetACL(ctx context.Context) ([]*VirtualEnviro
|
||||
}
|
||||
|
||||
// UpdateACL updates the access control list.
|
||||
func (c *VirtualEnvironmentClient) UpdateACL(ctx context.Context, d *VirtualEnvironmentACLUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateACL(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentACLUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, "access/acl", d, nil)
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ type VirtualEnvironmentACLGetResponseData struct {
|
||||
|
||||
// VirtualEnvironmentACLUpdateRequestBody contains the data for an access control list update request.
|
||||
type VirtualEnvironmentACLUpdateRequestBody struct {
|
||||
Delete *CustomBool `json:"delete,omitempty" url:"delete,omitempty,int"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
Path string `json:"path" url:"path"`
|
||||
Delete *CustomBool `json:"delete,omitempty" url:"delete,omitempty,int"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
Path string `json:"path" url:"path"`
|
||||
Propagate *CustomBool `json:"propagate,omitempty" url:"propagate,omitempty,int"`
|
||||
Roles []string `json:"roles" url:"roles,comma"`
|
||||
Users []string `json:"users,omitempty" url:"users,omitempty,comma"`
|
||||
Roles []string `json:"roles" url:"roles,comma"`
|
||||
Users []string `json:"users,omitempty" url:"users,omitempty,comma"`
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ package proxmox
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -19,7 +20,7 @@ const (
|
||||
)
|
||||
|
||||
// Authenticate authenticates against the specified endpoint.
|
||||
func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
||||
func (c *VirtualEnvironmentClient) Authenticate(ctx context.Context, reset bool) error {
|
||||
if c.authenticationData != nil && !reset {
|
||||
return nil
|
||||
}
|
||||
@ -41,8 +42,12 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
||||
))
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(hmPOST, fmt.Sprintf("%s/%s/access/ticket", c.Endpoint, basePathJSONAPI), reqBody)
|
||||
|
||||
req, err := http.NewRequestWithContext(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("%s/%s/access/ticket", c.Endpoint, basePathJSONAPI),
|
||||
reqBody,
|
||||
)
|
||||
if err != nil {
|
||||
return errors.New("failed to create authentication request")
|
||||
}
|
||||
@ -50,7 +55,6 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
||||
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
res, err := c.httpClient.Do(req)
|
||||
|
||||
if err != nil {
|
||||
return errors.New("failed to retrieve authentication response")
|
||||
}
|
||||
@ -73,7 +77,9 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
||||
}
|
||||
|
||||
if resBody.Data.CSRFPreventionToken == nil {
|
||||
return errors.New("the server did not include a CSRF prevention token in the authentication response")
|
||||
return errors.New(
|
||||
"the server did not include a CSRF prevention token in the authentication response",
|
||||
)
|
||||
}
|
||||
|
||||
if resBody.Data.Ticket == nil {
|
||||
@ -90,9 +96,8 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
||||
}
|
||||
|
||||
// AuthenticateRequest adds authentication data to a new request.
|
||||
func (c *VirtualEnvironmentClient) AuthenticateRequest(req *http.Request) error {
|
||||
err := c.Authenticate(false)
|
||||
|
||||
func (c *VirtualEnvironmentClient) AuthenticateRequest(ctx context.Context, req *http.Request) error {
|
||||
err := c.Authenticate(ctx, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -12,15 +12,33 @@ import (
|
||||
)
|
||||
|
||||
// DeleteCertificate deletes the custom certificate for a node.
|
||||
func (c *VirtualEnvironmentClient) DeleteCertificate(ctx context.Context, nodeName string, d *VirtualEnvironmentCertificateDeleteRequestBody) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
|
||||
func (c *VirtualEnvironmentClient) DeleteCertificate(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentCertificateDeleteRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// ListCertificates retrieves the list of certificates for a node.
|
||||
func (c *VirtualEnvironmentClient) ListCertificates(ctx context.Context, nodeName string) (*[]VirtualEnvironmentCertificateListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListCertificates(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*[]VirtualEnvironmentCertificateListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentCertificateListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/certificates/info", url.PathEscape(nodeName)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/certificates/info", url.PathEscape(nodeName)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -33,6 +51,16 @@ func (c *VirtualEnvironmentClient) ListCertificates(ctx context.Context, nodeNam
|
||||
}
|
||||
|
||||
// UpdateCertificate updates the custom certificate for a node.
|
||||
func (c *VirtualEnvironmentClient) UpdateCertificate(ctx context.Context, nodeName string, d *VirtualEnvironmentCertificateUpdateRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
|
||||
func (c *VirtualEnvironmentClient) UpdateCertificate(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentCertificateUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ type VirtualEnvironmentCertificateListResponseData struct {
|
||||
|
||||
// VirtualEnvironmentCertificateUpdateRequestBody contains the body for a custom certificate update request.
|
||||
type VirtualEnvironmentCertificateUpdateRequestBody struct {
|
||||
Certificates string `json:"certificates" url:"certificates"`
|
||||
Force *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
PrivateKey *string `json:"key,omitempty" url:"key,omitempty"`
|
||||
Certificates string `json:"certificates" url:"certificates"`
|
||||
Force *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
PrivateKey *string `json:"key,omitempty" url:"key,omitempty"`
|
||||
Restart *CustomBool `json:"restart,omitempty" url:"restart,omitempty,int"`
|
||||
}
|
||||
|
@ -22,23 +22,33 @@ import (
|
||||
)
|
||||
|
||||
// NewVirtualEnvironmentClient creates and initializes a VirtualEnvironmentClient instance.
|
||||
func NewVirtualEnvironmentClient(endpoint, username, password, otp string, insecure bool) (*VirtualEnvironmentClient, error) {
|
||||
func NewVirtualEnvironmentClient(
|
||||
endpoint, username, password, otp string,
|
||||
insecure bool,
|
||||
) (*VirtualEnvironmentClient, error) {
|
||||
u, err := url.ParseRequestURI(endpoint)
|
||||
|
||||
if err != nil {
|
||||
return nil, errors.New("you must specify a valid endpoint for the Proxmox Virtual Environment API (valid: https://host:port/)")
|
||||
return nil, errors.New(
|
||||
"you must specify a valid endpoint for the Proxmox Virtual Environment API (valid: https://host:port/)",
|
||||
)
|
||||
}
|
||||
|
||||
if u.Scheme != "https" {
|
||||
return nil, errors.New("you must specify a secure endpoint for the Proxmox Virtual Environment API (valid: https://host:port/)")
|
||||
return nil, errors.New(
|
||||
"you must specify a secure endpoint for the Proxmox Virtual Environment API (valid: https://host:port/)",
|
||||
)
|
||||
}
|
||||
|
||||
if password == "" {
|
||||
return nil, errors.New("you must specify a password for the Proxmox Virtual Environment API")
|
||||
return nil, errors.New(
|
||||
"you must specify a password for the Proxmox Virtual Environment API",
|
||||
)
|
||||
}
|
||||
|
||||
if username == "" {
|
||||
return nil, errors.New("you must specify a username for the Proxmox Virtual Environment API")
|
||||
return nil, errors.New(
|
||||
"you must specify a username for the Proxmox Virtual Environment API",
|
||||
)
|
||||
}
|
||||
|
||||
var pOTP *string
|
||||
@ -66,7 +76,11 @@ func NewVirtualEnvironmentClient(endpoint, username, password, otp string, insec
|
||||
}
|
||||
|
||||
// DoRequest performs a HTTP request against a JSON API endpoint.
|
||||
func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path string, requestBody, responseBody interface{}) error {
|
||||
func (c *VirtualEnvironmentClient) DoRequest(
|
||||
ctx context.Context,
|
||||
method, path string,
|
||||
requestBody, responseBody interface{},
|
||||
) error {
|
||||
var reqBodyReader io.Reader
|
||||
var reqContentLength *int64
|
||||
|
||||
@ -101,7 +115,6 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
||||
})
|
||||
} else {
|
||||
v, err := query.Values(requestBody)
|
||||
|
||||
if err != nil {
|
||||
fErr := fmt.Errorf("failed to encode HTTP %s request (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
||||
tflog.Warn(ctx, fErr.Error())
|
||||
@ -133,10 +146,19 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
||||
reqBodyReader = new(bytes.Buffer)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest(method, fmt.Sprintf("%s/%s/%s", c.Endpoint, basePathJSONAPI, modifiedPath), reqBodyReader)
|
||||
|
||||
req, err := http.NewRequestWithContext(
|
||||
ctx,
|
||||
method,
|
||||
fmt.Sprintf("%s/%s/%s", c.Endpoint, basePathJSONAPI, modifiedPath),
|
||||
reqBodyReader,
|
||||
)
|
||||
if err != nil {
|
||||
fErr := fmt.Errorf("failed to create HTTP %s request (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
||||
fErr := fmt.Errorf(
|
||||
"failed to create HTTP %s request (path: %s) - Reason: %w",
|
||||
method,
|
||||
modifiedPath,
|
||||
err,
|
||||
)
|
||||
tflog.Warn(ctx, fErr.Error())
|
||||
return fErr
|
||||
}
|
||||
@ -151,7 +173,7 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
||||
req.Header.Add("Content-Type", reqBodyType)
|
||||
}
|
||||
|
||||
err = c.AuthenticateRequest(req)
|
||||
err = c.AuthenticateRequest(ctx, req)
|
||||
|
||||
if err != nil {
|
||||
tflog.Warn(ctx, err.Error())
|
||||
@ -159,9 +181,13 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
||||
}
|
||||
|
||||
res, err := c.httpClient.Do(req)
|
||||
|
||||
if err != nil {
|
||||
fErr := fmt.Errorf("failed to perform HTTP %s request (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
||||
fErr := fmt.Errorf(
|
||||
"failed to perform HTTP %s request (path: %s) - Reason: %w",
|
||||
method,
|
||||
modifiedPath,
|
||||
err,
|
||||
)
|
||||
tflog.Warn(ctx, fErr.Error())
|
||||
return fErr
|
||||
}
|
||||
@ -185,7 +211,12 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
||||
err = json.NewDecoder(res.Body).Decode(responseBody)
|
||||
|
||||
if err != nil {
|
||||
fErr := fmt.Errorf("failed to decode HTTP %s response (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
||||
fErr := fmt.Errorf(
|
||||
"failed to decode HTTP %s response (path: %s) - Reason: %w",
|
||||
method,
|
||||
modifiedPath,
|
||||
err,
|
||||
)
|
||||
tflog.Warn(ctx, fErr.Error())
|
||||
return fErr
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ func (c *VirtualEnvironmentClient) GetClusterNextID(ctx context.Context, vmID *i
|
||||
|
||||
resBody := &VirtualEnvironmentClusterNextIDResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "cluster/nextid", reqBody, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -13,20 +13,37 @@ import (
|
||||
)
|
||||
|
||||
// CreateAlias create an alias
|
||||
func (c *VirtualEnvironmentClient) CreateAlias(ctx context.Context, d *VirtualEnvironmentClusterAliasCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateAlias(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentClusterAliasCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "cluster/firewall/aliases", d, nil)
|
||||
}
|
||||
|
||||
// DeleteAlias delete an alias
|
||||
func (c *VirtualEnvironmentClient) DeleteAlias(ctx context.Context, id string) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), nil, nil)
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// GetAlias retrieves an alias
|
||||
func (c *VirtualEnvironmentClient) GetAlias(ctx context.Context, id string) (*VirtualEnvironmentClusterAliasGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetAlias(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) (*VirtualEnvironmentClusterAliasGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentClusterAliasGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -39,10 +56,11 @@ func (c *VirtualEnvironmentClient) GetAlias(ctx context.Context, id string) (*Vi
|
||||
}
|
||||
|
||||
// ListAliases retrieves a list of aliases.
|
||||
func (c *VirtualEnvironmentClient) ListAliases(ctx context.Context) ([]*VirtualEnvironmentClusterAliasGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListAliases(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentClusterAliasGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentClusterAliasListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "cluster/firewall/aliases", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -59,6 +77,16 @@ func (c *VirtualEnvironmentClient) ListAliases(ctx context.Context) ([]*VirtualE
|
||||
}
|
||||
|
||||
// UpdateAlias updates an alias.
|
||||
func (c *VirtualEnvironmentClient) UpdateAlias(ctx context.Context, id string, d *VirtualEnvironmentClusterAliasUpdateRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), d, nil)
|
||||
func (c *VirtualEnvironmentClient) UpdateAlias(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentClusterAliasUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPUT,
|
||||
fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ package proxmox
|
||||
// VirtualEnvironmentClusterAliasCreateRequestBody contains the data for an alias create request.
|
||||
type VirtualEnvironmentClusterAliasCreateRequestBody struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
Name string `json:"name" url:"name"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterAliasGetResponseBody contains the body from an alias get response.
|
||||
@ -19,10 +19,10 @@ type VirtualEnvironmentClusterAliasGetResponseBody struct {
|
||||
// VirtualEnvironmentClusterAliasGetResponseData contains the data from an alias get response.
|
||||
type VirtualEnvironmentClusterAliasGetResponseData struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
Digest *string `json:"digest" url:"digest"`
|
||||
IPVersion int `json:"ipversion" url:"ipversion"`
|
||||
Name string `json:"name" url:"name"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
Digest *string `json:"digest" url:"digest"`
|
||||
IPVersion int `json:"ipversion" url:"ipversion"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterAliasListResponseBody contains the data from an alias get response.
|
||||
@ -33,6 +33,6 @@ type VirtualEnvironmentClusterAliasListResponseBody struct {
|
||||
// VirtualEnvironmentClusterAliasUpdateRequestBody contains the data for an alias update request.
|
||||
type VirtualEnvironmentClusterAliasUpdateRequestBody struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
ReName string `json:"rename" url:"rename"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
ReName string `json:"rename" url:"rename"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
}
|
||||
|
@ -13,35 +13,75 @@ import (
|
||||
)
|
||||
|
||||
// CreateIPSet create an IPSet
|
||||
func (c *VirtualEnvironmentClient) CreateIPSet(ctx context.Context, d *VirtualEnvironmentClusterIPSetCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateIPSet(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentClusterIPSetCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "cluster/firewall/ipset", d, nil)
|
||||
}
|
||||
|
||||
// AddCIDRToIPSet adds IP or Network to IPSet
|
||||
func (c *VirtualEnvironmentClient) AddCIDRToIPSet(ctx context.Context, id string, d *VirtualEnvironmentClusterIPSetGetResponseData) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("cluster/firewall/ipset/%s/", url.PathEscape(id)), d, nil)
|
||||
func (c *VirtualEnvironmentClient) AddCIDRToIPSet(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentClusterIPSetGetResponseData,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("cluster/firewall/ipset/%s/", url.PathEscape(id)),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// UpdateIPSet updates an IPSet.
|
||||
func (c *VirtualEnvironmentClient) UpdateIPSet(ctx context.Context, d *VirtualEnvironmentClusterIPSetUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateIPSet(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentClusterIPSetUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "cluster/firewall/ipset/", d, nil)
|
||||
}
|
||||
|
||||
// DeleteIPSet delete an IPSet
|
||||
func (c *VirtualEnvironmentClient) DeleteIPSet(ctx context.Context, id string) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)), nil, nil)
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// DeleteIPSetContent remove IP or Network from IPSet.
|
||||
func (c *VirtualEnvironmentClient) DeleteIPSetContent(ctx context.Context, id string, cidr string) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("cluster/firewall/ipset/%s/%s", url.PathEscape(id), url.PathEscape(cidr)), nil, nil)
|
||||
func (c *VirtualEnvironmentClient) DeleteIPSetContent(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
cidr string,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf("cluster/firewall/ipset/%s/%s", url.PathEscape(id), url.PathEscape(cidr)),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// GetListIPSetContent retrieve a list of IPSet content
|
||||
func (c *VirtualEnvironmentClient) GetListIPSetContent(ctx context.Context, id string) ([]*VirtualEnvironmentClusterIPSetGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetListIPSetContent(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) ([]*VirtualEnvironmentClusterIPSetGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentClusterIPSetGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -54,10 +94,11 @@ func (c *VirtualEnvironmentClient) GetListIPSetContent(ctx context.Context, id s
|
||||
}
|
||||
|
||||
// GetListIPSets retrieves list of IPSets.
|
||||
func (c *VirtualEnvironmentClient) GetListIPSets(ctx context.Context) (*VirtualEnvironmentClusterIPSetListResponseBody, error) {
|
||||
func (c *VirtualEnvironmentClient) GetListIPSets(
|
||||
ctx context.Context,
|
||||
) (*VirtualEnvironmentClusterIPSetListResponseBody, error) {
|
||||
resBody := &VirtualEnvironmentClusterIPSetListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "cluster/firewall/ipset", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ type VirtualEnvironmentClusterIPSetListResponseBody struct {
|
||||
// VirtualEnvironmentClusterIPSetCreateRequestBody contains the data for an IPSet create request
|
||||
type VirtualEnvironmentClusterIPSetCreateRequestBody struct {
|
||||
Comment string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
Name string `json:"name" url:"name"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterIPSetGetResponseBody contains the body from an IPSet get response.
|
||||
@ -26,22 +26,22 @@ type VirtualEnvironmentClusterIPSetGetResponseBody struct {
|
||||
|
||||
// VirtualEnvironmentClusterIPSetGetResponseData contains the data from an IPSet get response.
|
||||
type VirtualEnvironmentClusterIPSetGetResponseData struct {
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
CIDR string `json:"cidr" url:"cidr"`
|
||||
NoMatch *CustomBool `json:"nomatch,omitempty" url:"nomatch,omitempty,int"`
|
||||
Comment string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterIPSetUpdateRequestBody contains the data for an IPSet update request.
|
||||
type VirtualEnvironmentClusterIPSetUpdateRequestBody struct {
|
||||
ReName string `json:"rename,omitempty" url:"rename,omitempty"`
|
||||
ReName string `json:"rename,omitempty" url:"rename,omitempty"`
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
Name string `json:"name" url:"name"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterIPSetListResponseData contains list of IPSets from
|
||||
type VirtualEnvironmentClusterIPSetListResponseData struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
Name string `json:"name" url:"name"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentClusterIPSetContent is an array of VirtualEnvironmentClusterIPSetGetResponseData.
|
||||
|
@ -14,25 +14,59 @@ import (
|
||||
)
|
||||
|
||||
// CloneContainer clones a container.
|
||||
func (c *VirtualEnvironmentClient) CloneContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerCloneRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/clone", url.PathEscape(nodeName), vmID), d, nil)
|
||||
func (c *VirtualEnvironmentClient) CloneContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentContainerCloneRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/clone", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// CreateContainer creates a container.
|
||||
func (c *VirtualEnvironmentClient) CreateContainer(ctx context.Context, nodeName string, d *VirtualEnvironmentContainerCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentContainerCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc", url.PathEscape(nodeName)), d, nil)
|
||||
}
|
||||
|
||||
// DeleteContainer deletes a container.
|
||||
func (c *VirtualEnvironmentClient) DeleteContainer(ctx context.Context, nodeName string, vmID int) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/lxc/%d", url.PathEscape(nodeName), vmID), nil, nil)
|
||||
func (c *VirtualEnvironmentClient) DeleteContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// GetContainer retrieves a container.
|
||||
func (c *VirtualEnvironmentClient) GetContainer(ctx context.Context, nodeName string, vmID int) (*VirtualEnvironmentContainerGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*VirtualEnvironmentContainerGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentContainerGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/lxc/%d/config", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/config", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -45,10 +79,19 @@ func (c *VirtualEnvironmentClient) GetContainer(ctx context.Context, nodeName st
|
||||
}
|
||||
|
||||
// GetContainerStatus retrieves the status for a container.
|
||||
func (c *VirtualEnvironmentClient) GetContainerStatus(ctx context.Context, nodeName string, vmID int) (*VirtualEnvironmentContainerGetStatusResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetContainerStatus(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*VirtualEnvironmentContainerGetStatusResponseData, error) {
|
||||
resBody := &VirtualEnvironmentContainerGetStatusResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/lxc/%d/status/current", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/status/current", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -61,32 +104,94 @@ func (c *VirtualEnvironmentClient) GetContainerStatus(ctx context.Context, nodeN
|
||||
}
|
||||
|
||||
// RebootContainer reboots a container.
|
||||
func (c *VirtualEnvironmentClient) RebootContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerRebootRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/reboot", url.PathEscape(nodeName), vmID), d, nil)
|
||||
func (c *VirtualEnvironmentClient) RebootContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentContainerRebootRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/status/reboot", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// ShutdownContainer shuts down a container.
|
||||
func (c *VirtualEnvironmentClient) ShutdownContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerShutdownRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/shutdown", url.PathEscape(nodeName), vmID), d, nil)
|
||||
func (c *VirtualEnvironmentClient) ShutdownContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentContainerShutdownRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/status/shutdown", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// StartContainer starts a container.
|
||||
func (c *VirtualEnvironmentClient) StartContainer(ctx context.Context, nodeName string, vmID int) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/start", url.PathEscape(nodeName), vmID), nil, nil)
|
||||
func (c *VirtualEnvironmentClient) StartContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/status/start", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// StopContainer stops a container immediately.
|
||||
func (c *VirtualEnvironmentClient) StopContainer(ctx context.Context, nodeName string, vmID int) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/stop", url.PathEscape(nodeName), vmID), nil, nil)
|
||||
func (c *VirtualEnvironmentClient) StopContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/status/stop", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// UpdateContainer updates a container.
|
||||
func (c *VirtualEnvironmentClient) UpdateContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerUpdateRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/lxc/%d/config", url.PathEscape(nodeName), vmID), d, nil)
|
||||
func (c *VirtualEnvironmentClient) UpdateContainer(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentContainerUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPUT,
|
||||
fmt.Sprintf("nodes/%s/lxc/%d/config", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// WaitForContainerState waits for a container to reach a specific state.
|
||||
func (c *VirtualEnvironmentClient) WaitForContainerState(ctx context.Context, nodeName string, vmID int, state string, timeout int, delay int) error {
|
||||
//
|
||||
//nolint:dupl
|
||||
func (c *VirtualEnvironmentClient) WaitForContainerState(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
state string,
|
||||
timeout int,
|
||||
delay int,
|
||||
) error {
|
||||
state = strings.ToLower(state)
|
||||
|
||||
timeDelay := int64(delay)
|
||||
@ -97,7 +202,6 @@ func (c *VirtualEnvironmentClient) WaitForContainerState(ctx context.Context, no
|
||||
for timeElapsed.Seconds() < timeMax {
|
||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||
data, err := c.GetContainerStatus(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -118,11 +222,24 @@ func (c *VirtualEnvironmentClient) WaitForContainerState(ctx context.Context, no
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("timeout while waiting for container \"%d\" to enter the state \"%s\"", vmID, state)
|
||||
return fmt.Errorf(
|
||||
"timeout while waiting for container \"%d\" to enter the state \"%s\"",
|
||||
vmID,
|
||||
state,
|
||||
)
|
||||
}
|
||||
|
||||
// WaitForContainerLock waits for a container lock to be released.
|
||||
func (c *VirtualEnvironmentClient) WaitForContainerLock(ctx context.Context, nodeName string, vmID int, timeout int, delay int, ignoreErrorResponse bool) error {
|
||||
//
|
||||
//nolint:dupl
|
||||
func (c *VirtualEnvironmentClient) WaitForContainerLock(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
delay int,
|
||||
ignoreErrorResponse bool,
|
||||
) error {
|
||||
timeDelay := int64(delay)
|
||||
timeMax := float64(timeout)
|
||||
timeStart := time.Now()
|
||||
|
@ -14,81 +14,81 @@ import (
|
||||
|
||||
// VirtualEnvironmentContainerCloneRequestBody contains the data for an container clone request.
|
||||
type VirtualEnvironmentContainerCloneRequestBody struct {
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
FullCopy *CustomBool `json:"full,omitempty" url:"full,omitempty,int"`
|
||||
Hostname *string `json:"hostname,omitempty" url:"hostname,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
SnapshotName *string `json:"snapname,omitempty" url:"snapname,omitempty"`
|
||||
TargetNodeName *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
TargetStorage *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
VMIDNew int `json:"newid" url:"newid"`
|
||||
FullCopy *CustomBool `json:"full,omitempty" url:"full,omitempty,int"`
|
||||
Hostname *string `json:"hostname,omitempty" url:"hostname,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
SnapshotName *string `json:"snapname,omitempty" url:"snapname,omitempty"`
|
||||
TargetNodeName *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
TargetStorage *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
VMIDNew int `json:"newid" url:"newid"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCreateRequestBody contains the data for an user create request.
|
||||
type VirtualEnvironmentContainerCreateRequestBody struct {
|
||||
BandwidthLimit *float64 `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
ConsoleEnabled *CustomBool `json:"console,omitempty" url:"console,omitempty,int"`
|
||||
ConsoleMode *string `json:"cmode,omitempty" url:"cmode,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty" url:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty" url:"cores,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty" url:"cpulimit,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty" url:"cpuunits,omitempty"`
|
||||
DatastoreID *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Delete []string `json:"delete,omitempty" url:"delete,omitempty"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
DNSDomain *string `json:"searchdomain,omitempty" url:"searchdomain,omitempty"`
|
||||
DNSServer *string `json:"nameserver,omitempty" url:"nameserver,omitempty"`
|
||||
Features *VirtualEnvironmentContainerCustomFeatures `json:"features,omitempty" url:"features,omitempty"`
|
||||
Force *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
HookScript *string `json:"hookscript,omitempty" url:"hookscript,omitempty"`
|
||||
Hostname *string `json:"hostname,omitempty" url:"hostname,omitempty"`
|
||||
BandwidthLimit *float64 `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
ConsoleEnabled *CustomBool `json:"console,omitempty" url:"console,omitempty,int"`
|
||||
ConsoleMode *string `json:"cmode,omitempty" url:"cmode,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty" url:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty" url:"cores,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty" url:"cpulimit,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty" url:"cpuunits,omitempty"`
|
||||
DatastoreID *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Delete []string `json:"delete,omitempty" url:"delete,omitempty"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
DNSDomain *string `json:"searchdomain,omitempty" url:"searchdomain,omitempty"`
|
||||
DNSServer *string `json:"nameserver,omitempty" url:"nameserver,omitempty"`
|
||||
Features *VirtualEnvironmentContainerCustomFeatures `json:"features,omitempty" url:"features,omitempty"`
|
||||
Force *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
HookScript *string `json:"hookscript,omitempty" url:"hookscript,omitempty"`
|
||||
Hostname *string `json:"hostname,omitempty" url:"hostname,omitempty"`
|
||||
IgnoreUnpackErrors *CustomBool `json:"ignore-unpack-errors,omitempty" url:"force,omitempty,int"`
|
||||
Lock *string `json:"lock,omitempty" url:"lock,omitempty,int"`
|
||||
MountPoints VirtualEnvironmentContainerCustomMountPointArray `json:"mp,omitempty" url:"mp,omitempty,numbered"`
|
||||
NetworkInterfaces VirtualEnvironmentContainerCustomNetworkInterfaceArray `json:"net,omitempty" url:"net,omitempty,numbered"`
|
||||
OSTemplateFileVolume *string `json:"ostemplate,omitempty" url:"ostemplate,omitempty"`
|
||||
OSType *string `json:"ostype,omitempty" url:"ostype,omitempty"`
|
||||
Password *string `json:"password,omitempty" url:"password,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Protection *CustomBool `json:"protection,omitempty" url:"protection,omitempty,int"`
|
||||
Restore *CustomBool `json:"restore,omitempty" url:"restore,omitempty,int"`
|
||||
RootFS *VirtualEnvironmentContainerCustomRootFS `json:"rootfs,omitempty" url:"rootfs,omitempty"`
|
||||
SSHKeys *VirtualEnvironmentContainerCustomSSHKeys `json:"ssh-public-keys,omitempty" url:"ssh-public-keys,omitempty"`
|
||||
Start *CustomBool `json:"start,omitempty" url:"start,omitempty,int"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty" url:"onboot,omitempty,int"`
|
||||
StartupBehavior *VirtualEnvironmentContainerCustomStartupBehavior `json:"startup,omitempty" url:"startup,omitempty"`
|
||||
Swap *int `json:"swap,omitempty" url:"swap,omitempty"`
|
||||
Tags *string `json:"tags,omitempty" url:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty" url:"template,omitempty,int"`
|
||||
TTY *int `json:"tty,omitempty" url:"tty,omitempty"`
|
||||
Unique *CustomBool `json:"unique,omitempty" url:"unique,omitempty,int"`
|
||||
Unprivileged *CustomBool `json:"unprivileged,omitempty" url:"unprivileged,omitempty,int"`
|
||||
VMID *int `json:"vmid,omitempty" url:"vmid,omitempty"`
|
||||
Lock *string `json:"lock,omitempty" url:"lock,omitempty,int"`
|
||||
MountPoints VirtualEnvironmentContainerCustomMountPointArray `json:"mp,omitempty" url:"mp,omitempty,numbered"`
|
||||
NetworkInterfaces VirtualEnvironmentContainerCustomNetworkInterfaceArray `json:"net,omitempty" url:"net,omitempty,numbered"`
|
||||
OSTemplateFileVolume *string `json:"ostemplate,omitempty" url:"ostemplate,omitempty"`
|
||||
OSType *string `json:"ostype,omitempty" url:"ostype,omitempty"`
|
||||
Password *string `json:"password,omitempty" url:"password,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Protection *CustomBool `json:"protection,omitempty" url:"protection,omitempty,int"`
|
||||
Restore *CustomBool `json:"restore,omitempty" url:"restore,omitempty,int"`
|
||||
RootFS *VirtualEnvironmentContainerCustomRootFS `json:"rootfs,omitempty" url:"rootfs,omitempty"`
|
||||
SSHKeys *VirtualEnvironmentContainerCustomSSHKeys `json:"ssh-public-keys,omitempty" url:"ssh-public-keys,omitempty"`
|
||||
Start *CustomBool `json:"start,omitempty" url:"start,omitempty,int"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty" url:"onboot,omitempty,int"`
|
||||
StartupBehavior *VirtualEnvironmentContainerCustomStartupBehavior `json:"startup,omitempty" url:"startup,omitempty"`
|
||||
Swap *int `json:"swap,omitempty" url:"swap,omitempty"`
|
||||
Tags *string `json:"tags,omitempty" url:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty" url:"template,omitempty,int"`
|
||||
TTY *int `json:"tty,omitempty" url:"tty,omitempty"`
|
||||
Unique *CustomBool `json:"unique,omitempty" url:"unique,omitempty,int"`
|
||||
Unprivileged *CustomBool `json:"unprivileged,omitempty" url:"unprivileged,omitempty,int"`
|
||||
VMID *int `json:"vmid,omitempty" url:"vmid,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCustomFeatures contains the values for the "features" property.
|
||||
type VirtualEnvironmentContainerCustomFeatures struct {
|
||||
FUSE *CustomBool `json:"fuse,omitempty" url:"fuse,omitempty,int"`
|
||||
KeyControl *CustomBool `json:"keyctl,omitempty" url:"keyctl,omitempty,int"`
|
||||
MountTypes *[]string `json:"mount,omitempty" url:"mount,omitempty"`
|
||||
FUSE *CustomBool `json:"fuse,omitempty" url:"fuse,omitempty,int"`
|
||||
KeyControl *CustomBool `json:"keyctl,omitempty" url:"keyctl,omitempty,int"`
|
||||
MountTypes *[]string `json:"mount,omitempty" url:"mount,omitempty"`
|
||||
Nesting *CustomBool `json:"nesting,omitempty" url:"nesting,omitempty,int"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCustomMountPoint contains the values for the "mp[n]" properties.
|
||||
type VirtualEnvironmentContainerCustomMountPoint struct {
|
||||
ACL *CustomBool `json:"acl,omitempty" url:"acl,omitempty,int"`
|
||||
Backup *CustomBool `json:"backup,omitempty" url:"backup,omitempty,int"`
|
||||
DiskSize *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
ACL *CustomBool `json:"acl,omitempty" url:"acl,omitempty,int"`
|
||||
Backup *CustomBool `json:"backup,omitempty" url:"backup,omitempty,int"`
|
||||
DiskSize *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
MountOptions *[]string `json:"mountoptions,omitempty" url:"mountoptions,omitempty"`
|
||||
MountPoint string `json:"mp" url:"mp"`
|
||||
Quota *CustomBool `json:"quota,omitempty" url:"quota,omitempty,int"`
|
||||
ReadOnly *CustomBool `json:"ro,omitempty" url:"ro,omitempty,int"`
|
||||
Replicate *CustomBool `json:"replicate,omitempty" url:"replicate,omitempty,int"`
|
||||
Shared *CustomBool `json:"shared,omitempty" url:"shared,omitempty,int"`
|
||||
Volume string `json:"volume" url:"volume"`
|
||||
MountPoint string `json:"mp" url:"mp"`
|
||||
Quota *CustomBool `json:"quota,omitempty" url:"quota,omitempty,int"`
|
||||
ReadOnly *CustomBool `json:"ro,omitempty" url:"ro,omitempty,int"`
|
||||
Replicate *CustomBool `json:"replicate,omitempty" url:"replicate,omitempty,int"`
|
||||
Shared *CustomBool `json:"shared,omitempty" url:"shared,omitempty,int"`
|
||||
Volume string `json:"volume" url:"volume"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCustomMountPointArray is an array of VirtualEnvironmentContainerCustomMountPoint.
|
||||
@ -96,20 +96,20 @@ type VirtualEnvironmentContainerCustomMountPointArray []VirtualEnvironmentContai
|
||||
|
||||
// VirtualEnvironmentContainerCustomNetworkInterface contains the values for the "net[n]" properties.
|
||||
type VirtualEnvironmentContainerCustomNetworkInterface struct {
|
||||
Bridge *string `json:"bridge,omitempty" url:"bridge,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
Bridge *string `json:"bridge,omitempty" url:"bridge,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
Firewall *CustomBool `json:"firewall,omitempty" url:"firewall,omitempty,int"`
|
||||
IPv4Address *string `json:"ip,omitempty" url:"ip,omitempty"`
|
||||
IPv4Gateway *string `json:"gw,omitempty" url:"gw,omitempty"`
|
||||
IPv6Address *string `json:"ip6,omitempty" url:"ip6,omitempty"`
|
||||
IPv6Gateway *string `json:"gw6,omitempty" url:"gw6,omitempty"`
|
||||
MACAddress *string `json:"hwaddr,omitempty" url:"hwaddr,omitempty"`
|
||||
MTU *int `json:"mtu,omitempty" url:"mtu,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
||||
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
||||
Trunks *[]int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
||||
Type *string `json:"type,omitempty" url:"type,omitempty"`
|
||||
IPv4Address *string `json:"ip,omitempty" url:"ip,omitempty"`
|
||||
IPv4Gateway *string `json:"gw,omitempty" url:"gw,omitempty"`
|
||||
IPv6Address *string `json:"ip6,omitempty" url:"ip6,omitempty"`
|
||||
IPv6Gateway *string `json:"gw6,omitempty" url:"gw6,omitempty"`
|
||||
MACAddress *string `json:"hwaddr,omitempty" url:"hwaddr,omitempty"`
|
||||
MTU *int `json:"mtu,omitempty" url:"mtu,omitempty"`
|
||||
Name string `json:"name" url:"name"`
|
||||
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
||||
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
||||
Trunks *[]int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
||||
Type *string `json:"type,omitempty" url:"type,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCustomNetworkInterfaceArray is an array of VirtualEnvironmentContainerCustomNetworkInterface.
|
||||
@ -117,14 +117,14 @@ type VirtualEnvironmentContainerCustomNetworkInterfaceArray []VirtualEnvironment
|
||||
|
||||
// VirtualEnvironmentContainerCustomRootFS contains the values for the "rootfs" property.
|
||||
type VirtualEnvironmentContainerCustomRootFS struct {
|
||||
ACL *CustomBool `json:"acl,omitempty" url:"acl,omitempty,int"`
|
||||
DiskSize *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
ACL *CustomBool `json:"acl,omitempty" url:"acl,omitempty,int"`
|
||||
DiskSize *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
MountOptions *[]string `json:"mountoptions,omitempty" url:"mountoptions,omitempty"`
|
||||
Quota *CustomBool `json:"quota,omitempty" url:"quota,omitempty,int"`
|
||||
ReadOnly *CustomBool `json:"ro,omitempty" url:"ro,omitempty,int"`
|
||||
Replicate *CustomBool `json:"replicate,omitempty" url:"replicate,omitempty,int"`
|
||||
Shared *CustomBool `json:"shared,omitempty" url:"shared,omitempty,int"`
|
||||
Volume string `json:"volume" url:"volume"`
|
||||
Quota *CustomBool `json:"quota,omitempty" url:"quota,omitempty,int"`
|
||||
ReadOnly *CustomBool `json:"ro,omitempty" url:"ro,omitempty,int"`
|
||||
Replicate *CustomBool `json:"replicate,omitempty" url:"replicate,omitempty,int"`
|
||||
Shared *CustomBool `json:"shared,omitempty" url:"shared,omitempty,int"`
|
||||
Volume string `json:"volume" url:"volume"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerCustomSSHKeys contains the values for the "ssh-public-keys" property.
|
||||
@ -132,9 +132,9 @@ type VirtualEnvironmentContainerCustomSSHKeys []string
|
||||
|
||||
// VirtualEnvironmentContainerCustomStartupBehavior contains the values for the "startup" property.
|
||||
type VirtualEnvironmentContainerCustomStartupBehavior struct {
|
||||
Down *int `json:"down,omitempty" url:"down,omitempty"`
|
||||
Down *int `json:"down,omitempty" url:"down,omitempty"`
|
||||
Order *int `json:"order,omitempty" url:"order,omitempty"`
|
||||
Up *int `json:"up,omitempty" url:"up,omitempty"`
|
||||
Up *int `json:"up,omitempty" url:"up,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerGetResponseBody contains the body from an user get response.
|
||||
@ -211,7 +211,7 @@ type VirtualEnvironmentContainerRebootRequestBody struct {
|
||||
// VirtualEnvironmentContainerShutdownRequestBody contains the body for a container shutdown request.
|
||||
type VirtualEnvironmentContainerShutdownRequestBody struct {
|
||||
ForceStop *CustomBool `json:"forceStop,omitempty" url:"forceStop,omitempty,int"`
|
||||
Timeout *int `json:"timeout,omitempty" url:"timeout,omitempty"`
|
||||
Timeout *int `json:"timeout,omitempty" url:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentContainerUpdateRequestBody contains the data for an user update request.
|
||||
@ -332,7 +332,10 @@ func (r VirtualEnvironmentContainerCustomMountPoint) EncodeValues(key string, v
|
||||
}
|
||||
|
||||
// EncodeValues converts a VirtualEnvironmentContainerCustomMountPointArray array to multiple URL values.
|
||||
func (r VirtualEnvironmentContainerCustomMountPointArray) EncodeValues(key string, v *url.Values) error {
|
||||
func (r VirtualEnvironmentContainerCustomMountPointArray) EncodeValues(
|
||||
key string,
|
||||
v *url.Values,
|
||||
) error {
|
||||
for i, d := range r {
|
||||
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
||||
if err != nil {
|
||||
@ -344,7 +347,10 @@ func (r VirtualEnvironmentContainerCustomMountPointArray) EncodeValues(key strin
|
||||
}
|
||||
|
||||
// EncodeValues converts a VirtualEnvironmentContainerCustomNetworkInterface struct to a URL vlaue.
|
||||
func (r VirtualEnvironmentContainerCustomNetworkInterface) EncodeValues(key string, v *url.Values) error {
|
||||
func (r VirtualEnvironmentContainerCustomNetworkInterface) EncodeValues(
|
||||
key string,
|
||||
v *url.Values,
|
||||
) error {
|
||||
var values []string
|
||||
|
||||
if r.Bridge != nil {
|
||||
@ -415,7 +421,10 @@ func (r VirtualEnvironmentContainerCustomNetworkInterface) EncodeValues(key stri
|
||||
}
|
||||
|
||||
// EncodeValues converts a VirtualEnvironmentContainerCustomNetworkInterfaceArray array to multiple URL values.
|
||||
func (r VirtualEnvironmentContainerCustomNetworkInterfaceArray) EncodeValues(key string, v *url.Values) error {
|
||||
func (r VirtualEnvironmentContainerCustomNetworkInterfaceArray) EncodeValues(
|
||||
key string,
|
||||
v *url.Values,
|
||||
) error {
|
||||
for i, d := range r {
|
||||
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
||||
if err != nil {
|
||||
@ -497,7 +506,10 @@ func (r VirtualEnvironmentContainerCustomSSHKeys) EncodeValues(key string, v *ur
|
||||
}
|
||||
|
||||
// EncodeValues converts a VirtualEnvironmentContainerCustomStartupBehavior struct to a URL vlaue.
|
||||
func (r VirtualEnvironmentContainerCustomStartupBehavior) EncodeValues(key string, v *url.Values) error {
|
||||
func (r VirtualEnvironmentContainerCustomStartupBehavior) EncodeValues(
|
||||
key string,
|
||||
v *url.Values,
|
||||
) error {
|
||||
var values []string
|
||||
|
||||
if r.Down != nil {
|
||||
@ -524,7 +536,6 @@ func (r *VirtualEnvironmentContainerCustomFeatures) UnmarshalJSON(b []byte) erro
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -565,7 +576,6 @@ func (r *VirtualEnvironmentContainerCustomMountPoint) UnmarshalJSON(b []byte) er
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -621,7 +631,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -652,7 +661,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
||||
r.MACAddress = &v[1]
|
||||
case "mtu":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -662,7 +670,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
||||
r.Name = v[1]
|
||||
case "rate":
|
||||
fv, err := strconv.ParseFloat(v[1], 64)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -670,7 +677,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
||||
r.RateLimit = &fv
|
||||
case "tag":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -708,7 +714,6 @@ func (r *VirtualEnvironmentContainerCustomRootFS) UnmarshalJSON(b []byte) error
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -759,7 +764,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -773,7 +777,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
||||
switch v[0] {
|
||||
case "down":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -781,7 +784,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
||||
r.Down = &iv
|
||||
case "order":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -789,7 +791,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
||||
r.Order = &iv
|
||||
case "up":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -21,9 +21,22 @@ import (
|
||||
)
|
||||
|
||||
// DeleteDatastoreFile deletes a file in a datastore.
|
||||
func (c *VirtualEnvironmentClient) DeleteDatastoreFile(ctx context.Context, nodeName, datastoreID, volumeID string) error {
|
||||
err := c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/storage/%s/content/%s", url.PathEscape(nodeName), url.PathEscape(datastoreID), url.PathEscape(volumeID)), nil, nil)
|
||||
|
||||
func (c *VirtualEnvironmentClient) DeleteDatastoreFile(
|
||||
ctx context.Context,
|
||||
nodeName, datastoreID, volumeID string,
|
||||
) error {
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/storage/%s/content/%s",
|
||||
url.PathEscape(nodeName),
|
||||
url.PathEscape(datastoreID),
|
||||
url.PathEscape(volumeID),
|
||||
),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -32,10 +45,22 @@ func (c *VirtualEnvironmentClient) DeleteDatastoreFile(ctx context.Context, node
|
||||
}
|
||||
|
||||
// GetDatastoreStatus gets status information for a given datastore.
|
||||
func (c *VirtualEnvironmentClient) GetDatastoreStatus(ctx context.Context, nodeName, datastoreID string) (*VirtualEnvironmentDatastoreGetStatusResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetDatastoreStatus(
|
||||
ctx context.Context,
|
||||
nodeName, datastoreID string,
|
||||
) (*VirtualEnvironmentDatastoreGetStatusResponseData, error) {
|
||||
resBody := &VirtualEnvironmentDatastoreGetStatusResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/storage/%s/status", url.PathEscape(nodeName), url.PathEscape(datastoreID)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/storage/%s/status",
|
||||
url.PathEscape(nodeName),
|
||||
url.PathEscape(datastoreID),
|
||||
),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -48,10 +73,22 @@ func (c *VirtualEnvironmentClient) GetDatastoreStatus(ctx context.Context, nodeN
|
||||
}
|
||||
|
||||
// ListDatastoreFiles retrieves a list of the files in a datastore.
|
||||
func (c *VirtualEnvironmentClient) ListDatastoreFiles(ctx context.Context, nodeName, datastoreID string) ([]*VirtualEnvironmentDatastoreFileListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListDatastoreFiles(
|
||||
ctx context.Context,
|
||||
nodeName, datastoreID string,
|
||||
) ([]*VirtualEnvironmentDatastoreFileListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentDatastoreFileListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/storage/%s/content", url.PathEscape(nodeName), url.PathEscape(datastoreID)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/storage/%s/content",
|
||||
url.PathEscape(nodeName),
|
||||
url.PathEscape(datastoreID),
|
||||
),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -68,10 +105,19 @@ func (c *VirtualEnvironmentClient) ListDatastoreFiles(ctx context.Context, nodeN
|
||||
}
|
||||
|
||||
// ListDatastores retrieves a list of nodes.
|
||||
func (c *VirtualEnvironmentClient) ListDatastores(ctx context.Context, nodeName string, d *VirtualEnvironmentDatastoreListRequestBody) ([]*VirtualEnvironmentDatastoreListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListDatastores(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentDatastoreListRequestBody,
|
||||
) ([]*VirtualEnvironmentDatastoreListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentDatastoreListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/storage", url.PathEscape(nodeName)), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/storage", url.PathEscape(nodeName)),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -88,7 +134,10 @@ func (c *VirtualEnvironmentClient) ListDatastores(ctx context.Context, nodeName
|
||||
}
|
||||
|
||||
// UploadFileToDatastore uploads a file to a datastore.
|
||||
func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d *VirtualEnvironmentDatastoreUploadRequestBody) (*VirtualEnvironmentDatastoreUploadResponseBody, error) {
|
||||
func (c *VirtualEnvironmentClient) UploadFileToDatastore(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentDatastoreUploadRequestBody,
|
||||
) (*VirtualEnvironmentDatastoreUploadResponseBody, error) {
|
||||
switch d.ContentType {
|
||||
case "iso", "vztmpl":
|
||||
r, w := io.Pipe()
|
||||
@ -110,7 +159,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
}
|
||||
|
||||
part, err := m.CreateFormFile("filename", d.FileName)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -125,7 +173,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
// We need to store the multipart content in a temporary file to avoid using high amounts of memory.
|
||||
// This is necessary due to Proxmox VE not supporting chunked transfers in v6.1 and earlier versions.
|
||||
tempMultipartFile, err := os.CreateTemp("", "multipart")
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -147,7 +194,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
|
||||
// Now that the multipart data is stored in a file, we can go ahead and do a HTTP POST request.
|
||||
fileReader, err := os.Open(tempMultipartFileName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -155,7 +201,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
defer fileReader.Close()
|
||||
|
||||
fileInfo, err := fileReader.Stat()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -169,7 +214,17 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
}
|
||||
|
||||
resBody := &VirtualEnvironmentDatastoreUploadResponseBody{}
|
||||
err = c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/storage/%s/upload", url.PathEscape(d.NodeName), url.PathEscape(d.DatastoreID)), reqBody, resBody)
|
||||
err = c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/storage/%s/upload",
|
||||
url.PathEscape(d.NodeName),
|
||||
url.PathEscape(d.DatastoreID),
|
||||
),
|
||||
reqBody,
|
||||
resBody,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -180,7 +235,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
// We need to upload all other files using SFTP due to API limitations.
|
||||
// Hopefully, this will not be required in future releases of Proxmox VE.
|
||||
sshClient, err := c.OpenNodeShell(ctx, d.NodeName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -188,15 +242,16 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
defer sshClient.Close()
|
||||
|
||||
sshSession, err := sshClient.NewSession()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
buf, err := sshSession.CombinedOutput(
|
||||
fmt.Sprintf(`awk "/.+: %s$/,/^$/" /etc/pve/storage.cfg | grep -oP '(?<=path[ ])[^\s]+' | head -c -1`, d.DatastoreID),
|
||||
fmt.Sprintf(
|
||||
`awk "/.+: %s$/,/^$/" /etc/pve/storage.cfg | grep -oP '(?<=path[ ])[^\s]+' | head -c -1`,
|
||||
d.DatastoreID,
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
sshSession.Close()
|
||||
|
||||
@ -220,7 +275,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
|
||||
remoteFilePath := fmt.Sprintf("%s/%s", remoteFileDir, d.FileName)
|
||||
sftpClient, err := sftp.NewClient(sshClient)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -234,7 +288,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
||||
}
|
||||
|
||||
remoteFile, err := sftpClient.Create(remoteFilePath)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ type VirtualEnvironmentDatastoreGetStatusResponseData struct {
|
||||
type VirtualEnvironmentDatastoreListRequestBody struct {
|
||||
ContentTypes CustomCommaSeparatedList `json:"content,omitempty" url:"content,omitempty,comma"`
|
||||
Enabled *CustomBool `json:"enabled,omitempty" url:"enabled,omitempty,int"`
|
||||
Format *CustomBool `json:"format,omitempty" url:"format,omitempty,int"`
|
||||
Format *CustomBool `json:"format,omitempty" url:"format,omitempty,int"`
|
||||
ID *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
Target *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
Target *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentDatastoreListResponseBody contains the body from a datastore list response.
|
||||
|
@ -12,10 +12,18 @@ import (
|
||||
)
|
||||
|
||||
// GetDNS retrieves the DNS configuration for a node.
|
||||
func (c *VirtualEnvironmentClient) GetDNS(ctx context.Context, nodeName string) (*VirtualEnvironmentDNSGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetDNS(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*VirtualEnvironmentDNSGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentDNSGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -28,6 +36,10 @@ func (c *VirtualEnvironmentClient) GetDNS(ctx context.Context, nodeName string)
|
||||
}
|
||||
|
||||
// UpdateDNS updates the DNS configuration for a node.
|
||||
func (c *VirtualEnvironmentClient) UpdateDNS(ctx context.Context, nodeName string, d *VirtualEnvironmentDNSUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateDNS(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentDNSUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)), d, nil)
|
||||
}
|
||||
|
@ -11,16 +11,16 @@ type VirtualEnvironmentDNSGetResponseBody struct {
|
||||
|
||||
// VirtualEnvironmentDNSGetResponseData contains the data from a DNS get response.
|
||||
type VirtualEnvironmentDNSGetResponseData struct {
|
||||
Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
|
||||
Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
|
||||
Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
|
||||
Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
|
||||
Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
|
||||
Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
|
||||
SearchDomain *string `json:"search,omitempty" url:"search,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentDNSUpdateRequestBody contains the body for a DNS update request.
|
||||
type VirtualEnvironmentDNSUpdateRequestBody struct {
|
||||
Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
|
||||
Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
|
||||
Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
|
||||
Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
|
||||
Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
|
||||
Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
|
||||
SearchDomain *string `json:"search,omitempty" url:"search,omitempty"`
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ import (
|
||||
)
|
||||
|
||||
// CreateGroup creates an access group.
|
||||
func (c *VirtualEnvironmentClient) CreateGroup(ctx context.Context, d *VirtualEnvironmentGroupCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateGroup(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentGroupCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "access/groups", d, nil)
|
||||
}
|
||||
|
||||
@ -23,10 +26,18 @@ func (c *VirtualEnvironmentClient) DeleteGroup(ctx context.Context, id string) e
|
||||
}
|
||||
|
||||
// GetGroup retrieves an access group.
|
||||
func (c *VirtualEnvironmentClient) GetGroup(ctx context.Context, id string) (*VirtualEnvironmentGroupGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetGroup(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) (*VirtualEnvironmentGroupGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentGroupGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("access/groups/%s", url.PathEscape(id)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,10 +52,11 @@ func (c *VirtualEnvironmentClient) GetGroup(ctx context.Context, id string) (*Vi
|
||||
}
|
||||
|
||||
// ListGroups retrieves a list of access groups.
|
||||
func (c *VirtualEnvironmentClient) ListGroups(ctx context.Context) ([]*VirtualEnvironmentGroupListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListGroups(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentGroupListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentGroupListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "access/groups", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -61,6 +73,10 @@ func (c *VirtualEnvironmentClient) ListGroups(ctx context.Context) ([]*VirtualEn
|
||||
}
|
||||
|
||||
// UpdateGroup updates an access group.
|
||||
func (c *VirtualEnvironmentClient) UpdateGroup(ctx context.Context, id string, d *VirtualEnvironmentGroupUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateGroup(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentGroupUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), d, nil)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package proxmox
|
||||
// VirtualEnvironmentGroupCreateRequestBody contains the data for an access group create request.
|
||||
type VirtualEnvironmentGroupCreateRequestBody struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
ID string `json:"groupid" url:"groupid"`
|
||||
ID string `json:"groupid" url:"groupid"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentGroupGetResponseBody contains the body from an access group get response.
|
||||
|
@ -12,10 +12,18 @@ import (
|
||||
)
|
||||
|
||||
// GetHosts retrieves the Hosts configuration for a node.
|
||||
func (c *VirtualEnvironmentClient) GetHosts(ctx context.Context, nodeName string) (*VirtualEnvironmentHostsGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetHosts(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*VirtualEnvironmentHostsGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentHostsGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -28,6 +36,10 @@ func (c *VirtualEnvironmentClient) GetHosts(ctx context.Context, nodeName string
|
||||
}
|
||||
|
||||
// UpdateHosts updates the Hosts configuration for a node.
|
||||
func (c *VirtualEnvironmentClient) UpdateHosts(ctx context.Context, nodeName string, d *VirtualEnvironmentHostsUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateHosts(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentHostsUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)), d, nil)
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ type VirtualEnvironmentHostsGetResponseData struct {
|
||||
|
||||
// VirtualEnvironmentHostsUpdateRequestBody contains the body for a hosts update request.
|
||||
type VirtualEnvironmentHostsUpdateRequestBody struct {
|
||||
Data string `json:"data" url:"data"`
|
||||
Data string `json:"data" url:"data"`
|
||||
Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
|
||||
}
|
||||
|
@ -19,9 +19,12 @@ import (
|
||||
)
|
||||
|
||||
// ExecuteNodeCommands executes commands on a given node.
|
||||
func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, nodeName string, commands []string) error {
|
||||
func (c *VirtualEnvironmentClient) ExecuteNodeCommands(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
commands []string,
|
||||
) error {
|
||||
sshClient, err := c.OpenNodeShell(ctx, nodeName)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -36,7 +39,6 @@ func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, node
|
||||
}(sshClient)
|
||||
|
||||
sshSession, err := sshClient.NewSession()
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -56,7 +58,6 @@ func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, node
|
||||
strings.ReplaceAll(strings.Join(commands, " && \\\n"), "'", "'\"'\"'"),
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return errors.New(string(output))
|
||||
}
|
||||
@ -65,9 +66,11 @@ func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, node
|
||||
}
|
||||
|
||||
// GetNodeIP retrieves the IP address of a node.
|
||||
func (c *VirtualEnvironmentClient) GetNodeIP(ctx context.Context, nodeName string) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) GetNodeIP(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*string, error) {
|
||||
networkDevices, err := c.ListNodeNetworkDevices(ctx, nodeName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -91,10 +94,18 @@ func (c *VirtualEnvironmentClient) GetNodeIP(ctx context.Context, nodeName strin
|
||||
}
|
||||
|
||||
// GetNodeTime retrieves the time information for a node.
|
||||
func (c *VirtualEnvironmentClient) GetNodeTime(ctx context.Context, nodeName string) (*VirtualEnvironmentNodeGetTimeResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetNodeTime(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*VirtualEnvironmentNodeGetTimeResponseData, error) {
|
||||
resBody := &VirtualEnvironmentNodeGetTimeResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/time", url.PathEscape(nodeName)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/time", url.PathEscape(nodeName)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -107,10 +118,19 @@ func (c *VirtualEnvironmentClient) GetNodeTime(ctx context.Context, nodeName str
|
||||
}
|
||||
|
||||
// GetNodeTaskStatus retrieves the status of a node task.
|
||||
func (c *VirtualEnvironmentClient) GetNodeTaskStatus(ctx context.Context, nodeName string, upid string) (*VirtualEnvironmentNodeGetTaskStatusResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetNodeTaskStatus(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
upid string,
|
||||
) (*VirtualEnvironmentNodeGetTaskStatusResponseData, error) {
|
||||
resBody := &VirtualEnvironmentNodeGetTaskStatusResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/tasks/%s/status", url.PathEscape(nodeName), url.PathEscape(upid)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/tasks/%s/status", url.PathEscape(nodeName), url.PathEscape(upid)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -123,10 +143,18 @@ func (c *VirtualEnvironmentClient) GetNodeTaskStatus(ctx context.Context, nodeNa
|
||||
}
|
||||
|
||||
// ListNodeNetworkDevices retrieves a list of network devices for a specific nodes.
|
||||
func (c *VirtualEnvironmentClient) ListNodeNetworkDevices(ctx context.Context, nodeName string) ([]*VirtualEnvironmentNodeNetworkDeviceListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListNodeNetworkDevices(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) ([]*VirtualEnvironmentNodeNetworkDeviceListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentNodeNetworkDeviceListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/network", url.PathEscape(nodeName)), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/network", url.PathEscape(nodeName)),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -143,10 +171,11 @@ func (c *VirtualEnvironmentClient) ListNodeNetworkDevices(ctx context.Context, n
|
||||
}
|
||||
|
||||
// ListNodes retrieves a list of nodes.
|
||||
func (c *VirtualEnvironmentClient) ListNodes(ctx context.Context) ([]*VirtualEnvironmentNodeListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListNodes(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentNodeListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentNodeListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "nodes", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -163,9 +192,11 @@ func (c *VirtualEnvironmentClient) ListNodes(ctx context.Context) ([]*VirtualEnv
|
||||
}
|
||||
|
||||
// OpenNodeShell establishes a new SSH connection to a node.
|
||||
func (c *VirtualEnvironmentClient) OpenNodeShell(ctx context.Context, nodeName string) (*ssh.Client, error) {
|
||||
func (c *VirtualEnvironmentClient) OpenNodeShell(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
) (*ssh.Client, error) {
|
||||
nodeAddress, err := c.GetNodeIP(ctx, nodeName)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -179,7 +210,6 @@ func (c *VirtualEnvironmentClient) OpenNodeShell(ctx context.Context, nodeName s
|
||||
}
|
||||
|
||||
sshClient, err := ssh.Dial("tcp", *nodeAddress+":22", sshConfig)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -188,12 +218,22 @@ func (c *VirtualEnvironmentClient) OpenNodeShell(ctx context.Context, nodeName s
|
||||
}
|
||||
|
||||
// UpdateNodeTime updates the time on a node.
|
||||
func (c *VirtualEnvironmentClient) UpdateNodeTime(ctx context.Context, nodeName string, d *VirtualEnvironmentNodeUpdateTimeRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateNodeTime(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentNodeUpdateTimeRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/time", url.PathEscape(nodeName)), d, nil)
|
||||
}
|
||||
|
||||
// WaitForNodeTask waits for a specific node task to complete.
|
||||
func (c *VirtualEnvironmentClient) WaitForNodeTask(ctx context.Context, nodeName string, upid string, timeout int, delay int) error {
|
||||
func (c *VirtualEnvironmentClient) WaitForNodeTask(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
upid string,
|
||||
timeout int,
|
||||
delay int,
|
||||
) error {
|
||||
timeDelay := int64(delay)
|
||||
timeMax := float64(timeout)
|
||||
timeStart := time.Now()
|
||||
@ -202,14 +242,18 @@ func (c *VirtualEnvironmentClient) WaitForNodeTask(ctx context.Context, nodeName
|
||||
for timeElapsed.Seconds() < timeMax {
|
||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||
status, err := c.GetNodeTaskStatus(ctx, nodeName, upid)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if status.Status != "running" {
|
||||
if status.ExitCode != "OK" {
|
||||
return fmt.Errorf("task \"%s\" on node \"%s\" failed to complete with error: %s", upid, nodeName, status.ExitCode)
|
||||
return fmt.Errorf(
|
||||
"task \"%s\" on node \"%s\" failed to complete with error: %s",
|
||||
upid,
|
||||
nodeName,
|
||||
status.ExitCode,
|
||||
)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -226,5 +270,9 @@ func (c *VirtualEnvironmentClient) WaitForNodeTask(ctx context.Context, nodeName
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("timeout while waiting for task \"%s\" on node \"%s\" to complete", upid, nodeName)
|
||||
return fmt.Errorf(
|
||||
"timeout while waiting for task \"%s\" on node \"%s\" to complete",
|
||||
upid,
|
||||
nodeName,
|
||||
)
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ type VirtualEnvironmentNodeUpdateTimeRequestBody struct {
|
||||
// EncodeValues converts a CustomNodeCommands array to a JSON encoded URL vlaue.
|
||||
func (r CustomNodeCommands) EncodeValues(key string, v *url.Values) error {
|
||||
jsonArrayBytes, err := json.Marshal(r)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ import (
|
||||
)
|
||||
|
||||
// CreatePool creates a pool.
|
||||
func (c *VirtualEnvironmentClient) CreatePool(ctx context.Context, d *VirtualEnvironmentPoolCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreatePool(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentPoolCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "pools", d, nil)
|
||||
}
|
||||
|
||||
@ -23,10 +26,12 @@ func (c *VirtualEnvironmentClient) DeletePool(ctx context.Context, id string) er
|
||||
}
|
||||
|
||||
// GetPool retrieves a pool.
|
||||
func (c *VirtualEnvironmentClient) GetPool(ctx context.Context, id string) (*VirtualEnvironmentPoolGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetPool(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) (*VirtualEnvironmentPoolGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentPoolGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("pools/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -43,10 +48,11 @@ func (c *VirtualEnvironmentClient) GetPool(ctx context.Context, id string) (*Vir
|
||||
}
|
||||
|
||||
// ListPools retrieves a list of pools.
|
||||
func (c *VirtualEnvironmentClient) ListPools(ctx context.Context) ([]*VirtualEnvironmentPoolListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListPools(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentPoolListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentPoolListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "pools", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -63,6 +69,10 @@ func (c *VirtualEnvironmentClient) ListPools(ctx context.Context) ([]*VirtualEnv
|
||||
}
|
||||
|
||||
// UpdatePool updates a pool.
|
||||
func (c *VirtualEnvironmentClient) UpdatePool(ctx context.Context, id string, d *VirtualEnvironmentPoolUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdatePool(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentPoolUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("pools/%s", url.PathEscape(id)), d, nil)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package proxmox
|
||||
// VirtualEnvironmentPoolCreateRequestBody contains the data for an pool create request.
|
||||
type VirtualEnvironmentPoolCreateRequestBody struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
ID string `json:"groupid" url:"poolid"`
|
||||
ID string `json:"groupid" url:"poolid"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentPoolGetResponseBody contains the body from an pool get response.
|
||||
|
@ -13,7 +13,10 @@ import (
|
||||
)
|
||||
|
||||
// CreateRole creates an access role.
|
||||
func (c *VirtualEnvironmentClient) CreateRole(ctx context.Context, d *VirtualEnvironmentRoleCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateRole(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentRoleCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "access/roles", d, nil)
|
||||
}
|
||||
|
||||
@ -23,10 +26,12 @@ func (c *VirtualEnvironmentClient) DeleteRole(ctx context.Context, id string) er
|
||||
}
|
||||
|
||||
// GetRole retrieves an access role.
|
||||
func (c *VirtualEnvironmentClient) GetRole(ctx context.Context, id string) (*CustomPrivileges, error) {
|
||||
func (c *VirtualEnvironmentClient) GetRole(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) (*CustomPrivileges, error) {
|
||||
resBody := &VirtualEnvironmentRoleGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -41,10 +46,11 @@ func (c *VirtualEnvironmentClient) GetRole(ctx context.Context, id string) (*Cus
|
||||
}
|
||||
|
||||
// ListRoles retrieves a list of access roles.
|
||||
func (c *VirtualEnvironmentClient) ListRoles(ctx context.Context) ([]*VirtualEnvironmentRoleListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListRoles(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentRoleListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentRoleListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "access/roles", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -67,6 +73,10 @@ func (c *VirtualEnvironmentClient) ListRoles(ctx context.Context) ([]*VirtualEnv
|
||||
}
|
||||
|
||||
// UpdateRole updates an access role.
|
||||
func (c *VirtualEnvironmentClient) UpdateRole(ctx context.Context, id string, d *VirtualEnvironmentRoleUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateRole(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentRoleUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), d, nil)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ package proxmox
|
||||
// VirtualEnvironmentRoleCreateRequestBody contains the data for an access group create request.
|
||||
type VirtualEnvironmentRoleCreateRequestBody struct {
|
||||
ID string `json:"roleid" url:"roleid"`
|
||||
Privileges CustomPrivileges `json:"privs" url:"privs,comma"`
|
||||
Privileges CustomPrivileges `json:"privs" url:"privs,comma"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentRoleGetResponseBody contains the body from an access group get response.
|
||||
|
@ -14,7 +14,10 @@ import (
|
||||
)
|
||||
|
||||
// ChangeUserPassword changes a user's password.
|
||||
func (c *VirtualEnvironmentClient) ChangeUserPassword(ctx context.Context, id, password string) error {
|
||||
func (c *VirtualEnvironmentClient) ChangeUserPassword(
|
||||
ctx context.Context,
|
||||
id, password string,
|
||||
) error {
|
||||
d := VirtualEnvironmentUserChangePasswordRequestBody{
|
||||
ID: id,
|
||||
Password: password,
|
||||
@ -24,7 +27,10 @@ func (c *VirtualEnvironmentClient) ChangeUserPassword(ctx context.Context, id, p
|
||||
}
|
||||
|
||||
// CreateUser creates a user.
|
||||
func (c *VirtualEnvironmentClient) CreateUser(ctx context.Context, d *VirtualEnvironmentUserCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateUser(
|
||||
ctx context.Context,
|
||||
d *VirtualEnvironmentUserCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, "access/users", d, nil)
|
||||
}
|
||||
|
||||
@ -34,10 +40,12 @@ func (c *VirtualEnvironmentClient) DeleteUser(ctx context.Context, id string) er
|
||||
}
|
||||
|
||||
// GetUser retrieves a user.
|
||||
func (c *VirtualEnvironmentClient) GetUser(ctx context.Context, id string) (*VirtualEnvironmentUserGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetUser(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
) (*VirtualEnvironmentUserGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentUserGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/users/%s", url.PathEscape(id)), nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -59,10 +67,11 @@ func (c *VirtualEnvironmentClient) GetUser(ctx context.Context, id string) (*Vir
|
||||
}
|
||||
|
||||
// ListUsers retrieves a list of users.
|
||||
func (c *VirtualEnvironmentClient) ListUsers(ctx context.Context) ([]*VirtualEnvironmentUserListResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) ListUsers(
|
||||
ctx context.Context,
|
||||
) ([]*VirtualEnvironmentUserListResponseData, error) {
|
||||
resBody := &VirtualEnvironmentUserListResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "access/users", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -90,6 +99,10 @@ func (c *VirtualEnvironmentClient) ListUsers(ctx context.Context) ([]*VirtualEnv
|
||||
}
|
||||
|
||||
// UpdateUser updates a user.
|
||||
func (c *VirtualEnvironmentClient) UpdateUser(ctx context.Context, id string, d *VirtualEnvironmentUserUpdateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) UpdateUser(
|
||||
ctx context.Context,
|
||||
id string,
|
||||
d *VirtualEnvironmentUserUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/users/%s", url.PathEscape(id)), d, nil)
|
||||
}
|
||||
|
@ -6,22 +6,22 @@ package proxmox
|
||||
|
||||
// VirtualEnvironmentUserChangePasswordRequestBody contains the data for a user password change request.
|
||||
type VirtualEnvironmentUserChangePasswordRequestBody struct {
|
||||
ID string `json:"userid" url:"userid"`
|
||||
ID string `json:"userid" url:"userid"`
|
||||
Password string `json:"password" url:"password"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentUserCreateRequestBody contains the data for an user create request.
|
||||
type VirtualEnvironmentUserCreateRequestBody struct {
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Email *string `json:"email,omitempty" url:"email,omitempty"`
|
||||
Enabled *CustomBool `json:"enable,omitempty" url:"enable,omitempty,int"`
|
||||
ExpirationDate *CustomTimestamp `json:"expire,omitempty" url:"expire,omitempty,unix"`
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Email *string `json:"email,omitempty" url:"email,omitempty"`
|
||||
Enabled *CustomBool `json:"enable,omitempty" url:"enable,omitempty,int"`
|
||||
ExpirationDate *CustomTimestamp `json:"expire,omitempty" url:"expire,omitempty,unix"`
|
||||
FirstName *string `json:"firstname,omitempty" url:"firstname,omitempty"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
ID string `json:"userid" url:"userid"`
|
||||
Keys *string `json:"keys,omitempty" url:"keys,omitempty"`
|
||||
LastName *string `json:"lastname,omitempty" url:"lastname,omitempty"`
|
||||
Password string `json:"password" url:"password"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
ID string `json:"userid" url:"userid"`
|
||||
Keys *string `json:"keys,omitempty" url:"keys,omitempty"`
|
||||
LastName *string `json:"lastname,omitempty" url:"lastname,omitempty"`
|
||||
Password string `json:"password" url:"password"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentUserGetResponseBody contains the body from an user get response.
|
||||
@ -61,13 +61,13 @@ type VirtualEnvironmentUserListResponseData struct {
|
||||
|
||||
// VirtualEnvironmentUserUpdateRequestBody contains the data for an user update request.
|
||||
type VirtualEnvironmentUserUpdateRequestBody struct {
|
||||
Append *CustomBool `json:"append,omitempty" url:"append,omitempty"`
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Email *string `json:"email,omitempty" url:"email,omitempty"`
|
||||
Enabled *CustomBool `json:"enable,omitempty" url:"enable,omitempty,int"`
|
||||
ExpirationDate *CustomTimestamp `json:"expire,omitempty" url:"expire,omitempty,unix"`
|
||||
Append *CustomBool `json:"append,omitempty" url:"append,omitempty"`
|
||||
Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
|
||||
Email *string `json:"email,omitempty" url:"email,omitempty"`
|
||||
Enabled *CustomBool `json:"enable,omitempty" url:"enable,omitempty,int"`
|
||||
ExpirationDate *CustomTimestamp `json:"expire,omitempty" url:"expire,omitempty,unix"`
|
||||
FirstName *string `json:"firstname,omitempty" url:"firstname,omitempty"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
Keys *string `json:"keys,omitempty" url:"keys,omitempty"`
|
||||
LastName *string `json:"lastname,omitempty" url:"lastname,omitempty"`
|
||||
Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
|
||||
Keys *string `json:"keys,omitempty" url:"keys,omitempty"`
|
||||
LastName *string `json:"lastname,omitempty" url:"lastname,omitempty"`
|
||||
}
|
||||
|
@ -10,10 +10,11 @@ import (
|
||||
)
|
||||
|
||||
// Version retrieves the version information.
|
||||
func (c *VirtualEnvironmentClient) Version(ctx context.Context) (*VirtualEnvironmentVersionResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) Version(
|
||||
ctx context.Context,
|
||||
) (*VirtualEnvironmentVersionResponseData, error) {
|
||||
resBody := &VirtualEnvironmentVersionResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, "version", nil, resBody)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -27,7 +27,14 @@ var (
|
||||
)
|
||||
|
||||
// CloneVM clones a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) CloneVM(ctx context.Context, nodeName string, vmID int, retries int, d *VirtualEnvironmentVMCloneRequestBody, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) CloneVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
retries int,
|
||||
d *VirtualEnvironmentVMCloneRequestBody,
|
||||
timeout int,
|
||||
) error {
|
||||
resBody := &VirtualEnvironmentVMMoveDiskResponseBody{}
|
||||
var err error
|
||||
|
||||
@ -37,7 +44,13 @@ func (c *VirtualEnvironmentClient) CloneVM(ctx context.Context, nodeName string,
|
||||
}
|
||||
|
||||
for i := 0; i < retries; i++ {
|
||||
err = c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/clone", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
err = c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/clone", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@ -59,20 +72,43 @@ func (c *VirtualEnvironmentClient) CloneVM(ctx context.Context, nodeName string,
|
||||
}
|
||||
|
||||
// CreateVM creates a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) CreateVM(ctx context.Context, nodeName string, d *VirtualEnvironmentVMCreateRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) CreateVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
d *VirtualEnvironmentVMCreateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu", url.PathEscape(nodeName)), d, nil)
|
||||
}
|
||||
|
||||
// DeleteVM deletes a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) DeleteVM(ctx context.Context, nodeName string, vmID int) error {
|
||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/qemu/%d?destroy-unreferenced-disks=1&purge=1", url.PathEscape(nodeName), vmID), nil, nil)
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmDELETE,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/qemu/%d?destroy-unreferenced-disks=1&purge=1",
|
||||
url.PathEscape(nodeName),
|
||||
vmID,
|
||||
),
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// GetVM retrieves a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) GetVM(ctx context.Context, nodeName string, vmID int) (*VirtualEnvironmentVMGetResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*VirtualEnvironmentVMGetResponseData, error) {
|
||||
resBody := &VirtualEnvironmentVMGetResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -91,7 +127,6 @@ func (c *VirtualEnvironmentClient) GetVMID(ctx context.Context) (*int, error) {
|
||||
|
||||
if getVMIDCounter < 0 {
|
||||
nextVMID, err := c.GetClusterNextID(ctx, nil)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -113,7 +148,6 @@ func (c *VirtualEnvironmentClient) GetVMID(ctx context.Context) (*int, error) {
|
||||
|
||||
for vmID <= 2147483637 {
|
||||
_, err := c.GetClusterNextID(ctx, &vmID)
|
||||
|
||||
if err != nil {
|
||||
vmID += getVMIDStep
|
||||
|
||||
@ -133,10 +167,23 @@ func (c *VirtualEnvironmentClient) GetVMID(ctx context.Context) (*int, error) {
|
||||
}
|
||||
|
||||
// GetVMNetworkInterfacesFromAgent retrieves the network interfaces reported by the QEMU agent.
|
||||
func (c *VirtualEnvironmentClient) GetVMNetworkInterfacesFromAgent(ctx context.Context, nodeName string, vmID int) (*VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetVMNetworkInterfacesFromAgent(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseData, error) {
|
||||
resBody := &VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/qemu/%d/agent/network-get-interfaces", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf(
|
||||
"nodes/%s/qemu/%d/agent/network-get-interfaces",
|
||||
url.PathEscape(nodeName),
|
||||
vmID,
|
||||
),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -149,10 +196,19 @@ func (c *VirtualEnvironmentClient) GetVMNetworkInterfacesFromAgent(ctx context.C
|
||||
}
|
||||
|
||||
// GetVMStatus retrieves the status for a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) GetVMStatus(ctx context.Context, nodeName string, vmID int) (*VirtualEnvironmentVMGetStatusResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) GetVMStatus(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*VirtualEnvironmentVMGetStatusResponseData, error) {
|
||||
resBody := &VirtualEnvironmentVMGetStatusResponseBody{}
|
||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("nodes/%s/qemu/%d/status/current", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmGET,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/status/current", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -165,9 +221,14 @@ func (c *VirtualEnvironmentClient) GetVMStatus(ctx context.Context, nodeName str
|
||||
}
|
||||
|
||||
// MigrateVM migrates a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) MigrateVM(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMMigrateRequestBody, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) MigrateVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMMigrateRequestBody,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.MigrateVMAsync(ctx, nodeName, vmID, d)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -182,10 +243,20 @@ func (c *VirtualEnvironmentClient) MigrateVM(ctx context.Context, nodeName strin
|
||||
}
|
||||
|
||||
// MigrateVMAsync migrates a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) MigrateVMAsync(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMMigrateRequestBody) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) MigrateVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMMigrateRequestBody,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMMigrateResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/migrate", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/migrate", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -198,9 +269,14 @@ func (c *VirtualEnvironmentClient) MigrateVMAsync(ctx context.Context, nodeName
|
||||
}
|
||||
|
||||
// MoveVMDisk moves a virtual machine disk.
|
||||
func (c *VirtualEnvironmentClient) MoveVMDisk(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMMoveDiskRequestBody, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) MoveVMDisk(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMMoveDiskRequestBody,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.MoveVMDiskAsync(ctx, nodeName, vmID, d)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "you can't move to the same storage with same format") {
|
||||
// if someone tries to move to the same storage, the move is considered to be successful
|
||||
@ -220,10 +296,20 @@ func (c *VirtualEnvironmentClient) MoveVMDisk(ctx context.Context, nodeName stri
|
||||
}
|
||||
|
||||
// MoveVMDiskAsync moves a virtual machine disk asynchronously.
|
||||
func (c *VirtualEnvironmentClient) MoveVMDiskAsync(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMMoveDiskRequestBody) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) MoveVMDiskAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMMoveDiskRequestBody,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMMoveDiskResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/move_disk", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/move_disk", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -241,9 +327,14 @@ func (c *VirtualEnvironmentClient) ListVMs() ([]*VirtualEnvironmentVMListRespons
|
||||
}
|
||||
|
||||
// RebootVM reboots a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) RebootVM(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMRebootRequestBody, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) RebootVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMRebootRequestBody,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.RebootVMAsync(ctx, nodeName, vmID, d)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -258,10 +349,20 @@ func (c *VirtualEnvironmentClient) RebootVM(ctx context.Context, nodeName string
|
||||
}
|
||||
|
||||
// RebootVMAsync reboots a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) RebootVMAsync(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMRebootRequestBody) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) RebootVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMRebootRequestBody,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMRebootResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/status/reboot", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/status/reboot", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -274,14 +375,25 @@ func (c *VirtualEnvironmentClient) RebootVMAsync(ctx context.Context, nodeName s
|
||||
}
|
||||
|
||||
// ResizeVMDisk resizes a virtual machine disk.
|
||||
func (c *VirtualEnvironmentClient) ResizeVMDisk(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMResizeDiskRequestBody) error {
|
||||
func (c *VirtualEnvironmentClient) ResizeVMDisk(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMResizeDiskRequestBody,
|
||||
) error {
|
||||
var err error
|
||||
tflog.Debug(ctx, "resize disk", map[string]interface{}{
|
||||
"disk": d.Disk,
|
||||
"size": d.Size,
|
||||
})
|
||||
for i := 0; i < 5; i++ {
|
||||
err = c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/qemu/%d/resize", url.PathEscape(nodeName), vmID), d, nil)
|
||||
err = c.DoRequest(
|
||||
ctx,
|
||||
hmPUT,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/resize", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
@ -298,9 +410,14 @@ func (c *VirtualEnvironmentClient) ResizeVMDisk(ctx context.Context, nodeName st
|
||||
}
|
||||
|
||||
// ShutdownVM shuts down a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) ShutdownVM(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMShutdownRequestBody, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) ShutdownVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMShutdownRequestBody,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.ShutdownVMAsync(ctx, nodeName, vmID, d)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -315,10 +432,20 @@ func (c *VirtualEnvironmentClient) ShutdownVM(ctx context.Context, nodeName stri
|
||||
}
|
||||
|
||||
// ShutdownVMAsync shuts down a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) ShutdownVMAsync(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMShutdownRequestBody) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) ShutdownVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMShutdownRequestBody,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMShutdownResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/status/shutdown", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/status/shutdown", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -331,9 +458,13 @@ func (c *VirtualEnvironmentClient) ShutdownVMAsync(ctx context.Context, nodeName
|
||||
}
|
||||
|
||||
// StartVM starts a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) StartVM(ctx context.Context, nodeName string, vmID int, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) StartVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.StartVMAsync(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -348,10 +479,19 @@ func (c *VirtualEnvironmentClient) StartVM(ctx context.Context, nodeName string,
|
||||
}
|
||||
|
||||
// StartVMAsync starts a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) StartVMAsync(ctx context.Context, nodeName string, vmID int) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) StartVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMStartResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/status/start", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/status/start", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -364,9 +504,13 @@ func (c *VirtualEnvironmentClient) StartVMAsync(ctx context.Context, nodeName st
|
||||
}
|
||||
|
||||
// StopVM stops a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) StopVM(ctx context.Context, nodeName string, vmID int, timeout int) error {
|
||||
func (c *VirtualEnvironmentClient) StopVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
) error {
|
||||
taskID, err := c.StopVMAsync(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -381,10 +525,19 @@ func (c *VirtualEnvironmentClient) StopVM(ctx context.Context, nodeName string,
|
||||
}
|
||||
|
||||
// StopVMAsync stops a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) StopVMAsync(ctx context.Context, nodeName string, vmID int) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) StopVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMStopResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/status/stop", url.PathEscape(nodeName), vmID), nil, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/status/stop", url.PathEscape(nodeName), vmID),
|
||||
nil,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -397,15 +550,36 @@ func (c *VirtualEnvironmentClient) StopVMAsync(ctx context.Context, nodeName str
|
||||
}
|
||||
|
||||
// UpdateVM updates a virtual machine.
|
||||
func (c *VirtualEnvironmentClient) UpdateVM(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMUpdateRequestBody) error {
|
||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID), d, nil)
|
||||
func (c *VirtualEnvironmentClient) UpdateVM(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMUpdateRequestBody,
|
||||
) error {
|
||||
return c.DoRequest(
|
||||
ctx,
|
||||
hmPUT,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
// UpdateVMAsync updates a virtual machine asynchronously.
|
||||
func (c *VirtualEnvironmentClient) UpdateVMAsync(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMUpdateRequestBody) (*string, error) {
|
||||
func (c *VirtualEnvironmentClient) UpdateVMAsync(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
d *VirtualEnvironmentVMUpdateRequestBody,
|
||||
) (*string, error) {
|
||||
resBody := &VirtualEnvironmentVMUpdateAsyncResponseBody{}
|
||||
err := c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID), d, resBody)
|
||||
|
||||
err := c.DoRequest(
|
||||
ctx,
|
||||
hmPOST,
|
||||
fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID),
|
||||
d,
|
||||
resBody,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -418,7 +592,14 @@ func (c *VirtualEnvironmentClient) UpdateVMAsync(ctx context.Context, nodeName s
|
||||
}
|
||||
|
||||
// WaitForNetworkInterfacesFromVMAgent waits for a virtual machine's QEMU agent to publish the network interfaces.
|
||||
func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx context.Context, nodeName string, vmID int, timeout int, delay int, waitForIP bool) (*VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseData, error) {
|
||||
func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
delay int,
|
||||
waitForIP bool,
|
||||
) (*VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseData, error) {
|
||||
timeDelay := int64(delay)
|
||||
timeMax := float64(timeout)
|
||||
timeStart := time.Now()
|
||||
@ -438,7 +619,8 @@ func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx conte
|
||||
continue
|
||||
}
|
||||
|
||||
if nic.IPAddresses == nil || (nic.IPAddresses != nil && len(*nic.IPAddresses) == 0) {
|
||||
if nic.IPAddresses == nil ||
|
||||
(nic.IPAddresses != nil && len(*nic.IPAddresses) == 0) {
|
||||
missingIP = true
|
||||
break
|
||||
}
|
||||
@ -468,11 +650,20 @@ func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx conte
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("timeout while waiting for the QEMU agent on VM \"%d\" to publish the network interfaces", vmID)
|
||||
return nil, fmt.Errorf(
|
||||
"timeout while waiting for the QEMU agent on VM \"%d\" to publish the network interfaces",
|
||||
vmID,
|
||||
)
|
||||
}
|
||||
|
||||
// WaitForNoNetworkInterfacesFromVMAgent waits for a virtual machine's QEMU agent to unpublish the network interfaces.
|
||||
func (c *VirtualEnvironmentClient) WaitForNoNetworkInterfacesFromVMAgent(ctx context.Context, nodeName string, vmID int, timeout int, delay int) error {
|
||||
func (c *VirtualEnvironmentClient) WaitForNoNetworkInterfacesFromVMAgent(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
delay int,
|
||||
) error {
|
||||
timeDelay := int64(delay)
|
||||
timeMax := float64(timeout)
|
||||
timeStart := time.Now()
|
||||
@ -481,7 +672,6 @@ func (c *VirtualEnvironmentClient) WaitForNoNetworkInterfacesFromVMAgent(ctx con
|
||||
for timeElapsed.Seconds() < timeMax {
|
||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||
_, err := c.GetVMNetworkInterfacesFromAgent(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
@ -498,11 +688,23 @@ func (c *VirtualEnvironmentClient) WaitForNoNetworkInterfacesFromVMAgent(ctx con
|
||||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("timeout while waiting for the QEMU agent on VM \"%d\" to unpublish the network interfaces", vmID)
|
||||
return fmt.Errorf(
|
||||
"timeout while waiting for the QEMU agent on VM \"%d\" to unpublish the network interfaces",
|
||||
vmID,
|
||||
)
|
||||
}
|
||||
|
||||
// WaitForVMConfigUnlock waits for a virtual machine configuration to become unlocked.
|
||||
func (c *VirtualEnvironmentClient) WaitForVMConfigUnlock(ctx context.Context, nodeName string, vmID int, timeout int, delay int, ignoreErrorResponse bool) error {
|
||||
//
|
||||
//nolint:dupl
|
||||
func (c *VirtualEnvironmentClient) WaitForVMConfigUnlock(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
timeout int,
|
||||
delay int,
|
||||
ignoreErrorResponse bool,
|
||||
) error {
|
||||
timeDelay := int64(delay)
|
||||
timeMax := float64(timeout)
|
||||
timeStart := time.Now()
|
||||
@ -536,7 +738,16 @@ func (c *VirtualEnvironmentClient) WaitForVMConfigUnlock(ctx context.Context, no
|
||||
}
|
||||
|
||||
// WaitForVMState waits for a virtual machine to reach a specific state.
|
||||
func (c *VirtualEnvironmentClient) WaitForVMState(ctx context.Context, nodeName string, vmID int, state string, timeout int, delay int) error {
|
||||
//
|
||||
//nolint:dupl
|
||||
func (c *VirtualEnvironmentClient) WaitForVMState(
|
||||
ctx context.Context,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
state string,
|
||||
timeout int,
|
||||
delay int,
|
||||
) error {
|
||||
state = strings.ToLower(state)
|
||||
|
||||
timeDelay := int64(delay)
|
||||
|
@ -16,16 +16,16 @@ import (
|
||||
|
||||
// CustomAgent handles QEMU agent parameters.
|
||||
type CustomAgent struct {
|
||||
Enabled *CustomBool `json:"enabled,omitempty" url:"enabled,int"`
|
||||
Enabled *CustomBool `json:"enabled,omitempty" url:"enabled,int"`
|
||||
TrimClonedDisks *CustomBool `json:"fstrim_cloned_disks" url:"fstrim_cloned_disks,int"`
|
||||
Type *string `json:"type" url:"type"`
|
||||
Type *string `json:"type" url:"type"`
|
||||
}
|
||||
|
||||
// CustomAudioDevice handles QEMU audio parameters.
|
||||
type CustomAudioDevice struct {
|
||||
Device string `json:"device" url:"device"`
|
||||
Driver *string `json:"driver" url:"driver"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
}
|
||||
|
||||
// CustomAudioDevices handles QEMU audio device parameters.
|
||||
@ -33,29 +33,29 @@ type CustomAudioDevices []CustomAudioDevice
|
||||
|
||||
// CustomCloudInitConfig handles QEMU cloud-init parameters.
|
||||
type CustomCloudInitConfig struct {
|
||||
Files *CustomCloudInitFiles `json:"cicustom,omitempty" url:"cicustom,omitempty"`
|
||||
IPConfig []CustomCloudInitIPConfig `json:"ipconfig,omitempty" url:"ipconfig,omitempty,numbered"`
|
||||
Nameserver *string `json:"nameserver,omitempty" url:"nameserver,omitempty"`
|
||||
Password *string `json:"cipassword,omitempty" url:"cipassword,omitempty"`
|
||||
Files *CustomCloudInitFiles `json:"cicustom,omitempty" url:"cicustom,omitempty"`
|
||||
IPConfig []CustomCloudInitIPConfig `json:"ipconfig,omitempty" url:"ipconfig,omitempty,numbered"`
|
||||
Nameserver *string `json:"nameserver,omitempty" url:"nameserver,omitempty"`
|
||||
Password *string `json:"cipassword,omitempty" url:"cipassword,omitempty"`
|
||||
SearchDomain *string `json:"searchdomain,omitempty" url:"searchdomain,omitempty"`
|
||||
SSHKeys *CustomCloudInitSSHKeys `json:"sshkeys,omitempty" url:"sshkeys,omitempty"`
|
||||
Type *string `json:"citype,omitempty" url:"citype,omitempty"`
|
||||
Username *string `json:"ciuser,omitempty" url:"ciuser,omitempty"`
|
||||
SSHKeys *CustomCloudInitSSHKeys `json:"sshkeys,omitempty" url:"sshkeys,omitempty"`
|
||||
Type *string `json:"citype,omitempty" url:"citype,omitempty"`
|
||||
Username *string `json:"ciuser,omitempty" url:"ciuser,omitempty"`
|
||||
}
|
||||
|
||||
// CustomCloudInitFiles handles QEMU cloud-init custom files parameters.
|
||||
type CustomCloudInitFiles struct {
|
||||
MetaVolume *string `json:"meta,omitempty" url:"meta,omitempty"`
|
||||
MetaVolume *string `json:"meta,omitempty" url:"meta,omitempty"`
|
||||
NetworkVolume *string `json:"network,omitempty" url:"network,omitempty"`
|
||||
UserVolume *string `json:"user,omitempty" url:"user,omitempty"`
|
||||
VendorVolume *string `json:"vendor,omitempty" url:"vendor,omitempty"`
|
||||
UserVolume *string `json:"user,omitempty" url:"user,omitempty"`
|
||||
VendorVolume *string `json:"vendor,omitempty" url:"vendor,omitempty"`
|
||||
}
|
||||
|
||||
// CustomCloudInitIPConfig handles QEMU cloud-init IP configuration parameters.
|
||||
type CustomCloudInitIPConfig struct {
|
||||
GatewayIPv4 *string `json:"gw,omitempty" url:"gw,omitempty"`
|
||||
GatewayIPv4 *string `json:"gw,omitempty" url:"gw,omitempty"`
|
||||
GatewayIPv6 *string `json:"gw6,omitempty" url:"gw6,omitempty"`
|
||||
IPv4 *string `json:"ip,omitempty" url:"ip,omitempty"`
|
||||
IPv4 *string `json:"ip,omitempty" url:"ip,omitempty"`
|
||||
IPv6 *string `json:"ip6,omitempty" url:"ip6,omitempty"`
|
||||
}
|
||||
|
||||
@ -64,32 +64,32 @@ type CustomCloudInitSSHKeys []string
|
||||
|
||||
// CustomCPUEmulation handles QEMU CPU emulation parameters.
|
||||
type CustomCPUEmulation struct {
|
||||
Flags *[]string `json:"flags,omitempty" url:"flags,omitempty,semicolon"`
|
||||
Hidden *CustomBool `json:"hidden,omitempty" url:"hidden,omitempty,int"`
|
||||
Flags *[]string `json:"flags,omitempty" url:"flags,omitempty,semicolon"`
|
||||
Hidden *CustomBool `json:"hidden,omitempty" url:"hidden,omitempty,int"`
|
||||
HVVendorID *string `json:"hv-vendor-id,omitempty" url:"hv-vendor-id,omitempty"`
|
||||
Type string `json:"cputype,omitempty" url:"cputype,omitempty"`
|
||||
Type string `json:"cputype,omitempty" url:"cputype,omitempty"`
|
||||
}
|
||||
|
||||
// CustomEFIDisk handles QEMU EFI disk parameters.
|
||||
type CustomEFIDisk struct {
|
||||
DiskSize *int `json:"size,omitempty" url:"size,omitempty"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
DiskSize *int `json:"size,omitempty" url:"size,omitempty"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
Format *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
}
|
||||
|
||||
// CustomNetworkDevice handles QEMU network device parameters.
|
||||
type CustomNetworkDevice struct {
|
||||
Model string `json:"model" url:"model"`
|
||||
Bridge *string `json:"bridge,omitempty" url:"bridge,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
Firewall *CustomBool `json:"firewall,omitempty" url:"firewall,omitempty,int"`
|
||||
Model string `json:"model" url:"model"`
|
||||
Bridge *string `json:"bridge,omitempty" url:"bridge,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
Firewall *CustomBool `json:"firewall,omitempty" url:"firewall,omitempty,int"`
|
||||
LinkDown *CustomBool `json:"link_down,omitempty" url:"link_down,omitempty,int"`
|
||||
MACAddress *string `json:"macaddr,omitempty" url:"macaddr,omitempty"`
|
||||
Queues *int `json:"queues,omitempty" url:"queues,omitempty"`
|
||||
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
||||
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
||||
MTU *int `json:"mtu,omitempty" url:"mtu,omitempty"`
|
||||
Trunks []int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
||||
MACAddress *string `json:"macaddr,omitempty" url:"macaddr,omitempty"`
|
||||
Queues *int `json:"queues,omitempty" url:"queues,omitempty"`
|
||||
RateLimit *float64 `json:"rate,omitempty" url:"rate,omitempty"`
|
||||
Tag *int `json:"tag,omitempty" url:"tag,omitempty"`
|
||||
MTU *int `json:"mtu,omitempty" url:"mtu,omitempty"`
|
||||
Trunks []int `json:"trunks,omitempty" url:"trunks,omitempty"`
|
||||
}
|
||||
|
||||
// CustomNetworkDevices handles QEMU network device parameters.
|
||||
@ -97,10 +97,10 @@ type CustomNetworkDevices []CustomNetworkDevice
|
||||
|
||||
// CustomNUMADevice handles QEMU NUMA device parameters.
|
||||
type CustomNUMADevice struct {
|
||||
CPUIDs []string `json:"cpus" url:"cpus,semicolon"`
|
||||
CPUIDs []string `json:"cpus" url:"cpus,semicolon"`
|
||||
HostNodeNames *[]string `json:"hostnodes,omitempty" url:"hostnodes,omitempty,semicolon"`
|
||||
Memory *float64 `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Policy *string `json:"policy,omitempty" url:"policy,omitempty"`
|
||||
Memory *float64 `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Policy *string `json:"policy,omitempty" url:"policy,omitempty"`
|
||||
}
|
||||
|
||||
// CustomNUMADevices handles QEMU NUMA device parameters.
|
||||
@ -108,12 +108,12 @@ type CustomNUMADevices []CustomNUMADevice
|
||||
|
||||
// CustomPCIDevice handles QEMU host PCI device mapping parameters.
|
||||
type CustomPCIDevice struct {
|
||||
DeviceIDs []string `json:"host" url:"host,semicolon"`
|
||||
MDev *string `json:"mdev,omitempty" url:"mdev,omitempty"`
|
||||
PCIExpress *CustomBool `json:"pcie,omitempty" url:"pcie,omitempty,int"`
|
||||
ROMBAR *CustomBool `json:"rombar,omitempty" url:"rombar,omitempty,int"`
|
||||
DeviceIDs []string `json:"host" url:"host,semicolon"`
|
||||
MDev *string `json:"mdev,omitempty" url:"mdev,omitempty"`
|
||||
PCIExpress *CustomBool `json:"pcie,omitempty" url:"pcie,omitempty,int"`
|
||||
ROMBAR *CustomBool `json:"rombar,omitempty" url:"rombar,omitempty,int"`
|
||||
ROMFile *string `json:"romfile,omitempty" url:"romfile,omitempty"`
|
||||
XVGA *CustomBool `json:"x-vga,omitempty" url:"x-vga,omitempty,int"`
|
||||
XVGA *CustomBool `json:"x-vga,omitempty" url:"x-vga,omitempty,int"`
|
||||
}
|
||||
|
||||
// CustomPCIDevices handles QEMU host PCI device mapping parameters.
|
||||
@ -125,50 +125,50 @@ type CustomSerialDevices []string
|
||||
// CustomSharedMemory handles QEMU Inter-VM shared memory parameters.
|
||||
type CustomSharedMemory struct {
|
||||
Name *string `json:"name,omitempty" url:"name,omitempty"`
|
||||
Size int `json:"size" url:"size"`
|
||||
Size int `json:"size" url:"size"`
|
||||
}
|
||||
|
||||
// CustomSMBIOS handles QEMU SMBIOS parameters.
|
||||
type CustomSMBIOS struct {
|
||||
Base64 *CustomBool `json:"base64,omitempty" url:"base64,omitempty"`
|
||||
Family *string `json:"family,omitempty" url:"family,omitempty"`
|
||||
Base64 *CustomBool `json:"base64,omitempty" url:"base64,omitempty"`
|
||||
Family *string `json:"family,omitempty" url:"family,omitempty"`
|
||||
Manufacturer *string `json:"manufacturer,omitempty" url:"manufacturer,omitempty"`
|
||||
Product *string `json:"product,omitempty" url:"product,omitempty"`
|
||||
Serial *string `json:"serial,omitempty" url:"serial,omitempty"`
|
||||
SKU *string `json:"sku,omitempty" url:"sku,omitempty"`
|
||||
UUID *string `json:"uuid,omitempty" url:"uuid,omitempty"`
|
||||
Version *string `json:"version,omitempty" url:"version,omitempty"`
|
||||
Product *string `json:"product,omitempty" url:"product,omitempty"`
|
||||
Serial *string `json:"serial,omitempty" url:"serial,omitempty"`
|
||||
SKU *string `json:"sku,omitempty" url:"sku,omitempty"`
|
||||
UUID *string `json:"uuid,omitempty" url:"uuid,omitempty"`
|
||||
Version *string `json:"version,omitempty" url:"version,omitempty"`
|
||||
}
|
||||
|
||||
// CustomSpiceEnhancements handles QEMU spice enhancement parameters.
|
||||
type CustomSpiceEnhancements struct {
|
||||
FolderSharing *CustomBool `json:"foldersharing,omitempty" url:"foldersharing,omitempty"`
|
||||
FolderSharing *CustomBool `json:"foldersharing,omitempty" url:"foldersharing,omitempty"`
|
||||
VideoStreaming *string `json:"videostreaming,omitempty" url:"videostreaming,omitempty"`
|
||||
}
|
||||
|
||||
// CustomStartupOrder handles QEMU startup order parameters.
|
||||
type CustomStartupOrder struct {
|
||||
Down *int `json:"down,omitempty" url:"down,omitempty"`
|
||||
Down *int `json:"down,omitempty" url:"down,omitempty"`
|
||||
Order *int `json:"order,omitempty" url:"order,omitempty"`
|
||||
Up *int `json:"up,omitempty" url:"up,omitempty"`
|
||||
Up *int `json:"up,omitempty" url:"up,omitempty"`
|
||||
}
|
||||
|
||||
// CustomStorageDevice handles QEMU SATA device parameters.
|
||||
type CustomStorageDevice struct {
|
||||
AIO *string `json:"aio,omitempty" url:"aio,omitempty"`
|
||||
BackupEnabled *CustomBool `json:"backup,omitempty" url:"backup,omitempty,int"`
|
||||
AIO *string `json:"aio,omitempty" url:"aio,omitempty"`
|
||||
BackupEnabled *CustomBool `json:"backup,omitempty" url:"backup,omitempty,int"`
|
||||
BurstableReadSpeedMbps *int `json:"mbps_rd_max,omitempty" url:"mbps_rd_max,omitempty"`
|
||||
BurstableWriteSpeedMbps *int `json:"mbps_wr_max,omitempty" url:"mbps_wr_max,omitempty"`
|
||||
Discard *string `json:"discard,omitempty" url:"discard,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
Format *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
IOThread *CustomBool `json:"iothread,omitempty" url:"iothread,omitempty,int"`
|
||||
SSD *CustomBool `json:"ssd,omitempty" url:"ssd,omitempty,int"`
|
||||
MaxReadSpeedMbps *int `json:"mbps_rd,omitempty" url:"mbps_rd,omitempty"`
|
||||
MaxWriteSpeedMbps *int `json:"mbps_wr,omitempty" url:"mbps_wr,omitempty"`
|
||||
Media *string `json:"media,omitempty" url:"media,omitempty"`
|
||||
Size *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
Discard *string `json:"discard,omitempty" url:"discard,omitempty"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
Format *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
IOThread *CustomBool `json:"iothread,omitempty" url:"iothread,omitempty,int"`
|
||||
SSD *CustomBool `json:"ssd,omitempty" url:"ssd,omitempty,int"`
|
||||
MaxReadSpeedMbps *int `json:"mbps_rd,omitempty" url:"mbps_rd,omitempty"`
|
||||
MaxWriteSpeedMbps *int `json:"mbps_wr,omitempty" url:"mbps_wr,omitempty"`
|
||||
Media *string `json:"media,omitempty" url:"media,omitempty"`
|
||||
Size *string `json:"size,omitempty" url:"size,omitempty"`
|
||||
Interface *string
|
||||
ID *string
|
||||
FileID *string
|
||||
@ -180,7 +180,7 @@ type CustomStorageDevices map[string]CustomStorageDevice
|
||||
|
||||
// CustomUSBDevice handles QEMU USB device parameters.
|
||||
type CustomUSBDevice struct {
|
||||
HostDevice string `json:"host" url:"host"`
|
||||
HostDevice string `json:"host" url:"host"`
|
||||
USB3 *CustomBool `json:"usb3,omitempty" url:"usb3,omitempty,int"`
|
||||
}
|
||||
|
||||
@ -190,15 +190,15 @@ type CustomUSBDevices []CustomUSBDevice
|
||||
// CustomVGADevice handles QEMU VGA device parameters.
|
||||
type CustomVGADevice struct {
|
||||
Memory *int `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Type *string `json:"type,omitempty" url:"type,omitempty"`
|
||||
Type *string `json:"type,omitempty" url:"type,omitempty"`
|
||||
}
|
||||
|
||||
// CustomVirtualIODevice handles QEMU VirtIO device parameters.
|
||||
type CustomVirtualIODevice struct {
|
||||
AIO *string `json:"aio,omitempty" url:"aio,omitempty"`
|
||||
AIO *string `json:"aio,omitempty" url:"aio,omitempty"`
|
||||
BackupEnabled *CustomBool `json:"backup,omitempty" url:"backup,omitempty,int"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
Enabled bool `json:"-" url:"-"`
|
||||
FileVolume string `json:"file" url:"file"`
|
||||
}
|
||||
|
||||
// CustomVirtualIODevices handles QEMU VirtIO device parameters.
|
||||
@ -207,95 +207,95 @@ type CustomVirtualIODevices []CustomVirtualIODevice
|
||||
// CustomWatchdogDevice handles QEMU watchdog device parameters.
|
||||
type CustomWatchdogDevice struct {
|
||||
Action *string `json:"action,omitempty" url:"action,omitempty"`
|
||||
Model *string `json:"model" url:"model"`
|
||||
Model *string `json:"model" url:"model"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMCloneRequestBody contains the data for an virtual machine clone request.
|
||||
type VirtualEnvironmentVMCloneRequestBody struct {
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
FullCopy *CustomBool `json:"full,omitempty" url:"full,omitempty,int"`
|
||||
Name *string `json:"name,omitempty" url:"name,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
SnapshotName *string `json:"snapname,omitempty" url:"snapname,omitempty"`
|
||||
TargetNodeName *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
TargetStorage *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
TargetStorageFormat *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
VMIDNew int `json:"newid" url:"newid"`
|
||||
FullCopy *CustomBool `json:"full,omitempty" url:"full,omitempty,int"`
|
||||
Name *string `json:"name,omitempty" url:"name,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
SnapshotName *string `json:"snapname,omitempty" url:"snapname,omitempty"`
|
||||
TargetNodeName *string `json:"target,omitempty" url:"target,omitempty"`
|
||||
TargetStorage *string `json:"storage,omitempty" url:"storage,omitempty"`
|
||||
TargetStorageFormat *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
VMIDNew int `json:"newid" url:"newid"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMCreateRequestBody contains the data for a virtual machine create request.
|
||||
type VirtualEnvironmentVMCreateRequestBody struct {
|
||||
ACPI *CustomBool `json:"acpi,omitempty" url:"acpi,omitempty,int"`
|
||||
Agent *CustomAgent `json:"agent,omitempty" url:"agent,omitempty"`
|
||||
AllowReboot *CustomBool `json:"reboot,omitempty" url:"reboot,omitempty,int"`
|
||||
AudioDevices CustomAudioDevices `json:"audio,omitempty" url:"audio,omitempty"`
|
||||
Autostart *CustomBool `json:"autostart,omitempty" url:"autostart,omitempty,int"`
|
||||
BackupFile *string `json:"archive,omitempty" url:"archive,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
BIOS *string `json:"bios,omitempty" url:"bios,omitempty"`
|
||||
BootDisk *string `json:"bootdisk,omitempty" url:"bootdisk,omitempty"`
|
||||
BootOrder *string `json:"boot,omitempty" url:"boot,omitempty"`
|
||||
CDROM *string `json:"cdrom,omitempty" url:"cdrom,omitempty"`
|
||||
CloudInitConfig *CustomCloudInitConfig `json:"cloudinit,omitempty" url:"cloudinit,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty" url:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty" url:"cores,omitempty"`
|
||||
CPUEmulation *CustomCPUEmulation `json:"cpu,omitempty" url:"cpu,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty" url:"cpulimit,omitempty"`
|
||||
CPUSockets *int `json:"sockets,omitempty" url:"sockets,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty" url:"cpuunits,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Delete []string `json:"delete,omitempty" url:"delete,omitempty,comma"`
|
||||
DeletionProtection *CustomBool `json:"protection,omitempty" url:"force,omitempty,int"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
EFIDisk *CustomEFIDisk `json:"efidisk0,omitempty" url:"efidisk0,omitempty"`
|
||||
FloatingMemory *int `json:"balloon,omitempty" url:"balloon,omitempty"`
|
||||
FloatingMemoryShares *int `json:"shares,omitempty" url:"shares,omitempty"`
|
||||
Freeze *CustomBool `json:"freeze,omitempty" url:"freeze,omitempty,int"`
|
||||
HookScript *string `json:"hookscript,omitempty" url:"hookscript,omitempty"`
|
||||
Hotplug CustomCommaSeparatedList `json:"hotplug,omitempty" url:"hotplug,omitempty,comma"`
|
||||
Hugepages *string `json:"hugepages,omitempty" url:"hugepages,omitempty"`
|
||||
IDEDevices CustomStorageDevices `json:"ide,omitempty" url:",omitempty"`
|
||||
KeyboardLayout *string `json:"keyboard,omitempty" url:"keyboard,omitempty"`
|
||||
KVMArguments *string `json:"args,omitempty" url:"args,omitempty,space"`
|
||||
KVMEnabled *CustomBool `json:"kvm,omitempty" url:"kvm,omitempty,int"`
|
||||
LocalTime *CustomBool `json:"localtime,omitempty" url:"localtime,omitempty,int"`
|
||||
Lock *string `json:"lock,omitempty" url:"lock,omitempty"`
|
||||
Machine *string `json:"machine,omitempty" url:"machine,omitempty"`
|
||||
MigrateDowntime *float64 `json:"migrate_downtime,omitempty" url:"migrate_downtime,omitempty"`
|
||||
MigrateSpeed *int `json:"migrate_speed,omitempty" url:"migrate_speed,omitempty"`
|
||||
Name *string `json:"name,omitempty" url:"name,omitempty"`
|
||||
NetworkDevices CustomNetworkDevices `json:"net,omitempty" url:"net,omitempty"`
|
||||
NUMADevices CustomNUMADevices `json:"numa_devices,omitempty" url:"numa,omitempty"`
|
||||
NUMAEnabled *CustomBool `json:"numa,omitempty" url:"numa,omitempty,int"`
|
||||
OSType *string `json:"ostype,omitempty" url:"ostype,omitempty"`
|
||||
Overwrite *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
PCIDevices CustomPCIDevices `json:"hostpci,omitempty" url:"hostpci,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Revert *string `json:"revert,omitempty" url:"revert,omitempty"`
|
||||
SATADevices CustomStorageDevices `json:"sata,omitempty" url:"sata,omitempty"`
|
||||
SCSIDevices CustomStorageDevices `json:"scsi,omitempty" url:"scsi,omitempty"`
|
||||
SCSIHardware *string `json:"scsihw,omitempty" url:"scsihw,omitempty"`
|
||||
SerialDevices CustomSerialDevices `json:"serial,omitempty" url:"serial,omitempty"`
|
||||
SharedMemory *CustomSharedMemory `json:"ivshmem,omitempty" url:"ivshmem,omitempty"`
|
||||
SkipLock *CustomBool `json:"skiplock,omitempty" url:"skiplock,omitempty,int"`
|
||||
SMBIOS *CustomSMBIOS `json:"smbios1,omitempty" url:"smbios1,omitempty"`
|
||||
SpiceEnhancements *CustomSpiceEnhancements `json:"spice_enhancements,omitempty" url:"spice_enhancements,omitempty"`
|
||||
StartDate *string `json:"startdate,omitempty" url:"startdate,omitempty"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty" url:"onboot,omitempty,int"`
|
||||
StartupOrder *CustomStartupOrder `json:"startup,omitempty" url:"startup,omitempty"`
|
||||
TabletDeviceEnabled *CustomBool `json:"tablet,omitempty" url:"tablet,omitempty,int"`
|
||||
Tags *string `json:"tags,omitempty" url:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty" url:"template,omitempty,int"`
|
||||
TimeDriftFixEnabled *CustomBool `json:"tdf,omitempty" url:"tdf,omitempty,int"`
|
||||
USBDevices CustomUSBDevices `json:"usb,omitempty" url:"usb,omitempty"`
|
||||
VGADevice *CustomVGADevice `json:"vga,omitempty" url:"vga,omitempty"`
|
||||
VirtualCPUCount *int `json:"vcpus,omitempty" url:"vcpus,omitempty"`
|
||||
VirtualIODevices CustomStorageDevices `json:"virtio,omitempty" url:"virtio,omitempty"`
|
||||
VMGenerationID *string `json:"vmgenid,omitempty" url:"vmgenid,omitempty"`
|
||||
VMID *int `json:"vmid,omitempty" url:"vmid,omitempty"`
|
||||
VMStateDatastoreID *string `json:"vmstatestorage,omitempty" url:"vmstatestorage,omitempty"`
|
||||
WatchdogDevice *CustomWatchdogDevice `json:"watchdog,omitempty" url:"watchdog,omitempty"`
|
||||
ACPI *CustomBool `json:"acpi,omitempty" url:"acpi,omitempty,int"`
|
||||
Agent *CustomAgent `json:"agent,omitempty" url:"agent,omitempty"`
|
||||
AllowReboot *CustomBool `json:"reboot,omitempty" url:"reboot,omitempty,int"`
|
||||
AudioDevices CustomAudioDevices `json:"audio,omitempty" url:"audio,omitempty"`
|
||||
Autostart *CustomBool `json:"autostart,omitempty" url:"autostart,omitempty,int"`
|
||||
BackupFile *string `json:"archive,omitempty" url:"archive,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
BIOS *string `json:"bios,omitempty" url:"bios,omitempty"`
|
||||
BootDisk *string `json:"bootdisk,omitempty" url:"bootdisk,omitempty"`
|
||||
BootOrder *string `json:"boot,omitempty" url:"boot,omitempty"`
|
||||
CDROM *string `json:"cdrom,omitempty" url:"cdrom,omitempty"`
|
||||
CloudInitConfig *CustomCloudInitConfig `json:"cloudinit,omitempty" url:"cloudinit,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty" url:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty" url:"cores,omitempty"`
|
||||
CPUEmulation *CustomCPUEmulation `json:"cpu,omitempty" url:"cpu,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty" url:"cpulimit,omitempty"`
|
||||
CPUSockets *int `json:"sockets,omitempty" url:"sockets,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty" url:"cpuunits,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty" url:"memory,omitempty"`
|
||||
Delete []string `json:"delete,omitempty" url:"delete,omitempty,comma"`
|
||||
DeletionProtection *CustomBool `json:"protection,omitempty" url:"force,omitempty,int"`
|
||||
Description *string `json:"description,omitempty" url:"description,omitempty"`
|
||||
EFIDisk *CustomEFIDisk `json:"efidisk0,omitempty" url:"efidisk0,omitempty"`
|
||||
FloatingMemory *int `json:"balloon,omitempty" url:"balloon,omitempty"`
|
||||
FloatingMemoryShares *int `json:"shares,omitempty" url:"shares,omitempty"`
|
||||
Freeze *CustomBool `json:"freeze,omitempty" url:"freeze,omitempty,int"`
|
||||
HookScript *string `json:"hookscript,omitempty" url:"hookscript,omitempty"`
|
||||
Hotplug CustomCommaSeparatedList `json:"hotplug,omitempty" url:"hotplug,omitempty,comma"`
|
||||
Hugepages *string `json:"hugepages,omitempty" url:"hugepages,omitempty"`
|
||||
IDEDevices CustomStorageDevices `json:"ide,omitempty" url:",omitempty"`
|
||||
KeyboardLayout *string `json:"keyboard,omitempty" url:"keyboard,omitempty"`
|
||||
KVMArguments *string `json:"args,omitempty" url:"args,omitempty,space"`
|
||||
KVMEnabled *CustomBool `json:"kvm,omitempty" url:"kvm,omitempty,int"`
|
||||
LocalTime *CustomBool `json:"localtime,omitempty" url:"localtime,omitempty,int"`
|
||||
Lock *string `json:"lock,omitempty" url:"lock,omitempty"`
|
||||
Machine *string `json:"machine,omitempty" url:"machine,omitempty"`
|
||||
MigrateDowntime *float64 `json:"migrate_downtime,omitempty" url:"migrate_downtime,omitempty"`
|
||||
MigrateSpeed *int `json:"migrate_speed,omitempty" url:"migrate_speed,omitempty"`
|
||||
Name *string `json:"name,omitempty" url:"name,omitempty"`
|
||||
NetworkDevices CustomNetworkDevices `json:"net,omitempty" url:"net,omitempty"`
|
||||
NUMADevices CustomNUMADevices `json:"numa_devices,omitempty" url:"numa,omitempty"`
|
||||
NUMAEnabled *CustomBool `json:"numa,omitempty" url:"numa,omitempty,int"`
|
||||
OSType *string `json:"ostype,omitempty" url:"ostype,omitempty"`
|
||||
Overwrite *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
|
||||
PCIDevices CustomPCIDevices `json:"hostpci,omitempty" url:"hostpci,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Revert *string `json:"revert,omitempty" url:"revert,omitempty"`
|
||||
SATADevices CustomStorageDevices `json:"sata,omitempty" url:"sata,omitempty"`
|
||||
SCSIDevices CustomStorageDevices `json:"scsi,omitempty" url:"scsi,omitempty"`
|
||||
SCSIHardware *string `json:"scsihw,omitempty" url:"scsihw,omitempty"`
|
||||
SerialDevices CustomSerialDevices `json:"serial,omitempty" url:"serial,omitempty"`
|
||||
SharedMemory *CustomSharedMemory `json:"ivshmem,omitempty" url:"ivshmem,omitempty"`
|
||||
SkipLock *CustomBool `json:"skiplock,omitempty" url:"skiplock,omitempty,int"`
|
||||
SMBIOS *CustomSMBIOS `json:"smbios1,omitempty" url:"smbios1,omitempty"`
|
||||
SpiceEnhancements *CustomSpiceEnhancements `json:"spice_enhancements,omitempty" url:"spice_enhancements,omitempty"`
|
||||
StartDate *string `json:"startdate,omitempty" url:"startdate,omitempty"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty" url:"onboot,omitempty,int"`
|
||||
StartupOrder *CustomStartupOrder `json:"startup,omitempty" url:"startup,omitempty"`
|
||||
TabletDeviceEnabled *CustomBool `json:"tablet,omitempty" url:"tablet,omitempty,int"`
|
||||
Tags *string `json:"tags,omitempty" url:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty" url:"template,omitempty,int"`
|
||||
TimeDriftFixEnabled *CustomBool `json:"tdf,omitempty" url:"tdf,omitempty,int"`
|
||||
USBDevices CustomUSBDevices `json:"usb,omitempty" url:"usb,omitempty"`
|
||||
VGADevice *CustomVGADevice `json:"vga,omitempty" url:"vga,omitempty"`
|
||||
VirtualCPUCount *int `json:"vcpus,omitempty" url:"vcpus,omitempty"`
|
||||
VirtualIODevices CustomStorageDevices `json:"virtio,omitempty" url:"virtio,omitempty"`
|
||||
VMGenerationID *string `json:"vmgenid,omitempty" url:"vmgenid,omitempty"`
|
||||
VMID *int `json:"vmid,omitempty" url:"vmid,omitempty"`
|
||||
VMStateDatastoreID *string `json:"vmstatestorage,omitempty" url:"vmstatestorage,omitempty"`
|
||||
WatchdogDevice *CustomWatchdogDevice `json:"watchdog,omitempty" url:"watchdog,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseBody contains the body from a QEMU get network interfaces response.
|
||||
@ -335,144 +335,144 @@ type VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseResultStatistics struct
|
||||
TXPackets int `json:"tx-packets"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMGetResponseBody contains the body from an virtual machine get response.
|
||||
// VirtualEnvironmentVMGetResponseBody contains the body from a virtual machine get response.
|
||||
type VirtualEnvironmentVMGetResponseBody struct {
|
||||
Data *VirtualEnvironmentVMGetResponseData `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMGetResponseData contains the data from an virtual machine get response.
|
||||
type VirtualEnvironmentVMGetResponseData struct {
|
||||
ACPI *CustomBool `json:"acpi,omitempty"`
|
||||
Agent *CustomAgent `json:"agent,omitempty"`
|
||||
AllowReboot *CustomBool `json:"reboot,omitempty"`
|
||||
AudioDevice *CustomAudioDevice `json:"audio0,omitempty"`
|
||||
Autostart *CustomBool `json:"autostart,omitempty"`
|
||||
BackupFile *string `json:"archive,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty"`
|
||||
BIOS *string `json:"bios,omitempty"`
|
||||
BootDisk *string `json:"bootdisk,omitempty"`
|
||||
BootOrder *string `json:"boot,omitempty"`
|
||||
CDROM *string `json:"cdrom,omitempty"`
|
||||
CloudInitDNSDomain *string `json:"searchdomain,omitempty"`
|
||||
CloudInitDNSServer *string `json:"nameserver,omitempty"`
|
||||
CloudInitFiles *CustomCloudInitFiles `json:"cicustom,omitempty"`
|
||||
CloudInitPassword *string `json:"cipassword,omitempty"`
|
||||
CloudInitSSHKeys *CustomCloudInitSSHKeys `json:"sshkeys,omitempty"`
|
||||
CloudInitType *string `json:"citype,omitempty"`
|
||||
CloudInitUsername *string `json:"ciuser,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty"`
|
||||
CPUEmulation *CustomCPUEmulation `json:"cpu,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty"`
|
||||
CPUSockets *int `json:"sockets,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty"`
|
||||
DeletionProtection *CustomBool `json:"protection,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
EFIDisk *CustomEFIDisk `json:"efidisk0,omitempty"`
|
||||
FloatingMemory *int `json:"balloon,omitempty"`
|
||||
FloatingMemoryShares *int `json:"shares,omitempty"`
|
||||
Freeze *CustomBool `json:"freeze,omitempty"`
|
||||
HookScript *string `json:"hookscript,omitempty"`
|
||||
Hotplug *CustomCommaSeparatedList `json:"hotplug,omitempty"`
|
||||
Hugepages *string `json:"hugepages,omitempty"`
|
||||
IDEDevice0 *CustomStorageDevice `json:"ide0,omitempty"`
|
||||
IDEDevice1 *CustomStorageDevice `json:"ide1,omitempty"`
|
||||
IDEDevice2 *CustomStorageDevice `json:"ide2,omitempty"`
|
||||
IDEDevice3 *CustomStorageDevice `json:"ide3,omitempty"`
|
||||
IPConfig0 *CustomCloudInitIPConfig `json:"ipconfig0,omitempty"`
|
||||
IPConfig1 *CustomCloudInitIPConfig `json:"ipconfig1,omitempty"`
|
||||
IPConfig2 *CustomCloudInitIPConfig `json:"ipconfig2,omitempty"`
|
||||
IPConfig3 *CustomCloudInitIPConfig `json:"ipconfig3,omitempty"`
|
||||
IPConfig4 *CustomCloudInitIPConfig `json:"ipconfig4,omitempty"`
|
||||
IPConfig5 *CustomCloudInitIPConfig `json:"ipconfig5,omitempty"`
|
||||
IPConfig6 *CustomCloudInitIPConfig `json:"ipconfig6,omitempty"`
|
||||
IPConfig7 *CustomCloudInitIPConfig `json:"ipconfig7,omitempty"`
|
||||
KeyboardLayout *string `json:"keyboard,omitempty"`
|
||||
KVMArguments *string `json:"args,omitempty"`
|
||||
KVMEnabled *CustomBool `json:"kvm,omitempty"`
|
||||
LocalTime *CustomBool `json:"localtime,omitempty"`
|
||||
Lock *string `json:"lock,omitempty"`
|
||||
Machine *string `json:"machine,omitempty"`
|
||||
MigrateDowntime *float64 `json:"migrate_downtime,omitempty"`
|
||||
MigrateSpeed *int `json:"migrate_speed,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
NetworkDevice0 *CustomNetworkDevice `json:"net0,omitempty"`
|
||||
NetworkDevice1 *CustomNetworkDevice `json:"net1,omitempty"`
|
||||
NetworkDevice2 *CustomNetworkDevice `json:"net2,omitempty"`
|
||||
NetworkDevice3 *CustomNetworkDevice `json:"net3,omitempty"`
|
||||
NetworkDevice4 *CustomNetworkDevice `json:"net4,omitempty"`
|
||||
NetworkDevice5 *CustomNetworkDevice `json:"net5,omitempty"`
|
||||
NetworkDevice6 *CustomNetworkDevice `json:"net6,omitempty"`
|
||||
NetworkDevice7 *CustomNetworkDevice `json:"net7,omitempty"`
|
||||
NUMADevices *CustomNUMADevices `json:"numa_devices,omitempty"`
|
||||
NUMAEnabled *CustomBool `json:"numa,omitempty"`
|
||||
OSType *string `json:"ostype,omitempty"`
|
||||
Overwrite *CustomBool `json:"force,omitempty"`
|
||||
PCIDevice0 *CustomPCIDevice `json:"hostpci0,omitempty"`
|
||||
PCIDevice1 *CustomPCIDevice `json:"hostpci1,omitempty"`
|
||||
PCIDevice2 *CustomPCIDevice `json:"hostpci2,omitempty"`
|
||||
PCIDevice3 *CustomPCIDevice `json:"hostpci3,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Revert *string `json:"revert,omitempty"`
|
||||
SATADevice0 *CustomStorageDevice `json:"sata0,omitempty"`
|
||||
SATADevice1 *CustomStorageDevice `json:"sata1,omitempty"`
|
||||
SATADevice2 *CustomStorageDevice `json:"sata2,omitempty"`
|
||||
SATADevice3 *CustomStorageDevice `json:"sata3,omitempty"`
|
||||
SATADevice4 *CustomStorageDevice `json:"sata4,omitempty"`
|
||||
SATADevice5 *CustomStorageDevice `json:"sata5,omitempty"`
|
||||
SCSIDevice0 *CustomStorageDevice `json:"scsi0,omitempty"`
|
||||
SCSIDevice1 *CustomStorageDevice `json:"scsi1,omitempty"`
|
||||
SCSIDevice2 *CustomStorageDevice `json:"scsi2,omitempty"`
|
||||
SCSIDevice3 *CustomStorageDevice `json:"scsi3,omitempty"`
|
||||
SCSIDevice4 *CustomStorageDevice `json:"scsi4,omitempty"`
|
||||
SCSIDevice5 *CustomStorageDevice `json:"scsi5,omitempty"`
|
||||
SCSIDevice6 *CustomStorageDevice `json:"scsi6,omitempty"`
|
||||
SCSIDevice7 *CustomStorageDevice `json:"scsi7,omitempty"`
|
||||
SCSIDevice8 *CustomStorageDevice `json:"scsi8,omitempty"`
|
||||
SCSIDevice9 *CustomStorageDevice `json:"scsi9,omitempty"`
|
||||
SCSIDevice10 *CustomStorageDevice `json:"scsi10,omitempty"`
|
||||
SCSIDevice11 *CustomStorageDevice `json:"scsi11,omitempty"`
|
||||
SCSIDevice12 *CustomStorageDevice `json:"scsi12,omitempty"`
|
||||
SCSIDevice13 *CustomStorageDevice `json:"scsi13,omitempty"`
|
||||
SCSIHardware *string `json:"scsihw,omitempty"`
|
||||
SerialDevice0 *string `json:"serial0,omitempty"`
|
||||
SerialDevice1 *string `json:"serial1,omitempty"`
|
||||
SerialDevice2 *string `json:"serial2,omitempty"`
|
||||
SerialDevice3 *string `json:"serial3,omitempty"`
|
||||
SharedMemory *CustomSharedMemory `json:"ivshmem,omitempty"`
|
||||
SkipLock *CustomBool `json:"skiplock,omitempty"`
|
||||
SMBIOS *CustomSMBIOS `json:"smbios1,omitempty"`
|
||||
SpiceEnhancements *CustomSpiceEnhancements `json:"spice_enhancements,omitempty"`
|
||||
StartDate *string `json:"startdate,omitempty"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty"`
|
||||
StartupOrder *CustomStartupOrder `json:"startup,omitempty"`
|
||||
TabletDeviceEnabled *CustomBool `json:"tablet,omitempty"`
|
||||
Tags *string `json:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty"`
|
||||
TimeDriftFixEnabled *CustomBool `json:"tdf,omitempty"`
|
||||
USBDevices *CustomUSBDevices `json:"usb,omitempty"`
|
||||
VGADevice *CustomVGADevice `json:"vga,omitempty"`
|
||||
VirtualCPUCount *int `json:"vcpus,omitempty"`
|
||||
VirtualIODevice0 *CustomStorageDevice `json:"virtio0,omitempty"`
|
||||
VirtualIODevice1 *CustomStorageDevice `json:"virtio1,omitempty"`
|
||||
VirtualIODevice2 *CustomStorageDevice `json:"virtio2,omitempty"`
|
||||
VirtualIODevice3 *CustomStorageDevice `json:"virtio3,omitempty"`
|
||||
VirtualIODevice4 *CustomStorageDevice `json:"virtio4,omitempty"`
|
||||
VirtualIODevice5 *CustomStorageDevice `json:"virtio5,omitempty"`
|
||||
VirtualIODevice6 *CustomStorageDevice `json:"virtio6,omitempty"`
|
||||
VirtualIODevice7 *CustomStorageDevice `json:"virtio7,omitempty"`
|
||||
VirtualIODevice8 *CustomStorageDevice `json:"virtio8,omitempty"`
|
||||
VirtualIODevice9 *CustomStorageDevice `json:"virtio9,omitempty"`
|
||||
VirtualIODevice10 *CustomStorageDevice `json:"virtio10,omitempty"`
|
||||
VirtualIODevice11 *CustomStorageDevice `json:"virtio11,omitempty"`
|
||||
VirtualIODevice12 *CustomStorageDevice `json:"virtio12,omitempty"`
|
||||
VirtualIODevice13 *CustomStorageDevice `json:"virtio13,omitempty"`
|
||||
VirtualIODevice14 *CustomStorageDevice `json:"virtio14,omitempty"`
|
||||
VirtualIODevice15 *CustomStorageDevice `json:"virtio15,omitempty"`
|
||||
VMGenerationID *string `json:"vmgenid,omitempty"`
|
||||
VMStateDatastoreID *string `json:"vmstatestorage,omitempty"`
|
||||
WatchdogDevice *CustomWatchdogDevice `json:"watchdog,omitempty"`
|
||||
ACPI *CustomBool `json:"acpi,omitempty"`
|
||||
Agent *CustomAgent `json:"agent,omitempty"`
|
||||
AllowReboot *CustomBool `json:"reboot,omitempty"`
|
||||
AudioDevice *CustomAudioDevice `json:"audio0,omitempty"`
|
||||
Autostart *CustomBool `json:"autostart,omitempty"`
|
||||
BackupFile *string `json:"archive,omitempty"`
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty"`
|
||||
BIOS *string `json:"bios,omitempty"`
|
||||
BootDisk *string `json:"bootdisk,omitempty"`
|
||||
BootOrder *string `json:"boot,omitempty"`
|
||||
CDROM *string `json:"cdrom,omitempty"`
|
||||
CloudInitDNSDomain *string `json:"searchdomain,omitempty"`
|
||||
CloudInitDNSServer *string `json:"nameserver,omitempty"`
|
||||
CloudInitFiles *CustomCloudInitFiles `json:"cicustom,omitempty"`
|
||||
CloudInitPassword *string `json:"cipassword,omitempty"`
|
||||
CloudInitSSHKeys *CustomCloudInitSSHKeys `json:"sshkeys,omitempty"`
|
||||
CloudInitType *string `json:"citype,omitempty"`
|
||||
CloudInitUsername *string `json:"ciuser,omitempty"`
|
||||
CPUArchitecture *string `json:"arch,omitempty"`
|
||||
CPUCores *int `json:"cores,omitempty"`
|
||||
CPUEmulation *CustomCPUEmulation `json:"cpu,omitempty"`
|
||||
CPULimit *int `json:"cpulimit,omitempty"`
|
||||
CPUSockets *int `json:"sockets,omitempty"`
|
||||
CPUUnits *int `json:"cpuunits,omitempty"`
|
||||
DedicatedMemory *int `json:"memory,omitempty"`
|
||||
DeletionProtection *CustomBool `json:"protection,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
EFIDisk *CustomEFIDisk `json:"efidisk0,omitempty"`
|
||||
FloatingMemory *int `json:"balloon,omitempty"`
|
||||
FloatingMemoryShares *int `json:"shares,omitempty"`
|
||||
Freeze *CustomBool `json:"freeze,omitempty"`
|
||||
HookScript *string `json:"hookscript,omitempty"`
|
||||
Hotplug *CustomCommaSeparatedList `json:"hotplug,omitempty"`
|
||||
Hugepages *string `json:"hugepages,omitempty"`
|
||||
IDEDevice0 *CustomStorageDevice `json:"ide0,omitempty"`
|
||||
IDEDevice1 *CustomStorageDevice `json:"ide1,omitempty"`
|
||||
IDEDevice2 *CustomStorageDevice `json:"ide2,omitempty"`
|
||||
IDEDevice3 *CustomStorageDevice `json:"ide3,omitempty"`
|
||||
IPConfig0 *CustomCloudInitIPConfig `json:"ipconfig0,omitempty"`
|
||||
IPConfig1 *CustomCloudInitIPConfig `json:"ipconfig1,omitempty"`
|
||||
IPConfig2 *CustomCloudInitIPConfig `json:"ipconfig2,omitempty"`
|
||||
IPConfig3 *CustomCloudInitIPConfig `json:"ipconfig3,omitempty"`
|
||||
IPConfig4 *CustomCloudInitIPConfig `json:"ipconfig4,omitempty"`
|
||||
IPConfig5 *CustomCloudInitIPConfig `json:"ipconfig5,omitempty"`
|
||||
IPConfig6 *CustomCloudInitIPConfig `json:"ipconfig6,omitempty"`
|
||||
IPConfig7 *CustomCloudInitIPConfig `json:"ipconfig7,omitempty"`
|
||||
KeyboardLayout *string `json:"keyboard,omitempty"`
|
||||
KVMArguments *string `json:"args,omitempty"`
|
||||
KVMEnabled *CustomBool `json:"kvm,omitempty"`
|
||||
LocalTime *CustomBool `json:"localtime,omitempty"`
|
||||
Lock *string `json:"lock,omitempty"`
|
||||
Machine *string `json:"machine,omitempty"`
|
||||
MigrateDowntime *float64 `json:"migrate_downtime,omitempty"`
|
||||
MigrateSpeed *int `json:"migrate_speed,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
NetworkDevice0 *CustomNetworkDevice `json:"net0,omitempty"`
|
||||
NetworkDevice1 *CustomNetworkDevice `json:"net1,omitempty"`
|
||||
NetworkDevice2 *CustomNetworkDevice `json:"net2,omitempty"`
|
||||
NetworkDevice3 *CustomNetworkDevice `json:"net3,omitempty"`
|
||||
NetworkDevice4 *CustomNetworkDevice `json:"net4,omitempty"`
|
||||
NetworkDevice5 *CustomNetworkDevice `json:"net5,omitempty"`
|
||||
NetworkDevice6 *CustomNetworkDevice `json:"net6,omitempty"`
|
||||
NetworkDevice7 *CustomNetworkDevice `json:"net7,omitempty"`
|
||||
NUMADevices *CustomNUMADevices `json:"numa_devices,omitempty"`
|
||||
NUMAEnabled *CustomBool `json:"numa,omitempty"`
|
||||
OSType *string `json:"ostype,omitempty"`
|
||||
Overwrite *CustomBool `json:"force,omitempty"`
|
||||
PCIDevice0 *CustomPCIDevice `json:"hostpci0,omitempty"`
|
||||
PCIDevice1 *CustomPCIDevice `json:"hostpci1,omitempty"`
|
||||
PCIDevice2 *CustomPCIDevice `json:"hostpci2,omitempty"`
|
||||
PCIDevice3 *CustomPCIDevice `json:"hostpci3,omitempty"`
|
||||
PoolID *string `json:"pool,omitempty" url:"pool,omitempty"`
|
||||
Revert *string `json:"revert,omitempty"`
|
||||
SATADevice0 *CustomStorageDevice `json:"sata0,omitempty"`
|
||||
SATADevice1 *CustomStorageDevice `json:"sata1,omitempty"`
|
||||
SATADevice2 *CustomStorageDevice `json:"sata2,omitempty"`
|
||||
SATADevice3 *CustomStorageDevice `json:"sata3,omitempty"`
|
||||
SATADevice4 *CustomStorageDevice `json:"sata4,omitempty"`
|
||||
SATADevice5 *CustomStorageDevice `json:"sata5,omitempty"`
|
||||
SCSIDevice0 *CustomStorageDevice `json:"scsi0,omitempty"`
|
||||
SCSIDevice1 *CustomStorageDevice `json:"scsi1,omitempty"`
|
||||
SCSIDevice2 *CustomStorageDevice `json:"scsi2,omitempty"`
|
||||
SCSIDevice3 *CustomStorageDevice `json:"scsi3,omitempty"`
|
||||
SCSIDevice4 *CustomStorageDevice `json:"scsi4,omitempty"`
|
||||
SCSIDevice5 *CustomStorageDevice `json:"scsi5,omitempty"`
|
||||
SCSIDevice6 *CustomStorageDevice `json:"scsi6,omitempty"`
|
||||
SCSIDevice7 *CustomStorageDevice `json:"scsi7,omitempty"`
|
||||
SCSIDevice8 *CustomStorageDevice `json:"scsi8,omitempty"`
|
||||
SCSIDevice9 *CustomStorageDevice `json:"scsi9,omitempty"`
|
||||
SCSIDevice10 *CustomStorageDevice `json:"scsi10,omitempty"`
|
||||
SCSIDevice11 *CustomStorageDevice `json:"scsi11,omitempty"`
|
||||
SCSIDevice12 *CustomStorageDevice `json:"scsi12,omitempty"`
|
||||
SCSIDevice13 *CustomStorageDevice `json:"scsi13,omitempty"`
|
||||
SCSIHardware *string `json:"scsihw,omitempty"`
|
||||
SerialDevice0 *string `json:"serial0,omitempty"`
|
||||
SerialDevice1 *string `json:"serial1,omitempty"`
|
||||
SerialDevice2 *string `json:"serial2,omitempty"`
|
||||
SerialDevice3 *string `json:"serial3,omitempty"`
|
||||
SharedMemory *CustomSharedMemory `json:"ivshmem,omitempty"`
|
||||
SkipLock *CustomBool `json:"skiplock,omitempty"`
|
||||
SMBIOS *CustomSMBIOS `json:"smbios1,omitempty"`
|
||||
SpiceEnhancements *CustomSpiceEnhancements `json:"spice_enhancements,omitempty"`
|
||||
StartDate *string `json:"startdate,omitempty"`
|
||||
StartOnBoot *CustomBool `json:"onboot,omitempty"`
|
||||
StartupOrder *CustomStartupOrder `json:"startup,omitempty"`
|
||||
TabletDeviceEnabled *CustomBool `json:"tablet,omitempty"`
|
||||
Tags *string `json:"tags,omitempty"`
|
||||
Template *CustomBool `json:"template,omitempty"`
|
||||
TimeDriftFixEnabled *CustomBool `json:"tdf,omitempty"`
|
||||
USBDevices *CustomUSBDevices `json:"usb,omitempty"`
|
||||
VGADevice *CustomVGADevice `json:"vga,omitempty"`
|
||||
VirtualCPUCount *int `json:"vcpus,omitempty"`
|
||||
VirtualIODevice0 *CustomStorageDevice `json:"virtio0,omitempty"`
|
||||
VirtualIODevice1 *CustomStorageDevice `json:"virtio1,omitempty"`
|
||||
VirtualIODevice2 *CustomStorageDevice `json:"virtio2,omitempty"`
|
||||
VirtualIODevice3 *CustomStorageDevice `json:"virtio3,omitempty"`
|
||||
VirtualIODevice4 *CustomStorageDevice `json:"virtio4,omitempty"`
|
||||
VirtualIODevice5 *CustomStorageDevice `json:"virtio5,omitempty"`
|
||||
VirtualIODevice6 *CustomStorageDevice `json:"virtio6,omitempty"`
|
||||
VirtualIODevice7 *CustomStorageDevice `json:"virtio7,omitempty"`
|
||||
VirtualIODevice8 *CustomStorageDevice `json:"virtio8,omitempty"`
|
||||
VirtualIODevice9 *CustomStorageDevice `json:"virtio9,omitempty"`
|
||||
VirtualIODevice10 *CustomStorageDevice `json:"virtio10,omitempty"`
|
||||
VirtualIODevice11 *CustomStorageDevice `json:"virtio11,omitempty"`
|
||||
VirtualIODevice12 *CustomStorageDevice `json:"virtio12,omitempty"`
|
||||
VirtualIODevice13 *CustomStorageDevice `json:"virtio13,omitempty"`
|
||||
VirtualIODevice14 *CustomStorageDevice `json:"virtio14,omitempty"`
|
||||
VirtualIODevice15 *CustomStorageDevice `json:"virtio15,omitempty"`
|
||||
VMGenerationID *string `json:"vmgenid,omitempty"`
|
||||
VMStateDatastoreID *string `json:"vmstatestorage,omitempty"`
|
||||
WatchdogDevice *CustomWatchdogDevice `json:"watchdog,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMGetStatusResponseBody contains the body from a VM get status response.
|
||||
@ -509,9 +509,9 @@ type VirtualEnvironmentVMListResponseData struct {
|
||||
|
||||
// VirtualEnvironmentVMMigrateRequestBody contains the body for a VM migration request.
|
||||
type VirtualEnvironmentVMMigrateRequestBody struct {
|
||||
OnlineMigration *CustomBool `json:"online,omitempty" url:"online,omitempty"`
|
||||
TargetNode string `json:"target" url:"target"`
|
||||
TargetStorage *string `json:"targetstorage,omitempty" url:"targetstorage,omitempty"`
|
||||
OnlineMigration *CustomBool `json:"online,omitempty" url:"online,omitempty"`
|
||||
TargetNode string `json:"target" url:"target"`
|
||||
TargetStorage *string `json:"targetstorage,omitempty" url:"targetstorage,omitempty"`
|
||||
WithLocalDisks *CustomBool `json:"with-local-disks,omitempty" url:"with-local-disks,omitempty,int"`
|
||||
}
|
||||
|
||||
@ -523,11 +523,11 @@ type VirtualEnvironmentVMMigrateResponseBody struct {
|
||||
// VirtualEnvironmentVMMoveDiskRequestBody contains the body for a VM move disk request.
|
||||
type VirtualEnvironmentVMMoveDiskRequestBody struct {
|
||||
BandwidthLimit *int `json:"bwlimit,omitempty" url:"bwlimit,omitempty"`
|
||||
DeleteOriginalDisk *CustomBool `json:"delete,omitempty" url:"delete,omitempty,int"`
|
||||
Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
|
||||
Disk string `json:"disk" url:"disk"`
|
||||
TargetStorage string `json:"storage" url:"storage"`
|
||||
TargetStorageFormat *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
DeleteOriginalDisk *CustomBool `json:"delete,omitempty" url:"delete,omitempty,int"`
|
||||
Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
|
||||
Disk string `json:"disk" url:"disk"`
|
||||
TargetStorage string `json:"storage" url:"storage"`
|
||||
TargetStorageFormat *string `json:"format,omitempty" url:"format,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMMoveDiskResponseBody contains the body from a VM move disk response.
|
||||
@ -547,18 +547,18 @@ type VirtualEnvironmentVMRebootResponseBody struct {
|
||||
|
||||
// VirtualEnvironmentVMResizeDiskRequestBody contains the body for a VM resize disk request.
|
||||
type VirtualEnvironmentVMResizeDiskRequestBody struct {
|
||||
Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
|
||||
Disk string `json:"disk" url:"disk"`
|
||||
Size string `json:"size" url:"size"`
|
||||
Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
|
||||
Disk string `json:"disk" url:"disk"`
|
||||
Size string `json:"size" url:"size"`
|
||||
SkipLock *CustomBool `json:"skiplock,omitempty" url:"skiplock,omitempty,int"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMShutdownRequestBody contains the body for a VM shutdown request.
|
||||
type VirtualEnvironmentVMShutdownRequestBody struct {
|
||||
ForceStop *CustomBool `json:"forceStop,omitempty" url:"forceStop,omitempty,int"`
|
||||
ForceStop *CustomBool `json:"forceStop,omitempty" url:"forceStop,omitempty,int"`
|
||||
KeepActive *CustomBool `json:"keepActive,omitempty" url:"keepActive,omitempty,int"`
|
||||
SkipLock *CustomBool `json:"skipLock,omitempty" url:"skipLock,omitempty,int"`
|
||||
Timeout *int `json:"timeout,omitempty" url:"timeout,omitempty"`
|
||||
SkipLock *CustomBool `json:"skipLock,omitempty" url:"skipLock,omitempty,int"`
|
||||
Timeout *int `json:"timeout,omitempty" url:"timeout,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualEnvironmentVMShutdownResponseBody contains the body from a VM shutdown response.
|
||||
@ -705,7 +705,10 @@ func (r CustomCloudInitConfig) EncodeValues(_ string, v *url.Values) error {
|
||||
}
|
||||
|
||||
if r.SSHKeys != nil {
|
||||
v.Add("sshkeys", strings.ReplaceAll(url.QueryEscape(strings.Join(*r.SSHKeys, "\n")), "+", "%20"))
|
||||
v.Add(
|
||||
"sshkeys",
|
||||
strings.ReplaceAll(url.QueryEscape(strings.Join(*r.SSHKeys, "\n")), "+", "%20"),
|
||||
)
|
||||
}
|
||||
|
||||
if r.Type != nil {
|
||||
@ -1232,7 +1235,6 @@ func (r *CustomAgent) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1267,7 +1269,6 @@ func (r *CustomAudioDevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1295,7 +1296,6 @@ func (r *CustomCloudInitFiles) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1327,7 +1327,6 @@ func (r *CustomCloudInitIPConfig) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1359,7 +1358,6 @@ func (r *CustomCloudInitSSHKeys) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1384,7 +1382,6 @@ func (r *CustomCPUEmulation) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1429,7 +1426,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1455,7 +1451,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
r.Model = v[1]
|
||||
case "queues":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1463,7 +1458,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
r.Queues = &iv
|
||||
case "rate":
|
||||
fv, err := strconv.ParseFloat(v[1], 64)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1471,7 +1465,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
|
||||
case "mtu":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1479,7 +1472,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
|
||||
case "tag":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1491,7 +1483,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
||||
|
||||
for i, trunk := range trunks {
|
||||
iv, err := strconv.Atoi(trunk)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1515,7 +1506,6 @@ func (r *CustomPCIDevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1555,7 +1545,6 @@ func (r *CustomSharedMemory) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1587,7 +1576,6 @@ func (r *CustomSMBIOS) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1628,7 +1616,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1656,7 +1643,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
||||
r.FileVolume = v[1]
|
||||
case "mbps_rd":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1664,7 +1650,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
||||
r.MaxReadSpeedMbps = &iv
|
||||
case "mbps_rd_max":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1672,7 +1657,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
||||
r.BurstableReadSpeedMbps = &iv
|
||||
case "mbps_wr":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1680,7 +1664,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
||||
r.MaxWriteSpeedMbps = &iv
|
||||
case "mbps_wr_max":
|
||||
iv, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1714,7 +1697,6 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1734,7 +1716,6 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error {
|
||||
switch v[0] {
|
||||
case "memory":
|
||||
m, err := strconv.Atoi(v[1])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1754,7 +1735,6 @@ func (r *CustomWatchdogDevice) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
|
||||
err := json.Unmarshal(b, &s)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) {
|
||||
func strPtr(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
func boolPtr(s bool) *CustomBool {
|
||||
customBool := CustomBool(s)
|
||||
return &customBool
|
||||
|
@ -42,7 +42,11 @@ func dataSourceVirtualEnvironmentClusterAlias() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentAliasRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentAliasRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -29,7 +29,11 @@ func dataSourceVirtualEnvironmentClusterAliases() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentClusterAliasesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentClusterAliasesRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"sort"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -97,7 +96,11 @@ func dataSourceVirtualEnvironmentDatastores() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentDatastoresRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentDatastoresRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -43,7 +42,11 @@ func dataSourceVirtualEnvironmentDNS() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentDNSRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentDNSRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -69,7 +69,11 @@ func dataSourceVirtualEnvironmentGroup() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentGroupRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -36,7 +36,11 @@ func dataSourceVirtualEnvironmentGroups() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentGroupsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentGroupsRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -77,7 +76,11 @@ func dataSourceVirtualEnvironmentHosts() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentHostsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentHostsRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"math"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -87,7 +86,11 @@ func dataSourceVirtualEnvironmentNodes() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentNodesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentNodesRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -74,7 +74,11 @@ func dataSourceVirtualEnvironmentPool() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentPoolRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -29,7 +29,11 @@ func dataSourceVirtualEnvironmentPools() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentPoolsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentPoolsRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -35,7 +35,11 @@ func dataSourceVirtualEnvironmentRole() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentRoleRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -46,7 +46,11 @@ func dataSourceVirtualEnvironmentRoles() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentRolesRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentRolesRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -49,7 +48,12 @@ func dataSourceVirtualEnvironmentTime() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
//nolint:dupl
|
||||
func dataSourceVirtualEnvironmentTimeRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -78,7 +82,10 @@ func dataSourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.Resourc
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeUTCTime, time.Time(nodeTime.UTCTime).Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkDataSourceVirtualEnvironmentTimeUTCTime,
|
||||
time.Time(nodeTime.UTCTime).Format(time.RFC3339),
|
||||
)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
return diags
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -107,7 +106,11 @@ func dataSourceVirtualEnvironmentUser() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentUserRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -176,7 +179,10 @@ func dataSourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.Resourc
|
||||
if v.ExpirationDate != nil {
|
||||
t := time.Time(*v.ExpirationDate)
|
||||
if t.Unix() > 0 {
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentUserExpirationDate, t.UTC().Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkDataSourceVirtualEnvironmentUserExpirationDate,
|
||||
t.UTC().Format(time.RFC3339),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentUserExpirationDate, time.Unix(0, 0).UTC().Format(time.RFC3339))
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
@ -90,7 +89,11 @@ func dataSourceVirtualEnvironmentUsers() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentUsersRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentUsersRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -50,7 +50,11 @@ func dataSourceVirtualEnvironmentVersion() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func dataSourceVirtualEnvironmentVersionRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func dataSourceVirtualEnvironmentVersionRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -90,15 +90,18 @@ func Provider() *schema.Provider {
|
||||
|
||||
if value == "" {
|
||||
return []string{}, []error{
|
||||
errors.New("you must specify an endpoint for the Proxmox Virtual Environment API (valid: https://host:port)"),
|
||||
errors.New(
|
||||
"you must specify an endpoint for the Proxmox Virtual Environment API (valid: https://host:port)",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
_, err := url.ParseRequestURI(value)
|
||||
|
||||
if err != nil {
|
||||
return []string{}, []error{
|
||||
errors.New("you must specify a valid endpoint for the Proxmox Virtual Environment API (valid: https://host:port)"),
|
||||
errors.New(
|
||||
"you must specify a valid endpoint for the Proxmox Virtual Environment API (valid: https://host:port)",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +146,9 @@ func Provider() *schema.Provider {
|
||||
|
||||
if value == "" {
|
||||
return []string{}, []error{
|
||||
errors.New("you must specify a password for the Proxmox Virtual Environment API"),
|
||||
errors.New(
|
||||
"you must specify a password for the Proxmox Virtual Environment API",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +168,9 @@ func Provider() *schema.Provider {
|
||||
|
||||
if value == "" {
|
||||
return []string{}, []error{
|
||||
errors.New("you must specify a username for the Proxmox Virtual Environment API (valid: username@realm)"),
|
||||
errors.New(
|
||||
"you must specify a username for the Proxmox Virtual Environment API (valid: username@realm)",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,7 +216,9 @@ func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{},
|
||||
|
||||
func (c *providerConfiguration) GetVEClient() (*proxmox.VirtualEnvironmentClient, error) {
|
||||
if c.veClient == nil {
|
||||
return nil, errors.New("you must specify the virtual environment details in the provider configuration")
|
||||
return nil, errors.New(
|
||||
"you must specify the virtual environment details in the provider configuration",
|
||||
)
|
||||
}
|
||||
|
||||
return c.veClient, nil
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -122,7 +122,11 @@ func resourceVirtualEnvironmentCertificate() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentCertificateCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentCertificateCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
diags := resourceVirtualEnvironmentCertificateUpdate(ctx, d, m)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
@ -135,7 +139,9 @@ func resourceVirtualEnvironmentCertificateCreate(ctx context.Context, d *schema.
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentCertificateGetUpdateBody(d *schema.ResourceData) (*proxmox.VirtualEnvironmentCertificateUpdateRequestBody, error) {
|
||||
func resourceVirtualEnvironmentCertificateGetUpdateBody(
|
||||
d *schema.ResourceData,
|
||||
) *proxmox.VirtualEnvironmentCertificateUpdateRequestBody {
|
||||
certificate := d.Get(mkResourceVirtualEnvironmentCertificateCertificate).(string)
|
||||
certificateChain := d.Get(mkResourceVirtualEnvironmentCertificateCertificateChain).(string)
|
||||
overwrite := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentCertificateOverwrite).(bool))
|
||||
@ -162,10 +168,14 @@ func resourceVirtualEnvironmentCertificateGetUpdateBody(d *schema.ResourceData)
|
||||
Restart: &restart,
|
||||
}
|
||||
|
||||
return body, nil
|
||||
return body
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentCertificateRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -206,7 +216,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
||||
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateCertificate, newCertificate)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateCertificateChain, newCertificateChain)
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentCertificateCertificateChain,
|
||||
newCertificateChain,
|
||||
)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
}
|
||||
|
||||
@ -215,7 +228,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
||||
|
||||
if c.NotAfter != nil {
|
||||
t := time.Time(*c.NotAfter)
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateExpirationDate, t.UTC().Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentCertificateExpirationDate,
|
||||
t.UTC().Format(time.RFC3339),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateExpirationDate, "")
|
||||
}
|
||||
@ -257,7 +273,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
||||
|
||||
if c.NotBefore != nil {
|
||||
t := time.Time(*c.NotBefore)
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateStartDate, t.UTC().Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentCertificateStartDate,
|
||||
t.UTC().Format(time.RFC3339),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentCertificateStartDate, "")
|
||||
}
|
||||
@ -286,7 +305,11 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentCertificateUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentCertificateUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -295,10 +318,7 @@ func resourceVirtualEnvironmentCertificateUpdate(ctx context.Context, d *schema.
|
||||
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
||||
|
||||
body, err := resourceVirtualEnvironmentCertificateGetUpdateBody(d)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
body := resourceVirtualEnvironmentCertificateGetUpdateBody(d)
|
||||
|
||||
err = veClient.UpdateCertificate(ctx, nodeName, body)
|
||||
if err != nil {
|
||||
@ -308,7 +328,11 @@ func resourceVirtualEnvironmentCertificateUpdate(ctx context.Context, d *schema.
|
||||
return resourceVirtualEnvironmentCertificateRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentCertificateDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentCertificateDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -318,9 +342,13 @@ func resourceVirtualEnvironmentCertificateDelete(ctx context.Context, d *schema.
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
||||
restart := proxmox.CustomBool(true)
|
||||
|
||||
err = veClient.DeleteCertificate(ctx, nodeName, &proxmox.VirtualEnvironmentCertificateDeleteRequestBody{
|
||||
Restart: &restart,
|
||||
})
|
||||
err = veClient.DeleteCertificate(
|
||||
ctx,
|
||||
nodeName,
|
||||
&proxmox.VirtualEnvironmentCertificateDeleteRequestBody{
|
||||
Restart: &restart,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -51,7 +51,11 @@ func resourceVirtualEnvironmentClusterAlias() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterAliasCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterAliasCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -78,7 +82,11 @@ func resourceVirtualEnvironmentClusterAliasCreate(ctx context.Context, d *schema
|
||||
return resourceVirtualEnvironmentClusterAliasRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterAliasRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterAliasRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -87,7 +95,6 @@ func resourceVirtualEnvironmentClusterAliasRead(ctx context.Context, d *schema.R
|
||||
|
||||
name := d.Id()
|
||||
alias, err := veClient.GetAlias(ctx, name)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -112,7 +119,11 @@ func resourceVirtualEnvironmentClusterAliasRead(ctx context.Context, d *schema.R
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterAliasUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterAliasUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -140,7 +151,11 @@ func resourceVirtualEnvironmentClusterAliasUpdate(ctx context.Context, d *schema
|
||||
return resourceVirtualEnvironmentClusterAliasRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterAliasDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterAliasDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -83,7 +83,11 @@ func resourceVirtualEnvironmentClusterIPSet() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterIPSetCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterIPSetCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -136,7 +140,11 @@ func resourceVirtualEnvironmentClusterIPSetCreate(ctx context.Context, d *schema
|
||||
return resourceVirtualEnvironmentClusterIPSetRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterIPSetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterIPSetRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -162,7 +170,6 @@ func resourceVirtualEnvironmentClusterIPSetRead(ctx context.Context, d *schema.R
|
||||
}
|
||||
|
||||
IPSet, err := veClient.GetListIPSetContent(ctx, name)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -189,7 +196,11 @@ func resourceVirtualEnvironmentClusterIPSetRead(ctx context.Context, d *schema.R
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterIPSetUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterIPSetUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -216,7 +227,11 @@ func resourceVirtualEnvironmentClusterIPSetUpdate(ctx context.Context, d *schema
|
||||
return resourceVirtualEnvironmentClusterIPSetRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentClusterIPSetDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentClusterIPSetDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
|
@ -55,5 +55,4 @@ func TestResourceVirtualEnvironmentIPSetSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
|
||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: schema.TypeBool,
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
|
||||
@ -215,11 +214,13 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(1, 128)),
|
||||
},
|
||||
mkResourceVirtualEnvironmentContainerCPUUnits: {
|
||||
Type: schema.TypeInt,
|
||||
Description: "The CPU units",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerCPUUnits,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 500000)),
|
||||
Type: schema.TypeInt,
|
||||
Description: "The CPU units",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerCPUUnits,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(
|
||||
validation.IntBetween(0, 500000),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -402,7 +403,8 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
||||
Sensitive: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerInitializationUserAccountPassword,
|
||||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
||||
return len(old) > 0 && strings.ReplaceAll(old, "*", "") == ""
|
||||
return len(old) > 0 &&
|
||||
strings.ReplaceAll(old, "*", "") == ""
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -430,18 +432,22 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
mkResourceVirtualEnvironmentContainerMemoryDedicated: {
|
||||
Type: schema.TypeInt,
|
||||
Description: "The dedicated memory in megabytes",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerMemoryDedicated,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(16, 268435456)),
|
||||
Type: schema.TypeInt,
|
||||
Description: "The dedicated memory in megabytes",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerMemoryDedicated,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(
|
||||
validation.IntBetween(16, 268435456),
|
||||
),
|
||||
},
|
||||
mkResourceVirtualEnvironmentContainerMemorySwap: {
|
||||
Type: schema.TypeInt,
|
||||
Description: "The swap size in megabytes",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerMemorySwap,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 268435456)),
|
||||
Type: schema.TypeInt,
|
||||
Description: "The swap size in megabytes",
|
||||
Optional: true,
|
||||
Default: dvResourceVirtualEnvironmentContainerMemorySwap,
|
||||
ValidateDiagFunc: validation.ToDiagFunc(
|
||||
validation.IntBetween(0, 268435456),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -578,7 +584,11 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
clone := d.Get(mkResourceVirtualEnvironmentContainerClone).([]interface{})
|
||||
|
||||
if len(clone) > 0 {
|
||||
@ -588,7 +598,11 @@ func resourceVirtualEnvironmentContainerCreate(ctx context.Context, d *schema.Re
|
||||
return resourceVirtualEnvironmentContainerCreateCustom(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerCreateClone(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -675,7 +689,9 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
if len(console) > 0 {
|
||||
consoleBlock := console[0].(map[string]interface{})
|
||||
|
||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
||||
consoleEnabled := proxmox.CustomBool(
|
||||
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||
)
|
||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
||||
|
||||
@ -731,8 +747,14 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
if len(ipv4) > 0 {
|
||||
ipv4Block := ipv4[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
||||
initializationIPConfigIPv4Address = append(
|
||||
initializationIPConfigIPv4Address,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv4Gateway = append(
|
||||
initializationIPConfigIPv4Gateway,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||
@ -743,8 +765,14 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
if len(ipv6) > 0 {
|
||||
ipv6Block := ipv6[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
||||
initializationIPConfigIPv6Address = append(
|
||||
initializationIPConfigIPv6Address,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv6Gateway = append(
|
||||
initializationIPConfigIPv6Gateway,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||
@ -758,7 +786,10 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
||||
|
||||
if len(keys) > 0 {
|
||||
initializationUserAccountKeys := make(proxmox.VirtualEnvironmentContainerCustomSSHKeys, len(keys))
|
||||
initializationUserAccountKeys := make(
|
||||
proxmox.VirtualEnvironmentContainerCustomSSHKeys,
|
||||
len(keys),
|
||||
)
|
||||
|
||||
for ki, kv := range keys {
|
||||
initializationUserAccountKeys[ki] = kv.(string)
|
||||
@ -794,13 +825,21 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||
|
||||
if len(networkInterface) == 0 {
|
||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx, veClient, nodeName, vmID)
|
||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(
|
||||
ctx,
|
||||
veClient,
|
||||
nodeName,
|
||||
vmID,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
||||
networkInterfaceArray := make(
|
||||
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||
len(networkInterface),
|
||||
)
|
||||
|
||||
for ni, nv := range networkInterface {
|
||||
networkInterfaceMap := nv.(map[string]interface{})
|
||||
@ -904,7 +943,11 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
||||
return resourceVirtualEnvironmentContainerCreateStart(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerCreateCustom(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -914,16 +957,30 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentContainerNodeName).(string)
|
||||
resource := resourceVirtualEnvironmentContainer()
|
||||
|
||||
consoleBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerConsole}, 0, true)
|
||||
consoleBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerConsole},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
||||
consoleEnabled := proxmox.CustomBool(
|
||||
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||
)
|
||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
||||
|
||||
cpuBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerCPU}, 0, true)
|
||||
cpuBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerCPU},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -934,7 +991,13 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
|
||||
description := d.Get(mkResourceVirtualEnvironmentContainerDescription).(string)
|
||||
|
||||
diskBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerDisk}, 0, true)
|
||||
diskBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerDisk},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -982,8 +1045,14 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
if len(ipv4) > 0 {
|
||||
ipv4Block := ipv4[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
||||
initializationIPConfigIPv4Address = append(
|
||||
initializationIPConfigIPv4Address,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv4Gateway = append(
|
||||
initializationIPConfigIPv4Gateway,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||
@ -994,8 +1063,14 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
if len(ipv6) > 0 {
|
||||
ipv6Block := ipv6[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
||||
initializationIPConfigIPv6Address = append(
|
||||
initializationIPConfigIPv6Address,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv6Gateway = append(
|
||||
initializationIPConfigIPv6Gateway,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||
@ -1008,7 +1083,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
initializationUserAccountBlock := initializationUserAccount[0].(map[string]interface{})
|
||||
|
||||
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
||||
initializationUserAccountKeys = make(proxmox.VirtualEnvironmentContainerCustomSSHKeys, len(keys))
|
||||
initializationUserAccountKeys = make(
|
||||
proxmox.VirtualEnvironmentContainerCustomSSHKeys,
|
||||
len(keys),
|
||||
)
|
||||
|
||||
for ki, kv := range keys {
|
||||
initializationUserAccountKeys[ki] = kv.(string)
|
||||
@ -1018,7 +1096,13 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
}
|
||||
}
|
||||
|
||||
memoryBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerMemory}, 0, true)
|
||||
memoryBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerMemory},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -1027,7 +1111,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
memorySwap := memoryBlock[mkResourceVirtualEnvironmentContainerMemorySwap].(int)
|
||||
|
||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
||||
networkInterfaceArray := make(
|
||||
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||
len(networkInterface),
|
||||
)
|
||||
|
||||
for ni, nv := range networkInterface {
|
||||
networkInterfaceMap := nv.(map[string]interface{})
|
||||
@ -1088,7 +1175,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
operatingSystem := d.Get(mkResourceVirtualEnvironmentContainerOperatingSystem).([]interface{})
|
||||
|
||||
if len(operatingSystem) == 0 {
|
||||
return diag.Errorf("\"%s\": required field is not set", mkResourceVirtualEnvironmentContainerOperatingSystem)
|
||||
return diag.Errorf(
|
||||
"\"%s\": required field is not set",
|
||||
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
||||
)
|
||||
}
|
||||
|
||||
operatingSystemBlock := operatingSystem[0].(map[string]interface{})
|
||||
@ -1173,7 +1263,11 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
||||
return resourceVirtualEnvironmentContainerCreateStart(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerCreateStart(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerCreateStart(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
started := d.Get(mkResourceVirtualEnvironmentContainerStarted).(bool)
|
||||
template := d.Get(mkResourceVirtualEnvironmentContainerTemplate).(bool)
|
||||
|
||||
@ -1224,9 +1318,13 @@ func resourceVirtualEnvironmentContainerGetCPUArchitectureValidator() schema.Sch
|
||||
}, false))
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx context.Context, client *proxmox.VirtualEnvironmentClient, nodeName string, vmID int) ([]interface{}, error) {
|
||||
func resourceVirtualEnvironmentContainerGetExistingNetworkInterface(
|
||||
ctx context.Context,
|
||||
client *proxmox.VirtualEnvironmentClient,
|
||||
nodeName string,
|
||||
vmID int,
|
||||
) ([]interface{}, error) {
|
||||
containerInfo, err := client.GetContainer(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
return []interface{}{}, err
|
||||
}
|
||||
@ -1304,7 +1402,11 @@ func resourceVirtualEnvironmentContainerGetOperatingSystemTypeValidator() schema
|
||||
}, false))
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -1321,7 +1423,6 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
|
||||
// Retrieve the entire configuration in order to compare it to the state.
|
||||
containerConfig, err := veClient.GetContainer(ctx, nodeName, vmID)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") ||
|
||||
(strings.Contains(err.Error(), "HTTP 500") && strings.Contains(err.Error(), "does not exist")) {
|
||||
@ -1339,7 +1440,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
|
||||
if len(clone) == 0 || currentDescription != dvResourceVirtualEnvironmentContainerDescription {
|
||||
if containerConfig.Description != nil {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerDescription, strings.TrimSpace(*containerConfig.Description))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentContainerDescription,
|
||||
strings.TrimSpace(*containerConfig.Description),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerDescription, "")
|
||||
}
|
||||
@ -1447,6 +1551,7 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
if len(clone) > 0 {
|
||||
if len(currentDisk) > 0 {
|
||||
// do not override the rootfs size if it was not changed during the clone operation
|
||||
//nolint:lll
|
||||
if currentDisk[0].(map[string]interface{})[mkResourceVirtualEnvironmentContainerDiskSize] == dvResourceVirtualEnvironmentContainerDiskSize {
|
||||
disk[mkResourceVirtualEnvironmentContainerDiskSize] = dvResourceVirtualEnvironmentContainerDiskSize
|
||||
}
|
||||
@ -1507,7 +1612,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
initializationDNS[mkResourceVirtualEnvironmentContainerInitializationDNSServer] = ""
|
||||
}
|
||||
|
||||
initialization[mkResourceVirtualEnvironmentContainerInitializationDNS] = []interface{}{initializationDNS}
|
||||
initialization[mkResourceVirtualEnvironmentContainerInitializationDNS] = []interface{}{
|
||||
initializationDNS,
|
||||
}
|
||||
}
|
||||
|
||||
if containerConfig.Hostname != nil {
|
||||
@ -1534,7 +1641,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
continue
|
||||
}
|
||||
|
||||
if nv.IPv4Address != nil || nv.IPv4Gateway != nil || nv.IPv6Address != nil || nv.IPv6Gateway != nil {
|
||||
//nolint:nestif
|
||||
if nv.IPv4Address != nil || nv.IPv4Gateway != nil || nv.IPv6Address != nil ||
|
||||
nv.IPv6Gateway != nil {
|
||||
ipConfig := map[string]interface{}{}
|
||||
|
||||
if nv.IPv4Address != nil || nv.IPv4Gateway != nil {
|
||||
@ -1552,7 +1661,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway] = ""
|
||||
}
|
||||
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{ip}
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{
|
||||
ip,
|
||||
}
|
||||
} else {
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{}
|
||||
}
|
||||
@ -1572,7 +1683,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway] = ""
|
||||
}
|
||||
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{ip}
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{
|
||||
ip,
|
||||
}
|
||||
} else {
|
||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{}
|
||||
}
|
||||
@ -1651,7 +1764,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
}
|
||||
|
||||
if len(initialization) > 0 {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerInitialization, []interface{}{initialization})
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentContainerInitialization,
|
||||
[]interface{}{initialization},
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerInitialization, []interface{}{})
|
||||
}
|
||||
@ -1661,7 +1777,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
currentNetworkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||
|
||||
if len(currentNetworkInterface) > 0 {
|
||||
err := d.Set(mkResourceVirtualEnvironmentContainerNetworkInterface, networkInterfaceList)
|
||||
err := d.Set(
|
||||
mkResourceVirtualEnvironmentContainerNetworkInterface,
|
||||
networkInterfaceList,
|
||||
)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
}
|
||||
} else {
|
||||
@ -1696,7 +1815,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
|
||||
if len(clone) > 0 {
|
||||
if len(currentMemory) > 0 {
|
||||
err := d.Set(mkResourceVirtualEnvironmentContainerOperatingSystem, []interface{}{operatingSystem})
|
||||
err := d.Set(
|
||||
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
||||
[]interface{}{operatingSystem},
|
||||
)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
}
|
||||
} else if len(currentOperatingSystem) > 0 ||
|
||||
@ -1710,7 +1832,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
//nolint:gosimple
|
||||
if len(clone) == 0 || currentTemplate != dvResourceVirtualEnvironmentContainerTemplate {
|
||||
if containerConfig.Template != nil {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerTemplate, bool(*containerConfig.Template))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentContainerTemplate,
|
||||
bool(*containerConfig.Template),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentContainerTemplate, false)
|
||||
}
|
||||
@ -1729,7 +1854,11 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -1765,12 +1894,20 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
|
||||
// Prepare the new console configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerConsole) {
|
||||
consoleBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerConsole}, 0, true)
|
||||
consoleBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerConsole},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
||||
consoleEnabled := proxmox.CustomBool(
|
||||
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||
)
|
||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
||||
|
||||
@ -1783,7 +1920,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
|
||||
// Prepare the new CPU configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerCPU) {
|
||||
cpuBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerCPU}, 0, true)
|
||||
cpuBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerCPU},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -1829,8 +1972,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
if len(ipv4) > 0 {
|
||||
ipv4Block := ipv4[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
||||
initializationIPConfigIPv4Address = append(
|
||||
initializationIPConfigIPv4Address,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv4Gateway = append(
|
||||
initializationIPConfigIPv4Gateway,
|
||||
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||
@ -1841,8 +1990,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
if len(ipv6) > 0 {
|
||||
ipv6Block := ipv6[0].(map[string]interface{})
|
||||
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
||||
initializationIPConfigIPv6Address = append(
|
||||
initializationIPConfigIPv6Address,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||
)
|
||||
initializationIPConfigIPv6Gateway = append(
|
||||
initializationIPConfigIPv6Gateway,
|
||||
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||
)
|
||||
} else {
|
||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||
@ -1860,7 +2015,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
|
||||
// Prepare the new memory configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerMemory) {
|
||||
memoryBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerMemory}, 0, true)
|
||||
memoryBlock, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerMemory},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -1878,14 +2039,24 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||
|
||||
if len(networkInterface) == 0 && len(clone) > 0 {
|
||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx, veClient, nodeName, vmID)
|
||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(
|
||||
ctx,
|
||||
veClient,
|
||||
nodeName,
|
||||
vmID,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerInitialization) || d.HasChange(mkResourceVirtualEnvironmentContainerNetworkInterface) {
|
||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
||||
//nolint:nestif
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerInitialization) ||
|
||||
d.HasChange(mkResourceVirtualEnvironmentContainerNetworkInterface) {
|
||||
networkInterfaceArray := make(
|
||||
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||
len(networkInterface),
|
||||
)
|
||||
|
||||
for ni, nv := range networkInterface {
|
||||
networkInterfaceMap := nv.(map[string]interface{})
|
||||
@ -1961,7 +2132,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
|
||||
// Prepare the new operating system configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentContainerOperatingSystem) {
|
||||
operatingSystem, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerOperatingSystem}, 0, true)
|
||||
operatingSystem, err := getSchemaBlock(
|
||||
resource,
|
||||
d,
|
||||
[]string{mkResourceVirtualEnvironmentContainerOperatingSystem},
|
||||
0,
|
||||
true,
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -2018,9 +2195,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
if !bool(template) && rebootRequired {
|
||||
rebootTimeout := 300
|
||||
|
||||
err = veClient.RebootContainer(ctx, nodeName, vmID, &proxmox.VirtualEnvironmentContainerRebootRequestBody{
|
||||
Timeout: &rebootTimeout,
|
||||
})
|
||||
err = veClient.RebootContainer(
|
||||
ctx,
|
||||
nodeName,
|
||||
vmID,
|
||||
&proxmox.VirtualEnvironmentContainerRebootRequestBody{
|
||||
Timeout: &rebootTimeout,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -2029,7 +2211,11 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
||||
return resourceVirtualEnvironmentContainerRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentContainerDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentContainerDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -2052,10 +2238,15 @@ func resourceVirtualEnvironmentContainerDelete(ctx context.Context, d *schema.Re
|
||||
forceStop := proxmox.CustomBool(true)
|
||||
shutdownTimeout := 300
|
||||
|
||||
err = veClient.ShutdownContainer(ctx, nodeName, vmID, &proxmox.VirtualEnvironmentContainerShutdownRequestBody{
|
||||
ForceStop: &forceStop,
|
||||
Timeout: &shutdownTimeout,
|
||||
})
|
||||
err = veClient.ShutdownContainer(
|
||||
ctx,
|
||||
nodeName,
|
||||
vmID,
|
||||
&proxmox.VirtualEnvironmentContainerShutdownRequestBody{
|
||||
ForceStop: &forceStop,
|
||||
Timeout: &shutdownTimeout,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
@ -94,7 +94,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerDiskDatastoreID: schema.TypeString,
|
||||
})
|
||||
|
||||
initializationSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerInitialization)
|
||||
initializationSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
s,
|
||||
mkResourceVirtualEnvironmentContainerInitialization,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
||||
@ -110,7 +114,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount: schema.TypeList,
|
||||
})
|
||||
|
||||
initializationDNSSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationDNS)
|
||||
initializationDNSSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
initializationSchema,
|
||||
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationDNSSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationDNSDomain,
|
||||
@ -122,7 +130,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerInitializationDNSServer: schema.TypeString,
|
||||
})
|
||||
|
||||
initializationIPConfigSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfig)
|
||||
initializationIPConfigSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
initializationSchema,
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfig,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationIPConfigSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
||||
@ -134,7 +146,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6: schema.TypeList,
|
||||
})
|
||||
|
||||
initializationIPConfigIPv4Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4)
|
||||
initializationIPConfigIPv4Schema := testNestedSchemaExistence(
|
||||
t,
|
||||
initializationIPConfigSchema,
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address,
|
||||
@ -146,7 +162,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway: schema.TypeString,
|
||||
})
|
||||
|
||||
initializationIPConfigIPv6Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6)
|
||||
initializationIPConfigIPv6Schema := testNestedSchemaExistence(
|
||||
t,
|
||||
initializationIPConfigSchema,
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address,
|
||||
@ -158,7 +178,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway: schema.TypeString,
|
||||
})
|
||||
|
||||
initializationUserAccountSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationUserAccount)
|
||||
initializationUserAccountSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
initializationSchema,
|
||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount,
|
||||
)
|
||||
|
||||
testOptionalArguments(t, initializationUserAccountSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys,
|
||||
@ -182,7 +206,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerMemorySwap: schema.TypeInt,
|
||||
})
|
||||
|
||||
networkInterfaceSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerNetworkInterface)
|
||||
networkInterfaceSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
s,
|
||||
mkResourceVirtualEnvironmentContainerNetworkInterface,
|
||||
)
|
||||
|
||||
testRequiredArguments(t, networkInterfaceSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName,
|
||||
@ -207,7 +235,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU: schema.TypeInt,
|
||||
})
|
||||
|
||||
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerOperatingSystem)
|
||||
operatingSystemSchema := testNestedSchemaExistence(
|
||||
t,
|
||||
s,
|
||||
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
||||
)
|
||||
|
||||
testRequiredArguments(t, operatingSystemSchema, []string{
|
||||
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID,
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -53,7 +53,11 @@ func resourceVirtualEnvironmentDNS() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentDNSCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentDNSCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
diags := resourceVirtualEnvironmentDNSUpdate(ctx, d, m)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
@ -66,7 +70,9 @@ func resourceVirtualEnvironmentDNSCreate(ctx context.Context, d *schema.Resource
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentDNSGetUpdateBody(d *schema.ResourceData) (*proxmox.VirtualEnvironmentDNSUpdateRequestBody, error) {
|
||||
func resourceVirtualEnvironmentDNSGetUpdateBody(
|
||||
d *schema.ResourceData,
|
||||
) *proxmox.VirtualEnvironmentDNSUpdateRequestBody {
|
||||
domain := d.Get(mkResourceVirtualEnvironmentDNSDomain).(string)
|
||||
servers := d.Get(mkResourceVirtualEnvironmentDNSServers).([]interface{})
|
||||
|
||||
@ -87,10 +93,14 @@ func resourceVirtualEnvironmentDNSGetUpdateBody(d *schema.ResourceData) (*proxmo
|
||||
}
|
||||
}
|
||||
|
||||
return body, nil
|
||||
return body
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentDNSRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentDNSRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -132,7 +142,11 @@ func resourceVirtualEnvironmentDNSRead(ctx context.Context, d *schema.ResourceDa
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentDNSUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentDNSUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -141,10 +155,7 @@ func resourceVirtualEnvironmentDNSUpdate(ctx context.Context, d *schema.Resource
|
||||
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentDNSNodeName).(string)
|
||||
|
||||
body, err := resourceVirtualEnvironmentDNSGetUpdateBody(d)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
body := resourceVirtualEnvironmentDNSGetUpdateBody(d)
|
||||
|
||||
err = veClient.UpdateDNS(ctx, nodeName, body)
|
||||
if err != nil {
|
||||
@ -154,7 +165,11 @@ func resourceVirtualEnvironmentDNSUpdate(ctx context.Context, d *schema.Resource
|
||||
return resourceVirtualEnvironmentDNSRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentDNSDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentDNSDelete(
|
||||
_ context.Context,
|
||||
d *schema.ResourceData,
|
||||
_ interface{},
|
||||
) diag.Diagnostics {
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
|
@ -21,9 +21,9 @@ import (
|
||||
"github.com/hashicorp/go-cty/cty"
|
||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -190,7 +190,11 @@ func resourceVirtualEnvironmentFile() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentFileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentFileCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -314,7 +318,11 @@ func resourceVirtualEnvironmentFileCreate(ctx context.Context, d *schema.Resourc
|
||||
})
|
||||
|
||||
if sourceFileChecksum != calculatedChecksum {
|
||||
return diag.Errorf("the calculated SHA256 checksum \"%s\" does not match source checksum \"%s\"", calculatedChecksum, sourceFileChecksum)
|
||||
return diag.Errorf(
|
||||
"the calculated SHA256 checksum \"%s\" does not match source checksum \"%s\"",
|
||||
calculatedChecksum,
|
||||
sourceFileChecksum,
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if len(sourceRaw) > 0 {
|
||||
@ -402,7 +410,9 @@ func resourceVirtualEnvironmentFileCreate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentFileRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentFileGetContentType(d *schema.ResourceData) (*string, diag.Diagnostics) {
|
||||
func resourceVirtualEnvironmentFileGetContentType(
|
||||
d *schema.ResourceData,
|
||||
) (*string, diag.Diagnostics) {
|
||||
contentType := d.Get(mkResourceVirtualEnvironmentFileContentType).(string)
|
||||
sourceFile := d.Get(mkResourceVirtualEnvironmentFileSourceFile).([]interface{})
|
||||
sourceRaw := d.Get(mkResourceVirtualEnvironmentFileSourceRaw).([]interface{})
|
||||
@ -479,7 +489,6 @@ func resourceVirtualEnvironmentFileGetFileName(d *schema.ResourceData) (*string,
|
||||
if sourceFileFileName == "" {
|
||||
if resourceVirtualEnvironmentFileIsURL(d) {
|
||||
downloadURL, err := url.ParseRequestURI(sourceFilePath)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -488,7 +497,10 @@ func resourceVirtualEnvironmentFileGetFileName(d *schema.ResourceData) (*string,
|
||||
sourceFileFileName = path[len(path)-1]
|
||||
|
||||
if sourceFileFileName == "" {
|
||||
return nil, fmt.Errorf("failed to determine file name from the URL \"%s\"", sourceFilePath)
|
||||
return nil, fmt.Errorf(
|
||||
"failed to determine file name from the URL \"%s\"",
|
||||
sourceFilePath,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
sourceFileFileName = filepath.Base(sourceFilePath)
|
||||
@ -523,10 +535,15 @@ func resourceVirtualEnvironmentFileIsURL(d *schema.ResourceData) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
return strings.HasPrefix(sourceFilePath, "http://") || strings.HasPrefix(sourceFilePath, "https://")
|
||||
return strings.HasPrefix(sourceFilePath, "http://") ||
|
||||
strings.HasPrefix(sourceFilePath, "https://")
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentFileRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -571,7 +588,7 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
||||
}
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
lastFileModificationDate := d.Get(mkResourceVirtualEnvironmentFileFileModificationDate).(string)
|
||||
lastFileMD := d.Get(mkResourceVirtualEnvironmentFileFileModificationDate).(string)
|
||||
lastFileSize := int64(d.Get(mkResourceVirtualEnvironmentFileFileSize).(int))
|
||||
lastFileTag := d.Get(mkResourceVirtualEnvironmentFileFileTag).(string)
|
||||
|
||||
@ -584,7 +601,9 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
||||
err = d.Set(mkResourceVirtualEnvironmentFileFileTag, fileTag)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
sourceFileBlock[mkResourceVirtualEnvironmentFileSourceFileChanged] = lastFileModificationDate != fileModificationDate || lastFileSize != fileSize || lastFileTag != fileTag
|
||||
sourceFileBlock[mkResourceVirtualEnvironmentFileSourceFileChanged] = lastFileMD != fileModificationDate ||
|
||||
lastFileSize != fileSize ||
|
||||
lastFileTag != fileTag
|
||||
err = d.Set(mkResourceVirtualEnvironmentFileSourceFile, sourceFile)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
@ -600,14 +619,17 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
||||
return nil
|
||||
}
|
||||
|
||||
func readFile(ctx context.Context, sourceFilePath string) (fileModificationDate string, fileSize int64, fileTag string, err error) {
|
||||
func readFile(
|
||||
ctx context.Context,
|
||||
sourceFilePath string,
|
||||
) (fileModificationDate string, fileSize int64, fileTag string, err error) {
|
||||
f, err := os.Open(sourceFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
defer func(f *os.File) {
|
||||
var err = f.Close()
|
||||
err := f.Close()
|
||||
if err != nil {
|
||||
tflog.Error(ctx, "failed to close the file", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@ -627,14 +649,18 @@ func readFile(ctx context.Context, sourceFilePath string) (fileModificationDate
|
||||
return fileModificationDate, fileSize, fileTag, nil
|
||||
}
|
||||
|
||||
func readURL(ctx context.Context, d *schema.ResourceData, sourceFilePath string) (fileSize int64, fileModificationDate string, fileTag string, err error) {
|
||||
func readURL(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
sourceFilePath string,
|
||||
) (fileSize int64, fileModificationDate string, fileTag string, err error) {
|
||||
res, err := http.Head(sourceFilePath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
defer func(Body io.ReadCloser) {
|
||||
var err = Body.Close()
|
||||
err := Body.Close()
|
||||
if err != nil {
|
||||
tflog.Error(ctx, "failed to close the response body", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
@ -681,7 +707,11 @@ func readURL(ctx context.Context, d *schema.ResourceData, sourceFilePath string)
|
||||
return
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentFileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentFileDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -83,7 +83,11 @@ func resourceVirtualEnvironmentGroup() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentGroupCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -110,7 +114,9 @@ func resourceVirtualEnvironmentGroupCreate(ctx context.Context, d *schema.Resour
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(false)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -129,7 +135,11 @@ func resourceVirtualEnvironmentGroupCreate(ctx context.Context, d *schema.Resour
|
||||
return resourceVirtualEnvironmentGroupRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentGroupRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -140,7 +150,6 @@ func resourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.Resource
|
||||
|
||||
groupID := d.Id()
|
||||
group, err := veClient.GetGroup(ctx, groupID)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -191,7 +200,11 @@ func resourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.Resource
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentGroupUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -216,7 +229,9 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
||||
for _, v := range aclParsedOld {
|
||||
aclDelete := proxmox.CustomBool(true)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -237,7 +252,9 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(false)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -256,7 +273,11 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
||||
return resourceVirtualEnvironmentGroupRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentGroupDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -269,7 +290,9 @@ func resourceVirtualEnvironmentGroupDelete(ctx context.Context, d *schema.Resour
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(true)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -106,7 +106,11 @@ func resourceVirtualEnvironmentHosts() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentHostsCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentHostsCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
diags := resourceVirtualEnvironmentHostsUpdate(ctx, d, m)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
@ -119,7 +123,11 @@ func resourceVirtualEnvironmentHostsCreate(ctx context.Context, d *schema.Resour
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentHostsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentHostsRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -189,7 +197,11 @@ func resourceVirtualEnvironmentHostsRead(ctx context.Context, d *schema.Resource
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentHostsUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentHostsUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -228,7 +240,11 @@ func resourceVirtualEnvironmentHostsUpdate(ctx context.Context, d *schema.Resour
|
||||
return resourceVirtualEnvironmentHostsRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentHostsDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentHostsDelete(
|
||||
_ context.Context,
|
||||
d *schema.ResourceData,
|
||||
_ interface{},
|
||||
) diag.Diagnostics {
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -84,7 +84,11 @@ func resourceVirtualEnvironmentPool() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentPoolCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentPoolCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -109,7 +113,11 @@ func resourceVirtualEnvironmentPoolCreate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentPoolRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentPoolRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -120,7 +128,6 @@ func resourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceD
|
||||
|
||||
poolID := d.Id()
|
||||
pool, err := veClient.GetPool(ctx, poolID)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -167,7 +174,11 @@ func resourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceD
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentPoolUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentPoolUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -189,7 +200,11 @@ func resourceVirtualEnvironmentPoolUpdate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentPoolRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentPoolDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentPoolDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -9,9 +9,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -42,7 +42,11 @@ func resourceVirtualEnvironmentRole() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentRoleCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentRoleCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -72,7 +76,11 @@ func resourceVirtualEnvironmentRoleCreate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentRoleRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentRoleRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -81,7 +89,6 @@ func resourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceD
|
||||
|
||||
roleID := d.Id()
|
||||
role, err := veClient.GetRole(ctx, roleID)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -103,7 +110,11 @@ func resourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceD
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentRoleUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentRoleUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -130,7 +141,11 @@ func resourceVirtualEnvironmentRoleUpdate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentRoleRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentRoleDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentRoleDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -53,7 +53,11 @@ func resourceVirtualEnvironmentTime() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentTimeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentTimeCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
diags := resourceVirtualEnvironmentTimeUpdate(ctx, d, m)
|
||||
if diags.HasError() {
|
||||
return diags
|
||||
@ -66,7 +70,12 @@ func resourceVirtualEnvironmentTimeCreate(ctx context.Context, d *schema.Resourc
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
//nolint:dupl
|
||||
func resourceVirtualEnvironmentTimeRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
var diags diag.Diagnostics
|
||||
|
||||
config := m.(providerConfiguration)
|
||||
@ -91,17 +100,24 @@ func resourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.ResourceD
|
||||
localTimeOffset := time.Time(nodeTime.LocalTime).Sub(time.Now().UTC())
|
||||
localTime := time.Time(nodeTime.LocalTime).Add(-localTimeOffset).In(localLocation)
|
||||
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeLocalTime, localTime.Format(time.RFC3339))
|
||||
err = d.Set(mkResourceVirtualEnvironmentTimeLocalTime, localTime.Format(time.RFC3339))
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
||||
err = d.Set(mkResourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeUTCTime, time.Time(nodeTime.UTCTime).Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentTimeUTCTime,
|
||||
time.Time(nodeTime.UTCTime).Format(time.RFC3339),
|
||||
)
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentTimeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentTimeUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -111,9 +127,13 @@ func resourceVirtualEnvironmentTimeUpdate(ctx context.Context, d *schema.Resourc
|
||||
nodeName := d.Get(mkResourceVirtualEnvironmentTimeNodeName).(string)
|
||||
timeZone := d.Get(mkResourceVirtualEnvironmentTimeTimeZone).(string)
|
||||
|
||||
err = veClient.UpdateNodeTime(ctx, nodeName, &proxmox.VirtualEnvironmentNodeUpdateTimeRequestBody{
|
||||
TimeZone: timeZone,
|
||||
})
|
||||
err = veClient.UpdateNodeTime(
|
||||
ctx,
|
||||
nodeName,
|
||||
&proxmox.VirtualEnvironmentNodeUpdateTimeRequestBody{
|
||||
TimeZone: timeZone,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -121,7 +141,11 @@ func resourceVirtualEnvironmentTimeUpdate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentTimeRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentTimeDelete(_ context.Context, d *schema.ResourceData, _ interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentTimeDelete(
|
||||
_ context.Context,
|
||||
d *schema.ResourceData,
|
||||
_ interface{},
|
||||
) diag.Diagnostics {
|
||||
d.SetId("")
|
||||
|
||||
return nil
|
||||
|
@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||
|
||||
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -142,7 +142,11 @@ func resourceVirtualEnvironmentUser() *schema.Resource {
|
||||
}
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentUserCreate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -152,7 +156,10 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||
enabled := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
||||
expirationDate, err := time.Parse(time.RFC3339, d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string))
|
||||
expirationDate, err := time.Parse(
|
||||
time.RFC3339,
|
||||
d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string),
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -196,7 +203,9 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(false)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -215,7 +224,11 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentUserRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentUserRead(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -224,7 +237,6 @@ func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceD
|
||||
|
||||
userID := d.Id()
|
||||
user, err := veClient.GetUser(ctx, userID)
|
||||
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "HTTP 404") {
|
||||
d.SetId("")
|
||||
@ -286,7 +298,10 @@ func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceD
|
||||
diags = append(diags, diag.FromErr(err)...)
|
||||
|
||||
if user.ExpirationDate != nil {
|
||||
err = d.Set(mkResourceVirtualEnvironmentUserExpirationDate, time.Time(*user.ExpirationDate).Format(time.RFC3339))
|
||||
err = d.Set(
|
||||
mkResourceVirtualEnvironmentUserExpirationDate,
|
||||
time.Time(*user.ExpirationDate).Format(time.RFC3339),
|
||||
)
|
||||
} else {
|
||||
err = d.Set(mkResourceVirtualEnvironmentUserExpirationDate, time.Unix(0, 0).UTC().Format(time.RFC3339))
|
||||
}
|
||||
@ -327,7 +342,11 @@ func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceD
|
||||
return diags
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentUserUpdate(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -337,7 +356,10 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||
enabled := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
||||
expirationDate, err := time.Parse(time.RFC3339, d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string))
|
||||
expirationDate, err := time.Parse(
|
||||
time.RFC3339,
|
||||
d.Get(mkResourceVirtualEnvironmentUserExpirationDate).(string),
|
||||
)
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -385,7 +407,9 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
||||
for _, v := range aclParsedOld {
|
||||
aclDelete := proxmox.CustomBool(true)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -406,7 +430,9 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(false)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
@ -417,7 +443,6 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
||||
}
|
||||
|
||||
err := veClient.UpdateACL(ctx, aclBody)
|
||||
|
||||
if err != nil {
|
||||
return diag.FromErr(err)
|
||||
}
|
||||
@ -426,7 +451,11 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
||||
return resourceVirtualEnvironmentUserRead(ctx, d, m)
|
||||
}
|
||||
|
||||
func resourceVirtualEnvironmentUserDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
||||
func resourceVirtualEnvironmentUserDelete(
|
||||
ctx context.Context,
|
||||
d *schema.ResourceData,
|
||||
m interface{},
|
||||
) diag.Diagnostics {
|
||||
config := m.(providerConfiguration)
|
||||
veClient, err := config.GetVEClient()
|
||||
if err != nil {
|
||||
@ -439,7 +468,9 @@ func resourceVirtualEnvironmentUserDelete(ctx context.Context, d *schema.Resourc
|
||||
for _, v := range aclParsed {
|
||||
aclDelete := proxmox.CustomBool(true)
|
||||
aclEntry := v.(map[string]interface{})
|
||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
||||
aclPropagate := proxmox.CustomBool(
|
||||
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||
)
|
||||
|
||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||
Delete: &aclDelete,
|
||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user