mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-23 11:58:34 +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
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
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
|
50
README.md
50
README.md
@ -1,3 +1,5 @@
|
|||||||
|
# Terraform Provider for Proxmox
|
||||||
|
|
||||||
[](https://goreportcard.com/report/github.com/bpg/terraform-provider-proxmox)
|
[](https://goreportcard.com/report/github.com/bpg/terraform-provider-proxmox)
|
||||||
[](http://godoc.org/github.com/bpg/terraform-provider-proxmox)
|
[](http://godoc.org/github.com/bpg/terraform-provider-proxmox)
|
||||||
[](https://github.com/bpg/terraform-provider-proxmox/releases/latest)
|
[](https://github.com/bpg/terraform-provider-proxmox/releases/latest)
|
||||||
@ -6,62 +8,69 @@
|
|||||||
[](https://www.conventionalcommits.org/en/v1.0.0/#specification)
|
[](https://www.conventionalcommits.org/en/v1.0.0/#specification)
|
||||||
[](https://www.buymeacoffee.com/bpgca)
|
[](https://www.buymeacoffee.com/bpgca)
|
||||||
|
|
||||||
# Terraform Provider for Proxmox
|
|
||||||
A Terraform Provider which adds support for Proxmox solutions.
|
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
|
This repository is a fork of <https://github.com/danitso/terraform-provider-proxmox>
|
||||||
VM deployment in Proxmox v7.0, and a few other enhancements.
|
with several critical fixes to unblock VM deployment in Proxmox v7.0, and several
|
||||||
|
other enhancements.
|
||||||
|
|
||||||
## Compatibility Matrix
|
## Compatibility Matrix
|
||||||
|
|
||||||
| Proxmox version | Provider version |
|
| Proxmox version | Provider version |
|
||||||
|-----------------|--------------------------|
|
| --------------- | ---------------- |
|
||||||
| 6.x | \<= 0.4.4 |
|
| 6.x | \<= 0.4.4 |
|
||||||
| 7.x | 0.4.x \> 0.4.4 <br>0.5.x |
|
| 7.x | \>= 0.4.5 |
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [Terraform](https://www.terraform.io/downloads.html) 1.1+
|
- [Terraform](https://www.terraform.io/downloads.html) 1.1+
|
||||||
- [Go](https://golang.org/doc/install) 1.18+ (to build the provider plugin)
|
- [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)
|
- [GoReleaser](https://goreleaser.com/install/) v1.10+ (to build the provider plugin)
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
- [Building the provider](#building-the-provider)
|
- [Building the provider](#building-the-provider)
|
||||||
- [Using the provider](#using-the-provider)
|
- [Using the provider](#using-the-provider)
|
||||||
- [Testing the provider](#testing-the-provider)
|
- [Testing the provider](#testing-the-provider)
|
||||||
- [Known issues](#known-issues)
|
- [Known issues](#known-issues)
|
||||||
|
|
||||||
## Building the provider
|
## Building the provider
|
||||||
|
|
||||||
- Clone the repository to `$GOPATH/src/github.com/bpg/terraform-provider-proxmox`:
|
- Clone the repository to `$GOPATH/src/github.com/bpg/terraform-provider-proxmox`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ mkdir -p "${GOPATH}/src/github.com/bpg"
|
mkdir -p "${GOPATH}/src/github.com/bpg"
|
||||||
$ cd "${GOPATH}/src/github.com/bpg"
|
cd "${GOPATH}/src/github.com/bpg"
|
||||||
$ git clone git@github.com:bpg/terraform-provider-proxmox
|
git clone git@github.com:bpg/terraform-provider-proxmox
|
||||||
```
|
```
|
||||||
|
|
||||||
- Enter the provider directory and build it:
|
- Enter the provider directory and build it:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ cd "${GOPATH}/src/github.com/bpg/terraform-provider-proxmox"
|
cd "${GOPATH}/src/github.com/bpg/terraform-provider-proxmox"
|
||||||
$ make build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using the provider
|
## Using the provider
|
||||||
|
|
||||||
You can find the latest release and its documentation in the [Terraform Registry](https://registry.terraform.io/providers/bpg/proxmox/latest).
|
You can find the latest release and its documentation in the [Terraform Registry](https://registry.terraform.io/providers/bpg/proxmox/latest).
|
||||||
|
|
||||||
## Testing the provider
|
## Testing the provider
|
||||||
|
|
||||||
In order to test the provider, you can simply run `make test`.
|
In order to test the provider, you can simply run `make test`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ make test
|
make test
|
||||||
```
|
```
|
||||||
|
|
||||||
Tests are limited to regression tests, ensuring backwards compatibility.
|
Tests are limited to regression tests, ensuring backwards compatibility.
|
||||||
|
|
||||||
## Deploying the example resources
|
## 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:
|
The following assumptions are made about the test Proxmox cluster:
|
||||||
|
|
||||||
- It has one node named `pve`
|
- It has one node named `pve`
|
||||||
- The node has local storages named `local` and `local-lvm`
|
- 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.
|
Then run `make example` to deploy the example resources.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
### Disk images cannot be imported by non-PAM accounts
|
### 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
|
### 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
|
```hcl
|
||||||
resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
|
resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
|
||||||
@ -92,7 +103,8 @@ resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
|
|||||||
node_name = "node-name"
|
node_name = "node-name"
|
||||||
|
|
||||||
source_file {
|
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"
|
file_name = "vmdk-file-name.img"
|
||||||
path = "path-to-vmdk-file"
|
path = "path-to-vmdk-file"
|
||||||
}
|
}
|
||||||
@ -113,4 +125,6 @@ resource "proxmox_virtual_environment_vm" "example" {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Snippets cannot be uploaded by non-PAM accounts
|
### 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"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
@ -23,4 +23,4 @@ There are no arguments available for this data source.
|
|||||||
|
|
||||||
## Attribute Reference
|
## 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
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `active` - Whether the datastore is active.
|
- `active` - Whether the datastore is active.
|
||||||
* `content_types` - The allowed content types.
|
- `content_types` - The allowed content types.
|
||||||
* `datastore_ids` - The datastore identifiers.
|
- `datastore_ids` - The datastore identifiers.
|
||||||
* `enabled` - Whether the datastore is enabled.
|
- `enabled` - Whether the datastore is enabled.
|
||||||
* `shared` - Whether the datastore is shared.
|
- `shared` - Whether the datastore is shared.
|
||||||
* `space_available` - The available space in bytes.
|
- `space_available` - The available space in bytes.
|
||||||
* `space_total` - The total space in bytes.
|
- `space_total` - The total space in bytes.
|
||||||
* `space_used` - The used space in bytes.
|
- `space_used` - The used space in bytes.
|
||||||
* `types` - The storage types.
|
- `types` - The storage types.
|
||||||
|
@ -21,9 +21,9 @@ data "proxmox_virtual_environment_dns" "first_node" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `domain` - The DNS search domain.
|
- `domain` - The DNS search domain.
|
||||||
* `servers` - The DNS servers.
|
- `servers` - The DNS servers.
|
||||||
|
@ -21,13 +21,13 @@ data "proxmox_virtual_environment_group" "operations_team" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `group_id` - (Required) The group identifier.
|
- `group_id` - (Required) The group identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `acl` - The access control list.
|
- `acl` - The access control list.
|
||||||
* `path` - The path.
|
- `path` - The path.
|
||||||
* `propagate` - Whether to propagate to child paths.
|
- `propagate` - Whether to propagate to child paths.
|
||||||
* `role_id` - The role identifier.
|
- `role_id` - The role identifier.
|
||||||
* `comment` - The group comment.
|
- `comment` - The group comment.
|
||||||
* `members` - The group members as a list with `username@realm` entries.
|
- `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
|
## Attribute Reference
|
||||||
|
|
||||||
* `comments` - The group comments.
|
- `comments` - The group comments.
|
||||||
* `group_ids` - The group identifiers.
|
- `group_ids` - The group identifiers.
|
||||||
|
@ -21,11 +21,12 @@ data "proxmox_virtual_environment_hosts" "first_node_host_entries" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `addresses` - The IP addresses.
|
- `addresses` - The IP addresses.
|
||||||
* `digest` - The SHA1 digest.
|
- `digest` - The SHA1 digest.
|
||||||
* `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
|
- `entries` - The host entries (conversion of `addresses` and `hostnames` into
|
||||||
* `hostnames` - The hostnames associated with each of the IP addresses.
|
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
|
## Attribute Reference
|
||||||
|
|
||||||
* `cpu_count` - The CPU count for each node.
|
- `cpu_count` - The CPU count for each node.
|
||||||
* `cpu_utilization` - The CPU utilization on each node.
|
- `cpu_utilization` - The CPU utilization on each node.
|
||||||
* `memory_available` - The memory available on each node.
|
- `memory_available` - The memory available on each node.
|
||||||
* `memory_used` - The memory used on each node.
|
- `memory_used` - The memory used on each node.
|
||||||
* `names` - The node names.
|
- `names` - The node names.
|
||||||
* `online` - Whether a node is online.
|
- `online` - Whether a node is online.
|
||||||
* `ssl_fingerprints` - The SSL fingerprint for each node.
|
- `ssl_fingerprints` - The SSL fingerprint for each node.
|
||||||
* `support_levels` - The support level for each node.
|
- `support_levels` - The support level for each node.
|
||||||
* `uptime` - The uptime in seconds for each node.
|
- `uptime` - The uptime in seconds for each node.
|
||||||
|
@ -21,14 +21,14 @@ data "proxmox_virtual_environment_pool" "operations_pool" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `pool_id` - (Required) The pool identifier.
|
- `pool_id` - (Required) The pool identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `comment` - The pool comment.
|
- `comment` - The pool comment.
|
||||||
* `members` - The pool members.
|
- `members` - The pool members.
|
||||||
* `datastore_id` - The datastore identifier.
|
- `datastore_id` - The datastore identifier.
|
||||||
* `id` - The member identifier.
|
- `id` - The member identifier.
|
||||||
* `node_name` - The node name.
|
- `node_name` - The node name.
|
||||||
* `type` - The member type.
|
- `type` - The member type.
|
||||||
* `vm_id` - The virtual machine identifier.
|
- `vm_id` - The virtual machine identifier.
|
||||||
|
@ -23,4 +23,4 @@ There are no arguments available for this data source.
|
|||||||
|
|
||||||
## Attribute Reference
|
## 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
|
## Argument Reference
|
||||||
|
|
||||||
* `role_id` - (Required) The role identifier.
|
- `role_id` - (Required) The role identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## 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
|
## Attribute Reference
|
||||||
|
|
||||||
* `privileges` - The role privileges.
|
- `privileges` - The role privileges.
|
||||||
* `role_ids` - The role identifiers.
|
- `role_ids` - The role identifiers.
|
||||||
* `special` - Whether the role is special (built-in).
|
- `special` - Whether the role is special (built-in).
|
||||||
|
@ -21,10 +21,10 @@ data "proxmox_virtual_environment_time" "first_node_time" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `local_time` - The node's local time.
|
- `local_time` - The node's local time.
|
||||||
* `time_zone` - The node's time zone.
|
- `time_zone` - The node's time zone.
|
||||||
* `utc_time` - The node's local time formatted as UTC.
|
- `utc_time` - The node's local time formatted as UTC.
|
||||||
|
@ -21,19 +21,19 @@ data "proxmox_virtual_environment_user" "operations_user" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `user_id` - (Required) The user identifier.
|
- `user_id` - (Required) The user identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `acl` - The access control list.
|
- `acl` - The access control list.
|
||||||
* `path` - The path.
|
- `path` - The path.
|
||||||
* `propagate` - Whether to propagate to child paths.
|
- `propagate` - Whether to propagate to child paths.
|
||||||
* `role_id` - The role identifier.
|
- `role_id` - The role identifier.
|
||||||
* `comment` - The user comment.
|
- `comment` - The user comment.
|
||||||
* `email` - The user's email address.
|
- `email` - The user's email address.
|
||||||
* `enabled` - Whether the user account is enabled.
|
- `enabled` - Whether the user account is enabled.
|
||||||
* `expiration_date` - The user account's expiration date (RFC 3339).
|
- `expiration_date` - The user account's expiration date (RFC 3339).
|
||||||
* `first_name` - The user's first name.
|
- `first_name` - The user's first name.
|
||||||
* `groups` - The user's groups.
|
- `groups` - The user's groups.
|
||||||
* `keys` - The user's keys.
|
- `keys` - The user's keys.
|
||||||
* `last_name` - The user's last name.
|
- `last_name` - The user's last name.
|
||||||
|
@ -23,12 +23,12 @@ There are no arguments available for this data source.
|
|||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `comments` - The user comments.
|
- `comments` - The user comments.
|
||||||
* `emails` - The users' email addresses.
|
- `emails` - The users' email addresses.
|
||||||
* `enabled` - Whether a user account is enabled.
|
- `enabled` - Whether a user account is enabled.
|
||||||
* `expiration_dates` - The user accounts' expiration dates (RFC 3339).
|
- `expiration_dates` - The user accounts' expiration dates (RFC 3339).
|
||||||
* `first_names` - The users' first names.
|
- `first_names` - The users' first names.
|
||||||
* `groups` - The users' groups.
|
- `groups` - The users' groups.
|
||||||
* `keys` - The users' keys.
|
- `keys` - The users' keys.
|
||||||
* `last_names` - The users' last names.
|
- `last_names` - The users' last names.
|
||||||
* `user_ids` - The user identifiers.
|
- `user_ids` - The user identifiers.
|
||||||
|
@ -23,7 +23,7 @@ There are no arguments available for this data source.
|
|||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `keyboard_layout` - The keyboard layout.
|
- `keyboard_layout` - The keyboard layout.
|
||||||
* `release` - The release number.
|
- `release` - The release number.
|
||||||
* `repository_id` - The repository identifier.
|
- `repository_id` - The repository identifier.
|
||||||
* `version` - The version string.
|
- `version` - The version string.
|
||||||
|
@ -6,7 +6,10 @@ nav_order: 1
|
|||||||
|
|
||||||
# Proxmox Provider
|
# 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.
|
Use the navigation to the left to read about the available resources.
|
||||||
|
|
||||||
@ -25,16 +28,21 @@ provider "proxmox" {
|
|||||||
|
|
||||||
## Authentication
|
## 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
|
- Static credentials
|
||||||
* Environment variables
|
- Environment variables
|
||||||
|
|
||||||
### Static credentials
|
### 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
|
```terraform
|
||||||
provider "proxmox" {
|
provider "proxmox" {
|
||||||
@ -47,9 +55,11 @@ provider "proxmox" {
|
|||||||
|
|
||||||
### Environment variables
|
### 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" {
|
provider "proxmox" {
|
||||||
virtual_environment {}
|
virtual_environment {}
|
||||||
}
|
}
|
||||||
@ -58,18 +68,28 @@ provider "proxmox" {
|
|||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ export PROXMOX_VE_USERNAME="username@realm"
|
export PROXMOX_VE_USERNAME="username@realm"
|
||||||
$ export PROXMOX_VE_PASSWORD="a-strong-password"
|
export PROXMOX_VE_PASSWORD="a-strong-password"
|
||||||
$ terraform plan
|
terraform plan
|
||||||
```
|
```
|
||||||
|
|
||||||
## Argument Reference
|
## 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.
|
- `virtual_environment` - (Optional) The Proxmox Virtual Environment
|
||||||
* `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_ENDPOINT`).
|
configuration.
|
||||||
* `insecure` - (Optional) Whether to skip the TLS verification step (can also be sourced from `PROXMOX_VE_INSECURE`). If omitted, defaults to `false`.
|
- `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment
|
||||||
* `otp` - (Optional) The one-time password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_OTP`).
|
API (can also be sourced from `PROXMOX_VE_ENDPOINT`).
|
||||||
* `password` - (Required) The password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_PASSWORD`).
|
- `insecure` - (Optional) Whether to skip the TLS verification step (can
|
||||||
* `username` - (Required) The username and realm for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_USERNAME`).
|
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
|
## Argument Reference
|
||||||
|
|
||||||
* `certificate` - (Required) The PEM encoded certificate.
|
- `certificate` - (Required) The PEM encoded certificate.
|
||||||
* `certificate_chain` - (Optional) The PEM encoded certificate chain.
|
- `certificate_chain` - (Optional) The PEM encoded certificate chain.
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
* `private_key` - (Required) The PEM encoded private key.
|
- `private_key` - (Required) The PEM encoded private key.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `expiration_date` - The expiration date (RFC 3339).
|
- `expiration_date` - The expiration date (RFC 3339).
|
||||||
* `file_name` - The file name.
|
- `file_name` - The file name.
|
||||||
* `issuer` - The issuer.
|
- `issuer` - The issuer.
|
||||||
* `public_key_size` - The public key size.
|
- `public_key_size` - The public key size.
|
||||||
* `public_key_type` - The public key type.
|
- `public_key_type` - The public key type.
|
||||||
* `ssl_fingerprint` - The SSL fingerprint.
|
- `ssl_fingerprint` - The SSL fingerprint.
|
||||||
* `start_date` - The start date (RFC 3339).
|
- `start_date` - The start date (RFC 3339).
|
||||||
* `subject` - The subject.
|
- `subject` - The subject.
|
||||||
* `subject_alternative_names` - The subject alternative names.
|
- `subject_alternative_names` - The subject alternative names.
|
||||||
|
@ -30,9 +30,9 @@ resource "proxmox_virtual_environment_cluster_alias" "ubuntu_vm" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `name` - (Required) Alias name.
|
- `name` - (Required) Alias name.
|
||||||
* `cidr` - (Required) Network/IP specification in CIDR format.
|
- `cidr` - (Required) Network/IP specification in CIDR format.
|
||||||
* `comment` - (Optional) Alias comment.
|
- `comment` - (Optional) Alias comment.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -38,12 +38,13 @@ resource "proxmox_virtual_environment_cluster_ipset" "ipset" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `name` - (Required) Alias name.
|
- `name` - (Required) Alias name.
|
||||||
* `comment` - (Optional) Alias comment.
|
- `comment` - (Optional) Alias comment.
|
||||||
* `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
|
- `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
|
||||||
* `name` - Network/IP specification in CIDR format.
|
- `name` - Network/IP specification in CIDR format.
|
||||||
* `comment` - (Optional) Arbitrary string annotation.
|
- `comment` - (Optional) Arbitrary string annotation.
|
||||||
* `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those were not added to the set.
|
- `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those
|
||||||
|
were not added to the set.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -30,7 +30,9 @@ resource "proxmox_virtual_environment_container" "ubuntu_container" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user_account {
|
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
|
password = random_password.ubuntu_container_password.result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,72 +85,89 @@ output "ubuntu_container_public_key" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `clone` - (Optional) The cloning configuration.
|
- `clone` - (Optional) The cloning configuration.
|
||||||
* `datastore_id` - (Optional) The identifier for the target datastore.
|
- `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).
|
- `node_name` - (Optional) The name of the source node (leave blank, if
|
||||||
* `vm_id` - (Required) The identifier for the source container.
|
equal
|
||||||
* `console` - (Optional) The console configuration.
|
to the `node_name` argument).
|
||||||
* `enabled` - (Optional) Whether to enable the console device (defaults to `true`).
|
- `vm_id` - (Required) The identifier for the source container.
|
||||||
* `mode` - (Optional) The console mode (defaults to `tty`).
|
- `console` - (Optional) The console configuration.
|
||||||
* `console` - Console.
|
- `enabled` - (Optional) Whether to enable the console device (defaults
|
||||||
* `shell` - Shell.
|
to `true`).
|
||||||
* `tty` - TTY.
|
- `mode` - (Optional) The console mode (defaults to `tty`).
|
||||||
* `tty_count` - (Optional) The number of available TTY (defaults to `2`).
|
- `console` - Console.
|
||||||
* `cpu` - (Optional) The CPU configuration.
|
- `shell` - Shell.
|
||||||
* `architecture` - (Optional) The CPU architecture (defaults to `amd64`).
|
- `tty` - TTY.
|
||||||
* `amd64` - x86 (64 bit).
|
- `tty_count` - (Optional) The number of available TTY (defaults to `2`).
|
||||||
* `arm64` - ARM (64-bit).
|
- `cpu` - (Optional) The CPU configuration.
|
||||||
* `armhf` - ARM (32 bit).
|
- `architecture` - (Optional) The CPU architecture (defaults to `amd64`).
|
||||||
* `i386` - x86 (32 bit).
|
- `amd64` - x86 (64 bit).
|
||||||
* `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
- `arm64` - ARM (64-bit).
|
||||||
* `units` - (Optional) The CPU units (defaults to `1024`).
|
- `armhf` - ARM (32 bit).
|
||||||
* `description` - (Optional) The description.
|
- `i386` - x86 (32 bit).
|
||||||
* `disk` - (Optional) The disk configuration.
|
- `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||||
* `datastore_id` - (Optional) The identifier for the datastore to create the disk in (defaults to `local`).
|
- `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.
|
* `size` - (Optional) The size of the root filesystem in gigabytes (defaults to `4`). Requires `datastore_id` to be set.
|
||||||
* `initialization` - (Optional) The initialization configuration.
|
- `initialization` - (Optional) The initialization configuration.
|
||||||
* `dns` - (Optional) The DNS configuration.
|
- `dns` - (Optional) The DNS configuration.
|
||||||
* `domain` - (Optional) The DNS search domain.
|
- `domain` - (Optional) The DNS search domain.
|
||||||
* `server` - (Optional) The DNS server.
|
- `server` - (Optional) The DNS server.
|
||||||
* `hostname` - (Optional) The hostname.
|
- `hostname` - (Optional) The hostname.
|
||||||
* `ip_config` - (Optional) The IP configuration (one block per network device).
|
- `ip_config` - (Optional) The IP configuration (one block per network
|
||||||
* `ipv4` - (Optional) The IPv4 configuration.
|
device).
|
||||||
* `address` - (Optional) The IPv4 address (use `dhcp` for autodiscovery).
|
- `ipv4` - (Optional) The IPv4 configuration.
|
||||||
* `gateway` - (Optional) The IPv4 gateway (must be omitted when `dhcp` is used as the address).
|
- `address` - (Optional) The IPv4 address (use `dhcp` for
|
||||||
* `ipv6` - (Optional) The IPv4 configuration.
|
autodiscovery).
|
||||||
* `address` - (Optional) The IPv6 address (use `dhcp` for autodiscovery).
|
- `gateway` - (Optional) The IPv4 gateway (must be omitted
|
||||||
* `gateway` - (Optional) The IPv6 gateway (must be omitted when `dhcp` is used as the address).
|
when `dhcp` is
|
||||||
* `user_account` - (Optional) The user account configuration.
|
used as the address).
|
||||||
* `keys` - (Optional) The SSH keys for the root account.
|
- `ipv6` - (Optional) The IPv4 configuration.
|
||||||
* `password` - (Optional) The password for the root account.
|
- `address` - (Optional) The IPv6 address (use `dhcp` for
|
||||||
* `memory` - (Optional) The memory configuration.
|
autodiscovery).
|
||||||
* `dedicated` - (Optional) The dedicated memory in megabytes (defaults to `512`).
|
- `gateway` - (Optional) The IPv6 gateway (must be omitted
|
||||||
* `swap` - (Optional) The swap size in megabytes (defaults to `0`).
|
when `dhcp` is
|
||||||
* `network_interface` - (Optional) A network interface (multiple blocks supported).
|
used as the address).
|
||||||
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
- `user_account` - (Optional) The user account configuration.
|
||||||
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
- `keys` - (Optional) The SSH keys for the root account.
|
||||||
* `mac_address` - (Optional) The MAC address.
|
- `password` - (Optional) The password for the root account.
|
||||||
* `mtu` - (Optional) Maximum transfer unit of the interface. Cannot be larger than the bridge's MTU.
|
- `memory` - (Optional) The memory configuration.
|
||||||
* `name` - (Required) The network interface name.
|
- `dedicated` - (Optional) The dedicated memory in megabytes (defaults
|
||||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
to `512`).
|
||||||
* `vlan_id` - (Optional) The VLAN identifier.
|
- `swap` - (Optional) The swap size in megabytes (defaults to `0`).
|
||||||
* `node_name` - (Required) The name of the node to assign the container to.
|
- `network_interface` - (Optional) A network interface (multiple blocks
|
||||||
* `operating_system` - (Required) The Operating System configuration.
|
supported).
|
||||||
* `template_file_id` - (Required) The identifier for an OS template file.
|
- `bridge` - (Optional) The name of the network bridge (defaults
|
||||||
* `type` - (Optional) The type (defaults to `unmanaged`).
|
to `vmbr0`).
|
||||||
* `alpine` - Alpine.
|
- `enabled` - (Optional) Whether to enable the network device (defaults
|
||||||
* `archlinux` - Arch Linux.
|
to `true`).
|
||||||
* `centos` - CentOS.
|
- `mac_address` - (Optional) The MAC address.
|
||||||
* `debian` - Debian.
|
- `mtu` - (Optional) Maximum transfer unit of the interface. Cannot be
|
||||||
* `fedora` - Fedora.
|
larger
|
||||||
* `gentoo` - Gentoo.
|
than the bridge's MTU.
|
||||||
* `opensuse` - openSUSE.
|
- `name` - (Required) The network interface name.
|
||||||
* `ubuntu` - Ubuntu.
|
- `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||||
* `unmanaged` - Unmanaged.
|
- `vlan_id` - (Optional) The VLAN identifier.
|
||||||
* `pool_id` - (Optional) The identifier for a pool to assign the container to.
|
- `node_name` - (Required) The name of the node to assign the container to.
|
||||||
* `started` - (Optional) Whether to start the container (defaults to `true`).
|
- `operating_system` - (Required) The Operating System configuration.
|
||||||
* `template` - (Optional) Whether to create a template (defaults to `false`).
|
- `template_file_id` - (Required) The identifier for an OS template file.
|
||||||
* `vm_id` - (Optional) The virtual machine identifier
|
- `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
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ data "proxmox_virtual_environment_dns" "first_node_dns_configuration" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `domain` - (Required) The DNS search domain.
|
- `domain` - (Required) The DNS search domain.
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
* `servers` - (Optional) The DNS servers.
|
- `servers` - (Optional) The DNS servers.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -58,34 +58,38 @@ EOF
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `content_type` - (Optional) The content type.
|
- `content_type` - (Optional) The content type.
|
||||||
* `backup`
|
- `backup`
|
||||||
* `iso`
|
- `iso`
|
||||||
* `snippets`
|
- `snippets`
|
||||||
* `vztmpl`
|
- `vztmpl`
|
||||||
* `datastore_id` - (Required) The datastore id.
|
- `datastore_id` - (Required) The datastore id.
|
||||||
* `node_name` - (Required) The node name.
|
- `node_name` - (Required) The node name.
|
||||||
* `source_file` - (Optional) The source file (conflicts with `source_raw`).
|
- `source_file` - (Optional) The source file (conflicts with `source_raw`).
|
||||||
* `checksum` - (Optional) The SHA256 checksum of the source file.
|
- `checksum` - (Optional) The SHA256 checksum of the source file.
|
||||||
* `file_name` - (Optional) The file name to use instead of the source file name.
|
- `file_name` - (Optional) The file name to use instead of the source file
|
||||||
* `insecure` - (Optional) Whether to skip the TLS verification step for HTTPS sources (defaults to `false`).
|
name.
|
||||||
* `path` - (Required) A path to a local file or a URL.
|
- `insecure` - (Optional) Whether to skip the TLS verification step for
|
||||||
* `source_raw` - (Optional) The raw source (conflicts with `source_file`).
|
HTTPSsources (defaults to `false`).
|
||||||
* `data` - (Required) The raw data.
|
- `path` - (Required) A path to a local file or a URL.
|
||||||
* `file_name` - (Required) The file name.
|
- `source_raw` - (Optional) The raw source (conflicts with `source_file`).
|
||||||
* `resize` - (Optional) The number of bytes to resize the file to.
|
- `data` - (Required) The raw data.
|
||||||
|
- `file_name` - (Required) The file name.
|
||||||
|
- `resize` - (Optional) The number of bytes to resize the file to.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `file_modification_date` - The file modification date (RFC 3339).
|
- `file_modification_date` - The file modification date (RFC 3339).
|
||||||
* `file_name` - The file name.
|
- `file_name` - The file name.
|
||||||
* `file_size` - The file size in bytes.
|
- `file_size` - The file size in bytes.
|
||||||
* `file_tag` - The file tag.
|
- `file_tag` - The file tag.
|
||||||
|
|
||||||
## Important Notes
|
## Important Notes
|
||||||
|
|
||||||
The Proxmox VE API endpoint for file uploads does not support chunked transfer encoding, which means that we must first
|
The Proxmox VE API endpoint for file uploads does not support chunked transfer
|
||||||
store the source file as a temporary file locally before uploading it.
|
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
|
You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space
|
||||||
because a multipart payload needs to be created as another temporary file).
|
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
|
## Argument Reference
|
||||||
|
|
||||||
* `acl` - (Optional) The access control list (multiple blocks supported).
|
- `acl` - (Optional) The access control list (multiple blocks supported).
|
||||||
* `path` - The path.
|
- `path` - The path.
|
||||||
* `propagate` - Whether to propagate to child paths.
|
- `propagate` - Whether to propagate to child paths.
|
||||||
* `role_id` - The role identifier.
|
- `role_id` - The role identifier.
|
||||||
* `comment` - (Optional) The group comment.
|
- `comment` - (Optional) The group comment.
|
||||||
* `group_id` - (Required) The group identifier.
|
- `group_id` - (Required) The group identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## 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
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
* `entry` - (Required) A host entry (multiple blocks supported).
|
- `entry` - (Required) A host entry (multiple blocks supported).
|
||||||
* `address` - (Required) The IP address.
|
- `address` - (Required) The IP address.
|
||||||
* `hostnames` - (Required) The hostnames.
|
- `hostnames` - (Required) The hostnames.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `addresses` - The IP addresses.
|
- `addresses` - The IP addresses.
|
||||||
* `digest` - The SHA1 digest.
|
- `digest` - The SHA1 digest.
|
||||||
* `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
|
- `entries` - The host entries (conversion of `addresses` and `hostnames` into
|
||||||
* `hostnames` - The hostnames associated with each of the IP addresses.
|
objects).
|
||||||
|
- `hostnames` - The hostnames associated with each of the IP addresses.
|
||||||
|
@ -22,14 +22,14 @@ resource "proxmox_virtual_environment_pool" "operations_pool" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `comment` - (Optional) The pool comment.
|
- `comment` - (Optional) The pool comment.
|
||||||
* `pool_id` - (Required) The pool identifier.
|
- `pool_id` - (Required) The pool identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `members` - The pool members.
|
- `members` - The pool members.
|
||||||
* `datastore_id` - The datastore identifier.
|
- `datastore_id` - The datastore identifier.
|
||||||
* `id` - The member identifier.
|
- `id` - The member identifier.
|
||||||
* `node_name` - The node name.
|
- `node_name` - The node name.
|
||||||
* `type` - The member type.
|
- `type` - The member type.
|
||||||
* `vm_id` - The virtual machine identifier.
|
- `vm_id` - The virtual machine identifier.
|
||||||
|
@ -25,8 +25,8 @@ resource "proxmox_virtual_environment_role" "operations_monitoring" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `privileges` - (Required) The role privileges.
|
- `privileges` - (Required) The role privileges.
|
||||||
* `role_id` - (Required) The role identifier.
|
- `role_id` - (Required) The role identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ resource "proxmox_virtual_environment_time" "first_node_time" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `node_name` - (Required) A node name.
|
- `node_name` - (Required) A node name.
|
||||||
* `time_zone` - (Required) The node's time zone.
|
- `time_zone` - (Required) The node's time zone.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
* `local_time` - The node's local time.
|
- `local_time` - The node's local time.
|
||||||
* `utc_time` - The node's local time formatted as UTC.
|
- `utc_time` - The node's local time formatted as UTC.
|
||||||
|
@ -37,20 +37,20 @@ resource "proxmox_virtual_environment_role" "operations_monitoring" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `acl` - (Optional) The access control list (multiple blocks supported).
|
- `acl` - (Optional) The access control list (multiple blocks supported).
|
||||||
* `path` - The path.
|
- `path` - The path.
|
||||||
* `propagate` - Whether to propagate to child paths.
|
- `propagate` - Whether to propagate to child paths.
|
||||||
* `role_id` - The role identifier.
|
- `role_id` - The role identifier.
|
||||||
* `comment` - (Optional) The user comment.
|
- `comment` - (Optional) The user comment.
|
||||||
* `email` - (Optional) The user's email address.
|
- `email` - (Optional) The user's email address.
|
||||||
* `enabled` - (Optional) Whether the user account is enabled.
|
- `enabled` - (Optional) Whether the user account is enabled.
|
||||||
* `expiration_date` - (Optional) The user account's expiration date (RFC 3339).
|
- `expiration_date` - (Optional) The user account's expiration date (RFC 3339).
|
||||||
* `first_name` - (Optional) The user's first name.
|
- `first_name` - (Optional) The user's first name.
|
||||||
* `groups` - (Optional) The user's groups.
|
- `groups` - (Optional) The user's groups.
|
||||||
* `keys` - (Optional) The user's keys.
|
- `keys` - (Optional) The user's keys.
|
||||||
* `last_name` - (Optional) The user's last name.
|
- `last_name` - (Optional) The user's last name.
|
||||||
* `password` - (Required) The user's password.
|
- `password` - (Required) The user's password.
|
||||||
* `user_id` - (Required) The user identifier.
|
- `user_id` - (Required) The user identifier.
|
||||||
|
|
||||||
## Attribute Reference
|
## Attribute Reference
|
||||||
|
|
||||||
|
@ -97,251 +97,339 @@ output "ubuntu_vm_public_key" {
|
|||||||
|
|
||||||
## Argument Reference
|
## Argument Reference
|
||||||
|
|
||||||
* `acpi` - (Optional) Whether to enable ACPI (defaults to `true`).
|
- `acpi` - (Optional) Whether to enable ACPI (defaults to `true`).
|
||||||
* `agent` - (Optional) The QEMU agent configuration.
|
- `agent` - (Optional) The QEMU agent configuration.
|
||||||
* `enabled` - (Optional) Whether to enable the QEMU agent (defaults to `false`).
|
- `enabled` - (Optional) Whether to enable the QEMU agent (defaults
|
||||||
* `timeout` - (Optional) The maximum amount of time to wait for data from the QEMU agent to become available (
|
to `false`).
|
||||||
defaults to `15m`).
|
- `timeout` - (Optional) The maximum amount of time to wait for data from
|
||||||
* `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent (defaults to `false`).
|
the
|
||||||
* `type` - (Optional) The QEMU agent interface type (defaults to `virtio`).
|
QEMU agent to become available ( defaults to `15m`).
|
||||||
* `isa` - ISA Serial Port.
|
- `trim` - (Optional) Whether to enable the FSTRIM feature in the QEMU agent
|
||||||
* `virtio` - VirtIO (paravirtualized).
|
(defaults to `false`).
|
||||||
* `audio_device` - (Optional) An audio device.
|
- `type` - (Optional) The QEMU agent interface type (defaults to `virtio`).
|
||||||
* `device` - (Optional) The device (defaults to `intel-hda`).
|
- `isa` - ISA Serial Port.
|
||||||
* `AC97` - Intel 82801AA AC97 Audio.
|
- `virtio` - VirtIO (paravirtualized).
|
||||||
* `ich9-intel-hda` - Intel HD Audio Controller (ich9).
|
- `audio_device` - (Optional) An audio device.
|
||||||
* `intel-hda` - Intel HD Audio.
|
- `device` - (Optional) The device (defaults to `intel-hda`).
|
||||||
* `driver` - (Optional) The driver (defaults to `spice`).
|
- `AC97` - Intel 82801AA AC97 Audio.
|
||||||
* `spice` - Spice.
|
- `ich9-intel-hda` - Intel HD Audio Controller (ich9).
|
||||||
* `enabled` - (Optional) Whether to enable the audio device (defaults to `true`).
|
- `intel-hda` - Intel HD Audio.
|
||||||
* `bios` - (Optional) The BIOS implementation (defaults to `seabios`).
|
- `driver` - (Optional) The driver (defaults to `spice`).
|
||||||
* `ovmf` - OVMF (UEFI).
|
- `spice` - Spice.
|
||||||
* `seabios` - SeaBIOS.
|
- `enabled` - (Optional) Whether to enable the audio device (defaults
|
||||||
* `cdrom` - (Optional) The CDROM configuration.
|
to `true`).
|
||||||
* `enabled` - (Optional) Whether to enable the CDROM drive (defaults to `false`).
|
- `bios` - (Optional) The BIOS implementation (defaults to `seabios`).
|
||||||
* `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as in the physical drive).
|
- `ovmf` - OVMF (UEFI).
|
||||||
* `clone` - (Optional) The cloning configuration.
|
- `seabios` - SeaBIOS.
|
||||||
* `datastore_id` - (Optional) The identifier for the target datastore.
|
- `cdrom` - (Optional) The CDROM configuration.
|
||||||
* `node_name` - (Optional) The name of the source node (leave blank, if equal to the `node_name` argument).
|
- `enabled` - (Optional) Whether to enable the CDROM drive (defaults
|
||||||
* `retries` - (Optional) Number of retries in Proxmox for clone vm. Sometimes Proxmox errors with timeout when
|
to `false`).
|
||||||
creating multiple clones at once.
|
- `file_id` - (Optional) A file ID for an ISO file (defaults to `cdrom` as
|
||||||
* `vm_id` - (Required) The identifier for the source VM.
|
in
|
||||||
* `cpu` - (Optional) The CPU configuration.
|
the physical drive).
|
||||||
* `architecture` - (Optional) The CPU architecture (defaults to `x86_64`).
|
- `clone` - (Optional) The cloning configuration.
|
||||||
* `aarch64` - ARM (64 bit).
|
- `datastore_id` - (Optional) The identifier for the target datastore.
|
||||||
* `x86_64` - x86 (64-bit).
|
- `node_name` - (Optional) The name of the source node (leave blank, if
|
||||||
* `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
equal to the `node_name` argument).
|
||||||
* `flags` - (Optional) The CPU flags.
|
- `retries` - (Optional) Number of retries in Proxmox for clone vm.
|
||||||
* `+aes`/`-aes` - Activate AES instruction set for HW acceleration.
|
Sometimes Proxmox errors with timeout when creating multiple clones at once.
|
||||||
* `+amd-no-ssb`/`-amd-no-ssb` - Notifies guest OS that host is not vulnerable for Spectre on AMD CPUs.
|
- `vm_id` - (Required) The identifier for the source VM.
|
||||||
* `+amd-ssbd`/`-amd-ssbd` - Improves Spectre mitigation performance with AMD CPUs, best used with "virt-ssbd".
|
- `cpu` - (Optional) The CPU configuration.
|
||||||
* `+hv-evmcs`/`-hv-evmcs` - Improve performance for nested virtualization (only supported on Intel CPUs).
|
- `architecture` - (Optional) The CPU architecture (defaults to `x86_64`).
|
||||||
* `+hv-tlbflush`/`-hv-tlbflush` - Improve performance in overcommitted Windows guests (may lead to guest BSOD on
|
- `aarch64` - ARM (64 bit).
|
||||||
old CPUs).
|
- `x86_64` - x86 (64-bit).
|
||||||
* `+ibpb`/`-ibpb` - Allows improved Spectre mitigation on AMD CPUs.
|
- `cores` - (Optional) The number of CPU cores (defaults to `1`).
|
||||||
* `+md-clear`/`-md-clear` - Required to let the guest OS know if MDS is mitigated correctly.
|
- `flags` - (Optional) The CPU flags.
|
||||||
* `+pcid`/`-pcid` - Meltdown fix cost reduction on Westmere, Sandy- and Ivy Bridge Intel CPUs.
|
- `+aes`/`-aes` - Activate AES instruction set for HW acceleration.
|
||||||
* `+pdpe1gb`/`-pdpe1gb` - Allows guest OS to use 1 GB size pages, if host HW supports it.
|
- `+amd-no-ssb`/`-amd-no-ssb` - Notifies guest OS that host is not
|
||||||
* `+spec-ctrl`/`-spec-ctrl` - Allows improved Spectre mitigation with Intel CPUs.
|
vulnerable for Spectre on AMD CPUs.
|
||||||
* `+ssbd`/`-ssbd` - Protection for "Speculative Store Bypass" for Intel models.
|
- `+amd-ssbd`/`-amd-ssbd` - Improves Spectre mitigation performance with
|
||||||
* `+virt-ssbd`/`-virt-ssbd` - Basis for "Speculative Store Bypass" protection for AMD models.
|
AMD CPUs, best used with "virt-ssbd".
|
||||||
* `hotplugged` - (Optional) The number of hotplugged vCPUs (defaults to `0`).
|
- `+hv-evmcs`/`-hv-evmcs` - Improve performance for nested
|
||||||
* `sockets` - (Optional) The number of CPU sockets (defaults to `1`).
|
virtualization (only supported on Intel CPUs).
|
||||||
* `type` - (Optional) The emulated CPU type (defaults to `qemu64`).
|
- `+hv-tlbflush`/`-hv-tlbflush` - Improve performance in overcommitted
|
||||||
* `486` - Intel 486.
|
Windows guests (may lead to guest BSOD on old CPUs).
|
||||||
* `Broadwell`/`Broadwell-IBRS`/`Broadwell-noTSX`/`Broadwell-noTSX-IBRS` - Intel Core Processor (Broadwell, 2014)
|
- `+ibpb`/`-ibpb` - Allows improved Spectre mitigation on AMD CPUs.
|
||||||
.
|
- `+md-clear`/`-md-clear` - Required to let the guest OS know if MDS is
|
||||||
* `Cascadelake-Server` - Intel Xeon 32xx/42xx/52xx/62xx/82xx/92xx (2019).
|
mitigated correctly.
|
||||||
* `Conroe` - Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006).
|
- `+pcid`/`-pcid` - Meltdown fix cost reduction on Westmere, Sandy- and
|
||||||
* `EPYC`/`EPYC-IBPB` - AMD EPYC Processor (2017).
|
Ivy Bridge Intel CPUs.
|
||||||
* `Haswell`/`Haswell-IBRS`/`Haswell-noTSX`/`Haswell-noTSX-IBRS` - Intel Core Processor (Haswell, 2013).
|
- `+pdpe1gb`/`-pdpe1gb` - Allows guest OS to use 1 GB size pages, if
|
||||||
* `IvyBridge`/`IvyBridge-IBRS` - Intel Xeon E3-12xx v2 (Ivy Bridge, 2012).
|
host HW supports it.
|
||||||
* `KnightsMill` - Intel Xeon Phi 72xx (2017).
|
- `+spec-ctrl`/`-spec-ctrl` - Allows improved Spectre mitigation with
|
||||||
* `Nehalem`/`Nehalem-IBRS` - Intel Core i7 9xx (Nehalem Class Core i7, 2008).
|
Intel CPUs.
|
||||||
* `Opteron_G1` - AMD Opteron 240 (Gen 1 Class Opteron, 2004).
|
- `+ssbd`/`-ssbd` - Protection for "Speculative Store Bypass" for Intel
|
||||||
* `Opteron_G2` - AMD Opteron 22xx (Gen 2 Class Opteron, 2006).
|
models.
|
||||||
* `Opteron_G3` - AMD Opteron 23xx (Gen 3 Class Opteron, 2009).
|
- `+virt-ssbd`/`-virt-ssbd` - Basis for "Speculative Store Bypass"
|
||||||
* `Opteron_G4` - AMD Opteron 62xx class CPU (2011).
|
protection for AMD models.
|
||||||
* `Opteron_G5` - AMD Opteron 63xx class CPU (2012).
|
- `hotplugged` - (Optional) The number of hotplugged vCPUs (defaults
|
||||||
* `Penryn` - Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007).
|
to `0`).
|
||||||
* `SandyBridge`/`SandyBridge-IBRS` - Intel Xeon E312xx (Sandy Bridge, 2011).
|
- `sockets` - (Optional) The number of CPU sockets (defaults to `1`).
|
||||||
* `Skylake-Client`/`Skylake-Client-IBRS` - Intel Core Processor (Skylake, 2015).
|
- `type` - (Optional) The emulated CPU type (defaults to `qemu64`).
|
||||||
* `Skylake-Server`/`Skylake-Server-IBRS` - Intel Xeon Processor (Skylake, 2016).
|
- `486` - Intel 486.
|
||||||
* `Westmere`/`Westmere-IBRS` - Intel Westmere E56xx/L56xx/X56xx (Nehalem-C, 2010).
|
- `Broadwell`/`Broadwell-IBRS`/`Broadwell-noTSX`/`Broadwell-noTSX-IBRS`
|
||||||
* `athlon` - AMD Athlon.
|
- Intel Core Processor (Broadwell, 2014).
|
||||||
* `core2duo` - Intel Core 2 Duo.
|
- `Cascadelake-Server` - Intel Xeon 32xx/42xx/52xx/62xx/82xx/92xx (
|
||||||
* `coreduo` - Intel Core Duo.
|
2019).
|
||||||
* `host` - Host pass-through.
|
- `Conroe` - Intel Celeron_4x0 (Conroe/Merom Class Core 2, 2006).
|
||||||
* `kvm32`/`kvm64` - Common KVM processor (32 & 64 bit variants).
|
- `EPYC`/`EPYC-IBPB` - AMD EPYC Processor (2017).
|
||||||
* `max` - Maximum amount of features from host CPU.
|
- `Haswell`/`Haswell-IBRS`/`Haswell-noTSX`/`Haswell-noTSX-IBRS` - Intel
|
||||||
* `pentium` - Intel Pentium (1993).
|
Core Processor (Haswell, 2013).
|
||||||
* `pentium2` - Intel Pentium 2 (1997-1999).
|
- `IvyBridge`/`IvyBridge-IBRS` - Intel Xeon E3-12xx v2 (Ivy Bridge,
|
||||||
* `pentium3` - Intel Pentium 3 (1999-2001).
|
2012).
|
||||||
* `phenom` - AMD Phenom (2010).
|
- `KnightsMill` - Intel Xeon Phi 72xx (2017).
|
||||||
* `qemu32`/`qemu64` - QEMU Virtual CPU version 2.5+ (32 & 64 bit variants).
|
- `Nehalem`/`Nehalem-IBRS` - Intel Core i7 9xx (Nehalem Class Core i7,
|
||||||
* `units` - (Optional) The CPU units (defaults to `1024`).
|
2008).
|
||||||
* `description` - (Optional) The description.
|
- `Opteron_G1` - AMD Opteron 240 (Gen 1 Class Opteron, 2004).
|
||||||
* `disk` - (Optional) A disk (multiple blocks supported).
|
- `Opteron_G2` - AMD Opteron 22xx (Gen 2 Class Opteron, 2006).
|
||||||
* `datastore_id` - (Optional) The identifier for the datastore to create the disk in (defaults to `local-lvm`).
|
- `Opteron_G3` - AMD Opteron 23xx (Gen 3 Class Opteron, 2009).
|
||||||
* `discard` - (Optional) Whether to pass discard/trim requests to the underlying storage. Supported values are `on`/`ignore` (defaults to `ignore`)
|
- `Opteron_G4` - AMD Opteron 62xx class CPU (2011).
|
||||||
* `file_format` - (Optional) The file format (defaults to `qcow2`).
|
- `Opteron_G5` - AMD Opteron 63xx class CPU (2012).
|
||||||
* `qcow2` - QEMU Disk Image v2.
|
- `Penryn` - Intel Core 2 Duo P9xxx (Penryn Class Core 2, 2007).
|
||||||
* `raw` - Raw Disk Image.
|
- `SandyBridge`/`SandyBridge-IBRS` - Intel Xeon E312xx (Sandy Bridge,
|
||||||
* `vmdk` - VMware Disk Image.
|
2011).
|
||||||
* `file_id` - (Optional) The file ID for a disk image (experimental - might cause high CPU utilization during
|
- `Skylake-Client`/`Skylake-Client-IBRS` - Intel Core Processor (
|
||||||
import, especially with large disk images).
|
Skylake, 2015).
|
||||||
* `interface` - (Required) The disk interface for Proxmox, currently scsi, sata and virtio are supported.
|
- `Skylake-Server`/`Skylake-Server-IBRS` - Intel Xeon Processor (
|
||||||
* `iothread` - (Optional) Whether to use iothreads for this disk (defaults to `false`).
|
Skylake, 2016).
|
||||||
* `size` - (Optional) The disk size in gigabytes (defaults to `8`).
|
- `Westmere`/`Westmere-IBRS` - Intel Westmere E56xx/L56xx/X56xx (
|
||||||
* `speed` - (Optional) The speed limits.
|
Nehalem-C, 2010).
|
||||||
* `read` - (Optional) The maximum read speed in megabytes per second.
|
- `athlon` - AMD Athlon.
|
||||||
* `read_burstable` - (Optional) The maximum burstable read speed in megabytes per second.
|
- `core2duo` - Intel Core 2 Duo.
|
||||||
* `write` - (Optional) The maximum write speed in megabytes per second.
|
- `coreduo` - Intel Core Duo.
|
||||||
* `write_burstable` - (Optional) The maximum burstable write speed in megabytes per second.
|
- `host` - Host pass-through.
|
||||||
* `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.
|
- `kvm32`/`kvm64` - Common KVM processor (32 & 64 bit variants).
|
||||||
* `hostpci` - (Optional) A host PCI device mapping (multiple blocks supported).
|
- `max` - Maximum amount of features from host CPU.
|
||||||
* `device` - (Required) The PCI device name for Proxmox, in form of `hostpciX` where `X` is a sequential number from 0 to 3.
|
- `pentium` - Intel Pentium (1993).
|
||||||
* `id` - (Required) The PCI device ID.
|
- `pentium2` - Intel Pentium 2 (1997-1999).
|
||||||
* `mdev` - (Optional) The mediated device ID to use.
|
- `pentium3` - Intel Pentium 3 (1999-2001).
|
||||||
* `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.
|
- `phenom` - AMD Phenom (2010).
|
||||||
* `rombar` - (Optional) Makes the firmware ROM visible for the VM (defaults to `true`).
|
- `qemu32`/`qemu64` - QEMU Virtual CPU version 2.5+ (32 & 64 bit
|
||||||
* `rom_file` - (Optional) A path to a ROM file for the device to use. This is a relative path under `/usr/share/kvm/`.
|
variants).
|
||||||
* `xvga` - (Optional) Marks the PCI(e) device as the primary GPU of the VM. With this enabled the `vga` configuration argument will be ignored.
|
- `units` - (Optional) The CPU units (defaults to `1024`).
|
||||||
* `initialization` - (Optional) The cloud-init configuration.
|
- `description` - (Optional) The description.
|
||||||
* `datastore_id` - (Optional) The identifier for the datastore to create the cloud-init disk in (defaults
|
- `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`).
|
to `local-lvm`).
|
||||||
* `dns` - (Optional) The DNS configuration.
|
- `dns` - (Optional) The DNS configuration.
|
||||||
* `domain` - (Optional) The DNS search domain.
|
- `domain` - (Optional) The DNS search domain.
|
||||||
* `server` - (Optional) The DNS server.
|
- `server` - (Optional) The DNS server.
|
||||||
* `ip_config` - (Optional) The IP configuration (one block per network device).
|
- `ip_config` - (Optional) The IP configuration (one block per network
|
||||||
* `ipv4` - (Optional) The IPv4 configuration.
|
device).
|
||||||
* `address` - (Optional) The IPv4 address (use `dhcp` for autodiscovery).
|
- `ipv4` - (Optional) The IPv4 configuration.
|
||||||
* `gateway` - (Optional) The IPv4 gateway (must be omitted when `dhcp` is used as the address).
|
- `address` - (Optional) The IPv4 address (use `dhcp` for
|
||||||
* `ipv6` - (Optional) The IPv4 configuration.
|
autodiscovery).
|
||||||
* `address` - (Optional) The IPv6 address (use `dhcp` for autodiscovery).
|
- `gateway` - (Optional) The IPv4 gateway (must be omitted
|
||||||
* `gateway` - (Optional) The IPv6 gateway (must be omitted when `dhcp` is used as the address).
|
when `dhcp` is used as the address).
|
||||||
* `user_account` - (Optional) The user account configuration (conflicts with `user_data_file_id`).
|
- `ipv6` - (Optional) The IPv4 configuration.
|
||||||
* `keys` - (Optional) The SSH keys.
|
- `address` - (Optional) The IPv6 address (use `dhcp` for
|
||||||
* `password` - (Optional) The SSH password.
|
autodiscovery).
|
||||||
* `username` - (Optional) The SSH username.
|
- `gateway` - (Optional) The IPv6 gateway (must be omitted
|
||||||
* `network_data_file_id` - (Optional) The identifier for a file containing network configuration data passed to the
|
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`).
|
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`).
|
with `user_account`).
|
||||||
* `vendor_data_file_id` - (Optional) The identifier for a file containing all vendor data passed to the VM via cloud-init.
|
- `vendor_data_file_id` - (Optional) The identifier for a file containing
|
||||||
* `keyboard_layout` - (Optional) The keyboard layout (defaults to `en-us`).
|
all vendor data passed to the VM via cloud-init.
|
||||||
* `da` - Danish.
|
- `keyboard_layout` - (Optional) The keyboard layout (defaults to `en-us`).
|
||||||
* `de` - German.
|
- `da` - Danish.
|
||||||
* `de-ch` - Swiss German.
|
- `de` - German.
|
||||||
* `en-gb` - British English.
|
- `de-ch` - Swiss German.
|
||||||
* `en-us` - American English.
|
- `en-gb` - British English.
|
||||||
* `es` - Spanish.
|
- `en-us` - American English.
|
||||||
* `fi` - Finnish.
|
- `es` - Spanish.
|
||||||
* `fr` - French.
|
- `fi` - Finnish.
|
||||||
* `fr-be` - Belgian French.
|
- `fr` - French.
|
||||||
* `fr-ca` - French Canadian.
|
- `fr-be` - Belgian French.
|
||||||
* `fr-ch` - Swish French.
|
- `fr-ca` - French Canadian.
|
||||||
* `hu` - Hungarian.
|
- `fr-ch` - Swish French.
|
||||||
* `is` - Icelandic.
|
- `hu` - Hungarian.
|
||||||
* `it` - Italian.
|
- `is` - Icelandic.
|
||||||
* `ja` - Japanese.
|
- `it` - Italian.
|
||||||
* `lt` - Lithuanian.
|
- `ja` - Japanese.
|
||||||
* `mk` - Macedonian.
|
- `lt` - Lithuanian.
|
||||||
* `nl` - Dutch.
|
- `mk` - Macedonian.
|
||||||
* `no` - Norwegian.
|
- `nl` - Dutch.
|
||||||
* `pl` - Polish.
|
- `no` - Norwegian.
|
||||||
* `pt` - Portuguese.
|
- `pl` - Polish.
|
||||||
* `pt-br` - Brazilian Portuguese.
|
- `pt` - Portuguese.
|
||||||
* `sl` - Slovenian.
|
- `pt-br` - Brazilian Portuguese.
|
||||||
* `sv` - Swedish.
|
- `sl` - Slovenian.
|
||||||
* `tr` - Turkish.
|
- `sv` - Swedish.
|
||||||
* `kvm_arguments` - (Optional) Arbitrary arguments passed to kvm.
|
- `tr` - Turkish.
|
||||||
|
- `kvm_arguments` - (Optional) Arbitrary arguments passed to kvm.
|
||||||
* `machine` - (Optional) The VM machine type (defaults to `i440fx`).
|
* `machine` - (Optional) The VM machine type (defaults to `i440fx`).
|
||||||
* `i440fx` - Standard PC (i440FX + PIIX, 1996).
|
- `i440fx` - Standard PC (i440FX + PIIX, 1996).
|
||||||
* `q35` - Standard PC (Q35 + ICH9, 2009).
|
- `q35` - Standard PC (Q35 + ICH9, 2009).
|
||||||
* `memory` - (Optional) The memory configuration.
|
- `memory` - (Optional) The memory configuration.
|
||||||
* `dedicated` - (Optional) The dedicated memory in megabytes (defaults to `512`).
|
- `dedicated` - (Optional) The dedicated memory in megabytes (defaults
|
||||||
* `floating` - (Optional) The floating memory in megabytes (defaults to `0`).
|
to `512`).
|
||||||
* `shared` - (Optional) The shared memory in megabytes (defaults to `0`).
|
- `floating` - (Optional) The floating memory in megabytes (defaults
|
||||||
* `name` - (Optional) The virtual machine name.
|
to `0`).
|
||||||
* `network_device` - (Optional) A network device (multiple blocks supported).
|
- `shared` - (Optional) The shared memory in megabytes (defaults to `0`).
|
||||||
* `bridge` - (Optional) The name of the network bridge (defaults to `vmbr0`).
|
- `name` - (Optional) The virtual machine name.
|
||||||
* `enabled` - (Optional) Whether to enable the network device (defaults to `true`).
|
- `network_device` - (Optional) A network device (multiple blocks supported).
|
||||||
* `mac_address` - (Optional) The MAC address.
|
- `bridge` - (Optional) The name of the network bridge (defaults
|
||||||
* `model` - (Optional) The network device model (defaults to `virtio`).
|
to `vmbr0`).
|
||||||
* `e1000` - Intel E1000.
|
- `enabled` - (Optional) Whether to enable the network device (defaults
|
||||||
* `rtl8139` - Realtek RTL8139.
|
to `true`).
|
||||||
* `virtio` - VirtIO (paravirtualized).
|
- `mac_address` - (Optional) The MAC address.
|
||||||
* `vmxnet3` - VMware vmxnet3.
|
- `model` - (Optional) The network device model (defaults to `virtio`).
|
||||||
* `mtu` - (Optional) Force MTU, for VirtIO only. Set to 1 to use the bridge MTU. Cannot be larger than the bridge MTU.
|
- `e1000` - Intel E1000.
|
||||||
* `rate_limit` - (Optional) The rate limit in megabytes per second.
|
- `rtl8139` - Realtek RTL8139.
|
||||||
* `vlan_id` - (Optional) The VLAN identifier.
|
- `virtio` - VirtIO (paravirtualized).
|
||||||
* `node_name` - (Required) The name of the node to assign the virtual machine to.
|
- `vmxnet3` - VMware vmxnet3.
|
||||||
* `on_boot` - (Optional) Specifies whether a VM will be started during system boot. (defaults to `true`)
|
- `mtu` - (Optional) Force MTU, for VirtIO only. Set to 1 to use the bridge
|
||||||
* `operating_system` - (Optional) The Operating System configuration.
|
MTU. Cannot be larger than the bridge MTU.
|
||||||
* `type` - (Optional) The type (defaults to `other`).
|
- `rate_limit` - (Optional) The rate limit in megabytes per second.
|
||||||
* `l24` - Linux Kernel 2.4.
|
- `vlan_id` - (Optional) The VLAN identifier.
|
||||||
* `l26` - Linux Kernel 2.6 - 5.X.
|
- `node_name` - (Required) The name of the node to assign the virtual machine
|
||||||
* `other` - Unspecified OS.
|
to.
|
||||||
* `solaris` - OpenIndiania, OpenSolaris og Solaris Kernel.
|
- `on_boot` - (Optional) Specifies whether a VM will be started during system
|
||||||
* `w2k` - Windows 2000.
|
boot. (defaults to `true`)
|
||||||
* `w2k3` - Windows 2003.
|
- `operating_system` - (Optional) The Operating System configuration.
|
||||||
* `w2k8` - Windows 2008.
|
- `type` - (Optional) The type (defaults to `other`).
|
||||||
* `win7` - Windows 7.
|
- `l24` - Linux Kernel 2.4.
|
||||||
* `win8` - Windows 8, 2012 or 2012 R2.
|
- `l26` - Linux Kernel 2.6 - 5.X.
|
||||||
* `win10` - Windows 10 or 2016.
|
- `other` - Unspecified OS.
|
||||||
* `wvista` - Windows Vista.
|
- `solaris` - OpenIndiania, OpenSolaris og Solaris Kernel.
|
||||||
* `wxp` - Windows XP.
|
- `w2k` - Windows 2000.
|
||||||
* `pool_id` - (Optional) The identifier for a pool to assign the virtual machine to.
|
- `w2k3` - Windows 2003.
|
||||||
* `reboot` - (Optional) Reboot the VM after initial creation. (defaults to `false`)
|
- `w2k8` - Windows 2008.
|
||||||
* `serial_device` - (Optional) A serial device (multiple blocks supported).
|
- `win7` - Windows 7.
|
||||||
* `device` - (Optional) The device (defaults to `socket`).
|
- `win8` - Windows 8, 2012 or 2012 R2.
|
||||||
* `/dev/*` - A host serial device.
|
- `win10` - Windows 10 or 2016.
|
||||||
* `socket` - A unix socket.
|
- `wvista` - Windows Vista.
|
||||||
* `started` - (Optional) Whether to start the virtual machine (defaults to `true`).
|
- `wxp` - Windows XP.
|
||||||
* `tablet_device` - (Optional) Whether to enable the USB tablet device (defaults to `true`).
|
- `pool_id` - (Optional) The identifier for a pool to assign the virtual machine
|
||||||
* `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.
|
to.
|
||||||
* `template` - (Optional) Whether to create a template (defaults to `false`).
|
- `reboot` - (Optional) Reboot the VM after initial creation. (defaults
|
||||||
* `timeout_clone` - (Optional) Timeout for cloning a VM in seconds (defaults to 1800).
|
to `false`)
|
||||||
* `timeout_move_disk` - (Optional) Timeout for moving the disk of a VM in seconds (defaults to 1800).
|
- `serial_device` - (Optional) A serial device (multiple blocks supported).
|
||||||
* `timeout_reboot` - (Optional) Timeout for rebooting a VM in seconds (defaults to 1800).
|
- `device` - (Optional) The device (defaults to `socket`).
|
||||||
* `timeout_shutdown_vm` - (Optional) Timeout for shutting down a VM in seconds (defaults to 1800).
|
- `/dev/*` - A host serial device.
|
||||||
* `timeout_start_vm` - (Optional) Timeout for starting a VM in seconds (defaults to 1800).
|
- `socket` - A unix socket.
|
||||||
* `timeout_stop_vm` - (Optional) Timeout for stopping a VM in seconds (defaults to 300).
|
- `started` - (Optional) Whether to start the virtual machine (defaults
|
||||||
* `vga` - (Optional) The VGA configuration.
|
to `true`).
|
||||||
* `enabled` - (Optional) Whether to enable the VGA device (defaults to `true`).
|
- `tablet_device` - (Optional) Whether to enable the USB tablet device (defaults
|
||||||
* `memory` - (Optional) The VGA memory in megabytes (defaults to `16`).
|
to `true`).
|
||||||
* `type` - (Optional) The VGA type (defaults to `std`).
|
- `tags` - (Optional) A list of tags of the VM. This is only meta information (
|
||||||
* `cirrus` - Cirrus (deprecated since QEMU 2.2).
|
defaults to `[]`). Note: Proxmox always sorts the VM tags. If the list in
|
||||||
* `qxl` - SPICE.
|
template is not sorted, then Proxmox will always report a difference on the
|
||||||
* `qxl2` - SPICE Dual Monitor.
|
resource. You may use the `ignore_changes` lifecycle meta-argument to ignore
|
||||||
* `qxl3` - SPICE Triple Monitor.
|
changes to this attribute.
|
||||||
* `qxl4` - SPICE Quad Monitor.
|
- `template` - (Optional) Whether to create a template (defaults to `false`).
|
||||||
* `serial0` - Serial Terminal 0.
|
- `timeout_clone` - (Optional) Timeout for cloning a VM in seconds (defaults to
|
||||||
* `serial1` - Serial Terminal 1.
|
1800).
|
||||||
* `serial2` - Serial Terminal 2.
|
- `timeout_move_disk` - (Optional) Timeout for moving the disk of a VM in
|
||||||
* `serial3` - Serial Terminal 3.
|
seconds (defaults to 1800).
|
||||||
* `std` - Standard VGA.
|
- `timeout_reboot` - (Optional) Timeout for rebooting a VM in seconds (defaults
|
||||||
* `virtio` - VirtIO-GPU.
|
to 1800).
|
||||||
* `vmware` - VMware Compatible.
|
- `timeout_shutdown_vm` - (Optional) Timeout for shutting down a VM in seconds (
|
||||||
* `vm_id` - (Optional) The VM identifier.
|
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
|
## Attribute Reference
|
||||||
|
|
||||||
* `ipv4_addresses` - The IPv4 addresses per network interface published by the QEMU agent (empty list
|
- `ipv4_addresses` - The IPv4 addresses per network interface published by the
|
||||||
when `agent.enabled` is `false`)
|
QEMU agent (empty list when `agent.enabled` is `false`)
|
||||||
* `ipv6_addresses` - The IPv6 addresses per network interface published by the QEMU agent (empty list
|
- `ipv6_addresses` - The IPv6 addresses per network interface published by the
|
||||||
when `agent.enabled` is `false`)
|
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
|
- `mac_addresses` - The MAC addresses published by the QEMU agent with fallback
|
||||||
the agent is disabled
|
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`
|
- `network_interface_names` - The network interface names published by the QEMU
|
||||||
is `false`)
|
agent (empty list when `agent.enabled` is `false`)
|
||||||
|
|
||||||
## Important Notes
|
## Important Notes
|
||||||
|
|
||||||
When cloning an existing virtual machine, whether it's a template or not, the resource will only detect changes to the
|
When cloning an existing virtual machine, whether it's a template or not, the
|
||||||
arguments which are not set to their default values.
|
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
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -82,7 +81,6 @@ func (r *CustomInt) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
i, err := strconv.ParseInt(s, 10, 32)
|
i, err := strconv.ParseInt(s, 10, 32)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -104,7 +102,6 @@ func (r *CustomLineBreakSeparatedList) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -130,7 +127,6 @@ func (r *CustomPrivileges) UnmarshalJSON(b []byte) error {
|
|||||||
var privileges interface{}
|
var privileges interface{}
|
||||||
|
|
||||||
err := json.Unmarshal(b, &privileges)
|
err := json.Unmarshal(b, &privileges)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -167,7 +163,6 @@ func (r CustomTimestamp) MarshalJSON() ([]byte, error) {
|
|||||||
func (r *CustomTimestamp) UnmarshalJSON(b []byte) error {
|
func (r *CustomTimestamp) UnmarshalJSON(b []byte) error {
|
||||||
s := string(b)
|
s := string(b)
|
||||||
i, err := strconv.ParseInt(s, 10, 64)
|
i, err := strconv.ParseInt(s, 10, 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetACL retrieves the access control list.
|
// 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{}
|
resBody := &VirtualEnvironmentACLGetResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "access/acl", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "access/acl", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -31,6 +32,9 @@ func (c *VirtualEnvironmentClient) GetACL(ctx context.Context) ([]*VirtualEnviro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateACL updates the access control list.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, "access/acl", d, nil)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package proxmox
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -19,7 +20,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Authenticate authenticates against the specified endpoint.
|
// 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 {
|
if c.authenticationData != nil && !reset {
|
||||||
return nil
|
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 {
|
if err != nil {
|
||||||
return errors.New("failed to create authentication request")
|
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")
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
res, err := c.httpClient.Do(req)
|
res, err := c.httpClient.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("failed to retrieve authentication response")
|
return errors.New("failed to retrieve authentication response")
|
||||||
}
|
}
|
||||||
@ -73,7 +77,9 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if resBody.Data.CSRFPreventionToken == nil {
|
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 {
|
if resBody.Data.Ticket == nil {
|
||||||
@ -90,9 +96,8 @@ func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AuthenticateRequest adds authentication data to a new request.
|
// AuthenticateRequest adds authentication data to a new request.
|
||||||
func (c *VirtualEnvironmentClient) AuthenticateRequest(req *http.Request) error {
|
func (c *VirtualEnvironmentClient) AuthenticateRequest(ctx context.Context, req *http.Request) error {
|
||||||
err := c.Authenticate(false)
|
err := c.Authenticate(ctx, false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,33 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// DeleteCertificate deletes the custom certificate for a node.
|
// DeleteCertificate deletes the custom certificate for a node.
|
||||||
func (c *VirtualEnvironmentClient) DeleteCertificate(ctx context.Context, nodeName string, d *VirtualEnvironmentCertificateDeleteRequestBody) error {
|
func (c *VirtualEnvironmentClient) DeleteCertificate(
|
||||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -33,6 +51,16 @@ func (c *VirtualEnvironmentClient) ListCertificates(ctx context.Context, nodeNam
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCertificate updates the custom certificate for a node.
|
// UpdateCertificate updates the custom certificate for a node.
|
||||||
func (c *VirtualEnvironmentClient) UpdateCertificate(ctx context.Context, nodeName string, d *VirtualEnvironmentCertificateUpdateRequestBody) error {
|
func (c *VirtualEnvironmentClient) UpdateCertificate(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
|
ctx context.Context,
|
||||||
|
nodeName string,
|
||||||
|
d *VirtualEnvironmentCertificateUpdateRequestBody,
|
||||||
|
) error {
|
||||||
|
return c.DoRequest(
|
||||||
|
ctx,
|
||||||
|
hmPOST,
|
||||||
|
fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)),
|
||||||
|
d,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -22,23 +22,33 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewVirtualEnvironmentClient creates and initializes a VirtualEnvironmentClient instance.
|
// 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)
|
u, err := url.ParseRequestURI(endpoint)
|
||||||
|
|
||||||
if err != nil {
|
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" {
|
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 == "" {
|
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 == "" {
|
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
|
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.
|
// 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 reqBodyReader io.Reader
|
||||||
var reqContentLength *int64
|
var reqContentLength *int64
|
||||||
|
|
||||||
@ -101,7 +115,6 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
v, err := query.Values(requestBody)
|
v, err := query.Values(requestBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fErr := fmt.Errorf("failed to encode HTTP %s request (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
fErr := fmt.Errorf("failed to encode HTTP %s request (path: %s) - Reason: %s", method, modifiedPath, err.Error())
|
||||||
tflog.Warn(ctx, fErr.Error())
|
tflog.Warn(ctx, fErr.Error())
|
||||||
@ -133,10 +146,19 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
|||||||
reqBodyReader = new(bytes.Buffer)
|
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 {
|
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())
|
tflog.Warn(ctx, fErr.Error())
|
||||||
return fErr
|
return fErr
|
||||||
}
|
}
|
||||||
@ -151,7 +173,7 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
|||||||
req.Header.Add("Content-Type", reqBodyType)
|
req.Header.Add("Content-Type", reqBodyType)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.AuthenticateRequest(req)
|
err = c.AuthenticateRequest(ctx, req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tflog.Warn(ctx, err.Error())
|
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)
|
res, err := c.httpClient.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
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())
|
tflog.Warn(ctx, fErr.Error())
|
||||||
return fErr
|
return fErr
|
||||||
}
|
}
|
||||||
@ -185,7 +211,12 @@ func (c *VirtualEnvironmentClient) DoRequest(ctx context.Context, method, path s
|
|||||||
err = json.NewDecoder(res.Body).Decode(responseBody)
|
err = json.NewDecoder(res.Body).Decode(responseBody)
|
||||||
|
|
||||||
if err != nil {
|
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())
|
tflog.Warn(ctx, fErr.Error())
|
||||||
return fErr
|
return fErr
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ func (c *VirtualEnvironmentClient) GetClusterNextID(ctx context.Context, vmID *i
|
|||||||
|
|
||||||
resBody := &VirtualEnvironmentClusterNextIDResponseBody{}
|
resBody := &VirtualEnvironmentClusterNextIDResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "cluster/nextid", reqBody, resBody)
|
err := c.DoRequest(ctx, hmGET, "cluster/nextid", reqBody, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -13,20 +13,37 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateAlias create an alias
|
// 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)
|
return c.DoRequest(ctx, hmPOST, "cluster/firewall/aliases", d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAlias delete an alias
|
// DeleteAlias delete an alias
|
||||||
func (c *VirtualEnvironmentClient) DeleteAlias(ctx context.Context, id string) error {
|
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
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -39,10 +56,11 @@ func (c *VirtualEnvironmentClient) GetAlias(ctx context.Context, id string) (*Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListAliases retrieves a list of aliases.
|
// 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{}
|
resBody := &VirtualEnvironmentClusterAliasListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "cluster/firewall/aliases", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "cluster/firewall/aliases", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -59,6 +77,16 @@ func (c *VirtualEnvironmentClient) ListAliases(ctx context.Context) ([]*VirtualE
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAlias updates an alias.
|
// UpdateAlias updates an alias.
|
||||||
func (c *VirtualEnvironmentClient) UpdateAlias(ctx context.Context, id string, d *VirtualEnvironmentClusterAliasUpdateRequestBody) error {
|
func (c *VirtualEnvironmentClient) UpdateAlias(
|
||||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), d, nil)
|
ctx context.Context,
|
||||||
|
id string,
|
||||||
|
d *VirtualEnvironmentClusterAliasUpdateRequestBody,
|
||||||
|
) error {
|
||||||
|
return c.DoRequest(
|
||||||
|
ctx,
|
||||||
|
hmPUT,
|
||||||
|
fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)),
|
||||||
|
d,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
@ -13,35 +13,75 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateIPSet create an IPSet
|
// 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)
|
return c.DoRequest(ctx, hmPOST, "cluster/firewall/ipset", d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddCIDRToIPSet adds IP or Network to IPSet
|
// AddCIDRToIPSet adds IP or Network to IPSet
|
||||||
func (c *VirtualEnvironmentClient) AddCIDRToIPSet(ctx context.Context, id string, d *VirtualEnvironmentClusterIPSetGetResponseData) error {
|
func (c *VirtualEnvironmentClient) AddCIDRToIPSet(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("cluster/firewall/ipset/%s/", url.PathEscape(id)), d, nil)
|
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.
|
// 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)
|
return c.DoRequest(ctx, hmPOST, "cluster/firewall/ipset/", d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteIPSet delete an IPSet
|
// DeleteIPSet delete an IPSet
|
||||||
func (c *VirtualEnvironmentClient) DeleteIPSet(ctx context.Context, id string) error {
|
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.
|
// DeleteIPSetContent remove IP or Network from IPSet.
|
||||||
func (c *VirtualEnvironmentClient) DeleteIPSetContent(ctx context.Context, id string, cidr string) error {
|
func (c *VirtualEnvironmentClient) DeleteIPSetContent(
|
||||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("cluster/firewall/ipset/%s/%s", url.PathEscape(id), url.PathEscape(cidr)), nil, nil)
|
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
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -54,10 +94,11 @@ func (c *VirtualEnvironmentClient) GetListIPSetContent(ctx context.Context, id s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetListIPSets retrieves list of IPSets.
|
// 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{}
|
resBody := &VirtualEnvironmentClusterIPSetListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "cluster/firewall/ipset", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "cluster/firewall/ipset", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -14,25 +14,59 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CloneContainer clones a container.
|
// CloneContainer clones a container.
|
||||||
func (c *VirtualEnvironmentClient) CloneContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerCloneRequestBody) error {
|
func (c *VirtualEnvironmentClient) CloneContainer(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/clone", url.PathEscape(nodeName), vmID), d, nil)
|
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.
|
// 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)
|
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc", url.PathEscape(nodeName)), d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteContainer deletes a container.
|
// DeleteContainer deletes a container.
|
||||||
func (c *VirtualEnvironmentClient) DeleteContainer(ctx context.Context, nodeName string, vmID int) error {
|
func (c *VirtualEnvironmentClient) DeleteContainer(
|
||||||
return c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/lxc/%d", url.PathEscape(nodeName), vmID), nil, nil)
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -45,10 +79,19 @@ func (c *VirtualEnvironmentClient) GetContainer(ctx context.Context, nodeName st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetContainerStatus retrieves the status for a container.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -61,32 +104,94 @@ func (c *VirtualEnvironmentClient) GetContainerStatus(ctx context.Context, nodeN
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RebootContainer reboots a container.
|
// RebootContainer reboots a container.
|
||||||
func (c *VirtualEnvironmentClient) RebootContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerRebootRequestBody) error {
|
func (c *VirtualEnvironmentClient) RebootContainer(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/reboot", url.PathEscape(nodeName), vmID), d, nil)
|
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.
|
// ShutdownContainer shuts down a container.
|
||||||
func (c *VirtualEnvironmentClient) ShutdownContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerShutdownRequestBody) error {
|
func (c *VirtualEnvironmentClient) ShutdownContainer(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/shutdown", url.PathEscape(nodeName), vmID), d, nil)
|
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.
|
// StartContainer starts a container.
|
||||||
func (c *VirtualEnvironmentClient) StartContainer(ctx context.Context, nodeName string, vmID int) error {
|
func (c *VirtualEnvironmentClient) StartContainer(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/start", url.PathEscape(nodeName), vmID), nil, nil)
|
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.
|
// StopContainer stops a container immediately.
|
||||||
func (c *VirtualEnvironmentClient) StopContainer(ctx context.Context, nodeName string, vmID int) error {
|
func (c *VirtualEnvironmentClient) StopContainer(
|
||||||
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/lxc/%d/status/stop", url.PathEscape(nodeName), vmID), nil, nil)
|
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.
|
// UpdateContainer updates a container.
|
||||||
func (c *VirtualEnvironmentClient) UpdateContainer(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentContainerUpdateRequestBody) error {
|
func (c *VirtualEnvironmentClient) UpdateContainer(
|
||||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/lxc/%d/config", url.PathEscape(nodeName), vmID), d, nil)
|
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.
|
// 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)
|
state = strings.ToLower(state)
|
||||||
|
|
||||||
timeDelay := int64(delay)
|
timeDelay := int64(delay)
|
||||||
@ -97,7 +202,6 @@ func (c *VirtualEnvironmentClient) WaitForContainerState(ctx context.Context, no
|
|||||||
for timeElapsed.Seconds() < timeMax {
|
for timeElapsed.Seconds() < timeMax {
|
||||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||||
data, err := c.GetContainerStatus(ctx, nodeName, vmID)
|
data, err := c.GetContainerStatus(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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.
|
// 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)
|
timeDelay := int64(delay)
|
||||||
timeMax := float64(timeout)
|
timeMax := float64(timeout)
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
|
@ -332,7 +332,10 @@ func (r VirtualEnvironmentContainerCustomMountPoint) EncodeValues(key string, v
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EncodeValues converts a VirtualEnvironmentContainerCustomMountPointArray array to multiple URL values.
|
// 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 {
|
for i, d := range r {
|
||||||
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -344,7 +347,10 @@ func (r VirtualEnvironmentContainerCustomMountPointArray) EncodeValues(key strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EncodeValues converts a VirtualEnvironmentContainerCustomNetworkInterface struct to a URL vlaue.
|
// 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
|
var values []string
|
||||||
|
|
||||||
if r.Bridge != nil {
|
if r.Bridge != nil {
|
||||||
@ -415,7 +421,10 @@ func (r VirtualEnvironmentContainerCustomNetworkInterface) EncodeValues(key stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EncodeValues converts a VirtualEnvironmentContainerCustomNetworkInterfaceArray array to multiple URL values.
|
// 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 {
|
for i, d := range r {
|
||||||
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
err := d.EncodeValues(fmt.Sprintf("%s%d", key, i), v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -497,7 +506,10 @@ func (r VirtualEnvironmentContainerCustomSSHKeys) EncodeValues(key string, v *ur
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EncodeValues converts a VirtualEnvironmentContainerCustomStartupBehavior struct to a URL vlaue.
|
// 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
|
var values []string
|
||||||
|
|
||||||
if r.Down != nil {
|
if r.Down != nil {
|
||||||
@ -524,7 +536,6 @@ func (r *VirtualEnvironmentContainerCustomFeatures) UnmarshalJSON(b []byte) erro
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -565,7 +576,6 @@ func (r *VirtualEnvironmentContainerCustomMountPoint) UnmarshalJSON(b []byte) er
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -621,7 +631,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -652,7 +661,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
|||||||
r.MACAddress = &v[1]
|
r.MACAddress = &v[1]
|
||||||
case "mtu":
|
case "mtu":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -662,7 +670,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
|||||||
r.Name = v[1]
|
r.Name = v[1]
|
||||||
case "rate":
|
case "rate":
|
||||||
fv, err := strconv.ParseFloat(v[1], 64)
|
fv, err := strconv.ParseFloat(v[1], 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -670,7 +677,6 @@ func (r *VirtualEnvironmentContainerCustomNetworkInterface) UnmarshalJSON(b []by
|
|||||||
r.RateLimit = &fv
|
r.RateLimit = &fv
|
||||||
case "tag":
|
case "tag":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -708,7 +714,6 @@ func (r *VirtualEnvironmentContainerCustomRootFS) UnmarshalJSON(b []byte) error
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -759,7 +764,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -773,7 +777,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
|||||||
switch v[0] {
|
switch v[0] {
|
||||||
case "down":
|
case "down":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -781,7 +784,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
|||||||
r.Down = &iv
|
r.Down = &iv
|
||||||
case "order":
|
case "order":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -789,7 +791,6 @@ func (r *VirtualEnvironmentContainerCustomStartupBehavior) UnmarshalJSON(b []byt
|
|||||||
r.Order = &iv
|
r.Order = &iv
|
||||||
case "up":
|
case "up":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// DeleteDatastoreFile deletes a file in a datastore.
|
// DeleteDatastoreFile deletes a file in a datastore.
|
||||||
func (c *VirtualEnvironmentClient) DeleteDatastoreFile(ctx context.Context, nodeName, datastoreID, volumeID string) error {
|
func (c *VirtualEnvironmentClient) DeleteDatastoreFile(
|
||||||
err := c.DoRequest(ctx, hmDELETE, fmt.Sprintf("nodes/%s/storage/%s/content/%s", url.PathEscape(nodeName), url.PathEscape(datastoreID), url.PathEscape(volumeID)), nil, nil)
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -32,10 +45,22 @@ func (c *VirtualEnvironmentClient) DeleteDatastoreFile(ctx context.Context, node
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetDatastoreStatus gets status information for a given datastore.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -68,10 +105,19 @@ func (c *VirtualEnvironmentClient) ListDatastoreFiles(ctx context.Context, nodeN
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListDatastores retrieves a list of nodes.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -88,7 +134,10 @@ func (c *VirtualEnvironmentClient) ListDatastores(ctx context.Context, nodeName
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UploadFileToDatastore uploads a file to a datastore.
|
// 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 {
|
switch d.ContentType {
|
||||||
case "iso", "vztmpl":
|
case "iso", "vztmpl":
|
||||||
r, w := io.Pipe()
|
r, w := io.Pipe()
|
||||||
@ -110,7 +159,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
part, err := m.CreateFormFile("filename", d.FileName)
|
part, err := m.CreateFormFile("filename", d.FileName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
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.
|
// 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.
|
// This is necessary due to Proxmox VE not supporting chunked transfers in v6.1 and earlier versions.
|
||||||
tempMultipartFile, err := os.CreateTemp("", "multipart")
|
tempMultipartFile, err := os.CreateTemp("", "multipart")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// 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)
|
fileReader, err := os.Open(tempMultipartFileName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -155,7 +201,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
defer fileReader.Close()
|
defer fileReader.Close()
|
||||||
|
|
||||||
fileInfo, err := fileReader.Stat()
|
fileInfo, err := fileReader.Stat()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -169,7 +214,17 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
resBody := &VirtualEnvironmentDatastoreUploadResponseBody{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// 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.
|
// Hopefully, this will not be required in future releases of Proxmox VE.
|
||||||
sshClient, err := c.OpenNodeShell(ctx, d.NodeName)
|
sshClient, err := c.OpenNodeShell(ctx, d.NodeName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -188,15 +242,16 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
defer sshClient.Close()
|
defer sshClient.Close()
|
||||||
|
|
||||||
sshSession, err := sshClient.NewSession()
|
sshSession, err := sshClient.NewSession()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := sshSession.CombinedOutput(
|
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 {
|
if err != nil {
|
||||||
sshSession.Close()
|
sshSession.Close()
|
||||||
|
|
||||||
@ -220,7 +275,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
|
|
||||||
remoteFilePath := fmt.Sprintf("%s/%s", remoteFileDir, d.FileName)
|
remoteFilePath := fmt.Sprintf("%s/%s", remoteFileDir, d.FileName)
|
||||||
sftpClient, err := sftp.NewClient(sshClient)
|
sftpClient, err := sftp.NewClient(sshClient)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -234,7 +288,6 @@ func (c *VirtualEnvironmentClient) UploadFileToDatastore(ctx context.Context, d
|
|||||||
}
|
}
|
||||||
|
|
||||||
remoteFile, err := sftpClient.Create(remoteFilePath)
|
remoteFile, err := sftpClient.Create(remoteFilePath)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetDNS retrieves the DNS configuration for a node.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -28,6 +36,10 @@ func (c *VirtualEnvironmentClient) GetDNS(ctx context.Context, nodeName string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateDNS updates the DNS configuration for a node.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateGroup creates an access group.
|
// 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)
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -41,10 +52,11 @@ func (c *VirtualEnvironmentClient) GetGroup(ctx context.Context, id string) (*Vi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListGroups retrieves a list of access groups.
|
// 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{}
|
resBody := &VirtualEnvironmentGroupListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "access/groups", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "access/groups", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -61,6 +73,10 @@ func (c *VirtualEnvironmentClient) ListGroups(ctx context.Context) ([]*VirtualEn
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateGroup updates an access group.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// GetHosts retrieves the Hosts configuration for a node.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -28,6 +36,10 @@ func (c *VirtualEnvironmentClient) GetHosts(ctx context.Context, nodeName string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateHosts updates the Hosts configuration for a node.
|
// 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)
|
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ExecuteNodeCommands executes commands on a given node.
|
// 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)
|
sshClient, err := c.OpenNodeShell(ctx, nodeName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -36,7 +39,6 @@ func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, node
|
|||||||
}(sshClient)
|
}(sshClient)
|
||||||
|
|
||||||
sshSession, err := sshClient.NewSession()
|
sshSession, err := sshClient.NewSession()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -56,7 +58,6 @@ func (c *VirtualEnvironmentClient) ExecuteNodeCommands(ctx context.Context, node
|
|||||||
strings.ReplaceAll(strings.Join(commands, " && \\\n"), "'", "'\"'\"'"),
|
strings.ReplaceAll(strings.Join(commands, " && \\\n"), "'", "'\"'\"'"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New(string(output))
|
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.
|
// 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)
|
networkDevices, err := c.ListNodeNetworkDevices(ctx, nodeName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -91,10 +94,18 @@ func (c *VirtualEnvironmentClient) GetNodeIP(ctx context.Context, nodeName strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeTime retrieves the time information for a node.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -107,10 +118,19 @@ func (c *VirtualEnvironmentClient) GetNodeTime(ctx context.Context, nodeName str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetNodeTaskStatus retrieves the status of a node task.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -143,10 +171,11 @@ func (c *VirtualEnvironmentClient) ListNodeNetworkDevices(ctx context.Context, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListNodes retrieves a list of nodes.
|
// 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{}
|
resBody := &VirtualEnvironmentNodeListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "nodes", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "nodes", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -163,9 +192,11 @@ func (c *VirtualEnvironmentClient) ListNodes(ctx context.Context) ([]*VirtualEnv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// OpenNodeShell establishes a new SSH connection to a node.
|
// 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)
|
nodeAddress, err := c.GetNodeIP(ctx, nodeName)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -179,7 +210,6 @@ func (c *VirtualEnvironmentClient) OpenNodeShell(ctx context.Context, nodeName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
sshClient, err := ssh.Dial("tcp", *nodeAddress+":22", sshConfig)
|
sshClient, err := ssh.Dial("tcp", *nodeAddress+":22", sshConfig)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -188,12 +218,22 @@ func (c *VirtualEnvironmentClient) OpenNodeShell(ctx context.Context, nodeName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateNodeTime updates the time on a node.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/time", url.PathEscape(nodeName)), d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForNodeTask waits for a specific node task to complete.
|
// 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)
|
timeDelay := int64(delay)
|
||||||
timeMax := float64(timeout)
|
timeMax := float64(timeout)
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
@ -202,14 +242,18 @@ func (c *VirtualEnvironmentClient) WaitForNodeTask(ctx context.Context, nodeName
|
|||||||
for timeElapsed.Seconds() < timeMax {
|
for timeElapsed.Seconds() < timeMax {
|
||||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||||
status, err := c.GetNodeTaskStatus(ctx, nodeName, upid)
|
status, err := c.GetNodeTaskStatus(ctx, nodeName, upid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Status != "running" {
|
if status.Status != "running" {
|
||||||
if status.ExitCode != "OK" {
|
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
|
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.
|
// EncodeValues converts a CustomNodeCommands array to a JSON encoded URL vlaue.
|
||||||
func (r CustomNodeCommands) EncodeValues(key string, v *url.Values) error {
|
func (r CustomNodeCommands) EncodeValues(key string, v *url.Values) error {
|
||||||
jsonArrayBytes, err := json.Marshal(r)
|
jsonArrayBytes, err := json.Marshal(r)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreatePool creates a pool.
|
// 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)
|
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.
|
// 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{}
|
resBody := &VirtualEnvironmentPoolGetResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("pools/%s", url.PathEscape(id)), nil, resBody)
|
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("pools/%s", url.PathEscape(id)), nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -43,10 +48,11 @@ func (c *VirtualEnvironmentClient) GetPool(ctx context.Context, id string) (*Vir
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListPools retrieves a list of pools.
|
// 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{}
|
resBody := &VirtualEnvironmentPoolListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "pools", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "pools", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -63,6 +69,10 @@ func (c *VirtualEnvironmentClient) ListPools(ctx context.Context) ([]*VirtualEnv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePool updates a pool.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("pools/%s", url.PathEscape(id)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateRole creates an access role.
|
// 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)
|
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.
|
// 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{}
|
resBody := &VirtualEnvironmentRoleGetResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), nil, resBody)
|
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -41,10 +46,11 @@ func (c *VirtualEnvironmentClient) GetRole(ctx context.Context, id string) (*Cus
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListRoles retrieves a list of access roles.
|
// 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{}
|
resBody := &VirtualEnvironmentRoleListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "access/roles", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "access/roles", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -67,6 +73,10 @@ func (c *VirtualEnvironmentClient) ListRoles(ctx context.Context) ([]*VirtualEnv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRole updates an access role.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ChangeUserPassword changes a user's password.
|
// 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{
|
d := VirtualEnvironmentUserChangePasswordRequestBody{
|
||||||
ID: id,
|
ID: id,
|
||||||
Password: password,
|
Password: password,
|
||||||
@ -24,7 +27,10 @@ func (c *VirtualEnvironmentClient) ChangeUserPassword(ctx context.Context, id, p
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateUser creates a user.
|
// 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)
|
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.
|
// 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{}
|
resBody := &VirtualEnvironmentUserGetResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/users/%s", url.PathEscape(id)), nil, resBody)
|
err := c.DoRequest(ctx, hmGET, fmt.Sprintf("access/users/%s", url.PathEscape(id)), nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -59,10 +67,11 @@ func (c *VirtualEnvironmentClient) GetUser(ctx context.Context, id string) (*Vir
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListUsers retrieves a list of users.
|
// 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{}
|
resBody := &VirtualEnvironmentUserListResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "access/users", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "access/users", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -90,6 +99,10 @@ func (c *VirtualEnvironmentClient) ListUsers(ctx context.Context) ([]*VirtualEnv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateUser updates a user.
|
// 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)
|
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("access/users/%s", url.PathEscape(id)), d, nil)
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Version retrieves the version information.
|
// 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{}
|
resBody := &VirtualEnvironmentVersionResponseBody{}
|
||||||
err := c.DoRequest(ctx, hmGET, "version", nil, resBody)
|
err := c.DoRequest(ctx, hmGET, "version", nil, resBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,14 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CloneVM clones a virtual machine.
|
// 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{}
|
resBody := &VirtualEnvironmentVMMoveDiskResponseBody{}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -37,7 +44,13 @@ func (c *VirtualEnvironmentClient) CloneVM(ctx context.Context, nodeName string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < retries; i++ {
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -59,20 +72,43 @@ func (c *VirtualEnvironmentClient) CloneVM(ctx context.Context, nodeName string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateVM creates a virtual machine.
|
// 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)
|
return c.DoRequest(ctx, hmPOST, fmt.Sprintf("nodes/%s/qemu", url.PathEscape(nodeName)), d, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteVM deletes a virtual machine.
|
// DeleteVM deletes a virtual machine.
|
||||||
func (c *VirtualEnvironmentClient) DeleteVM(ctx context.Context, nodeName string, vmID int) error {
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -91,7 +127,6 @@ func (c *VirtualEnvironmentClient) GetVMID(ctx context.Context) (*int, error) {
|
|||||||
|
|
||||||
if getVMIDCounter < 0 {
|
if getVMIDCounter < 0 {
|
||||||
nextVMID, err := c.GetClusterNextID(ctx, nil)
|
nextVMID, err := c.GetClusterNextID(ctx, nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -113,7 +148,6 @@ func (c *VirtualEnvironmentClient) GetVMID(ctx context.Context) (*int, error) {
|
|||||||
|
|
||||||
for vmID <= 2147483637 {
|
for vmID <= 2147483637 {
|
||||||
_, err := c.GetClusterNextID(ctx, &vmID)
|
_, err := c.GetClusterNextID(ctx, &vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
vmID += getVMIDStep
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -149,10 +196,19 @@ func (c *VirtualEnvironmentClient) GetVMNetworkInterfacesFromAgent(ctx context.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetVMStatus retrieves the status for a virtual machine.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -165,9 +221,14 @@ func (c *VirtualEnvironmentClient) GetVMStatus(ctx context.Context, nodeName str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MigrateVM migrates a virtual machine.
|
// 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)
|
taskID, err := c.MigrateVMAsync(ctx, nodeName, vmID, d)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -182,10 +243,20 @@ func (c *VirtualEnvironmentClient) MigrateVM(ctx context.Context, nodeName strin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MigrateVMAsync migrates a virtual machine asynchronously.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -198,9 +269,14 @@ func (c *VirtualEnvironmentClient) MigrateVMAsync(ctx context.Context, nodeName
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MoveVMDisk moves a virtual machine disk.
|
// 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)
|
taskID, err := c.MoveVMDiskAsync(ctx, nodeName, vmID, d)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "you can't move to the same storage with same format") {
|
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
|
// 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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -241,9 +327,14 @@ func (c *VirtualEnvironmentClient) ListVMs() ([]*VirtualEnvironmentVMListRespons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RebootVM reboots a virtual machine.
|
// 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)
|
taskID, err := c.RebootVMAsync(ctx, nodeName, vmID, d)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -258,10 +349,20 @@ func (c *VirtualEnvironmentClient) RebootVM(ctx context.Context, nodeName string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RebootVMAsync reboots a virtual machine asynchronously.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -274,14 +375,25 @@ func (c *VirtualEnvironmentClient) RebootVMAsync(ctx context.Context, nodeName s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResizeVMDisk resizes a virtual machine disk.
|
// 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
|
var err error
|
||||||
tflog.Debug(ctx, "resize disk", map[string]interface{}{
|
tflog.Debug(ctx, "resize disk", map[string]interface{}{
|
||||||
"disk": d.Disk,
|
"disk": d.Disk,
|
||||||
"size": d.Size,
|
"size": d.Size,
|
||||||
})
|
})
|
||||||
for i := 0; i < 5; i++ {
|
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 {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -298,9 +410,14 @@ func (c *VirtualEnvironmentClient) ResizeVMDisk(ctx context.Context, nodeName st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ShutdownVM shuts down a virtual machine.
|
// 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)
|
taskID, err := c.ShutdownVMAsync(ctx, nodeName, vmID, d)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -315,10 +432,20 @@ func (c *VirtualEnvironmentClient) ShutdownVM(ctx context.Context, nodeName stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ShutdownVMAsync shuts down a virtual machine asynchronously.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -331,9 +458,13 @@ func (c *VirtualEnvironmentClient) ShutdownVMAsync(ctx context.Context, nodeName
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartVM starts a virtual machine.
|
// 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)
|
taskID, err := c.StartVMAsync(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -348,10 +479,19 @@ func (c *VirtualEnvironmentClient) StartVM(ctx context.Context, nodeName string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StartVMAsync starts a virtual machine asynchronously.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -364,9 +504,13 @@ func (c *VirtualEnvironmentClient) StartVMAsync(ctx context.Context, nodeName st
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StopVM stops a virtual machine.
|
// 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)
|
taskID, err := c.StopVMAsync(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -381,10 +525,19 @@ func (c *VirtualEnvironmentClient) StopVM(ctx context.Context, nodeName string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// StopVMAsync stops a virtual machine asynchronously.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -397,15 +550,36 @@ func (c *VirtualEnvironmentClient) StopVMAsync(ctx context.Context, nodeName str
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateVM updates a virtual machine.
|
// UpdateVM updates a virtual machine.
|
||||||
func (c *VirtualEnvironmentClient) UpdateVM(ctx context.Context, nodeName string, vmID int, d *VirtualEnvironmentVMUpdateRequestBody) error {
|
func (c *VirtualEnvironmentClient) UpdateVM(
|
||||||
return c.DoRequest(ctx, hmPUT, fmt.Sprintf("nodes/%s/qemu/%d/config", url.PathEscape(nodeName), vmID), d, nil)
|
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.
|
// 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{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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.
|
// 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)
|
timeDelay := int64(delay)
|
||||||
timeMax := float64(timeout)
|
timeMax := float64(timeout)
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
@ -438,7 +619,8 @@ func (c *VirtualEnvironmentClient) WaitForNetworkInterfacesFromVMAgent(ctx conte
|
|||||||
continue
|
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
|
missingIP = true
|
||||||
break
|
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.
|
// 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)
|
timeDelay := int64(delay)
|
||||||
timeMax := float64(timeout)
|
timeMax := float64(timeout)
|
||||||
timeStart := time.Now()
|
timeStart := time.Now()
|
||||||
@ -481,7 +672,6 @@ func (c *VirtualEnvironmentClient) WaitForNoNetworkInterfacesFromVMAgent(ctx con
|
|||||||
for timeElapsed.Seconds() < timeMax {
|
for timeElapsed.Seconds() < timeMax {
|
||||||
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
if int64(timeElapsed.Seconds())%timeDelay == 0 {
|
||||||
_, err := c.GetVMNetworkInterfacesFromAgent(ctx, nodeName, vmID)
|
_, err := c.GetVMNetworkInterfacesFromAgent(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 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.
|
// 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)
|
timeDelay := int64(delay)
|
||||||
timeMax := float64(timeout)
|
timeMax := float64(timeout)
|
||||||
timeStart := time.Now()
|
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.
|
// 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)
|
state = strings.ToLower(state)
|
||||||
|
|
||||||
timeDelay := int64(delay)
|
timeDelay := int64(delay)
|
||||||
|
@ -335,7 +335,7 @@ type VirtualEnvironmentVMGetQEMUNetworkInterfacesResponseResultStatistics struct
|
|||||||
TXPackets int `json:"tx-packets"`
|
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 {
|
type VirtualEnvironmentVMGetResponseBody struct {
|
||||||
Data *VirtualEnvironmentVMGetResponseData `json:"data,omitempty"`
|
Data *VirtualEnvironmentVMGetResponseData `json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
@ -705,7 +705,10 @@ func (r CustomCloudInitConfig) EncodeValues(_ string, v *url.Values) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.SSHKeys != nil {
|
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 {
|
if r.Type != nil {
|
||||||
@ -1232,7 +1235,6 @@ func (r *CustomAgent) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1267,7 +1269,6 @@ func (r *CustomAudioDevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1295,7 +1296,6 @@ func (r *CustomCloudInitFiles) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1327,7 +1327,6 @@ func (r *CustomCloudInitIPConfig) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1359,7 +1358,6 @@ func (r *CustomCloudInitSSHKeys) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1384,7 +1382,6 @@ func (r *CustomCPUEmulation) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1429,7 +1426,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1455,7 +1451,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.Model = v[1]
|
r.Model = v[1]
|
||||||
case "queues":
|
case "queues":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1463,7 +1458,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.Queues = &iv
|
r.Queues = &iv
|
||||||
case "rate":
|
case "rate":
|
||||||
fv, err := strconv.ParseFloat(v[1], 64)
|
fv, err := strconv.ParseFloat(v[1], 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1471,7 +1465,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
case "mtu":
|
case "mtu":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1479,7 +1472,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
case "tag":
|
case "tag":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1491,7 +1483,6 @@ func (r *CustomNetworkDevice) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
for i, trunk := range trunks {
|
for i, trunk := range trunks {
|
||||||
iv, err := strconv.Atoi(trunk)
|
iv, err := strconv.Atoi(trunk)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1515,7 +1506,6 @@ func (r *CustomPCIDevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1555,7 +1545,6 @@ func (r *CustomSharedMemory) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1587,7 +1576,6 @@ func (r *CustomSMBIOS) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1628,7 +1616,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1656,7 +1643,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.FileVolume = v[1]
|
r.FileVolume = v[1]
|
||||||
case "mbps_rd":
|
case "mbps_rd":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1664,7 +1650,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.MaxReadSpeedMbps = &iv
|
r.MaxReadSpeedMbps = &iv
|
||||||
case "mbps_rd_max":
|
case "mbps_rd_max":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1672,7 +1657,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.BurstableReadSpeedMbps = &iv
|
r.BurstableReadSpeedMbps = &iv
|
||||||
case "mbps_wr":
|
case "mbps_wr":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1680,7 +1664,6 @@ func (r *CustomStorageDevice) UnmarshalJSON(b []byte) error {
|
|||||||
r.MaxWriteSpeedMbps = &iv
|
r.MaxWriteSpeedMbps = &iv
|
||||||
case "mbps_wr_max":
|
case "mbps_wr_max":
|
||||||
iv, err := strconv.Atoi(v[1])
|
iv, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1714,7 +1697,6 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1734,7 +1716,6 @@ func (r *CustomVGADevice) UnmarshalJSON(b []byte) error {
|
|||||||
switch v[0] {
|
switch v[0] {
|
||||||
case "memory":
|
case "memory":
|
||||||
m, err := strconv.Atoi(v[1])
|
m, err := strconv.Atoi(v[1])
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1754,7 +1735,6 @@ func (r *CustomWatchdogDevice) UnmarshalJSON(b []byte) error {
|
|||||||
var s string
|
var s string
|
||||||
|
|
||||||
err := json.Unmarshal(b, &s)
|
err := json.Unmarshal(b, &s)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) {
|
|||||||
func strPtr(s string) *string {
|
func strPtr(s string) *string {
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
func boolPtr(s bool) *CustomBool {
|
func boolPtr(s bool) *CustomBool {
|
||||||
customBool := CustomBool(s)
|
customBool := CustomBool(s)
|
||||||
return &customBool
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -78,7 +82,10 @@ func dataSourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.Resourc
|
|||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
err = d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
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)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
|
||||||
return diags
|
return diags
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -176,7 +179,10 @@ func dataSourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.Resourc
|
|||||||
if v.ExpirationDate != nil {
|
if v.ExpirationDate != nil {
|
||||||
t := time.Time(*v.ExpirationDate)
|
t := time.Time(*v.ExpirationDate)
|
||||||
if t.Unix() > 0 {
|
if t.Unix() > 0 {
|
||||||
err = d.Set(mkDataSourceVirtualEnvironmentUserExpirationDate, t.UTC().Format(time.RFC3339))
|
err = d.Set(
|
||||||
|
mkDataSourceVirtualEnvironmentUserExpirationDate,
|
||||||
|
t.UTC().Format(time.RFC3339),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkDataSourceVirtualEnvironmentUserExpirationDate, time.Unix(0, 0).UTC().Format(time.RFC3339))
|
err = d.Set(mkDataSourceVirtualEnvironmentUserExpirationDate, time.Unix(0, 0).UTC().Format(time.RFC3339))
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -90,15 +90,18 @@ func Provider() *schema.Provider {
|
|||||||
|
|
||||||
if value == "" {
|
if value == "" {
|
||||||
return []string{}, []error{
|
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)
|
_, err := url.ParseRequestURI(value)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}, []error{
|
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 == "" {
|
if value == "" {
|
||||||
return []string{}, []error{
|
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 == "" {
|
if value == "" {
|
||||||
return []string{}, []error{
|
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) {
|
func (c *providerConfiguration) GetVEClient() (*proxmox.VirtualEnvironmentClient, error) {
|
||||||
if c.veClient == nil {
|
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
|
return c.veClient, nil
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
diags := resourceVirtualEnvironmentCertificateUpdate(ctx, d, m)
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
return diags
|
return diags
|
||||||
@ -135,7 +139,9 @@ func resourceVirtualEnvironmentCertificateCreate(ctx context.Context, d *schema.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVirtualEnvironmentCertificateGetUpdateBody(d *schema.ResourceData) (*proxmox.VirtualEnvironmentCertificateUpdateRequestBody, error) {
|
func resourceVirtualEnvironmentCertificateGetUpdateBody(
|
||||||
|
d *schema.ResourceData,
|
||||||
|
) *proxmox.VirtualEnvironmentCertificateUpdateRequestBody {
|
||||||
certificate := d.Get(mkResourceVirtualEnvironmentCertificateCertificate).(string)
|
certificate := d.Get(mkResourceVirtualEnvironmentCertificateCertificate).(string)
|
||||||
certificateChain := d.Get(mkResourceVirtualEnvironmentCertificateCertificateChain).(string)
|
certificateChain := d.Get(mkResourceVirtualEnvironmentCertificateCertificateChain).(string)
|
||||||
overwrite := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentCertificateOverwrite).(bool))
|
overwrite := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentCertificateOverwrite).(bool))
|
||||||
@ -162,10 +168,14 @@ func resourceVirtualEnvironmentCertificateGetUpdateBody(d *schema.ResourceData)
|
|||||||
Restart: &restart,
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -206,7 +216,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateCertificate, newCertificate)
|
err = d.Set(mkResourceVirtualEnvironmentCertificateCertificate, newCertificate)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateCertificateChain, newCertificateChain)
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentCertificateCertificateChain,
|
||||||
|
newCertificateChain,
|
||||||
|
)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +228,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
if c.NotAfter != nil {
|
if c.NotAfter != nil {
|
||||||
t := time.Time(*c.NotAfter)
|
t := time.Time(*c.NotAfter)
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateExpirationDate, t.UTC().Format(time.RFC3339))
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentCertificateExpirationDate,
|
||||||
|
t.UTC().Format(time.RFC3339),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateExpirationDate, "")
|
err = d.Set(mkResourceVirtualEnvironmentCertificateExpirationDate, "")
|
||||||
}
|
}
|
||||||
@ -257,7 +273,10 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
if c.NotBefore != nil {
|
if c.NotBefore != nil {
|
||||||
t := time.Time(*c.NotBefore)
|
t := time.Time(*c.NotBefore)
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateStartDate, t.UTC().Format(time.RFC3339))
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentCertificateStartDate,
|
||||||
|
t.UTC().Format(time.RFC3339),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentCertificateStartDate, "")
|
err = d.Set(mkResourceVirtualEnvironmentCertificateStartDate, "")
|
||||||
}
|
}
|
||||||
@ -286,7 +305,11 @@ func resourceVirtualEnvironmentCertificateRead(ctx context.Context, d *schema.Re
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -295,10 +318,7 @@ func resourceVirtualEnvironmentCertificateUpdate(ctx context.Context, d *schema.
|
|||||||
|
|
||||||
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
||||||
|
|
||||||
body, err := resourceVirtualEnvironmentCertificateGetUpdateBody(d)
|
body := resourceVirtualEnvironmentCertificateGetUpdateBody(d)
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = veClient.UpdateCertificate(ctx, nodeName, body)
|
err = veClient.UpdateCertificate(ctx, nodeName, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -308,7 +328,11 @@ func resourceVirtualEnvironmentCertificateUpdate(ctx context.Context, d *schema.
|
|||||||
return resourceVirtualEnvironmentCertificateRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -318,9 +342,13 @@ func resourceVirtualEnvironmentCertificateDelete(ctx context.Context, d *schema.
|
|||||||
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
nodeName := d.Get(mkResourceVirtualEnvironmentCertificateNodeName).(string)
|
||||||
restart := proxmox.CustomBool(true)
|
restart := proxmox.CustomBool(true)
|
||||||
|
|
||||||
err = veClient.DeleteCertificate(ctx, nodeName, &proxmox.VirtualEnvironmentCertificateDeleteRequestBody{
|
err = veClient.DeleteCertificate(
|
||||||
|
ctx,
|
||||||
|
nodeName,
|
||||||
|
&proxmox.VirtualEnvironmentCertificateDeleteRequestBody{
|
||||||
Restart: &restart,
|
Restart: &restart,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -78,7 +82,11 @@ func resourceVirtualEnvironmentClusterAliasCreate(ctx context.Context, d *schema
|
|||||||
return resourceVirtualEnvironmentClusterAliasRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -87,7 +95,6 @@ func resourceVirtualEnvironmentClusterAliasRead(ctx context.Context, d *schema.R
|
|||||||
|
|
||||||
name := d.Id()
|
name := d.Id()
|
||||||
alias, err := veClient.GetAlias(ctx, name)
|
alias, err := veClient.GetAlias(ctx, name)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -112,7 +119,11 @@ func resourceVirtualEnvironmentClusterAliasRead(ctx context.Context, d *schema.R
|
|||||||
return nil
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -140,7 +151,11 @@ func resourceVirtualEnvironmentClusterAliasUpdate(ctx context.Context, d *schema
|
|||||||
return resourceVirtualEnvironmentClusterAliasRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -136,7 +140,11 @@ func resourceVirtualEnvironmentClusterIPSetCreate(ctx context.Context, d *schema
|
|||||||
return resourceVirtualEnvironmentClusterIPSetRead(ctx, d, m)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -162,7 +170,6 @@ func resourceVirtualEnvironmentClusterIPSetRead(ctx context.Context, d *schema.R
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPSet, err := veClient.GetListIPSetContent(ctx, name)
|
IPSet, err := veClient.GetListIPSetContent(ctx, name)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -189,7 +196,11 @@ func resourceVirtualEnvironmentClusterIPSetRead(ctx context.Context, d *schema.R
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -216,7 +227,11 @@ func resourceVirtualEnvironmentClusterIPSetUpdate(ctx context.Context, d *schema
|
|||||||
return resourceVirtualEnvironmentClusterIPSetRead(ctx, d, m)
|
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
|
var diags diag.Diagnostics
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
|
@ -55,5 +55,4 @@ func TestResourceVirtualEnvironmentIPSetSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
|
mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
|
||||||
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: schema.TypeBool,
|
mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: schema.TypeBool,
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
|
||||||
@ -219,7 +218,9 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
|||||||
Description: "The CPU units",
|
Description: "The CPU units",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvResourceVirtualEnvironmentContainerCPUUnits,
|
Default: dvResourceVirtualEnvironmentContainerCPUUnits,
|
||||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 500000)),
|
ValidateDiagFunc: validation.ToDiagFunc(
|
||||||
|
validation.IntBetween(0, 500000),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -402,7 +403,8 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
|||||||
Sensitive: true,
|
Sensitive: true,
|
||||||
Default: dvResourceVirtualEnvironmentContainerInitializationUserAccountPassword,
|
Default: dvResourceVirtualEnvironmentContainerInitializationUserAccountPassword,
|
||||||
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
|
||||||
return len(old) > 0 && strings.ReplaceAll(old, "*", "") == ""
|
return len(old) > 0 &&
|
||||||
|
strings.ReplaceAll(old, "*", "") == ""
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -434,14 +436,18 @@ func resourceVirtualEnvironmentContainer() *schema.Resource {
|
|||||||
Description: "The dedicated memory in megabytes",
|
Description: "The dedicated memory in megabytes",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvResourceVirtualEnvironmentContainerMemoryDedicated,
|
Default: dvResourceVirtualEnvironmentContainerMemoryDedicated,
|
||||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(16, 268435456)),
|
ValidateDiagFunc: validation.ToDiagFunc(
|
||||||
|
validation.IntBetween(16, 268435456),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
mkResourceVirtualEnvironmentContainerMemorySwap: {
|
mkResourceVirtualEnvironmentContainerMemorySwap: {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Description: "The swap size in megabytes",
|
Description: "The swap size in megabytes",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Default: dvResourceVirtualEnvironmentContainerMemorySwap,
|
Default: dvResourceVirtualEnvironmentContainerMemorySwap,
|
||||||
ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 268435456)),
|
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{})
|
clone := d.Get(mkResourceVirtualEnvironmentContainerClone).([]interface{})
|
||||||
|
|
||||||
if len(clone) > 0 {
|
if len(clone) > 0 {
|
||||||
@ -588,7 +598,11 @@ func resourceVirtualEnvironmentContainerCreate(ctx context.Context, d *schema.Re
|
|||||||
return resourceVirtualEnvironmentContainerCreateCustom(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -675,7 +689,9 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
if len(console) > 0 {
|
if len(console) > 0 {
|
||||||
consoleBlock := console[0].(map[string]interface{})
|
consoleBlock := console[0].(map[string]interface{})
|
||||||
|
|
||||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
consoleEnabled := proxmox.CustomBool(
|
||||||
|
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||||
|
)
|
||||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
||||||
|
|
||||||
@ -731,8 +747,14 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
if len(ipv4) > 0 {
|
if len(ipv4) > 0 {
|
||||||
ipv4Block := ipv4[0].(map[string]interface{})
|
ipv4Block := ipv4[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
initializationIPConfigIPv4Address = append(
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
initializationIPConfigIPv4Address,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv4Gateway = append(
|
||||||
|
initializationIPConfigIPv4Gateway,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||||
@ -743,8 +765,14 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
if len(ipv6) > 0 {
|
if len(ipv6) > 0 {
|
||||||
ipv6Block := ipv6[0].(map[string]interface{})
|
ipv6Block := ipv6[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
initializationIPConfigIPv6Address = append(
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
initializationIPConfigIPv6Address,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv6Gateway = append(
|
||||||
|
initializationIPConfigIPv6Gateway,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||||
@ -758,7 +786,10 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
||||||
|
|
||||||
if len(keys) > 0 {
|
if len(keys) > 0 {
|
||||||
initializationUserAccountKeys := make(proxmox.VirtualEnvironmentContainerCustomSSHKeys, len(keys))
|
initializationUserAccountKeys := make(
|
||||||
|
proxmox.VirtualEnvironmentContainerCustomSSHKeys,
|
||||||
|
len(keys),
|
||||||
|
)
|
||||||
|
|
||||||
for ki, kv := range keys {
|
for ki, kv := range keys {
|
||||||
initializationUserAccountKeys[ki] = kv.(string)
|
initializationUserAccountKeys[ki] = kv.(string)
|
||||||
@ -794,13 +825,21 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||||
|
|
||||||
if len(networkInterface) == 0 {
|
if len(networkInterface) == 0 {
|
||||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx, veClient, nodeName, vmID)
|
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(
|
||||||
|
ctx,
|
||||||
|
veClient,
|
||||||
|
nodeName,
|
||||||
|
vmID,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
networkInterfaceArray := make(
|
||||||
|
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||||
|
len(networkInterface),
|
||||||
|
)
|
||||||
|
|
||||||
for ni, nv := range networkInterface {
|
for ni, nv := range networkInterface {
|
||||||
networkInterfaceMap := nv.(map[string]interface{})
|
networkInterfaceMap := nv.(map[string]interface{})
|
||||||
@ -904,7 +943,11 @@ func resourceVirtualEnvironmentContainerCreateClone(ctx context.Context, d *sche
|
|||||||
return resourceVirtualEnvironmentContainerCreateStart(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -914,16 +957,30 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
nodeName := d.Get(mkResourceVirtualEnvironmentContainerNodeName).(string)
|
nodeName := d.Get(mkResourceVirtualEnvironmentContainerNodeName).(string)
|
||||||
resource := resourceVirtualEnvironmentContainer()
|
resource := resourceVirtualEnvironmentContainer()
|
||||||
|
|
||||||
consoleBlock, err := getSchemaBlock(resource, d, []string{mkResourceVirtualEnvironmentContainerConsole}, 0, true)
|
consoleBlock, err := getSchemaBlock(
|
||||||
|
resource,
|
||||||
|
d,
|
||||||
|
[]string{mkResourceVirtualEnvironmentContainerConsole},
|
||||||
|
0,
|
||||||
|
true,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
consoleEnabled := proxmox.CustomBool(
|
||||||
|
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||||
|
)
|
||||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -934,7 +991,13 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
|
|
||||||
description := d.Get(mkResourceVirtualEnvironmentContainerDescription).(string)
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -982,8 +1045,14 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
if len(ipv4) > 0 {
|
if len(ipv4) > 0 {
|
||||||
ipv4Block := ipv4[0].(map[string]interface{})
|
ipv4Block := ipv4[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
initializationIPConfigIPv4Address = append(
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
initializationIPConfigIPv4Address,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv4Gateway = append(
|
||||||
|
initializationIPConfigIPv4Gateway,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||||
@ -994,8 +1063,14 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
if len(ipv6) > 0 {
|
if len(ipv6) > 0 {
|
||||||
ipv6Block := ipv6[0].(map[string]interface{})
|
ipv6Block := ipv6[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
initializationIPConfigIPv6Address = append(
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
initializationIPConfigIPv6Address,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv6Gateway = append(
|
||||||
|
initializationIPConfigIPv6Gateway,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||||
@ -1008,7 +1083,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
initializationUserAccountBlock := initializationUserAccount[0].(map[string]interface{})
|
initializationUserAccountBlock := initializationUserAccount[0].(map[string]interface{})
|
||||||
|
|
||||||
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
keys := initializationUserAccountBlock[mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys].([]interface{})
|
||||||
initializationUserAccountKeys = make(proxmox.VirtualEnvironmentContainerCustomSSHKeys, len(keys))
|
initializationUserAccountKeys = make(
|
||||||
|
proxmox.VirtualEnvironmentContainerCustomSSHKeys,
|
||||||
|
len(keys),
|
||||||
|
)
|
||||||
|
|
||||||
for ki, kv := range keys {
|
for ki, kv := range keys {
|
||||||
initializationUserAccountKeys[ki] = kv.(string)
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -1027,7 +1111,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
memorySwap := memoryBlock[mkResourceVirtualEnvironmentContainerMemorySwap].(int)
|
memorySwap := memoryBlock[mkResourceVirtualEnvironmentContainerMemorySwap].(int)
|
||||||
|
|
||||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
networkInterfaceArray := make(
|
||||||
|
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||||
|
len(networkInterface),
|
||||||
|
)
|
||||||
|
|
||||||
for ni, nv := range networkInterface {
|
for ni, nv := range networkInterface {
|
||||||
networkInterfaceMap := nv.(map[string]interface{})
|
networkInterfaceMap := nv.(map[string]interface{})
|
||||||
@ -1088,7 +1175,10 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
operatingSystem := d.Get(mkResourceVirtualEnvironmentContainerOperatingSystem).([]interface{})
|
operatingSystem := d.Get(mkResourceVirtualEnvironmentContainerOperatingSystem).([]interface{})
|
||||||
|
|
||||||
if len(operatingSystem) == 0 {
|
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{})
|
operatingSystemBlock := operatingSystem[0].(map[string]interface{})
|
||||||
@ -1173,7 +1263,11 @@ func resourceVirtualEnvironmentContainerCreateCustom(ctx context.Context, d *sch
|
|||||||
return resourceVirtualEnvironmentContainerCreateStart(ctx, d, m)
|
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)
|
started := d.Get(mkResourceVirtualEnvironmentContainerStarted).(bool)
|
||||||
template := d.Get(mkResourceVirtualEnvironmentContainerTemplate).(bool)
|
template := d.Get(mkResourceVirtualEnvironmentContainerTemplate).(bool)
|
||||||
|
|
||||||
@ -1224,9 +1318,13 @@ func resourceVirtualEnvironmentContainerGetCPUArchitectureValidator() schema.Sch
|
|||||||
}, false))
|
}, 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)
|
containerInfo, err := client.GetContainer(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []interface{}{}, err
|
return []interface{}{}, err
|
||||||
}
|
}
|
||||||
@ -1304,7 +1402,11 @@ func resourceVirtualEnvironmentContainerGetOperatingSystemTypeValidator() schema
|
|||||||
}, false))
|
}, 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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
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.
|
// Retrieve the entire configuration in order to compare it to the state.
|
||||||
containerConfig, err := veClient.GetContainer(ctx, nodeName, vmID)
|
containerConfig, err := veClient.GetContainer(ctx, nodeName, vmID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") ||
|
if strings.Contains(err.Error(), "HTTP 404") ||
|
||||||
(strings.Contains(err.Error(), "HTTP 500") && strings.Contains(err.Error(), "does not exist")) {
|
(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 len(clone) == 0 || currentDescription != dvResourceVirtualEnvironmentContainerDescription {
|
||||||
if containerConfig.Description != nil {
|
if containerConfig.Description != nil {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerDescription, strings.TrimSpace(*containerConfig.Description))
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentContainerDescription,
|
||||||
|
strings.TrimSpace(*containerConfig.Description),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerDescription, "")
|
err = d.Set(mkResourceVirtualEnvironmentContainerDescription, "")
|
||||||
}
|
}
|
||||||
@ -1447,6 +1551,7 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
if len(clone) > 0 {
|
if len(clone) > 0 {
|
||||||
if len(currentDisk) > 0 {
|
if len(currentDisk) > 0 {
|
||||||
// do not override the rootfs size if it was not changed during the clone operation
|
// 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 {
|
if currentDisk[0].(map[string]interface{})[mkResourceVirtualEnvironmentContainerDiskSize] == dvResourceVirtualEnvironmentContainerDiskSize {
|
||||||
disk[mkResourceVirtualEnvironmentContainerDiskSize] = dvResourceVirtualEnvironmentContainerDiskSize
|
disk[mkResourceVirtualEnvironmentContainerDiskSize] = dvResourceVirtualEnvironmentContainerDiskSize
|
||||||
}
|
}
|
||||||
@ -1507,7 +1612,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
initializationDNS[mkResourceVirtualEnvironmentContainerInitializationDNSServer] = ""
|
initializationDNS[mkResourceVirtualEnvironmentContainerInitializationDNSServer] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
initialization[mkResourceVirtualEnvironmentContainerInitializationDNS] = []interface{}{initializationDNS}
|
initialization[mkResourceVirtualEnvironmentContainerInitializationDNS] = []interface{}{
|
||||||
|
initializationDNS,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if containerConfig.Hostname != nil {
|
if containerConfig.Hostname != nil {
|
||||||
@ -1534,7 +1641,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
continue
|
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{}{}
|
ipConfig := map[string]interface{}{}
|
||||||
|
|
||||||
if nv.IPv4Address != nil || nv.IPv4Gateway != nil {
|
if nv.IPv4Address != nil || nv.IPv4Gateway != nil {
|
||||||
@ -1552,7 +1661,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway] = ""
|
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{ip}
|
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{
|
||||||
|
ip,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{}
|
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4] = []interface{}{}
|
||||||
}
|
}
|
||||||
@ -1572,7 +1683,9 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway] = ""
|
ip[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway] = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{ip}
|
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{
|
||||||
|
ip,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{}
|
ipConfig[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6] = []interface{}{}
|
||||||
}
|
}
|
||||||
@ -1651,7 +1764,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(initialization) > 0 {
|
if len(initialization) > 0 {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerInitialization, []interface{}{initialization})
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentContainerInitialization,
|
||||||
|
[]interface{}{initialization},
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerInitialization, []interface{}{})
|
err = d.Set(mkResourceVirtualEnvironmentContainerInitialization, []interface{}{})
|
||||||
}
|
}
|
||||||
@ -1661,7 +1777,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
currentNetworkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
currentNetworkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||||
|
|
||||||
if len(currentNetworkInterface) > 0 {
|
if len(currentNetworkInterface) > 0 {
|
||||||
err := d.Set(mkResourceVirtualEnvironmentContainerNetworkInterface, networkInterfaceList)
|
err := d.Set(
|
||||||
|
mkResourceVirtualEnvironmentContainerNetworkInterface,
|
||||||
|
networkInterfaceList,
|
||||||
|
)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1696,7 +1815,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
|
|
||||||
if len(clone) > 0 {
|
if len(clone) > 0 {
|
||||||
if len(currentMemory) > 0 {
|
if len(currentMemory) > 0 {
|
||||||
err := d.Set(mkResourceVirtualEnvironmentContainerOperatingSystem, []interface{}{operatingSystem})
|
err := d.Set(
|
||||||
|
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
||||||
|
[]interface{}{operatingSystem},
|
||||||
|
)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
}
|
}
|
||||||
} else if len(currentOperatingSystem) > 0 ||
|
} else if len(currentOperatingSystem) > 0 ||
|
||||||
@ -1710,7 +1832,10 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
//nolint:gosimple
|
//nolint:gosimple
|
||||||
if len(clone) == 0 || currentTemplate != dvResourceVirtualEnvironmentContainerTemplate {
|
if len(clone) == 0 || currentTemplate != dvResourceVirtualEnvironmentContainerTemplate {
|
||||||
if containerConfig.Template != nil {
|
if containerConfig.Template != nil {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerTemplate, bool(*containerConfig.Template))
|
err = d.Set(
|
||||||
|
mkResourceVirtualEnvironmentContainerTemplate,
|
||||||
|
bool(*containerConfig.Template),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentContainerTemplate, false)
|
err = d.Set(mkResourceVirtualEnvironmentContainerTemplate, false)
|
||||||
}
|
}
|
||||||
@ -1729,7 +1854,11 @@ func resourceVirtualEnvironmentContainerRead(ctx context.Context, d *schema.Reso
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1765,12 +1894,20 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
// Prepare the new console configuration.
|
// Prepare the new console configuration.
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentContainerConsole) {
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
consoleEnabled := proxmox.CustomBool(consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool))
|
consoleEnabled := proxmox.CustomBool(
|
||||||
|
consoleBlock[mkResourceVirtualEnvironmentContainerConsoleEnabled].(bool),
|
||||||
|
)
|
||||||
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
consoleMode := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleMode].(string)
|
||||||
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
consoleTTYCount := consoleBlock[mkResourceVirtualEnvironmentContainerConsoleTTYCount].(int)
|
||||||
|
|
||||||
@ -1783,7 +1920,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
// Prepare the new CPU configuration.
|
// Prepare the new CPU configuration.
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentContainerCPU) {
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -1829,8 +1972,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
if len(ipv4) > 0 {
|
if len(ipv4) > 0 {
|
||||||
ipv4Block := ipv4[0].(map[string]interface{})
|
ipv4Block := ipv4[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string))
|
initializationIPConfigIPv4Address = append(
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string))
|
initializationIPConfigIPv4Address,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv4Gateway = append(
|
||||||
|
initializationIPConfigIPv4Gateway,
|
||||||
|
ipv4Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
initializationIPConfigIPv4Address = append(initializationIPConfigIPv4Address, "")
|
||||||
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
initializationIPConfigIPv4Gateway = append(initializationIPConfigIPv4Gateway, "")
|
||||||
@ -1841,8 +1990,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
if len(ipv6) > 0 {
|
if len(ipv6) > 0 {
|
||||||
ipv6Block := ipv6[0].(map[string]interface{})
|
ipv6Block := ipv6[0].(map[string]interface{})
|
||||||
|
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string))
|
initializationIPConfigIPv6Address = append(
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string))
|
initializationIPConfigIPv6Address,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address].(string),
|
||||||
|
)
|
||||||
|
initializationIPConfigIPv6Gateway = append(
|
||||||
|
initializationIPConfigIPv6Gateway,
|
||||||
|
ipv6Block[mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway].(string),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
initializationIPConfigIPv6Address = append(initializationIPConfigIPv6Address, "")
|
||||||
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
initializationIPConfigIPv6Gateway = append(initializationIPConfigIPv6Gateway, "")
|
||||||
@ -1860,7 +2015,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
// Prepare the new memory configuration.
|
// Prepare the new memory configuration.
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentContainerMemory) {
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -1878,14 +2039,24 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
networkInterface := d.Get(mkResourceVirtualEnvironmentContainerNetworkInterface).([]interface{})
|
||||||
|
|
||||||
if len(networkInterface) == 0 && len(clone) > 0 {
|
if len(networkInterface) == 0 && len(clone) > 0 {
|
||||||
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(ctx, veClient, nodeName, vmID)
|
networkInterface, err = resourceVirtualEnvironmentContainerGetExistingNetworkInterface(
|
||||||
|
ctx,
|
||||||
|
veClient,
|
||||||
|
nodeName,
|
||||||
|
vmID,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentContainerInitialization) || d.HasChange(mkResourceVirtualEnvironmentContainerNetworkInterface) {
|
//nolint:nestif
|
||||||
networkInterfaceArray := make(proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray, len(networkInterface))
|
if d.HasChange(mkResourceVirtualEnvironmentContainerInitialization) ||
|
||||||
|
d.HasChange(mkResourceVirtualEnvironmentContainerNetworkInterface) {
|
||||||
|
networkInterfaceArray := make(
|
||||||
|
proxmox.VirtualEnvironmentContainerCustomNetworkInterfaceArray,
|
||||||
|
len(networkInterface),
|
||||||
|
)
|
||||||
|
|
||||||
for ni, nv := range networkInterface {
|
for ni, nv := range networkInterface {
|
||||||
networkInterfaceMap := nv.(map[string]interface{})
|
networkInterfaceMap := nv.(map[string]interface{})
|
||||||
@ -1961,7 +2132,13 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
|
|
||||||
// Prepare the new operating system configuration.
|
// Prepare the new operating system configuration.
|
||||||
if d.HasChange(mkResourceVirtualEnvironmentContainerOperatingSystem) {
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -2018,9 +2195,14 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
if !bool(template) && rebootRequired {
|
if !bool(template) && rebootRequired {
|
||||||
rebootTimeout := 300
|
rebootTimeout := 300
|
||||||
|
|
||||||
err = veClient.RebootContainer(ctx, nodeName, vmID, &proxmox.VirtualEnvironmentContainerRebootRequestBody{
|
err = veClient.RebootContainer(
|
||||||
|
ctx,
|
||||||
|
nodeName,
|
||||||
|
vmID,
|
||||||
|
&proxmox.VirtualEnvironmentContainerRebootRequestBody{
|
||||||
Timeout: &rebootTimeout,
|
Timeout: &rebootTimeout,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -2029,7 +2211,11 @@ func resourceVirtualEnvironmentContainerUpdate(ctx context.Context, d *schema.Re
|
|||||||
return resourceVirtualEnvironmentContainerRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -2052,10 +2238,15 @@ func resourceVirtualEnvironmentContainerDelete(ctx context.Context, d *schema.Re
|
|||||||
forceStop := proxmox.CustomBool(true)
|
forceStop := proxmox.CustomBool(true)
|
||||||
shutdownTimeout := 300
|
shutdownTimeout := 300
|
||||||
|
|
||||||
err = veClient.ShutdownContainer(ctx, nodeName, vmID, &proxmox.VirtualEnvironmentContainerShutdownRequestBody{
|
err = veClient.ShutdownContainer(
|
||||||
|
ctx,
|
||||||
|
nodeName,
|
||||||
|
vmID,
|
||||||
|
&proxmox.VirtualEnvironmentContainerShutdownRequestBody{
|
||||||
ForceStop: &forceStop,
|
ForceStop: &forceStop,
|
||||||
Timeout: &shutdownTimeout,
|
Timeout: &shutdownTimeout,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerDiskDatastoreID: schema.TypeString,
|
mkResourceVirtualEnvironmentContainerDiskDatastoreID: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerInitialization)
|
initializationSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitialization,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationSchema, []string{
|
testOptionalArguments(t, initializationSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
||||||
@ -110,7 +114,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount: schema.TypeList,
|
mkResourceVirtualEnvironmentContainerInitializationUserAccount: schema.TypeList,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationDNSSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationDNS)
|
initializationDNSSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationDNSSchema, []string{
|
testOptionalArguments(t, initializationDNSSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSDomain,
|
mkResourceVirtualEnvironmentContainerInitializationDNSDomain,
|
||||||
@ -122,7 +130,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerInitializationDNSServer: schema.TypeString,
|
mkResourceVirtualEnvironmentContainerInitializationDNSServer: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfig)
|
initializationIPConfigSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitializationIPConfig,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigSchema, []string{
|
testOptionalArguments(t, initializationIPConfigSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
||||||
@ -134,7 +146,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6: schema.TypeList,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6: schema.TypeList,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigIPv4Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4)
|
initializationIPConfigIPv4Schema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
testOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address,
|
||||||
@ -146,7 +162,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway: schema.TypeString,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigIPv6Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6)
|
initializationIPConfigIPv6Schema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
testOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address,
|
||||||
@ -158,7 +178,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway: schema.TypeString,
|
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationUserAccountSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentContainerInitializationUserAccount)
|
initializationUserAccountSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentContainerInitializationUserAccount,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationUserAccountSchema, []string{
|
testOptionalArguments(t, initializationUserAccountSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys,
|
mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys,
|
||||||
@ -182,7 +206,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerMemorySwap: schema.TypeInt,
|
mkResourceVirtualEnvironmentContainerMemorySwap: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
networkInterfaceSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerNetworkInterface)
|
networkInterfaceSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentContainerNetworkInterface,
|
||||||
|
)
|
||||||
|
|
||||||
testRequiredArguments(t, networkInterfaceSchema, []string{
|
testRequiredArguments(t, networkInterfaceSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceName,
|
||||||
@ -207,7 +235,11 @@ func TestResourceVirtualEnvironmentContainerSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU: schema.TypeInt,
|
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerOperatingSystem)
|
operatingSystemSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
||||||
|
)
|
||||||
|
|
||||||
testRequiredArguments(t, operatingSystemSchema, []string{
|
testRequiredArguments(t, operatingSystemSchema, []string{
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID,
|
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID,
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
diags := resourceVirtualEnvironmentDNSUpdate(ctx, d, m)
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
return diags
|
return diags
|
||||||
@ -66,7 +70,9 @@ func resourceVirtualEnvironmentDNSCreate(ctx context.Context, d *schema.Resource
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resourceVirtualEnvironmentDNSGetUpdateBody(d *schema.ResourceData) (*proxmox.VirtualEnvironmentDNSUpdateRequestBody, error) {
|
func resourceVirtualEnvironmentDNSGetUpdateBody(
|
||||||
|
d *schema.ResourceData,
|
||||||
|
) *proxmox.VirtualEnvironmentDNSUpdateRequestBody {
|
||||||
domain := d.Get(mkResourceVirtualEnvironmentDNSDomain).(string)
|
domain := d.Get(mkResourceVirtualEnvironmentDNSDomain).(string)
|
||||||
servers := d.Get(mkResourceVirtualEnvironmentDNSServers).([]interface{})
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -132,7 +142,11 @@ func resourceVirtualEnvironmentDNSRead(ctx context.Context, d *schema.ResourceDa
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -141,10 +155,7 @@ func resourceVirtualEnvironmentDNSUpdate(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
nodeName := d.Get(mkResourceVirtualEnvironmentDNSNodeName).(string)
|
nodeName := d.Get(mkResourceVirtualEnvironmentDNSNodeName).(string)
|
||||||
|
|
||||||
body, err := resourceVirtualEnvironmentDNSGetUpdateBody(d)
|
body := resourceVirtualEnvironmentDNSGetUpdateBody(d)
|
||||||
if err != nil {
|
|
||||||
return diag.FromErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = veClient.UpdateDNS(ctx, nodeName, body)
|
err = veClient.UpdateDNS(ctx, nodeName, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -154,7 +165,11 @@ func resourceVirtualEnvironmentDNSUpdate(ctx context.Context, d *schema.Resource
|
|||||||
return resourceVirtualEnvironmentDNSRead(ctx, d, m)
|
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("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"github.com/hashicorp/go-cty/cty"
|
"github.com/hashicorp/go-cty/cty"
|
||||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -314,7 +318,11 @@ func resourceVirtualEnvironmentFileCreate(ctx context.Context, d *schema.Resourc
|
|||||||
})
|
})
|
||||||
|
|
||||||
if sourceFileChecksum != calculatedChecksum {
|
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 {
|
} else if len(sourceRaw) > 0 {
|
||||||
@ -402,7 +410,9 @@ func resourceVirtualEnvironmentFileCreate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentFileRead(ctx, d, m)
|
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)
|
contentType := d.Get(mkResourceVirtualEnvironmentFileContentType).(string)
|
||||||
sourceFile := d.Get(mkResourceVirtualEnvironmentFileSourceFile).([]interface{})
|
sourceFile := d.Get(mkResourceVirtualEnvironmentFileSourceFile).([]interface{})
|
||||||
sourceRaw := d.Get(mkResourceVirtualEnvironmentFileSourceRaw).([]interface{})
|
sourceRaw := d.Get(mkResourceVirtualEnvironmentFileSourceRaw).([]interface{})
|
||||||
@ -479,7 +489,6 @@ func resourceVirtualEnvironmentFileGetFileName(d *schema.ResourceData) (*string,
|
|||||||
if sourceFileFileName == "" {
|
if sourceFileFileName == "" {
|
||||||
if resourceVirtualEnvironmentFileIsURL(d) {
|
if resourceVirtualEnvironmentFileIsURL(d) {
|
||||||
downloadURL, err := url.ParseRequestURI(sourceFilePath)
|
downloadURL, err := url.ParseRequestURI(sourceFilePath)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -488,7 +497,10 @@ func resourceVirtualEnvironmentFileGetFileName(d *schema.ResourceData) (*string,
|
|||||||
sourceFileFileName = path[len(path)-1]
|
sourceFileFileName = path[len(path)-1]
|
||||||
|
|
||||||
if sourceFileFileName == "" {
|
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 {
|
} else {
|
||||||
sourceFileFileName = filepath.Base(sourceFilePath)
|
sourceFileFileName = filepath.Base(sourceFilePath)
|
||||||
@ -523,10 +535,15 @@ func resourceVirtualEnvironmentFileIsURL(d *schema.ResourceData) bool {
|
|||||||
return false
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -571,7 +588,7 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
|||||||
}
|
}
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
|
||||||
lastFileModificationDate := d.Get(mkResourceVirtualEnvironmentFileFileModificationDate).(string)
|
lastFileMD := d.Get(mkResourceVirtualEnvironmentFileFileModificationDate).(string)
|
||||||
lastFileSize := int64(d.Get(mkResourceVirtualEnvironmentFileFileSize).(int))
|
lastFileSize := int64(d.Get(mkResourceVirtualEnvironmentFileFileSize).(int))
|
||||||
lastFileTag := d.Get(mkResourceVirtualEnvironmentFileFileTag).(string)
|
lastFileTag := d.Get(mkResourceVirtualEnvironmentFileFileTag).(string)
|
||||||
|
|
||||||
@ -584,7 +601,9 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
|||||||
err = d.Set(mkResourceVirtualEnvironmentFileFileTag, fileTag)
|
err = d.Set(mkResourceVirtualEnvironmentFileFileTag, fileTag)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
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)
|
err = d.Set(mkResourceVirtualEnvironmentFileSourceFile, sourceFile)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
|
||||||
@ -600,14 +619,17 @@ func resourceVirtualEnvironmentFileRead(ctx context.Context, d *schema.ResourceD
|
|||||||
return nil
|
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)
|
f, err := os.Open(sourceFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func(f *os.File) {
|
defer func(f *os.File) {
|
||||||
var err = f.Close()
|
err := f.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tflog.Error(ctx, "failed to close the file", map[string]interface{}{
|
tflog.Error(ctx, "failed to close the file", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
@ -627,14 +649,18 @@ func readFile(ctx context.Context, sourceFilePath string) (fileModificationDate
|
|||||||
return fileModificationDate, fileSize, fileTag, nil
|
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)
|
res, err := http.Head(sourceFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func(Body io.ReadCloser) {
|
defer func(Body io.ReadCloser) {
|
||||||
var err = Body.Close()
|
err := Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tflog.Error(ctx, "failed to close the response body", map[string]interface{}{
|
tflog.Error(ctx, "failed to close the response body", map[string]interface{}{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
@ -681,7 +707,11 @@ func readURL(ctx context.Context, d *schema.ResourceData, sourceFilePath string)
|
|||||||
return
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -110,7 +114,9 @@ func resourceVirtualEnvironmentGroupCreate(ctx context.Context, d *schema.Resour
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(false)
|
aclDelete := proxmox.CustomBool(false)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -129,7 +135,11 @@ func resourceVirtualEnvironmentGroupCreate(ctx context.Context, d *schema.Resour
|
|||||||
return resourceVirtualEnvironmentGroupRead(ctx, d, m)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -140,7 +150,6 @@ func resourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.Resource
|
|||||||
|
|
||||||
groupID := d.Id()
|
groupID := d.Id()
|
||||||
group, err := veClient.GetGroup(ctx, groupID)
|
group, err := veClient.GetGroup(ctx, groupID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -191,7 +200,11 @@ func resourceVirtualEnvironmentGroupRead(ctx context.Context, d *schema.Resource
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -216,7 +229,9 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
|||||||
for _, v := range aclParsedOld {
|
for _, v := range aclParsedOld {
|
||||||
aclDelete := proxmox.CustomBool(true)
|
aclDelete := proxmox.CustomBool(true)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -237,7 +252,9 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(false)
|
aclDelete := proxmox.CustomBool(false)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -256,7 +273,11 @@ func resourceVirtualEnvironmentGroupUpdate(ctx context.Context, d *schema.Resour
|
|||||||
return resourceVirtualEnvironmentGroupRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -269,7 +290,9 @@ func resourceVirtualEnvironmentGroupDelete(ctx context.Context, d *schema.Resour
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(true)
|
aclDelete := proxmox.CustomBool(true)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentGroupACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
diags := resourceVirtualEnvironmentHostsUpdate(ctx, d, m)
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
return diags
|
return diags
|
||||||
@ -119,7 +123,11 @@ func resourceVirtualEnvironmentHostsCreate(ctx context.Context, d *schema.Resour
|
|||||||
return diags
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -189,7 +197,11 @@ func resourceVirtualEnvironmentHostsRead(ctx context.Context, d *schema.Resource
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -228,7 +240,11 @@ func resourceVirtualEnvironmentHostsUpdate(ctx context.Context, d *schema.Resour
|
|||||||
return resourceVirtualEnvironmentHostsRead(ctx, d, m)
|
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("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -109,7 +113,11 @@ func resourceVirtualEnvironmentPoolCreate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentPoolRead(ctx, d, m)
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -120,7 +128,6 @@ func resourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceD
|
|||||||
|
|
||||||
poolID := d.Id()
|
poolID := d.Id()
|
||||||
pool, err := veClient.GetPool(ctx, poolID)
|
pool, err := veClient.GetPool(ctx, poolID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -167,7 +174,11 @@ func resourceVirtualEnvironmentPoolRead(ctx context.Context, d *schema.ResourceD
|
|||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -189,7 +200,11 @@ func resourceVirtualEnvironmentPoolUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentPoolRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,9 +9,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -72,7 +76,11 @@ func resourceVirtualEnvironmentRoleCreate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentRoleRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -81,7 +89,6 @@ func resourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceD
|
|||||||
|
|
||||||
roleID := d.Id()
|
roleID := d.Id()
|
||||||
role, err := veClient.GetRole(ctx, roleID)
|
role, err := veClient.GetRole(ctx, roleID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -103,7 +110,11 @@ func resourceVirtualEnvironmentRoleRead(ctx context.Context, d *schema.ResourceD
|
|||||||
return diag.FromErr(err)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -130,7 +141,11 @@ func resourceVirtualEnvironmentRoleUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentRoleRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -10,9 +10,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/bpg/terraform-provider-proxmox/proxmox"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
diags := resourceVirtualEnvironmentTimeUpdate(ctx, d, m)
|
||||||
if diags.HasError() {
|
if diags.HasError() {
|
||||||
return diags
|
return diags
|
||||||
@ -66,7 +70,12 @@ func resourceVirtualEnvironmentTimeCreate(ctx context.Context, d *schema.Resourc
|
|||||||
return nil
|
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
|
var diags diag.Diagnostics
|
||||||
|
|
||||||
config := m.(providerConfiguration)
|
config := m.(providerConfiguration)
|
||||||
@ -91,17 +100,24 @@ func resourceVirtualEnvironmentTimeRead(ctx context.Context, d *schema.ResourceD
|
|||||||
localTimeOffset := time.Time(nodeTime.LocalTime).Sub(time.Now().UTC())
|
localTimeOffset := time.Time(nodeTime.LocalTime).Sub(time.Now().UTC())
|
||||||
localTime := time.Time(nodeTime.LocalTime).Add(-localTimeOffset).In(localLocation)
|
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)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
err = d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
err = d.Set(mkResourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
|
||||||
diags = append(diags, diag.FromErr(err)...)
|
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)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
|
||||||
return diags
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -111,9 +127,13 @@ func resourceVirtualEnvironmentTimeUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
nodeName := d.Get(mkResourceVirtualEnvironmentTimeNodeName).(string)
|
nodeName := d.Get(mkResourceVirtualEnvironmentTimeNodeName).(string)
|
||||||
timeZone := d.Get(mkResourceVirtualEnvironmentTimeTimeZone).(string)
|
timeZone := d.Get(mkResourceVirtualEnvironmentTimeTimeZone).(string)
|
||||||
|
|
||||||
err = veClient.UpdateNodeTime(ctx, nodeName, &proxmox.VirtualEnvironmentNodeUpdateTimeRequestBody{
|
err = veClient.UpdateNodeTime(
|
||||||
|
ctx,
|
||||||
|
nodeName,
|
||||||
|
&proxmox.VirtualEnvironmentNodeUpdateTimeRequestBody{
|
||||||
TimeZone: timeZone,
|
TimeZone: timeZone,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -121,7 +141,11 @@ func resourceVirtualEnvironmentTimeUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentTimeRead(ctx, d, m)
|
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("")
|
d.SetId("")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -10,10 +10,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
"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/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/proxmox"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -152,7 +156,10 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
|||||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||||
enabled := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -196,7 +203,9 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(false)
|
aclDelete := proxmox.CustomBool(false)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -215,7 +224,11 @@ func resourceVirtualEnvironmentUserCreate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentUserRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -224,7 +237,6 @@ func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceD
|
|||||||
|
|
||||||
userID := d.Id()
|
userID := d.Id()
|
||||||
user, err := veClient.GetUser(ctx, userID)
|
user, err := veClient.GetUser(ctx, userID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if strings.Contains(err.Error(), "HTTP 404") {
|
if strings.Contains(err.Error(), "HTTP 404") {
|
||||||
d.SetId("")
|
d.SetId("")
|
||||||
@ -286,7 +298,10 @@ func resourceVirtualEnvironmentUserRead(ctx context.Context, d *schema.ResourceD
|
|||||||
diags = append(diags, diag.FromErr(err)...)
|
diags = append(diags, diag.FromErr(err)...)
|
||||||
|
|
||||||
if user.ExpirationDate != nil {
|
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 {
|
} else {
|
||||||
err = d.Set(mkResourceVirtualEnvironmentUserExpirationDate, time.Unix(0, 0).UTC().Format(time.RFC3339))
|
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
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -337,7 +356,10 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
comment := d.Get(mkResourceVirtualEnvironmentUserComment).(string)
|
||||||
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
email := d.Get(mkResourceVirtualEnvironmentUserEmail).(string)
|
||||||
enabled := proxmox.CustomBool(d.Get(mkResourceVirtualEnvironmentUserEnabled).(bool))
|
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 {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -385,7 +407,9 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
for _, v := range aclParsedOld {
|
for _, v := range aclParsedOld {
|
||||||
aclDelete := proxmox.CustomBool(true)
|
aclDelete := proxmox.CustomBool(true)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -406,7 +430,9 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(false)
|
aclDelete := proxmox.CustomBool(false)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
@ -417,7 +443,6 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := veClient.UpdateACL(ctx, aclBody)
|
err := veClient.UpdateACL(ctx, aclBody)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
@ -426,7 +451,11 @@ func resourceVirtualEnvironmentUserUpdate(ctx context.Context, d *schema.Resourc
|
|||||||
return resourceVirtualEnvironmentUserRead(ctx, d, m)
|
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)
|
config := m.(providerConfiguration)
|
||||||
veClient, err := config.GetVEClient()
|
veClient, err := config.GetVEClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -439,7 +468,9 @@ func resourceVirtualEnvironmentUserDelete(ctx context.Context, d *schema.Resourc
|
|||||||
for _, v := range aclParsed {
|
for _, v := range aclParsed {
|
||||||
aclDelete := proxmox.CustomBool(true)
|
aclDelete := proxmox.CustomBool(true)
|
||||||
aclEntry := v.(map[string]interface{})
|
aclEntry := v.(map[string]interface{})
|
||||||
aclPropagate := proxmox.CustomBool(aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool))
|
aclPropagate := proxmox.CustomBool(
|
||||||
|
aclEntry[mkResourceVirtualEnvironmentUserACLPropagate].(bool),
|
||||||
|
)
|
||||||
|
|
||||||
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
aclBody := &proxmox.VirtualEnvironmentACLUpdateRequestBody{
|
||||||
Delete: &aclDelete,
|
Delete: &aclDelete,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -185,7 +185,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMDiskSize: schema.TypeInt,
|
mkResourceVirtualEnvironmentVMDiskSize: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
diskSpeedSchema := testNestedSchemaExistence(t, diskSchema, mkResourceVirtualEnvironmentVMDiskSpeed)
|
diskSpeedSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
diskSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMDiskSpeed,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, diskSpeedSchema, []string{
|
testOptionalArguments(t, diskSpeedSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedRead,
|
mkResourceVirtualEnvironmentVMDiskSpeedRead,
|
||||||
@ -201,7 +205,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMDiskSpeedWriteBurstable: schema.TypeInt,
|
mkResourceVirtualEnvironmentVMDiskSpeedWriteBurstable: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMInitialization)
|
initializationSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentVMInitialization,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationSchema, []string{
|
testOptionalArguments(t, initializationSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationDatastoreID,
|
mkResourceVirtualEnvironmentVMInitializationDatastoreID,
|
||||||
@ -236,7 +244,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA: schema.TypeBool,
|
mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA: schema.TypeBool,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationDNSSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentVMInitializationDNS)
|
initializationDNSSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMInitializationDNS,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationDNSSchema, []string{
|
testOptionalArguments(t, initializationDNSSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSDomain,
|
mkResourceVirtualEnvironmentVMInitializationDNSDomain,
|
||||||
@ -248,7 +260,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMInitializationDNSServer: schema.TypeString,
|
mkResourceVirtualEnvironmentVMInitializationDNSServer: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentVMInitializationIPConfig)
|
initializationIPConfigSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMInitializationIPConfig,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigSchema, []string{
|
testOptionalArguments(t, initializationIPConfigSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4,
|
||||||
@ -260,7 +276,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6: schema.TypeList,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6: schema.TypeList,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigIPv4Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4)
|
initializationIPConfigIPv4Schema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
testOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Address,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Address,
|
||||||
@ -272,7 +292,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Gateway: schema.TypeString,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Gateway: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationIPConfigIPv6Schema := testNestedSchemaExistence(t, initializationIPConfigSchema, mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6)
|
initializationIPConfigIPv6Schema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
testOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Address,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Address,
|
||||||
@ -284,7 +308,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Gateway: schema.TypeString,
|
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Gateway: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
initializationUserAccountSchema := testNestedSchemaExistence(t, initializationSchema, mkResourceVirtualEnvironmentVMInitializationUserAccount)
|
initializationUserAccountSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkResourceVirtualEnvironmentVMInitializationUserAccount,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, initializationUserAccountSchema, []string{
|
testOptionalArguments(t, initializationUserAccountSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountKeys,
|
mkResourceVirtualEnvironmentVMInitializationUserAccountKeys,
|
||||||
@ -312,7 +340,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMMemoryShared: schema.TypeInt,
|
mkResourceVirtualEnvironmentVMMemoryShared: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
networkDeviceSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMNetworkDevice)
|
networkDeviceSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentVMNetworkDevice,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, networkDeviceSchema, []string{
|
testOptionalArguments(t, networkDeviceSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceBridge,
|
mkResourceVirtualEnvironmentVMNetworkDeviceBridge,
|
||||||
@ -334,7 +366,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: schema.TypeInt,
|
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: schema.TypeInt,
|
||||||
})
|
})
|
||||||
|
|
||||||
operatingSystemSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMOperatingSystem)
|
operatingSystemSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentVMOperatingSystem,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, operatingSystemSchema, []string{
|
testOptionalArguments(t, operatingSystemSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystemType,
|
mkResourceVirtualEnvironmentVMOperatingSystemType,
|
||||||
@ -344,7 +380,11 @@ func TestResourceVirtualEnvironmentVMSchema(t *testing.T) {
|
|||||||
mkResourceVirtualEnvironmentVMOperatingSystemType: schema.TypeString,
|
mkResourceVirtualEnvironmentVMOperatingSystemType: schema.TypeString,
|
||||||
})
|
})
|
||||||
|
|
||||||
serialDeviceSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMSerialDevice)
|
serialDeviceSchema := testNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkResourceVirtualEnvironmentVMSerialDevice,
|
||||||
|
)
|
||||||
|
|
||||||
testOptionalArguments(t, serialDeviceSchema, []string{
|
testOptionalArguments(t, serialDeviceSchema, []string{
|
||||||
mkResourceVirtualEnvironmentVMSerialDeviceDevice,
|
mkResourceVirtualEnvironmentVMSerialDeviceDevice,
|
||||||
|
Loading…
Reference in New Issue
Block a user