├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── release.yml
│ └── test.yml
├── .gitignore
├── .goreleaser.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── docs
├── .gitignore
├── 404.html
├── Gemfile
├── Gemfile.lock
├── _config.yml
├── assets
│ └── js
│ │ └── search-data.json
├── data-sources
│ ├── index.html
│ ├── virtual_environment_cluster_alias.md
│ ├── virtual_environment_cluster_aliases.md
│ ├── virtual_environment_datastores.md
│ ├── virtual_environment_dns.md
│ ├── virtual_environment_group.md
│ ├── virtual_environment_groups.md
│ ├── virtual_environment_hosts.md
│ ├── virtual_environment_nodes.md
│ ├── virtual_environment_pool.md
│ ├── virtual_environment_pools.md
│ ├── virtual_environment_role.md
│ ├── virtual_environment_roles.md
│ ├── virtual_environment_time.md
│ ├── virtual_environment_user.md
│ ├── virtual_environment_users.md
│ └── virtual_environment_version.md
├── index.md
└── resources
│ ├── index.html
│ ├── virtual_environment_certificate.md
│ ├── virtual_environment_cluster_alias.md
│ ├── virtual_environment_cluster_ipset.md
│ ├── virtual_environment_container.md
│ ├── virtual_environment_dns.md
│ ├── virtual_environment_file.md
│ ├── virtual_environment_group.md
│ ├── virtual_environment_hosts.md
│ ├── virtual_environment_pool.md
│ ├── virtual_environment_role.md
│ ├── virtual_environment_time.md
│ ├── virtual_environment_user.md
│ └── virtual_environment_vm.md
├── example.tfrc
├── example
├── data_source_virtual_environment_cluster_alias.tf
├── data_source_virtual_environment_cluster_aliases.tf
├── data_source_virtual_environment_datastores.tf
├── data_source_virtual_environment_dns.tf
├── data_source_virtual_environment_group.tf
├── data_source_virtual_environment_groups.tf
├── data_source_virtual_environment_hosts.tf
├── data_source_virtual_environment_nodes.tf
├── data_source_virtual_environment_pool.tf
├── data_source_virtual_environment_pools.tf
├── data_source_virtual_environment_role.tf
├── data_source_virtual_environment_roles.tf
├── data_source_virtual_environment_time.tf
├── data_source_virtual_environment_user.tf
├── data_source_virtual_environment_users.tf
├── data_source_virtual_environment_version.tf
├── main.tf
├── resource_virtual_environemnt_cluster_alias.tf
├── resource_virtual_environment_certificate.tf
├── resource_virtual_environment_cluster_ipset.tf
├── resource_virtual_environment_container.tf
├── resource_virtual_environment_dns.tf
├── resource_virtual_environment_file.tf
├── resource_virtual_environment_group.tf
├── resource_virtual_environment_hosts.tf
├── resource_virtual_environment_pool.tf
├── resource_virtual_environment_role.tf
├── resource_virtual_environment_time.tf
├── resource_virtual_environment_user.tf
├── resource_virtual_environment_vm.tf
├── ssh.tf
├── variables.tf
└── versions.tf
├── go.mod
├── go.sum
├── main.go
├── proxmox
├── common_types.go
├── virtual_environment_acl.go
├── virtual_environment_acl_types.go
├── virtual_environment_authentication.go
├── virtual_environment_authentication_types.go
├── virtual_environment_certificate.go
├── virtual_environment_certificate_types.go
├── virtual_environment_client.go
├── virtual_environment_client_types.go
├── virtual_environment_cluster.go
├── virtual_environment_cluster_alias.go
├── virtual_environment_cluster_alias_types.go
├── virtual_environment_cluster_ipset.go
├── virtual_environment_cluster_ipset_types.go
├── virtual_environment_cluster_types.go
├── virtual_environment_container.go
├── virtual_environment_container_types.go
├── virtual_environment_datastores.go
├── virtual_environment_datastores_types.go
├── virtual_environment_dns.go
├── virtual_environment_dns_types.go
├── virtual_environment_groups.go
├── virtual_environment_groups_types.go
├── virtual_environment_hosts.go
├── virtual_environment_hosts_types.go
├── virtual_environment_nodes.go
├── virtual_environment_nodes_types.go
├── virtual_environment_pools.go
├── virtual_environment_pools_types.go
├── virtual_environment_roles.go
├── virtual_environment_roles_types.go
├── virtual_environment_users.go
├── virtual_environment_users_types.go
├── virtual_environment_version.go
├── virtual_environment_version_types.go
├── virtual_environment_vm.go
└── virtual_environment_vm_types.go
└── proxmoxtf
├── data_source_virtual_environment_cluster_alias.go
├── data_source_virtual_environment_cluster_alias_test.go
├── data_source_virtual_environment_cluster_aliases.go
├── data_source_virtual_environment_cluster_aliases_test.go
├── data_source_virtual_environment_datastores.go
├── data_source_virtual_environment_datastores_test.go
├── data_source_virtual_environment_dns.go
├── data_source_virtual_environment_dns_test.go
├── data_source_virtual_environment_group.go
├── data_source_virtual_environment_group_test.go
├── data_source_virtual_environment_groups.go
├── data_source_virtual_environment_groups_test.go
├── data_source_virtual_environment_hosts.go
├── data_source_virtual_environment_hosts_test.go
├── data_source_virtual_environment_nodes.go
├── data_source_virtual_environment_nodes_test.go
├── data_source_virtual_environment_pool.go
├── data_source_virtual_environment_pool_test.go
├── data_source_virtual_environment_pools.go
├── data_source_virtual_environment_pools_test.go
├── data_source_virtual_environment_role.go
├── data_source_virtual_environment_role_test.go
├── data_source_virtual_environment_roles.go
├── data_source_virtual_environment_roles_test.go
├── data_source_virtual_environment_time.go
├── data_source_virtual_environment_time_test.go
├── data_source_virtual_environment_user.go
├── data_source_virtual_environment_user_test.go
├── data_source_virtual_environment_users.go
├── data_source_virtual_environment_users_test.go
├── data_source_virtual_environment_version.go
├── data_source_virtual_environment_version_test.go
├── provider.go
├── provider_test.go
├── resource_virtual_environment_certificate.go
├── resource_virtual_environment_certificate_test.go
├── resource_virtual_environment_cluster_alias.go
├── resource_virtual_environment_cluster_alias_test.go
├── resource_virtual_environment_cluster_ipset.go
├── resource_virtual_environment_cluster_ipset_test.go
├── resource_virtual_environment_container.go
├── resource_virtual_environment_container_test.go
├── resource_virtual_environment_dns.go
├── resource_virtual_environment_dns_test.go
├── resource_virtual_environment_file.go
├── resource_virtual_environment_file_test.go
├── resource_virtual_environment_group.go
├── resource_virtual_environment_group_test.go
├── resource_virtual_environment_hosts.go
├── resource_virtual_environment_hosts_test.go
├── resource_virtual_environment_pool.go
├── resource_virtual_environment_pool_test.go
├── resource_virtual_environment_role.go
├── resource_virtual_environment_role_test.go
├── resource_virtual_environment_time.go
├── resource_virtual_environment_time_test.go
├── resource_virtual_environment_user.go
├── resource_virtual_environment_user_test.go
├── resource_virtual_environment_vm.go
├── resource_virtual_environment_vm_test.go
├── utils.go
└── version.go
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[FEATURE]"
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
2 | ### Community Note
3 |
4 | * Please vote on this pull request by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original pull request comment to help the community and maintainers prioritize this request
5 | * Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
6 |
7 |
8 |
9 | Relates OR Closes #0000
10 |
11 | Release note for [CHANGELOG](https://github.com/danitso/terraform-provider-proxmox/blob/master/CHANGELOG.md):
12 |
13 |
14 | ```release-note
15 |
16 | ```
17 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Create release
2 | on:
3 | push:
4 | tags:
5 | - 'v*'
6 | jobs:
7 | release:
8 | name: Tag
9 | runs-on: ubuntu-20.04
10 | steps:
11 | -
12 | name: Checkout the code
13 | uses: actions/checkout@v2
14 | with:
15 | fetch-depth: 0
16 | -
17 | name: Install and configure Go
18 | uses: actions/setup-go@v2
19 | with:
20 | go-version: 1.15
21 | -
22 | name: Install and configure GoReleaser
23 | env:
24 | GORELEASER_VERSION: '0.155.1'
25 | run: |
26 | curl -sL -o goreleaser_amd64.deb "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_amd64.deb"
27 | sudo dpkg -i goreleaser_amd64.deb
28 | rm -f goreleaser_amd64.deb
29 | -
30 | name: Import the GPG signing key
31 | env:
32 | GPG_KEY: ${{ secrets.GPG_KEY }}
33 | GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
34 | run: |
35 | mkdir -p ~/.gnupg
36 | chmod 0700 ~/.gnupg
37 |
38 | cat << EOF > ~/.gnupg/gpg.conf
39 | use-agent
40 | pinentry-mode loopback
41 | EOF
42 |
43 | echo "$GPG_KEY" | base64 -d | gpg --batch --allow-secret-key-import --import
44 | gpg --keyid-format LONG --list-secret-keys
45 |
46 | cat << EOF > ~/.gnupg/gpg-agent.conf
47 | default-cache-ttl 7200
48 | max-cache-ttl 31536000
49 | allow-loopback-pinentry
50 | allow-preset-passphrase
51 | EOF
52 |
53 | echo RELOADAGENT | gpg-connect-agent
54 |
55 | printf '%s' "$GPG_PASSPHRASE" > /tmp/.gpg_passphrase
56 | -
57 | name: Create release
58 | env:
59 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 | GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
61 | run: |
62 | goreleaser release --parallelism 2 --rm-dist --timeout 1h
63 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test changes
2 | on:
3 | pull_request:
4 | branches:
5 | - main
6 | - master
7 | - 'release/v*'
8 | jobs:
9 | test:
10 | name: Pull Request
11 | runs-on: ubuntu-20.04
12 | steps:
13 | -
14 | name: Checkout the code
15 | uses: actions/checkout@v2
16 | with:
17 | fetch-depth: 0
18 | -
19 | name: Install and configure Go
20 | uses: actions/setup-go@v2
21 | with:
22 | go-version: 1.15
23 | -
24 | name: Install and configure GoReleaser
25 | env:
26 | GORELEASER_VERSION: '0.155.1'
27 | run: |
28 | curl -sL -o goreleaser_amd64.deb "https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/goreleaser_amd64.deb"
29 | sudo dpkg -i goreleaser_amd64.deb
30 | rm -f goreleaser_amd64.deb
31 | -
32 | name: Create snapshot
33 | run: |
34 | goreleaser build --parallelism 2 --rm-dist --snapshot --timeout 1h
35 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /example/terraform-provider-*
2 | /pkg/
3 | /website/.vagrant
4 | /website/.bundle
5 | /website/build
6 | /website/node_modules
7 | /website/vendor
8 |
9 | autogenerated/
10 | bin/
11 | cache/
12 | dist/
13 | modules-dev/
14 |
15 | .terraform/
16 | .vagrant/
17 |
18 | *~
19 | *.backup
20 | *.bak
21 | *.dll
22 | *.exe
23 | *.iml
24 | *.lock.hcl
25 | *.log
26 | *.test
27 | *.tfplan
28 | *.tfstate
29 | *.tfstate.lock.info
30 | *.tfvars
31 |
32 | .*.swp
33 | .DS_Store
34 | .idea
35 |
36 | # Test exclusions
37 | !command/test-fixtures/**/*.tfstate
38 | !command/test-fixtures/**/.terraform/
39 |
--------------------------------------------------------------------------------
/.goreleaser.yml:
--------------------------------------------------------------------------------
1 | before:
2 | hooks:
3 | - go mod tidy
4 | builds:
5 | - env:
6 | - CGO_ENABLED=0
7 | mod_timestamp: '{{ .CommitTimestamp }}'
8 | flags:
9 | - -trimpath
10 | ldflags:
11 | - '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
12 | goos:
13 | - freebsd
14 | - windows
15 | - linux
16 | - darwin
17 | goarch:
18 | - amd64
19 | - '386'
20 | - arm
21 | - arm64
22 | ignore:
23 | - goos: darwin
24 | goarch: '386'
25 | binary: '{{ .ProjectName }}_v{{ .Version }}'
26 | archives:
27 | - format: zip
28 | name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
29 | checksum:
30 | name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
31 | algorithm: sha256
32 | signs:
33 | - artifacts: checksum
34 | args:
35 | - "--batch"
36 | - "--local-user"
37 | - "{{ .Env.GPG_FINGERPRINT }}"
38 | - "--output"
39 | - "${signature}"
40 | - "--passphrase-fd"
41 | - "0"
42 | - "--detach-sign"
43 | - "${artifact}"
44 | stdin_file: /tmp/.gpg_passphrase
45 | release:
46 | draft: false
47 | changelog:
48 | skip: true
49 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at info@danitso.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | **First:** if you're unsure or afraid of _anything_, ask for help! You can
4 | submit a work in progress (WIP) pull request, or file an issue with the parts
5 | you know. We'll do our best to guide you in the right direction, and let you
6 | know if there are guidelines we will need to follow. We want people to be able
7 | to participate without fear of doing the wrong thing.
8 |
9 | Below are our expectations for contributors. Following these guidelines gives us
10 | the best opportunity to work with you, by making sure we have the things we need
11 | in order to make it happen. Doing your best to follow it will speed up our
12 | ability to merge PRs and respond to issues.
13 |
14 | ## Testing
15 |
16 | The project has a handful of test cases which must pass for a contribution to be
17 | accepted. We also expect that you either create new test cases or modify
18 | existing ones in order to target your changes.
19 |
20 | You can run all the test cases by invoking `make test`.
21 |
22 | ## Submitting changes
23 |
24 | Please create a new PR against the `master` branch which must be based on the
25 | project's [pull request template](.github/PULL_REQUEST_TEMPLATE.md).
26 |
27 | ## Coding conventions
28 |
29 | We expect that all code contributions have been formatted using `gofmt`.
30 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
2 | NAME=$$(grep TerraformProviderName proxmoxtf/version.go | grep -o -e 'terraform-provider-[a-z]*')
3 | TARGETS=darwin linux windows
4 | TERRAFORM_PLUGIN_EXTENSION=
5 | VERSION=$$(grep TerraformProviderVersion proxmoxtf/version.go | grep -o -e '[0-9]\.[0-9]\.[0-9]')
6 | VERSION_EXAMPLE=9999.0.0
7 |
8 | ifeq ($(OS),Windows_NT)
9 | TERRAFORM_PLATFORM=windows_amd64
10 | TERRAFORM_PLUGIN_CACHE_DIRECTORY=$$(cygpath -u "$(shell pwd -P)")/cache/plugins
11 | TERRAFORM_PLUGIN_EXTENSION=.exe
12 | else
13 | UNAME_S=$$(shell uname -s)
14 |
15 | ifeq ($(UNAME_S),Darwin)
16 | TERRAFORM_PLATFORM=darwin_amd64
17 | else
18 | TERRAFORM_PLATFORM=linux_amd64
19 | endif
20 |
21 | TERRAFORM_PLUGIN_CACHE_DIRECTORY=$(shell pwd -P)/cache/plugins
22 | endif
23 |
24 | TERRAFORM_PLUGIN_DIRECTORY=$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)/registry.terraform.io/danitso/proxmox/$(VERSION)/$(TERRAFORM_PLATFORM)
25 | TERRAFORM_PLUGIN_DIRECTORY_EXAMPLE=$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)/registry.terraform.io/danitso/proxmox/$(VERSION_EXAMPLE)/$(TERRAFORM_PLATFORM)
26 | TERRAFORM_PLUGIN_EXECUTABLE=$(TERRAFORM_PLUGIN_DIRECTORY)/$(NAME)_v$(VERSION)_x4$(TERRAFORM_PLUGIN_EXTENSION)
27 | TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE=$(TERRAFORM_PLUGIN_DIRECTORY_EXAMPLE)/$(NAME)_v$(VERSION_EXAMPLE)_x4$(TERRAFORM_PLUGIN_EXTENSION)
28 |
29 | default: build
30 |
31 | build:
32 | mkdir -p "$(TERRAFORM_PLUGIN_DIRECTORY)"
33 | rm -f "$(TERRAFORM_PLUGIN_EXECUTABLE)"
34 | go build -o "$(TERRAFORM_PLUGIN_EXECUTABLE)"
35 |
36 | example: example-build example-init example-apply example-apply example-destroy
37 |
38 | example-apply:
39 | export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
40 | && export TF_DISABLE_CHECKPOINT="true" \
41 | && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
42 | && cd ./example \
43 | && terraform apply -auto-approve
44 |
45 | example-build:
46 | mkdir -p "$(TERRAFORM_PLUGIN_DIRECTORY_EXAMPLE)"
47 | rm -f "$(TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE)"
48 | go build -o "$(TERRAFORM_PLUGIN_EXECUTABLE_EXAMPLE)"
49 |
50 | example-destroy:
51 | export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
52 | && export TF_DISABLE_CHECKPOINT="true" \
53 | && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
54 | && cd ./example \
55 | && terraform destroy -auto-approve
56 |
57 | example-init:
58 | export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
59 | && export TF_DISABLE_CHECKPOINT="true" \
60 | && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
61 | && cd ./example \
62 | && rm -f .terraform.lock.hcl \
63 | && terraform init \
64 | -verify-plugins=false
65 |
66 | example-plan:
67 | export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \
68 | && export TF_DISABLE_CHECKPOINT="true" \
69 | && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \
70 | && cd ./example \
71 | && terraform plan
72 |
73 | fmt:
74 | gofmt -s -w $(GOFMT_FILES)
75 |
76 | init:
77 | go get ./...
78 |
79 | targets: $(TARGETS)
80 |
81 | test:
82 | go test -v ./...
83 |
84 | $(TARGETS):
85 | GOOS=$@ GOARCH=amd64 CGO_ENABLED=0 go build \
86 | -o "dist/$@/$(NAME)_v$(VERSION)-custom_x4" \
87 | -a -ldflags '-extldflags "-static"'
88 | zip \
89 | -j "dist/$(NAME)_v$(VERSION)-custom_$@_amd64.zip" \
90 | "dist/$@/$(NAME)_v$(VERSION)-custom_x4"
91 |
92 | .PHONY: build example example-apply example-destroy example-init example-plan fmt init targets test $(TARGETS)
93 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://goreportcard.com/report/github.com/danitso/terraform-provider-proxmox)
2 | [](http://godoc.org/github.com/danitso/terraform-provider-proxmox)
3 |
4 | # Terraform Provider for Proxmox
5 | A Terraform Provider which adds support for Proxmox solutions.
6 |
7 | ## Requirements
8 | - [Terraform](https://www.terraform.io/downloads.html) 0.13+
9 | - [Go](https://golang.org/doc/install) 1.15+ (to build the provider plugin)
10 | - [GoReleaser](https://goreleaser.com/install/) 0.155+ (to build the provider plugin)
11 |
12 | ## Table of Contents
13 | - [Building the provider](#building-the-provider)
14 | - [Using the provider](#using-the-provider)
15 | - [Testing the provider](#testing-the-provider)
16 | - [Known issues](#known-issues)
17 |
18 | ## Building the provider
19 | - Clone the repository to `$GOPATH/src/github.com/danitso/terraform-provider-proxmox`:
20 |
21 | ```sh
22 | $ mkdir -p "${GOPATH}/src/github.com/danitso"
23 | $ cd "${GOPATH}/src/github.com/danitso"
24 | $ git clone git@github.com:danitso/terraform-provider-proxmox
25 | ```
26 |
27 | - Enter the provider directory and build it:
28 |
29 | ```sh
30 | $ cd "${GOPATH}/src/github.com/danitso/terraform-provider-proxmox"
31 | $ make build
32 | ```
33 |
34 | ## Using the provider
35 | You can find the latest release and its documentation in the [Terraform Registry](https://registry.terraform.io/providers/danitso/proxmox/latest).
36 |
37 | ## Testing the provider
38 | In order to test the provider, you can simply run `make test`.
39 |
40 | ```sh
41 | $ make test
42 | ```
43 |
44 | Tests are limited to regression tests, ensuring backwards compability.
45 |
46 | ## Known issues
47 |
48 | ### Disk images cannot be imported by non-PAM accounts
49 | 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).
50 |
51 | ### Disk images from VMware cannot be uploaded or imported
52 | Proxmox VE is not currently supporting VMware disk images directly. However, you can still use them as disk images by using this workaround:
53 |
54 | ```hcl
55 | resource "proxmox_virtual_environment_file" "vmdk_disk_image" {
56 | content_type = "iso"
57 | datastore_id = "datastore-id"
58 | node_name = "node-name"
59 |
60 | source_file {
61 | # We must override the file extension to bypass the validation code in the Proxmox VE API.
62 | file_name = "vmdk-file-name.img"
63 | path = "path-to-vmdk-file"
64 | }
65 | }
66 |
67 | resource "proxmox_virtual_environment_vm" "example" {
68 | ...
69 |
70 | disk {
71 | datastore_id = "datastore-id"
72 | # We must tell the provider that the file format is vmdk instead of qcow2.
73 | file_format = "vmdk"
74 | file_id = "${proxmox_virtual_environment_file.vmdk_disk_image.id}"
75 | }
76 |
77 | ...
78 | }
79 | ```
80 |
81 | ### Snippets cannot be uploaded by non-PAM accounts
82 | 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).
83 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | _site
2 | .sass-cache
3 | .jekyll-metadata
4 |
--------------------------------------------------------------------------------
/docs/404.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: 404
4 | nav_exclude: true
5 | ---
6 |
7 |
20 |
21 |
22 |
404
23 |
24 |
Page not found :(
25 |
The requested page could not be found.
26 |
27 |
--------------------------------------------------------------------------------
/docs/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | # Hello! This is where you manage which Jekyll version is used to run.
4 | # When you want to use a different version, change it below, save the
5 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
6 | #
7 | # bundle exec jekyll serve
8 | #
9 | # This will help ensure the proper Jekyll version is running.
10 | # Happy Jekylling!
11 |
12 | gem "activesupport", ">= 4.1.11"
13 | gem "jekyll", "~> 3.9"
14 | gem "just-the-docs", "~> 0.3"
15 | gem "webrick", "~> 1.7"
16 |
17 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and
18 | # uncomment the line below. To upgrade, run `bundle update github-pages`.
19 | gem "github-pages", group: :jekyll_plugins
20 |
21 | # If you have any plugins, put them here!
22 | group :jekyll_plugins do
23 | gem "rouge", "~> 3.26"
24 | end
25 |
26 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
27 | gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
28 |
29 | # Performance-booster for watching directories on Windows
30 | gem "wdm", "~> 0.1" if Gem.win_platform?
31 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | email: info@danitso.com
2 | title: Proxmox Provider
3 | description: >-
4 | Terraform Provider for Proxmox.
5 | github_username: "danitso"
6 |
7 | highlighter: rouge
8 | markdown: kramdown
9 | plugins:
10 | - github-pages
11 | remote_theme: pmarsceill/just-the-docs
12 |
13 | # Theme settings.
14 | footer_content: 'Copyright © 2019-2020 Danitso - Distributed under the Mozilla Public License 2.0'
15 | heading_anchors: true
16 | search_enabled: false
17 |
--------------------------------------------------------------------------------
/docs/assets/js/search-data.json:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/danitso/terraform-provider-proxmox/f3d5b410a166026a5ca5b47d16a1cc1df0392518/docs/assets/js/search-data.json
--------------------------------------------------------------------------------
/docs/data-sources/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: Data Sources
4 | permalink: /data-sources
5 | nav_order: 3
6 | has_children: true
7 | ---
8 |
9 | # Data Sources
10 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_cluster_alias.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_cluster_alias
4 | permalink: /data-sources/virtual_environment_cluster_alias
5 | nav_order: 1
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_cluster_alias
11 |
12 | Retrieves information about a specific alias.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_cluster_alias" "local_network" {
18 | name = "local_network"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `name` - (Required) Alias name.
25 |
26 | ## Attribute Reference
27 |
28 | * `cidr` - (Required) Network/IP specification in CIDR format.
29 | * `comment` - (Optional) Alias comment.
30 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_cluster_aliases.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_cluster_aliases
4 | permalink: /data-sources/virtual_environment_cluster_aliases
5 | nav_order: 2
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_cluster_aliases
11 |
12 | Retrieves the identifiers for all the available aliases.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_cluster_aliases" "available_aliases" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `alias_ids` - The pool identifiers.
27 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_datastores.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_datastores
4 | permalink: /data-sources/virtual_environment_datastores
5 | nav_order: 3
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_datastores
11 |
12 | Retrieves information about all the datastores available to a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_datastores" "first_node" {
18 | node_name = "first-node"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `node_name` - (Required) A node name.
25 |
26 | ## Attribute Reference
27 |
28 | * `active` - Whether the datastore is active.
29 | * `content_types` - The allowed content types.
30 | * `datastore_ids` - The datastore identifiers.
31 | * `enabled` - Whether the datastore is enabled.
32 | * `shared` - Whether the datastore is shared.
33 | * `space_available` - The available space in bytes.
34 | * `space_total` - The total space in bytes.
35 | * `space_used` - The used space in bytes.
36 | * `types` - The storage types.
37 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_dns.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_dns
4 | permalink: /data-sources/virtual_environment_dns
5 | nav_order: 4
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_dns
11 |
12 | Retrieves the DNS configuration for a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_dns" "first_node" {
18 | node_name = "first-node"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `node_name` - (Required) A node name.
25 |
26 | ## Attribute Reference
27 |
28 | * `domain` - The DNS search domain.
29 | * `servers` - The DNS servers.
30 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_group.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_group
4 | permalink: /data-sources/virtual_environment_group
5 | nav_order: 5
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_group
11 |
12 | Retrieves information about a specific user group.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_group" "operations_team" {
18 | group_id = "operations-team"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `group_id` - (Required) The group identifier.
25 |
26 | ## Attribute Reference
27 |
28 | * `acl` - The access control list.
29 | * `path` - The path.
30 | * `propagate` - Whether to propagate to child paths.
31 | * `role_id` - The role identifier.
32 | * `comment` - The group comment.
33 | * `members` - The group members as a list with `username@realm` entries.
34 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_groups.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_groups
4 | permalink: /data-sources/virtual_environment_groups
5 | nav_order: 6
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_groups
11 |
12 | Retrieves basic information about all available user groups.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_groups" "available_groups" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `comments` - The group comments.
27 | * `group_ids` - The group identifiers.
28 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_hosts.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_hosts
4 | permalink: /data-sources/virtual_environment_hosts
5 | nav_order: 7
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_hosts
11 |
12 | Retrieves all the host entries from a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_hosts" "first_node_host_entries" {
18 | node_name = "first-node"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `node_name` - (Required) A node name.
25 |
26 | ## Attribute Reference
27 |
28 | * `addresses` - The IP addresses.
29 | * `digest` - The SHA1 digest.
30 | * `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
31 | * `hostnames` - The hostnames associated with each of the IP addresses.
32 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_nodes.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_nodes
4 | permalink: /data-sources/virtual_environment_nodes
5 | nav_order: 8
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_nodes
11 |
12 | Retrieves information about all available nodes.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_nodes" "available_nodes" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `cpu_count` - The CPU count for each node.
27 | * `cpu_utilization` - The CPU utilization on each node.
28 | * `memory_available` - The memory available on each node.
29 | * `memory_used` - The memory used on each node.
30 | * `names` - The node names.
31 | * `online` - Whether a node is online.
32 | * `ssl_fingerprints` - The SSL fingerprint for each node.
33 | * `support_levels` - The support level for each node.
34 | * `uptime` - The uptime in seconds for each node.
35 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_pool.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_pool
4 | permalink: /data-sources/virtual_environment_pool
5 | nav_order: 9
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_pool
11 |
12 | Retrieves information about a specific resource pool.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_pool" "operations_pool" {
18 | pool_id = "operations"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `pool_id` - (Required) The pool identifier.
25 |
26 | ## Attribute Reference
27 |
28 | * `comment` - The pool comment.
29 | * `members` - The pool members.
30 | * `datastore_id` - The datastore identifier.
31 | * `id` - The member identifier.
32 | * `node_name` - The node name.
33 | * `type` - The member type.
34 | * `vm_id` - The virtual machine identifier.
35 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_pools.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_pools
4 | permalink: /data-sources/virtual_environment_pools
5 | nav_order: 10
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_pools
11 |
12 | Retrieves the identifiers for all the available resource pools.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_pools" "available_pools" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `pool_ids` - The pool identifiers.
27 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_role.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_role
4 | permalink: /data-sources/virtual_environment_role
5 | nav_order: 11
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_role
11 |
12 | Retrieves information about a specific role.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_role" "operations_role" {
18 | role_id = "operations"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `role_id` - (Required) The role identifier.
25 |
26 | ## Attribute Reference
27 |
28 | * `privileges` - The role privileges
29 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_roles.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_roles
4 | permalink: /data-sources/virtual_environment_roles
5 | nav_order: 12
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_roles
11 |
12 | Retrieves information about all the available roles.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_roles" "available_roles" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `privileges` - The role privileges.
27 | * `role_ids` - The role identifiers.
28 | * `special` - Whether the role is special (built-in).
29 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_time.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_time
4 | permalink: /data-sources/virtual_environment_time
5 | nav_order: 13
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_time
11 |
12 | Retrieves the current time for a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_time" "first_node_time" {
18 | node_name = "first-node"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `node_name` - (Required) A node name.
25 |
26 | ## Attribute Reference
27 |
28 | * `local_time` - The node's local time.
29 | * `time_zone` - The node's time zone.
30 | * `utc_time` - The node's local time formatted as UTC.
31 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_user.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_user
4 | permalink: /data-sources/virtual_environment_user
5 | nav_order: 14
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_user
11 |
12 | Retrieves information about a specific user.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_user" "operations_user" {
18 | user_id = "operation@pam"
19 | }
20 | ```
21 |
22 | ## Argument Reference
23 |
24 | * `user_id` - (Required) The user identifier.
25 |
26 | ## Attribute Reference
27 |
28 | * `acl` - The access control list.
29 | * `path` - The path.
30 | * `propagate` - Whether to propagate to child paths.
31 | * `role_id` - The role identifier.
32 | * `comment` - The user comment.
33 | * `email` - The user's email address.
34 | * `enabled` - Whether the user account is enabled.
35 | * `expiration_date` - The user account's expiration date (RFC 3339).
36 | * `first_name` - The user's first name.
37 | * `groups` - The user's groups.
38 | * `keys` - The user's keys.
39 | * `last_name` - The user's last name.
40 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_users.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_users
4 | permalink: /data-sources/virtual_environment_users
5 | nav_order: 15
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_users
11 |
12 | Retrieves information about all the available users.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_users" "available_users" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `comments` - The user comments.
27 | * `emails` - The users' email addresses.
28 | * `enabled` - Whether a user account is enabled.
29 | * `expiration_dates` - The user accounts' expiration dates (RFC 3339).
30 | * `first_names` - The users' first names.
31 | * `groups` - The users' groups.
32 | * `keys` - The users' keys.
33 | * `last_names` - The users' last names.
34 | * `user_ids` - The user identifiers.
35 |
--------------------------------------------------------------------------------
/docs/data-sources/virtual_environment_version.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_version
4 | permalink: /data-sources/virtual_environment_version
5 | nav_order: 16
6 | parent: Data Sources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Data Source: proxmox_virtual_environment_version
11 |
12 | Retrieves the version information from the API endpoint.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | data "proxmox_virtual_environment_version" "current_version" {}
18 | ```
19 |
20 | ## Argument Reference
21 |
22 | There are no arguments available for this data source.
23 |
24 | ## Attribute Reference
25 |
26 | * `keyboard_layout` - The keyboard layout.
27 | * `release` - The release number.
28 | * `repository_id` - The repository identifier.
29 | * `version` - The version string.
30 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: home
3 | title: Introduction
4 | nav_order: 1
5 | ---
6 |
7 | # Proxmox Provider
8 |
9 | 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.
10 |
11 | Use the navigation to the left to read about the available resources.
12 |
13 | ## Example Usage
14 |
15 | ```
16 | provider "proxmox" {
17 | virtual_environment {
18 | endpoint = "https://10.0.0.2"
19 | username = "root@pam"
20 | password = "the-password-set-during-installation-of-proxmox-ve"
21 | insecure = true
22 | }
23 | }
24 | ```
25 |
26 | ## Authentication
27 |
28 | The Proxmox provider offers a flexible means of providing credentials for authentication. The following methods are supported, in this order, and explained below:
29 |
30 | * Static credentials
31 | * Environment variables
32 |
33 | ### Static credentials
34 |
35 | > 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.
36 |
37 | Static credentials can be provided by adding a `username` and `password` in-line in the Proxmox provider block:
38 |
39 | ```
40 | provider "proxmox" {
41 | virtual_environment {
42 | username = "username@realm"
43 | password = "a-strong-password"
44 | }
45 | }
46 | ```
47 |
48 | ### Environment variables
49 |
50 | You can provide your credentials via the `PROXMOX_VE_USERNAME` and `PROXMOX_VE_PASSWORD`, environment variables, representing your Proxmox username, realm and password, respectively:
51 |
52 | ```
53 | provider "proxmox" {
54 | virtual_environment {}
55 | }
56 | ```
57 |
58 | Usage:
59 |
60 | ```sh
61 | $ export PROXMOX_VE_USERNAME="username@realm"
62 | $ export PROXMOX_VE_PASSWORD="a-strong-password"
63 | $ terraform plan
64 | ```
65 |
66 | ## Argument Reference
67 |
68 | 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:
69 |
70 | * `virtual_environment` - (Optional) The Proxmox Virtual Environment configuration.
71 | * `endpoint` - (Required) The endpoint for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_ENDPOINT`).
72 | * `insecure` - (Optional) Whether to skip the TLS verification step (can also be sourced from `PROXMOX_VE_INSECURE`). If omitted, defaults to `false`.
73 | * `otp` - (Optional) The one-time password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_OTP`).
74 | * `password` - (Required) The password for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_PASSWORD`).
75 | * `username` - (Required) The username and realm for the Proxmox Virtual Environment API (can also be sourced from `PROXMOX_VE_USERNAME`).
76 |
--------------------------------------------------------------------------------
/docs/resources/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: Resources
4 | permalink: /resources
5 | nav_order: 2
6 | has_children: true
7 | ---
8 |
9 | # Resources
10 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_certificate.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_certificate
4 | permalink: /resources/virtual_environment_certificate
5 | nav_order: 1
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_certificate
11 |
12 | Manages the custom SSL/TLS certificate for a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_certificate" "example" {
18 | certificate = "${tls_self_signed_cert.proxmox_virtual_environment_certificate.cert_pem}"
19 | node_name = "first-node"
20 | private_key = "${tls_private_key.proxmox_virtual_environment_certificate.private_key_pem}"
21 | }
22 |
23 | resource "tls_private_key" "proxmox_virtual_environment_certificate" {
24 | algorithm = "RSA"
25 | rsa_bits = 2048
26 | }
27 |
28 | resource "tls_self_signed_cert" "proxmox_virtual_environment_certificate" {
29 | key_algorithm = "${tls_private_key.proxmox_virtual_environment_certificate.algorithm}"
30 | private_key_pem = "${tls_private_key.proxmox_virtual_environment_certificate.private_key_pem}"
31 |
32 | subject {
33 | common_name = "example.com"
34 | organization = "Terraform Provider for Proxmox"
35 | }
36 |
37 | validity_period_hours = 8760
38 |
39 | allowed_uses = [
40 | "key_encipherment",
41 | "digital_signature",
42 | "server_auth",
43 | ]
44 | }
45 | ```
46 |
47 | ## Argument Reference
48 |
49 | * `certificate` - (Required) The PEM encoded certificate.
50 | * `certificate_chain` - (Optional) The PEM encoded certificate chain.
51 | * `node_name` - (Required) A node name.
52 | * `private_key` - (Required) The PEM encoded private key.
53 |
54 | ## Attribute Reference
55 |
56 | * `expiration_date` - The expiration date (RFC 3339).
57 | * `file_name` - The file name.
58 | * `issuer` - The issuer.
59 | * `public_key_size` - The public key size.
60 | * `public_key_type` - The public key type.
61 | * `ssl_fingerprint` - The SSL fingerprint.
62 | * `start_date` - The start date (RFC 3339).
63 | * `subject` - The subject.
64 | * `subject_alternative_names` - The subject alternative names.
65 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_cluster_alias.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_cluster_alias
4 | permalink: /resources/virtual_environment_cluster_alias
5 | nav_order: 2
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_cluster_alias
11 |
12 | Aliases are used to see what devices or group of devices are affected by a rule.
13 | We can create aliases to identify an IP address or a network.
14 |
15 | ## Example Usage
16 |
17 | ```
18 | resource "proxmox_virtual_environment_cluster_alias" "local_network" {
19 | name = "local_network"
20 | cidr = "192.168.0.0/23"
21 | comment = "Managed by Terraform"
22 | }
23 |
24 | resource "proxmox_virtual_environment_cluster_alias" "ubuntu_vm" {
25 | name = "ubuntu"
26 | cidr = "192.168.0.1"
27 | comment = "Managed by Terraform"
28 | }
29 | ```
30 |
31 | ## Argument Reference
32 |
33 | * `name` - (Required) Alias name.
34 | * `cidr` - (Required) Network/IP specification in CIDR format.
35 | * `comment` - (Optional) Alias comment.
36 |
37 | ## Attribute Reference
38 |
39 | There are no attribute references available for this resource.
40 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_cluster_ipset.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_cluster_ipset
4 | permalink: /resources/virtual_environment_cluster_ipset
5 | nav_order: 3
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_cluster_ipset
11 |
12 | An IPSet allows us to group multiple IP addresses, IP subnets and aliases.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_cluster_ipset" "ipset" {
18 | name = "local_network"
19 | comment = "Managed by Terraform"
20 |
21 | cidr {
22 | name = "192.168.0.0/23"
23 | comment = "Local network 1"
24 | }
25 |
26 | cidr {
27 | name = "192.168.0.1"
28 | comment = "Server 1"
29 | nomatch = true
30 | }
31 |
32 | cidr {
33 | name = "192.168.2.1"
34 | comment = "Server 1"
35 | }
36 | }
37 | ```
38 |
39 | ## Argument Reference
40 |
41 | * `name` - (Required) Alias name.
42 | * `comment` - (Optional) Alias comment.
43 | * `cidr` - (Optional) IP/CIDR block (multiple blocks supported).
44 | * `name` - Network/IP specification in CIDR format.
45 | * `comment` - (Optional) Arbitrary string annotation.
46 | * `nomatch` - (Optional) Entries marked as `nomatch` are skipped as if those were not added to the set.
47 |
48 | ## Attribute Reference
49 |
50 | There are no attribute references available for this resource.
51 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_dns.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_dns
4 | permalink: /resources/virtual_environment_dns
5 | nav_order: 5
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_dns
11 |
12 | Manages the DNS configuration for a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_dns" "first_node_dns_configuration" {
18 | domain = "${data.proxmox_virtual_environment_dns.first_node_dns_configuration.domain}"
19 | node_name = "${data.proxmox_virtual_environment_dns.first_node_dns_configuration.node_name}"
20 |
21 | servers = [
22 | "1.1.1.1",
23 | "1.0.0.1",
24 | ]
25 | }
26 |
27 | data "proxmox_virtual_environment_dns" "first_node_dns_configuration" {
28 | node_name = "first-node"
29 | }
30 | ```
31 |
32 | ## Argument Reference
33 |
34 | * `domain` - (Required) The DNS search domain.
35 | * `node_name` - (Required) A node name.
36 | * `servers` - (Optional) The DNS servers.
37 |
38 | ## Attribute Reference
39 |
40 | There are no additional attributes available for this resource.
41 |
42 | ## Important Notes
43 |
44 | Be careful not to use this resource multiple times for the same node.
45 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_file.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_file
4 | permalink: /resources/virtual_environment_file
5 | nav_order: 6
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_file
11 |
12 | Manages a file.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_file" "ubuntu_container_template" {
18 | content_type = "vztmpl"
19 | datastore_id = "local"
20 | node_name = "first-node"
21 |
22 | source_file {
23 | path = "http://download.proxmox.com/images/system/ubuntu-18.04-standard_18.04.1-1_amd64.tar.gz"
24 | }
25 | }
26 | ```
27 |
28 | ## Argument Reference
29 |
30 | * `content_type` - (Optional) The content type.
31 | * `backup`
32 | * `iso`
33 | * `snippets`
34 | * `vztmpl`
35 | * `datastore_id` - (Required) The datastore id.
36 | * `node_name` - (Required) The node name.
37 | * `source_file` - (Optional) The source file (conflicts with `source_raw`).
38 | * `checksum` - (Optional) The SHA256 checksum of the source file.
39 | * `file_name` - (Optional) The file name to use instead of the source file name.
40 | * `insecure` - (Optional) Whether to skip the TLS verification step for HTTPS sources (defaults to `false`).
41 | * `path` - (Required) A path to a local file or a URL.
42 | * `source_raw` - (Optional) The raw source (conflicts with `source_file`).
43 | * `data` - (Required) The raw data.
44 | * `file_name` - (Required) The file name.
45 | * `resize` - (Optional) The number of bytes to resize the file to.
46 |
47 | ## Attribute Reference
48 |
49 | * `file_modification_date` - The file modification date (RFC 3339).
50 | * `file_name` - The file name.
51 | * `file_size` - The file size in bytes.
52 | * `file_tag` - The file tag.
53 |
54 | ## Important Notes
55 |
56 | The Proxmox VE API endpoint for file uploads does not support chunked transfer encoding, which means that we must first store the source file as a temporary file locally before uploading it.
57 |
58 | You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space available (twice the size plus overhead because a multipart payload needs to be created as another temporary file).
59 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_group.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_group
4 | permalink: /resources/virtual_environment_group
5 | nav_order: 7
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_group
11 |
12 | Manages a user group.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_group" "operations_team" {
18 | comment = "Managed by Terraform"
19 | group_id = "operations-team"
20 | }
21 | ```
22 |
23 | ## Argument Reference
24 |
25 | * `acl` - (Optional) The access control list (multiple blocks supported).
26 | * `path` - The path.
27 | * `propagate` - Whether to propagate to child paths.
28 | * `role_id` - The role identifier.
29 | * `comment` - (Optional) The group comment.
30 | * `group_id` - (Required) The group identifier.
31 |
32 | ## Attribute Reference
33 |
34 | * `members` - The group members as a list of `username@realm` entries
35 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_hosts.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_hosts
4 | permalink: /resources/virtual_environment_hosts
5 | nav_order: 8
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_hosts
11 |
12 | Manages the host entries on a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_hosts" "first_node_host_entries" {
18 | node_name = "first-node"
19 |
20 | entry {
21 | address = "127.0.0.1"
22 |
23 | hostnames = [
24 | "localhost",
25 | "localhost.localdomain",
26 | ]
27 | }
28 | }
29 | ```
30 |
31 | ## Argument Reference
32 |
33 | * `node_name` - (Required) A node name.
34 | * `entry` - (Required) A host entry (multiple blocks supported).
35 | * `address` - (Required) The IP address.
36 | * `hostnames` - (Required) The hostnames.
37 |
38 | ## Attribute Reference
39 |
40 | * `addresses` - The IP addresses.
41 | * `digest` - The SHA1 digest.
42 | * `entries` - The host entries (conversion of `addresses` and `hostnames` into objects).
43 | * `hostnames` - The hostnames associated with each of the IP addresses.
44 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_pool.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_pool
4 | permalink: /resources/virtual_environment_pool
5 | nav_order: 9
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_pool
11 |
12 | Manages a resource pool.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_pool" "operations_pool" {
18 | comment = "Managed by Terraform"
19 | pool_id = "operations-pool"
20 | }
21 | ```
22 |
23 | ## Argument Reference
24 |
25 | * `comment` - (Optional) The pool comment.
26 | * `pool_id` - (Required) The pool identifier.
27 |
28 | ## Attribute Reference
29 |
30 | * `members` - The pool members.
31 | * `datastore_id` - The datastore identifier.
32 | * `id` - The member identifier.
33 | * `node_name` - The node name.
34 | * `type` - The member type.
35 | * `vm_id` - The virtual machine identifier.
36 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_role.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_role
4 | permalink: /resources/virtual_environment_role
5 | nav_order: 10
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_role
11 |
12 | Manages a role.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_role" "operations_monitoring" {
18 | role_id = "operations-monitoring"
19 |
20 | privileges = [
21 | "VM.Monitor",
22 | ]
23 | }
24 | ```
25 |
26 | ## Argument Reference
27 |
28 | * `privileges` - (Required) The role privileges.
29 | * `role_id` - (Required) The role identifier.
30 |
31 | ## Attribute Reference
32 |
33 | There are no additional attributes available for this resource.
34 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_time.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_time
4 | permalink: /resources/virtual_environment_time
5 | nav_order: 11
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_time
11 |
12 | Manages the time for a specific node.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_time" "first_node_time" {
18 | node_name = "first-node"
19 | time_zone = "UTC"
20 | }
21 | ```
22 |
23 | ## Argument Reference
24 |
25 | * `node_name` - (Required) A node name.
26 | * `time_zone` - (Required) The node's time zone.
27 |
28 | ## Attribute Reference
29 |
30 | * `local_time` - The node's local time.
31 | * `utc_time` - The node's local time formatted as UTC.
32 |
--------------------------------------------------------------------------------
/docs/resources/virtual_environment_user.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: page
3 | title: proxmox_virtual_environment_user
4 | permalink: /resources/virtual_environment_user
5 | nav_order: 12
6 | parent: Resources
7 | subcategory: Virtual Environment
8 | ---
9 |
10 | # Resource: proxmox_virtual_environment_user
11 |
12 | Manages a user.
13 |
14 | ## Example Usage
15 |
16 | ```
17 | resource "proxmox_virtual_environment_user" "operations_automation" {
18 | acl {
19 | path = "/vms/1234"
20 | propagate = true
21 | role_id = "${proxmox_virtual_environment_role.operations_monitoring.role_id}"
22 | }
23 |
24 | comment = "Managed by Terraform"
25 | password = "a-strong-password"
26 | user_id = "operations-automation@pve"
27 | }
28 |
29 | resource "proxmox_virtual_environment_role" "operations_monitoring" {
30 | role_id = "operations-monitoring"
31 |
32 | privileges = [
33 | "VM.Monitor",
34 | ]
35 | }
36 | ```
37 |
38 | ## Argument Reference
39 |
40 | * `acl` - (Optional) The access control list (multiple blocks supported).
41 | * `path` - The path.
42 | * `propagate` - Whether to propagate to child paths.
43 | * `role_id` - The role identifier.
44 | * `comment` - (Optional) The user comment.
45 | * `email` - (Optional) The user's email address.
46 | * `enabled` - (Optional) Whether the user account is enabled.
47 | * `expiration_date` - (Optional) The user account's expiration date (RFC 3339).
48 | * `first_name` - (Optional) The user's first name.
49 | * `groups` - (Optional) The user's groups.
50 | * `keys` - (Optional) The user's keys.
51 | * `last_name` - (Optional) The user's last name.
52 | * `password` - (Required) The user's password.
53 | * `user_id` - (Required) The user identifier.
54 |
55 | ## Attribute Reference
56 |
57 | There are no additional attributes available for this resource.
58 |
--------------------------------------------------------------------------------
/example.tfrc:
--------------------------------------------------------------------------------
1 | provider_installation {
2 | filesystem_mirror {
3 | path = "../cache/plugins"
4 | include = ["registry.terraform.io/danitso/proxmox"]
5 | }
6 | direct {
7 | exclude = ["registry.terraform.io/danitso/proxmox"]
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_cluster_alias.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_cluster_alias" "example" {
2 | depends_on = [proxmox_virtual_environment_cluster_alias.example]
3 |
4 | name = proxmox_virtual_environment_cluster_alias.example.name
5 | }
6 |
7 | output "data_proxmox_virtual_environment_cluster_alias_example_cidr" {
8 | value = proxmox_virtual_environment_cluster_alias.example.cidr
9 | }
10 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_cluster_aliases.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_cluster_aliases" "example" {
2 | depends_on = [proxmox_virtual_environment_cluster_alias.example]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_cluster_aliases" {
6 | value = {
7 | "alias_ids" = data.proxmox_virtual_environment_cluster_aliases.example.alias_ids
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_datastores.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_datastores" "example" {
2 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_datastores_example_active" {
6 | value = data.proxmox_virtual_environment_datastores.example.active
7 | }
8 |
9 | output "data_proxmox_virtual_environment_datastores_example_content_types" {
10 | value = data.proxmox_virtual_environment_datastores.example.content_types
11 | }
12 |
13 | output "data_proxmox_virtual_environment_datastores_example_datastore_ids" {
14 | value = data.proxmox_virtual_environment_datastores.example.datastore_ids
15 | }
16 |
17 | output "data_proxmox_virtual_environment_datastores_example_enabled" {
18 | value = data.proxmox_virtual_environment_datastores.example.enabled
19 | }
20 |
21 | output "data_proxmox_virtual_environment_datastores_example_node_name" {
22 | value = data.proxmox_virtual_environment_datastores.example.node_name
23 | }
24 |
25 | output "data_proxmox_virtual_environment_datastores_example_shared" {
26 | value = data.proxmox_virtual_environment_datastores.example.shared
27 | }
28 |
29 | output "data_proxmox_virtual_environment_datastores_example_space_available" {
30 | value = data.proxmox_virtual_environment_datastores.example.space_available
31 | }
32 |
33 | output "data_proxmox_virtual_environment_datastores_example_space_total" {
34 | value = data.proxmox_virtual_environment_datastores.example.space_total
35 | }
36 |
37 | output "data_proxmox_virtual_environment_datastores_example_space_used" {
38 | value = data.proxmox_virtual_environment_datastores.example.space_used
39 | }
40 |
41 | output "data_proxmox_virtual_environment_datastores_example_types" {
42 | value = data.proxmox_virtual_environment_datastores.example.types
43 | }
44 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_dns.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_dns" "example" {
2 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_dns_example_domain" {
6 | value = data.proxmox_virtual_environment_dns.example.domain
7 | }
8 |
9 | output "data_proxmox_virtual_environment_dns_example_servers" {
10 | value = data.proxmox_virtual_environment_dns.example.servers
11 | }
12 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_group.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_group" "example" {
2 | group_id = proxmox_virtual_environment_group.example.id
3 | }
4 |
5 | output "data_proxmox_virtual_environment_group_example_acl" {
6 | value = data.proxmox_virtual_environment_group.example.acl
7 | }
8 |
9 | output "data_proxmox_virtual_environment_group_example_comment" {
10 | value = data.proxmox_virtual_environment_group.example.comment
11 | }
12 |
13 | output "data_proxmox_virtual_environment_group_example_members" {
14 | value = data.proxmox_virtual_environment_group.example.members
15 | }
16 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_groups.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_groups" "example" {
2 | depends_on = [proxmox_virtual_environment_group.example]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_groups_example" {
6 | value = map(
7 | "comments", data.proxmox_virtual_environment_groups.example.comments,
8 | "group_ids", data.proxmox_virtual_environment_groups.example.group_ids,
9 | )
10 | }
11 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_hosts.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_hosts" "example" {
2 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_hosts_example_addresses" {
6 | value = data.proxmox_virtual_environment_hosts.example.addresses
7 | }
8 |
9 | output "data_proxmox_virtual_environment_hosts_example_digest" {
10 | value = data.proxmox_virtual_environment_hosts.example.digest
11 | }
12 |
13 | output "data_proxmox_virtual_environment_hosts_example_entries" {
14 | value = data.proxmox_virtual_environment_hosts.example.entries
15 | }
16 |
17 | output "data_proxmox_virtual_environment_hosts_example_hostnames" {
18 | value = data.proxmox_virtual_environment_hosts.example.hostnames
19 | }
20 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_nodes.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_nodes" "example" {}
2 |
3 | output "data_proxmox_virtual_environment_nodes_example_cpu_count" {
4 | value = data.proxmox_virtual_environment_nodes.example.cpu_count
5 | }
6 |
7 | output "data_proxmox_virtual_environment_nodes_example_cpu_utilization" {
8 | value = data.proxmox_virtual_environment_nodes.example.cpu_utilization
9 | }
10 |
11 | output "data_proxmox_virtual_environment_nodes_example_memory_available" {
12 | value = data.proxmox_virtual_environment_nodes.example.memory_available
13 | }
14 |
15 | output "data_proxmox_virtual_environment_nodes_example_memory_used" {
16 | value = data.proxmox_virtual_environment_nodes.example.memory_used
17 | }
18 |
19 | output "data_proxmox_virtual_environment_nodes_example_names" {
20 | value = data.proxmox_virtual_environment_nodes.example.names
21 | }
22 |
23 | output "data_proxmox_virtual_environment_nodes_example_online" {
24 | value = data.proxmox_virtual_environment_nodes.example.online
25 | }
26 |
27 | output "data_proxmox_virtual_environment_nodes_example_ssl_fingerprints" {
28 | value = data.proxmox_virtual_environment_nodes.example.ssl_fingerprints
29 | }
30 |
31 | output "data_proxmox_virtual_environment_nodes_example_support_levels" {
32 | value = data.proxmox_virtual_environment_nodes.example.support_levels
33 | }
34 |
35 | output "data_proxmox_virtual_environment_nodes_example_uptime" {
36 | value = data.proxmox_virtual_environment_nodes.example.uptime
37 | }
38 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_pool.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_pool" "example" {
2 | pool_id = proxmox_virtual_environment_pool.example.id
3 | }
4 |
5 | output "data_proxmox_virtual_environment_pool_example_comment" {
6 | value = data.proxmox_virtual_environment_pool.example.comment
7 | }
8 |
9 | output "data_proxmox_virtual_environment_pool_example_members" {
10 | value = data.proxmox_virtual_environment_pool.example.members
11 | }
12 |
13 | output "data_proxmox_virtual_environment_pool_example_pool_id" {
14 | value = data.proxmox_virtual_environment_pool.example.id
15 | }
16 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_pools.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_pools" "example" {
2 | depends_on = [proxmox_virtual_environment_pool.example]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_pools_example" {
6 | value = {
7 | pool_ids = data.proxmox_virtual_environment_pools.example.pool_ids
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_role.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_role" "example" {
2 | role_id = proxmox_virtual_environment_role.example.id
3 | }
4 |
5 | output "data_proxmox_virtual_environment_role_example_privileges" {
6 | value = data.proxmox_virtual_environment_role.example.privileges
7 | }
8 |
9 | output "data_proxmox_virtual_environment_role_example_role_id" {
10 | value = data.proxmox_virtual_environment_role.example.id
11 | }
12 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_roles.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_roles" "example" {
2 | depends_on = [proxmox_virtual_environment_role.example]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_roles_example_privileges" {
6 | value = data.proxmox_virtual_environment_roles.example.privileges
7 | }
8 |
9 | output "data_proxmox_virtual_environment_roles_example_role_ids" {
10 | value = data.proxmox_virtual_environment_roles.example.role_ids
11 | }
12 |
13 | output "data_proxmox_virtual_environment_roles_example_special" {
14 | value = data.proxmox_virtual_environment_roles.example.special
15 | }
16 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_time.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_time" "example" {
2 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_time" {
6 | value = {
7 | local_time = data.proxmox_virtual_environment_time.example.local_time
8 | time_zone = data.proxmox_virtual_environment_time.example.time_zone
9 | utc_time = data.proxmox_virtual_environment_time.example.utc_time
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_user.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_user" "example" {
2 | user_id = proxmox_virtual_environment_user.example.id
3 | }
4 |
5 | output "data_proxmox_virtual_environment_user_example_acl" {
6 | value = data.proxmox_virtual_environment_user.example.acl
7 | }
8 |
9 | output "data_proxmox_virtual_environment_user_example_comment" {
10 | value = data.proxmox_virtual_environment_user.example.comment
11 | }
12 |
13 | output "data_proxmox_virtual_environment_user_example_email" {
14 | value = data.proxmox_virtual_environment_user.example.email
15 | }
16 |
17 | output "data_proxmox_virtual_environment_user_example_enabled" {
18 | value = data.proxmox_virtual_environment_user.example.enabled
19 | }
20 |
21 | output "data_proxmox_virtual_environment_user_example_expiration_date" {
22 | value = data.proxmox_virtual_environment_user.example.expiration_date
23 | }
24 |
25 | output "data_proxmox_virtual_environment_user_example_first_name" {
26 | value = data.proxmox_virtual_environment_user.example.first_name
27 | }
28 |
29 | output "data_proxmox_virtual_environment_user_example_groups" {
30 | value = data.proxmox_virtual_environment_user.example.groups
31 | }
32 |
33 | output "data_proxmox_virtual_environment_user_example_keys" {
34 | value = data.proxmox_virtual_environment_user.example.keys
35 | }
36 |
37 | output "data_proxmox_virtual_environment_user_example_last_name" {
38 | value = data.proxmox_virtual_environment_user.example.last_name
39 | }
40 |
41 | output "data_proxmox_virtual_environment_user_example_user_id" {
42 | value = data.proxmox_virtual_environment_user.example.id
43 | }
44 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_users.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_users" "example" {
2 | depends_on = [proxmox_virtual_environment_user.example]
3 | }
4 |
5 | output "data_proxmox_virtual_environment_users_example_comments" {
6 | value = data.proxmox_virtual_environment_users.example.comments
7 | }
8 |
9 | output "data_proxmox_virtual_environment_users_example_emails" {
10 | value = data.proxmox_virtual_environment_users.example.emails
11 | }
12 |
13 | output "data_proxmox_virtual_environment_users_example_enabled" {
14 | value = data.proxmox_virtual_environment_users.example.enabled
15 | }
16 |
17 | output "data_proxmox_virtual_environment_users_example_expiration_dates" {
18 | value = data.proxmox_virtual_environment_users.example.expiration_dates
19 | }
20 |
21 | output "data_proxmox_virtual_environment_users_example_first_names" {
22 | value = data.proxmox_virtual_environment_users.example.first_names
23 | }
24 |
25 | output "data_proxmox_virtual_environment_users_example_groups" {
26 | value = data.proxmox_virtual_environment_users.example.groups
27 | }
28 |
29 | output "data_proxmox_virtual_environment_users_example_keys" {
30 | value = data.proxmox_virtual_environment_users.example.keys
31 | }
32 |
33 | output "data_proxmox_virtual_environment_users_example_last_names" {
34 | value = data.proxmox_virtual_environment_users.example.last_names
35 | }
36 |
37 | output "data_proxmox_virtual_environment_users_example_user_ids" {
38 | value = data.proxmox_virtual_environment_users.example.user_ids
39 | }
40 |
--------------------------------------------------------------------------------
/example/data_source_virtual_environment_version.tf:
--------------------------------------------------------------------------------
1 | data "proxmox_virtual_environment_version" "example" {}
2 |
3 | output "data_proxmox_virtual_environment_version" {
4 | value = {
5 | keyboard_layout = data.proxmox_virtual_environment_version.example.keyboard_layout
6 | release = data.proxmox_virtual_environment_version.example.release
7 | repository_id = data.proxmox_virtual_environment_version.example.repository_id
8 | version = data.proxmox_virtual_environment_version.example.version
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/example/main.tf:
--------------------------------------------------------------------------------
1 | provider "proxmox" {
2 | virtual_environment {
3 | endpoint = var.virtual_environment_endpoint
4 | username = var.virtual_environment_username
5 | password = var.virtual_environment_password
6 | insecure = true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/example/resource_virtual_environemnt_cluster_alias.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_cluster_alias" "example" {
2 | name = "example"
3 | cidr = "192.168.0.0/23"
4 | comment = "Managed by Terraform"
5 | }
6 |
7 | output "proxmox_virtual_environment_cluster_alias_example_name" {
8 | value = proxmox_virtual_environment_cluster_alias.example.name
9 | }
10 |
11 | output "proxmox_virtual_environment_cluster_alias_example_cidr" {
12 | value = proxmox_virtual_environment_cluster_alias.example.cidr
13 | }
14 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_certificate.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_certificate" "example" {
2 | certificate = tls_self_signed_cert.proxmox_virtual_environment_certificate.cert_pem
3 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
4 | private_key = tls_private_key.proxmox_virtual_environment_certificate.private_key_pem
5 | }
6 |
7 | resource "tls_private_key" "proxmox_virtual_environment_certificate" {
8 | algorithm = "RSA"
9 | rsa_bits = 2048
10 | }
11 |
12 | resource "tls_self_signed_cert" "proxmox_virtual_environment_certificate" {
13 | key_algorithm = tls_private_key.proxmox_virtual_environment_certificate.algorithm
14 | private_key_pem = tls_private_key.proxmox_virtual_environment_certificate.private_key_pem
15 |
16 | subject {
17 | common_name = "example.com"
18 | organization = "Terraform Provider for Proxmox"
19 | }
20 |
21 | validity_period_hours = 8760
22 |
23 | allowed_uses = [
24 | "key_encipherment",
25 | "digital_signature",
26 | "server_auth",
27 | ]
28 | }
29 |
30 | output "resource_proxmox_virtual_environment_certificate_example_expiration_date" {
31 | value = proxmox_virtual_environment_certificate.example.expiration_date
32 | }
33 |
34 | output "resource_proxmox_virtual_environment_certificate_example_file_name" {
35 | value = proxmox_virtual_environment_certificate.example.file_name
36 | }
37 |
38 | output "resource_proxmox_virtual_environment_certificate_example_issuer" {
39 | value = proxmox_virtual_environment_certificate.example.issuer
40 | }
41 |
42 | output "resource_proxmox_virtual_environment_certificate_example_public_key_size" {
43 | value = proxmox_virtual_environment_certificate.example.public_key_size
44 | }
45 |
46 | output "resource_proxmox_virtual_environment_certificate_example_public_key_type" {
47 | value = proxmox_virtual_environment_certificate.example.public_key_type
48 | }
49 |
50 | output "resource_proxmox_virtual_environment_certificate_example_ssl_fingerprint" {
51 | value = proxmox_virtual_environment_certificate.example.ssl_fingerprint
52 | }
53 |
54 | output "resource_proxmox_virtual_environment_certificate_example_start_date" {
55 | value = proxmox_virtual_environment_certificate.example.start_date
56 | }
57 |
58 | output "resource_proxmox_virtual_environment_certificate_example_subject" {
59 | value = proxmox_virtual_environment_certificate.example.subject
60 | }
61 |
62 | output "resource_proxmox_virtual_environment_certificate_example_subject_alternative_names" {
63 | value = proxmox_virtual_environment_certificate.example.subject_alternative_names
64 | }
65 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_cluster_ipset.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_cluster_ipset" "example" {
2 | name = "local_network"
3 | comment = "Managed by Terraform"
4 |
5 | cidr {
6 | name = "192.168.0.0/23"
7 | comment = "Local network 1"
8 | }
9 |
10 | cidr {
11 | name = "192.168.0.1"
12 | comment = "Server 1"
13 | nomatch = true
14 | }
15 |
16 | cidr {
17 | name = "192.168.2.1"
18 | comment = "Server 1"
19 | }
20 | }
21 |
22 | output "resource_proxmox_virtual_environment_cluster_ipset" {
23 | value = proxmox_virtual_environment_cluster_ipset.example.name
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_container.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_container" "example_template" {
2 | description = "Managed by Terraform"
3 |
4 | initialization {
5 | dns {
6 | server = "1.1.1.1"
7 | }
8 |
9 | hostname = "terraform-provider-proxmox-example-lxc-template"
10 |
11 | ip_config {
12 | ipv4 {
13 | address = "dhcp"
14 | }
15 | }
16 |
17 | user_account {
18 | keys = [trimspace(tls_private_key.example.public_key_openssh)]
19 | password = "example"
20 | }
21 | }
22 |
23 | network_interface {
24 | name = "veth0"
25 | }
26 |
27 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
28 |
29 | operating_system {
30 | template_file_id = proxmox_virtual_environment_file.ubuntu_container_template.id
31 | type = "ubuntu"
32 | }
33 |
34 | pool_id = proxmox_virtual_environment_pool.example.id
35 | template = true
36 | vm_id = 2042
37 | }
38 |
39 | resource "proxmox_virtual_environment_container" "example" {
40 | clone {
41 | vm_id = proxmox_virtual_environment_container.example_template.id
42 | }
43 |
44 | initialization {
45 | hostname = "terraform-provider-proxmox-example-lxc"
46 | }
47 |
48 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
49 | pool_id = proxmox_virtual_environment_pool.example.id
50 | vm_id = 2043
51 | }
52 |
53 | output "resource_proxmox_virtual_environment_container_example_id" {
54 | value = proxmox_virtual_environment_container.example.id
55 | }
56 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_dns.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_dns" "example" {
2 | domain = data.proxmox_virtual_environment_dns.example.domain
3 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
4 | servers = data.proxmox_virtual_environment_dns.example.servers
5 | }
6 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_group.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_group" "example" {
2 | acl {
3 | path = "/vms/${proxmox_virtual_environment_vm.example.id}"
4 | role_id = proxmox_virtual_environment_role.example.id
5 | }
6 |
7 | comment = "Managed by Terraform"
8 | group_id = "terraform-provider-proxmox-example"
9 | }
10 |
11 | output "resource_proxmox_virtual_environment_group_example_acl" {
12 | value = proxmox_virtual_environment_group.example.acl
13 | }
14 |
15 | output "resource_proxmox_virtual_environment_group_example_comment" {
16 | value = proxmox_virtual_environment_group.example.comment
17 | }
18 |
19 | output "resource_proxmox_virtual_environment_group_example_id" {
20 | value = proxmox_virtual_environment_group.example.id
21 | }
22 |
23 | output "resource_proxmox_virtual_environment_group_example_members" {
24 | value = proxmox_virtual_environment_group.example.members
25 | }
26 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_hosts.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_hosts" "example" {
2 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
3 |
4 | dynamic "entry" {
5 | for_each = data.proxmox_virtual_environment_hosts.example.entries
6 |
7 | content {
8 | address = entry.value.address
9 | hostnames = entry.value.hostnames
10 | }
11 | }
12 | }
13 |
14 | output "resource_proxmox_virtual_environment_hosts_example_addresses" {
15 | value = proxmox_virtual_environment_hosts.example.addresses
16 | }
17 |
18 | output "resource_proxmox_virtual_environment_hosts_example_digest" {
19 | value = proxmox_virtual_environment_hosts.example.digest
20 | }
21 |
22 | output "resource_proxmox_virtual_environment_hosts_example_entries" {
23 | value = proxmox_virtual_environment_hosts.example.entries
24 | }
25 |
26 | output "resource_proxmox_virtual_environment_hosts_example_hostnames" {
27 | value = proxmox_virtual_environment_hosts.example.hostnames
28 | }
29 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_pool.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_pool" "example" {
2 | comment = "Managed by Terraform"
3 | pool_id = "terraform-provider-proxmox-example"
4 | }
5 |
6 | output "resource_proxmox_virtual_environment_pool_example_comment" {
7 | value = proxmox_virtual_environment_pool.example.comment
8 | }
9 |
10 | output "resource_proxmox_virtual_environment_pool_example_members" {
11 | value = proxmox_virtual_environment_pool.example.members
12 | }
13 |
14 | output "resource_proxmox_virtual_environment_pool_example_pool_id" {
15 | value = proxmox_virtual_environment_pool.example.id
16 | }
17 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_role.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_role" "example" {
2 | privileges = [
3 | "VM.Monitor",
4 | ]
5 | role_id = "terraform-provider-proxmox-example"
6 | }
7 |
8 | output "resource_proxmox_virtual_environment_role_example_privileges" {
9 | value = proxmox_virtual_environment_role.example.privileges
10 | }
11 |
12 | output "resource_proxmox_virtual_environment_role_example_role_id" {
13 | value = proxmox_virtual_environment_role.example.role_id
14 | }
15 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_time.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_time" "example" {
2 | node_name = data.proxmox_virtual_environment_time.example.node_name
3 | time_zone = data.proxmox_virtual_environment_time.example.time_zone
4 | }
5 |
6 | output "resource_proxmox_virtual_environment_time" {
7 | value = {
8 | local_time = proxmox_virtual_environment_time.example.local_time
9 | time_zone = proxmox_virtual_environment_time.example.time_zone
10 | utc_time = proxmox_virtual_environment_time.example.utc_time
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_user.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_user" "example" {
2 | acl {
3 | path = "/vms/${proxmox_virtual_environment_vm.example.id}"
4 | propagate = true
5 | role_id = "PVEVMAdmin"
6 | }
7 |
8 | comment = "Managed by Terraform"
9 | password = "Test1234!"
10 | user_id = "terraform-provider-proxmox-example@pve"
11 | }
12 |
13 | output "resource_proxmox_virtual_environment_user_example_acl" {
14 | value = proxmox_virtual_environment_user.example.acl
15 | }
16 |
17 | output "resource_proxmox_virtual_environment_user_example_comment" {
18 | value = proxmox_virtual_environment_user.example.comment
19 | }
20 |
21 | output "resource_proxmox_virtual_environment_user_example_email" {
22 | value = proxmox_virtual_environment_user.example.email
23 | }
24 |
25 | output "resource_proxmox_virtual_environment_user_example_enabled" {
26 | value = proxmox_virtual_environment_user.example.enabled
27 | }
28 |
29 | output "resource_proxmox_virtual_environment_user_example_expiration_date" {
30 | value = proxmox_virtual_environment_user.example.expiration_date
31 | }
32 |
33 | output "resource_proxmox_virtual_environment_user_example_first_name" {
34 | value = proxmox_virtual_environment_user.example.first_name
35 | }
36 |
37 | output "resource_proxmox_virtual_environment_user_example_groups" {
38 | value = proxmox_virtual_environment_user.example.groups
39 | }
40 |
41 | output "resource_proxmox_virtual_environment_user_example_keys" {
42 | value = proxmox_virtual_environment_user.example.keys
43 | }
44 |
45 | output "resource_proxmox_virtual_environment_user_example_last_name" {
46 | value = proxmox_virtual_environment_user.example.last_name
47 | }
48 |
49 | output "resource_proxmox_virtual_environment_user_example_password" {
50 | value = proxmox_virtual_environment_user.example.password
51 | sensitive = true
52 | }
53 |
54 | output "resource_proxmox_virtual_environment_user_example_user_id" {
55 | value = proxmox_virtual_environment_user.example.id
56 | }
57 |
--------------------------------------------------------------------------------
/example/resource_virtual_environment_vm.tf:
--------------------------------------------------------------------------------
1 | resource "proxmox_virtual_environment_vm" "example_template" {
2 | agent {
3 | enabled = true
4 | }
5 |
6 | description = "Managed by Terraform"
7 |
8 | disk {
9 | datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local-lvm"))
10 | file_id = proxmox_virtual_environment_file.ubuntu_cloud_image.id
11 | interface = "scsi0"
12 | }
13 |
14 | initialization {
15 | datastore_id = element(data.proxmox_virtual_environment_datastores.example.datastore_ids, index(data.proxmox_virtual_environment_datastores.example.datastore_ids, "local-lvm"))
16 |
17 | dns {
18 | server = "1.1.1.1"
19 | }
20 |
21 | ip_config {
22 | ipv4 {
23 | address = "dhcp"
24 | }
25 | }
26 |
27 | user_account {
28 | keys = [trimspace(tls_private_key.example.public_key_openssh)]
29 | password = "example"
30 | username = "ubuntu"
31 | }
32 |
33 | user_data_file_id = proxmox_virtual_environment_file.cloud_config.id
34 | }
35 |
36 | name = "terraform-provider-proxmox-example-template"
37 |
38 | network_device {}
39 |
40 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
41 |
42 | operating_system {
43 | type = "l26"
44 | }
45 |
46 | pool_id = proxmox_virtual_environment_pool.example.id
47 |
48 | serial_device {}
49 |
50 | template = true
51 | vm_id = 2040
52 | }
53 |
54 | resource "proxmox_virtual_environment_vm" "example" {
55 | name = "terraform-provider-proxmox-example"
56 | node_name = data.proxmox_virtual_environment_nodes.example.names[0]
57 | pool_id = proxmox_virtual_environment_pool.example.id
58 | vm_id = 2041
59 |
60 | clone {
61 | vm_id = proxmox_virtual_environment_vm.example_template.id
62 | }
63 |
64 | memory {
65 | dedicated = 768
66 | }
67 |
68 | connection {
69 | type = "ssh"
70 | agent = false
71 | host = element(element(self.ipv4_addresses, index(self.network_interface_names, "eth0")), 0)
72 | private_key = tls_private_key.example.private_key_pem
73 | user = "ubuntu"
74 | }
75 |
76 | provisioner "remote-exec" {
77 | inline = [
78 | "echo Welcome to $(hostname)!",
79 | ]
80 | }
81 | }
82 |
83 | output "resource_proxmox_virtual_environment_vm_example_id" {
84 | value = proxmox_virtual_environment_vm.example.id
85 | }
86 |
87 | output "resource_proxmox_virtual_environment_vm_example_ipv4_addresses" {
88 | value = proxmox_virtual_environment_vm.example.ipv4_addresses
89 | }
90 |
91 | output "resource_proxmox_virtual_environment_vm_example_ipv6_addresses" {
92 | value = proxmox_virtual_environment_vm.example.ipv6_addresses
93 | }
94 |
95 | output "resource_proxmox_virtual_environment_vm_example_mac_addresses" {
96 | value = proxmox_virtual_environment_vm.example.mac_addresses
97 | }
98 |
99 | output "resource_proxmox_virtual_environment_vm_example_network_interface_names" {
100 | value = proxmox_virtual_environment_vm.example.network_interface_names
101 | }
102 |
--------------------------------------------------------------------------------
/example/ssh.tf:
--------------------------------------------------------------------------------
1 | resource "local_file" "example_ssh_private_key" {
2 | filename = "${path.module}/autogenerated/id_rsa"
3 | sensitive_content = tls_private_key.example.private_key_pem
4 | }
5 |
6 | resource "local_file" "example_ssh_public_key" {
7 | filename = "${path.module}/autogenerated/id_rsa.pub"
8 | sensitive_content = tls_private_key.example.public_key_openssh
9 | }
10 |
11 | resource "tls_private_key" "example" {
12 | algorithm = "RSA"
13 | rsa_bits = 2048
14 | }
15 |
--------------------------------------------------------------------------------
/example/variables.tf:
--------------------------------------------------------------------------------
1 | variable "virtual_environment_endpoint" {
2 | type = string
3 | description = "The endpoint for the Proxmox Virtual Environment API (example: https://host:port)"
4 | }
5 |
6 | variable "virtual_environment_password" {
7 | type = string
8 | description = "The password for the Proxmox Virtual Environment API"
9 | }
10 |
11 | variable "virtual_environment_username" {
12 | type = string
13 | description = "The username and realm for the Proxmox Virtual Environment API (example: root@pam)"
14 | }
15 |
--------------------------------------------------------------------------------
/example/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_providers {
3 | local = {
4 | source = "hashicorp/local"
5 | version = "2.0.0"
6 | }
7 | proxmox = {
8 | source = "danitso/proxmox"
9 | version = "9999.0.0"
10 | }
11 | tls = {
12 | source = "hashicorp/tls"
13 | version = "3.0.0"
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/danitso/terraform-provider-proxmox
2 |
3 | go 1.15
4 |
5 | require (
6 | cloud.google.com/go v0.74.0 // indirect
7 | cloud.google.com/go/storage v1.12.0 // indirect
8 | github.com/agext/levenshtein v1.2.3 // indirect
9 | github.com/apparentlymart/go-cidr v1.1.0 // indirect
10 | github.com/aws/aws-sdk-go v1.36.19 // indirect
11 | github.com/fatih/color v1.10.0 // indirect
12 | github.com/google/go-querystring v1.0.0
13 | github.com/google/uuid v1.1.3 // indirect
14 | github.com/hashicorp/errwrap v1.1.0 // indirect
15 | github.com/hashicorp/go-getter v1.5.1 // indirect
16 | github.com/hashicorp/go-hclog v0.15.0 // indirect
17 | github.com/hashicorp/go-multierror v1.1.0 // indirect
18 | github.com/hashicorp/go-plugin v1.4.0 // indirect
19 | github.com/hashicorp/go-uuid v1.0.2 // indirect
20 | github.com/hashicorp/hcl/v2 v2.8.1 // indirect
21 | github.com/hashicorp/terraform-plugin-sdk v1.16.0
22 | github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
23 | github.com/hashicorp/yamux v0.0.0-20200609203250-aecfd211c9ce // indirect
24 | github.com/mitchellh/cli v1.1.2 // indirect
25 | github.com/mitchellh/go-testing-interface v1.14.1 // indirect
26 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect
27 | github.com/mitchellh/mapstructure v1.4.0 // indirect
28 | github.com/oklog/run v1.1.0 // indirect
29 | github.com/pkg/sftp v1.12.0
30 | github.com/posener/complete v1.2.3 // indirect
31 | github.com/spf13/afero v1.5.1 // indirect
32 | github.com/ulikunitz/xz v0.5.9 // indirect
33 | github.com/vmihailenco/tagparser v0.1.2 // indirect
34 | github.com/zclconf/go-cty v1.7.1 // indirect
35 | github.com/zclconf/go-cty-yaml v1.0.2 // indirect
36 | golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
37 | golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
38 | golang.org/x/sys v0.0.0-20201231184435-2d18734c6014 // indirect
39 | golang.org/x/tools v0.0.0-20210102185154-773b96fafca2 // indirect
40 | google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d // indirect
41 | )
42 |
--------------------------------------------------------------------------------
/main.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package main
6 |
7 | import (
8 | "github.com/danitso/terraform-provider-proxmox/proxmoxtf"
9 | "github.com/hashicorp/terraform-plugin-sdk/plugin"
10 | "github.com/hashicorp/terraform-plugin-sdk/terraform"
11 | )
12 |
13 | func main() {
14 | plugin.Serve(&plugin.ServeOpts{
15 | ProviderFunc: func() terraform.ResourceProvider {
16 | return proxmoxtf.Provider()
17 | },
18 | })
19 | }
20 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_acl.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "sort"
10 | )
11 |
12 | // GetACL retrieves the access control list.
13 | func (c *VirtualEnvironmentClient) GetACL() ([]*VirtualEnvironmentACLGetResponseData, error) {
14 | resBody := &VirtualEnvironmentACLGetResponseBody{}
15 | err := c.DoRequest(hmGET, "access/acl", nil, resBody)
16 |
17 | if err != nil {
18 | return nil, err
19 | }
20 |
21 | if resBody.Data == nil {
22 | return nil, errors.New("The server did not include a data object in the response")
23 | }
24 |
25 | sort.Slice(resBody.Data, func(i, j int) bool {
26 | return resBody.Data[i].Path < resBody.Data[j].Path
27 | })
28 |
29 | return resBody.Data, nil
30 | }
31 |
32 | // UpdateACL updates the access control list.
33 | func (c *VirtualEnvironmentClient) UpdateACL(d *VirtualEnvironmentACLUpdateRequestBody) error {
34 | return c.DoRequest(hmPUT, "access/acl", d, nil)
35 | }
36 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_acl_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentACLGetResponseBody contains the body from an access control list response.
8 | type VirtualEnvironmentACLGetResponseBody struct {
9 | Data []*VirtualEnvironmentACLGetResponseData `json:"data,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentACLGetResponseData contains the data from an access control list response.
13 | type VirtualEnvironmentACLGetResponseData struct {
14 | Path string `json:"path"`
15 | Propagate *CustomBool `json:"propagate,omitempty"`
16 | RoleID string `json:"roleid"`
17 | Type string `json:"type"`
18 | UserOrGroupID string `json:"ugid"`
19 | }
20 |
21 | // VirtualEnvironmentACLUpdateRequestBody contains the data for an access control list update request.
22 | type VirtualEnvironmentACLUpdateRequestBody struct {
23 | Delete *CustomBool `json:"delete,omitempty" url:"delete,omitempty,int"`
24 | Groups []string `json:"groups,omitempty" url:"groups,omitempty,comma"`
25 | Path string `json:"path" url:"path"`
26 | Propagate *CustomBool `json:"propagate,omitempty" url:"propagate,omitempty,int"`
27 | Roles []string `json:"roles" url:"roles,comma"`
28 | Users []string `json:"users,omitempty" url:"users,omitempty,comma"`
29 | }
30 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_authentication.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "bytes"
9 | "encoding/json"
10 | "errors"
11 | "fmt"
12 | "net/http"
13 | "net/url"
14 | )
15 |
16 | const (
17 | // DefaultRootAccount contains the default username and realm for the root account.
18 | DefaultRootAccount = "root@pam"
19 | )
20 |
21 | // Authenticate authenticates against the specified endpoint.
22 | func (c *VirtualEnvironmentClient) Authenticate(reset bool) error {
23 | if c.authenticationData != nil && !reset {
24 | return nil
25 | }
26 |
27 | var reqBody *bytes.Buffer
28 |
29 | if c.OTP != nil {
30 | reqBody = bytes.NewBufferString(fmt.Sprintf(
31 | "username=%s&password=%s&otp=%s",
32 | url.QueryEscape(c.Username),
33 | url.QueryEscape(c.Password),
34 | url.QueryEscape(*c.OTP),
35 | ))
36 | } else {
37 | reqBody = bytes.NewBufferString(fmt.Sprintf(
38 | "username=%s&password=%s",
39 | url.QueryEscape(c.Username),
40 | url.QueryEscape(c.Password),
41 | ))
42 | }
43 |
44 | req, err := http.NewRequest(hmPOST, fmt.Sprintf("%s/%s/access/ticket", c.Endpoint, basePathJSONAPI), reqBody)
45 |
46 | if err != nil {
47 | return errors.New("Failed to create authentication request")
48 | }
49 |
50 | req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
51 |
52 | res, err := c.httpClient.Do(req)
53 |
54 | if err != nil {
55 | return errors.New("Failed to retrieve authentication response")
56 | }
57 |
58 | err = c.ValidateResponseCode(res)
59 |
60 | if err != nil {
61 | return err
62 | }
63 |
64 | resBody := VirtualEnvironmentAuthenticationResponseBody{}
65 | err = json.NewDecoder(res.Body).Decode(&resBody)
66 |
67 | if err != nil {
68 | return errors.New("Failed to decode authentication response")
69 | }
70 |
71 | if resBody.Data == nil {
72 | return errors.New("The server did not include a data object in the authentication response")
73 | }
74 |
75 | if resBody.Data.CSRFPreventionToken == nil {
76 | return errors.New("The server did not include a CSRF prevention token in the authentication response")
77 | }
78 |
79 | if resBody.Data.Ticket == nil {
80 | return errors.New("The server did not include a ticket in the authentication response")
81 | }
82 |
83 | if resBody.Data.Username == "" {
84 | return errors.New("The server did not include the username in the authentication response")
85 | }
86 |
87 | c.authenticationData = resBody.Data
88 |
89 | return nil
90 | }
91 |
92 | // AuthenticateRequest adds authentication data to a new request.
93 | func (c *VirtualEnvironmentClient) AuthenticateRequest(req *http.Request) error {
94 | err := c.Authenticate(false)
95 |
96 | if err != nil {
97 | return err
98 | }
99 |
100 | req.AddCookie(&http.Cookie{
101 | Name: "PVEAuthCookie",
102 | Value: *c.authenticationData.Ticket,
103 | })
104 |
105 | if req.Method != "GET" {
106 | req.Header.Add("CSRFPreventionToken", *c.authenticationData.CSRFPreventionToken)
107 | }
108 |
109 | return nil
110 | }
111 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_authentication_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentAuthenticationResponseBody contains the body from an authentication response.
8 | type VirtualEnvironmentAuthenticationResponseBody struct {
9 | Data *VirtualEnvironmentAuthenticationResponseData `json:"data,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentAuthenticationResponseCapabilities contains the supported capabilities for a session.
13 | type VirtualEnvironmentAuthenticationResponseCapabilities struct {
14 | Access *CustomPrivileges `json:"access,omitempty"`
15 | Datacenter *CustomPrivileges `json:"dc,omitempty"`
16 | Nodes *CustomPrivileges `json:"nodes,omitempty"`
17 | Storage *CustomPrivileges `json:"storage,omitempty"`
18 | VMs *CustomPrivileges `json:"vms,omitempty"`
19 | }
20 |
21 | // VirtualEnvironmentAuthenticationResponseData contains the data from an authentication response.
22 | type VirtualEnvironmentAuthenticationResponseData struct {
23 | ClusterName *string `json:"clustername,omitempty"`
24 | CSRFPreventionToken *string `json:"CSRFPreventionToken,omitempty"`
25 | Capabilities *VirtualEnvironmentAuthenticationResponseCapabilities `json:"cap,omitempty"`
26 | Ticket *string `json:"ticket,omitempty"`
27 | Username string `json:"username"`
28 | }
29 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_certificate.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | )
12 |
13 | // DeleteCertificate deletes the custom certificate for a node.
14 | func (c *VirtualEnvironmentClient) DeleteCertificate(nodeName string, d *VirtualEnvironmentCertificateDeleteRequestBody) error {
15 | return c.DoRequest(hmDELETE, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
16 | }
17 |
18 | // ListCertificates retrieves the list of certificates for a node.
19 | func (c *VirtualEnvironmentClient) ListCertificates(nodeName string) (*[]VirtualEnvironmentCertificateListResponseData, error) {
20 | resBody := &VirtualEnvironmentCertificateListResponseBody{}
21 | err := c.DoRequest(hmGET, fmt.Sprintf("nodes/%s/certificates/info", url.PathEscape(nodeName)), nil, resBody)
22 |
23 | if err != nil {
24 | return nil, err
25 | }
26 |
27 | if resBody.Data == nil {
28 | return nil, errors.New("The server did not include a data object in the response")
29 | }
30 |
31 | return resBody.Data, nil
32 | }
33 |
34 | // UpdateCertificate updates the custom certificate for a node.
35 | func (c *VirtualEnvironmentClient) UpdateCertificate(nodeName string, d *VirtualEnvironmentCertificateUpdateRequestBody) error {
36 | return c.DoRequest(hmPOST, fmt.Sprintf("nodes/%s/certificates/custom", url.PathEscape(nodeName)), d, nil)
37 | }
38 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_certificate_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentCertificateDeleteRequestBody contains the data for a custom certificate delete request.
8 | type VirtualEnvironmentCertificateDeleteRequestBody struct {
9 | Restart *CustomBool `json:"restart,omitempty" url:"restart,omitempty,int"`
10 | }
11 |
12 | // VirtualEnvironmentCertificateListResponseBody contains the body from a certificate list response.
13 | type VirtualEnvironmentCertificateListResponseBody struct {
14 | Data *[]VirtualEnvironmentCertificateListResponseData `json:"data,omitempty"`
15 | }
16 |
17 | // VirtualEnvironmentCertificateListResponseData contains the data from a certificate list response.
18 | type VirtualEnvironmentCertificateListResponseData struct {
19 | Certificates *string `json:"pem,omitempty"`
20 | FileName *string `json:"filename,omitempty"`
21 | Fingerprint *string `json:"fingerprint,omitempty"`
22 | Issuer *string `json:"issuer,omitempty"`
23 | NotAfter *CustomTimestamp `json:"notafter,omitempty"`
24 | NotBefore *CustomTimestamp `json:"notbefore,omitempty"`
25 | PublicKeyBits *int `json:"public-key-bits,omitempty"`
26 | PublicKeyType *string `json:"public-key-type,omitempty"`
27 | Subject *string `json:"subject,omitempty"`
28 | SubjectAlternativeNames *[]string `json:"san,omitempty"`
29 | }
30 |
31 | // VirtualEnvironmentCertificateUpdateRequestBody contains the body for a custom certificate update request.
32 | type VirtualEnvironmentCertificateUpdateRequestBody struct {
33 | Certificates string `json:"certificates" url:"certificates"`
34 | Force *CustomBool `json:"force,omitempty" url:"force,omitempty,int"`
35 | PrivateKey *string `json:"key,omitempty" url:"key,omitempty"`
36 | Restart *CustomBool `json:"restart,omitempty" url:"restart,omitempty,int"`
37 | }
38 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_client_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "io"
9 | "net/http"
10 | )
11 |
12 | const (
13 | basePathJSONAPI = "api2/json"
14 | hmDELETE = "DELETE"
15 | hmGET = "GET"
16 | hmHEAD = "HEAD"
17 | hmPOST = "POST"
18 | hmPUT = "PUT"
19 | )
20 |
21 | // VirtualEnvironmentClient implements an API client for the Proxmox Virtual Environment API.
22 | type VirtualEnvironmentClient struct {
23 | Endpoint string
24 | Insecure bool
25 | OTP *string
26 | Password string
27 | Username string
28 |
29 | authenticationData *VirtualEnvironmentAuthenticationResponseData
30 | httpClient *http.Client
31 | }
32 |
33 | // VirtualEnvironmentErrorResponseBody contains the body of an error response.
34 | type VirtualEnvironmentErrorResponseBody struct {
35 | Data *string
36 | Errors *map[string]string
37 | }
38 |
39 | // VirtualEnvironmentMultiPartData enables multipart uploads in DoRequest.
40 | type VirtualEnvironmentMultiPartData struct {
41 | Boundary string
42 | Reader io.Reader
43 | Size *int64
44 | }
45 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | )
10 |
11 | // GetClusterNextID retrieves the next free VM identifier for the cluster.
12 | func (c *VirtualEnvironmentClient) GetClusterNextID(vmID *int) (*int, error) {
13 | reqBody := &VirtualEnvironmentClusterNextIDRequestBody{
14 | VMID: vmID,
15 | }
16 |
17 | resBody := &VirtualEnvironmentClusterNextIDResponseBody{}
18 | err := c.DoRequest(hmGET, "cluster/nextid", reqBody, resBody)
19 |
20 | if err != nil {
21 | return nil, err
22 | }
23 |
24 | if resBody.Data == nil {
25 | return nil, errors.New("The server did not include a data object in the response")
26 | }
27 |
28 | return (*int)(resBody.Data), nil
29 | }
30 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster_alias.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | )
13 |
14 | // CreateAlias create an alias
15 | func (c *VirtualEnvironmentClient) CreateAlias(d *VirtualEnvironmentClusterAliasCreateRequestBody) error {
16 | return c.DoRequest(hmPOST, "cluster/firewall/aliases", d, nil)
17 | }
18 |
19 | // DeleteAlias delete an alias
20 | func (c *VirtualEnvironmentClient) DeleteAlias(id string) error {
21 | return c.DoRequest(hmDELETE, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), nil, nil)
22 | }
23 |
24 | // GetAlias retrieves an alias
25 | func (c *VirtualEnvironmentClient) GetAlias(id string) (*VirtualEnvironmentClusterAliasGetResponseData, error) {
26 | resBody := &VirtualEnvironmentClusterAliasGetResponseBody{}
27 | err := c.DoRequest(hmGET, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), nil, resBody)
28 |
29 | if err != nil {
30 | return nil, err
31 | }
32 |
33 | if resBody.Data == nil {
34 | return nil, errors.New("The server did not include a data object in the response")
35 | }
36 |
37 | return resBody.Data, nil
38 | }
39 |
40 | // ListAlias retrieves a list of aliases.
41 | func (c *VirtualEnvironmentClient) ListAliases() ([]*VirtualEnvironmentClusterAliasGetResponseData, error) {
42 | resBody := &VirtualEnvironmentClusterAliasListResponseBody{}
43 | err := c.DoRequest(hmGET, "cluster/firewall/aliases", nil, resBody)
44 |
45 | if err != nil {
46 | return nil, err
47 | }
48 |
49 | if resBody.Data == nil {
50 | return nil, errors.New("The server did not include a data object in the response")
51 | }
52 |
53 | sort.Slice(resBody.Data, func(i, j int) bool {
54 | return resBody.Data[i].Name < resBody.Data[j].Name
55 | })
56 |
57 | return resBody.Data, nil
58 | }
59 |
60 | // UpdateAlias updates an alias.
61 | func (c *VirtualEnvironmentClient) UpdateAlias(id string, d *VirtualEnvironmentClusterAliasUpdateRequestBody) error {
62 | return c.DoRequest(hmPUT, fmt.Sprintf("cluster/firewall/aliases/%s", url.PathEscape(id)), d, nil)
63 | }
64 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster_alias_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentClusterAliasCreateRequestBody contains the data for an alias create request.
8 | type VirtualEnvironmentClusterAliasCreateRequestBody struct {
9 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
10 | Name string `json:"name" url:"name"`
11 | CIDR string `json:"cidr" url:"cidr"`
12 | }
13 |
14 | // VirtualEnvironmentClusterAliasGetResponseBody contains the body from an alias get response.
15 | type VirtualEnvironmentClusterAliasGetResponseBody struct {
16 | Data *VirtualEnvironmentClusterAliasGetResponseData `json:"data,omitempty"`
17 | }
18 |
19 | // VirtualEnvironmentClusterAliasGetResponseData contains the data from an alias get response.
20 | type VirtualEnvironmentClusterAliasGetResponseData struct {
21 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
22 | Name string `json:"name" url:"name"`
23 | CIDR string `json:"cidr" url:"cidr"`
24 | Digest *string `json:"digest" url:"digest"`
25 | IPVersion int `json:"ipversion" url:"ipversion"`
26 | }
27 |
28 | // VirtualEnvironmentClusterAliasListResponseBody contains the data from an alias get response.
29 | type VirtualEnvironmentClusterAliasListResponseBody struct {
30 | Data []*VirtualEnvironmentClusterAliasGetResponseData `json:"data,omitempty"`
31 | }
32 |
33 | // VirtualEnvironmentClusterAliasUpdateRequestBody contains the data for an alias update request.
34 | type VirtualEnvironmentClusterAliasUpdateRequestBody struct {
35 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
36 | ReName string `json:"rename" url:"rename"`
37 | CIDR string `json:"cidr" url:"cidr"`
38 | }
39 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster_ipset.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | )
13 |
14 | // CreateIPSet create an IPSet
15 | func (c *VirtualEnvironmentClient) CreateIPSet(d *VirtualEnvironmentClusterIPSetCreateRequestBody) error {
16 | return c.DoRequest(hmPOST, "cluster/firewall/ipset", d, nil)
17 | }
18 |
19 | // Add IP or Network to IPSet
20 | func (c *VirtualEnvironmentClient) AddCIDRToIPSet(id string, d *VirtualEnvironmentClusterIPSetGetResponseData) error {
21 | return c.DoRequest(hmPOST, fmt.Sprintf("cluster/firewall/ipset/%s/", url.PathEscape(id)), d, nil)
22 | }
23 |
24 | // UpdateIPSet updates an IPSet.
25 | func (c *VirtualEnvironmentClient) UpdateIPSet(d *VirtualEnvironmentClusterIPSetUpdateRequestBody) error {
26 | return c.DoRequest(hmPOST, fmt.Sprint("cluster/firewall/ipset/"), d, nil)
27 | }
28 |
29 | // DeleteIPSet delete an IPSet
30 | func (c *VirtualEnvironmentClient) DeleteIPSet(id string) error {
31 | return c.DoRequest(hmDELETE, fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)), nil, nil)
32 | }
33 |
34 | // DeleteIPSetContent remove IP or Network from IPSet.
35 | func (c *VirtualEnvironmentClient) DeleteIPSetContent(id string, cidr string) error {
36 | return c.DoRequest(hmDELETE, fmt.Sprintf("cluster/firewall/ipset/%s/%s", url.PathEscape(id), url.PathEscape(cidr)), nil, nil)
37 | }
38 |
39 | // GetListIPSetContent retrieve a list of IPSet content
40 | func (c *VirtualEnvironmentClient) GetListIPSetContent(id string) ([]*VirtualEnvironmentClusterIPSetGetResponseData, error) {
41 | resBody := &VirtualEnvironmentClusterIPSetGetResponseBody{}
42 | err := c.DoRequest(hmGET, fmt.Sprintf("cluster/firewall/ipset/%s", url.PathEscape(id)), nil, resBody)
43 |
44 | if err != nil {
45 | return nil, err
46 | }
47 |
48 | if resBody.Data == nil {
49 | return nil, errors.New("The server did not include a data object in the response")
50 | }
51 |
52 | return resBody.Data, nil
53 | }
54 |
55 | // GetListIPSets retrieves list of IPSets.
56 | func (c *VirtualEnvironmentClient) GetListIPSets() (*VirtualEnvironmentClusterIPSetListResponseBody, error) {
57 | resBody := &VirtualEnvironmentClusterIPSetListResponseBody{}
58 | err := c.DoRequest(hmGET, "cluster/firewall/ipset", nil, resBody)
59 |
60 | if err != nil {
61 | return nil, err
62 | }
63 |
64 | if resBody.Data == nil {
65 | return nil, errors.New("The server did not include a data object in the response")
66 | }
67 |
68 | sort.Slice(resBody.Data, func(i, j int) bool {
69 | return resBody.Data[i].Name < resBody.Data[j].Name
70 | })
71 |
72 | return resBody, nil
73 | }
74 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster_ipset_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | /**
6 | * Reference: https://pve.proxmox.com/pve-docs/api-viewer/#/cluster/firewall/ipset
7 | */
8 |
9 | package proxmox
10 |
11 | // VirtualEnvironmentClusterIPSetListResponseBody contains the data from an IPSet get response.
12 | type VirtualEnvironmentClusterIPSetListResponseBody struct {
13 | Data []*VirtualEnvironmentClusterIPSetCreateRequestBody `json:"data,omitempty"`
14 | }
15 |
16 | // VirtualEnvironmentClusterIPSetCreateRequestBody contains the data for an IPSet create request
17 | type VirtualEnvironmentClusterIPSetCreateRequestBody struct {
18 | Comment string `json:"comment,omitempty" url:"comment,omitempty"`
19 | Name string `json:"name" url:"name"`
20 | }
21 |
22 | // VirtualEnvironmentClusterIPSetGetResponseBody contains the body from an IPSet get response.
23 | type VirtualEnvironmentClusterIPSetGetResponseBody struct {
24 | Data []*VirtualEnvironmentClusterIPSetGetResponseData `json:"data,omitempty"`
25 | }
26 |
27 | // VirtualEnvironmentClusterIPSetGetResponseData contains the data from an IPSet get response.
28 | type VirtualEnvironmentClusterIPSetGetResponseData struct {
29 | CIDR string `json:"cidr" url:"cidr"`
30 | NoMatch *CustomBool `json:"nomatch,omitempty" url:"nomatch,omitempty,int"`
31 | Comment string `json:"comment,omitempty" url:"comment,omitempty"`
32 | }
33 |
34 | // VirtualEnvironmentClusterIPSetUpdateRequestBody contains the data for an IPSet update request.
35 | type VirtualEnvironmentClusterIPSetUpdateRequestBody struct {
36 | ReName string `json:"rename,omitempty" url:"rename,omitempty"`
37 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
38 | Name string `json:"name" url:"name"`
39 | }
40 |
41 | // VirtualEnvironmentClusterIPSetGetResponseData contains list of IPSets from
42 | type VirtualEnvironmentClusterIPSetListResponseData struct {
43 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
44 | Name string `json:"name" url:"name"`
45 | }
46 |
47 | // VirtualEnvironmentClusterIPSetContent is an array of VirtualEnvironmentClusterIPSetGetResponseData.
48 | type VirtualEnvironmentClusterIPSetContent []VirtualEnvironmentClusterIPSetGetResponseData
49 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_cluster_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentClusterNextIDRequestBody contains the data for a cluster next id request.
8 | type VirtualEnvironmentClusterNextIDRequestBody struct {
9 | VMID *int `json:"vmid,omitempty" url:"vmid,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentClusterNextIDResponseBody contains the body from a cluster next id response.
13 | type VirtualEnvironmentClusterNextIDResponseBody struct {
14 | Data *CustomInt `json:"data,omitempty"`
15 | }
16 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_datastores_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "io"
9 | )
10 |
11 | // VirtualEnvironmentDatastoreFileListResponseBody contains the body from a datastore content list response.
12 | type VirtualEnvironmentDatastoreFileListResponseBody struct {
13 | Data []*VirtualEnvironmentDatastoreFileListResponseData `json:"data,omitempty"`
14 | }
15 |
16 | // VirtualEnvironmentDatastoreFileListResponseData contains the data from a datastore content list response.
17 | type VirtualEnvironmentDatastoreFileListResponseData struct {
18 | ContentType string `json:"content"`
19 | FileFormat string `json:"format"`
20 | FileSize int `json:"size"`
21 | ParentVolumeID *string `json:"parent,omitempty"`
22 | SpaceUsed *int `json:"used,omitempty"`
23 | VMID *int `json:"vmid,omitempty"`
24 | VolumeID string `json:"volid"`
25 | }
26 |
27 | // VirtualEnvironmentDatastoreListRequestBody contains the body for a datastore list request.
28 | type VirtualEnvironmentDatastoreListRequestBody struct {
29 | ContentTypes CustomCommaSeparatedList `json:"content,omitempty" url:"content,omitempty,comma"`
30 | Enabled *CustomBool `json:"enabled,omitempty" url:"enabled,omitempty,int"`
31 | Format *CustomBool `json:"format,omitempty" url:"format,omitempty,int"`
32 | ID *string `json:"storage,omitempty" url:"storage,omitempty"`
33 | Target *string `json:"target,omitempty" url:"target,omitempty"`
34 | }
35 |
36 | // VirtualEnvironmentDatastoreListResponseBody contains the body from a datastore list response.
37 | type VirtualEnvironmentDatastoreListResponseBody struct {
38 | Data []*VirtualEnvironmentDatastoreListResponseData `json:"data,omitempty"`
39 | }
40 |
41 | // VirtualEnvironmentDatastoreListResponseData contains the data from a datastore list response.
42 | type VirtualEnvironmentDatastoreListResponseData struct {
43 | Active *CustomBool `json:"active,omitempty"`
44 | ContentTypes *CustomCommaSeparatedList `json:"content,omitempty"`
45 | Enabled *CustomBool `json:"enabled,omitempty"`
46 | ID string `json:"storage,omitempty"`
47 | Shared *CustomBool `json:"shared,omitempty"`
48 | SpaceAvailable *int `json:"avail,omitempty"`
49 | SpaceTotal *int `json:"total,omitempty"`
50 | SpaceUsed *int `json:"used,omitempty"`
51 | SpaceUsedPercentage *float64 `json:"used_fraction,omitempty"`
52 | Type string `json:"type,omitempty"`
53 | }
54 |
55 | // VirtualEnvironmentDatastoreUploadRequestBody contains the body for a datastore upload request.
56 | type VirtualEnvironmentDatastoreUploadRequestBody struct {
57 | ContentType string `json:"content,omitempty"`
58 | DatastoreID string `json:"storage,omitempty"`
59 | FileName string `json:"filename,omitempty"`
60 | FileReader io.Reader `json:"-"`
61 | NodeName string `json:"node,omitempty"`
62 | }
63 |
64 | // VirtualEnvironmentDatastoreUploadResponseBody contains the body from a datastore upload response.
65 | type VirtualEnvironmentDatastoreUploadResponseBody struct {
66 | UploadID *string `json:"data,omitempty"`
67 | }
68 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_dns.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | )
12 |
13 | // GetDNS retrieves the DNS configuration for a node.
14 | func (c *VirtualEnvironmentClient) GetDNS(nodeName string) (*VirtualEnvironmentDNSGetResponseData, error) {
15 | resBody := &VirtualEnvironmentDNSGetResponseBody{}
16 | err := c.DoRequest(hmGET, fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)), nil, resBody)
17 |
18 | if err != nil {
19 | return nil, err
20 | }
21 |
22 | if resBody.Data == nil {
23 | return nil, errors.New("The server did not include a data object in the response")
24 | }
25 |
26 | return resBody.Data, nil
27 | }
28 |
29 | // UpdateDNS updates the DNS configuration for a node.
30 | func (c *VirtualEnvironmentClient) UpdateDNS(nodeName string, d *VirtualEnvironmentDNSUpdateRequestBody) error {
31 | return c.DoRequest(hmPUT, fmt.Sprintf("nodes/%s/dns", url.PathEscape(nodeName)), d, nil)
32 | }
33 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_dns_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentDNSGetResponseBody contains the body from a DNS get response.
8 | type VirtualEnvironmentDNSGetResponseBody struct {
9 | Data *VirtualEnvironmentDNSGetResponseData `json:"data,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentDNSGetResponseData contains the data from a DNS get response.
13 | type VirtualEnvironmentDNSGetResponseData struct {
14 | Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
15 | Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
16 | Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
17 | SearchDomain *string `json:"search,omitempty" url:"search,omitempty"`
18 | }
19 |
20 | // VirtualEnvironmentDNSUpdateRequestBody contains the body for a DNS update request.
21 | type VirtualEnvironmentDNSUpdateRequestBody struct {
22 | Server1 *string `json:"dns1,omitempty" url:"dns1,omitempty"`
23 | Server2 *string `json:"dns2,omitempty" url:"dns2,omitempty"`
24 | Server3 *string `json:"dns3,omitempty" url:"dns3,omitempty"`
25 | SearchDomain *string `json:"search,omitempty" url:"search,omitempty"`
26 | }
27 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_groups.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | )
13 |
14 | // CreateGroup creates an access group.
15 | func (c *VirtualEnvironmentClient) CreateGroup(d *VirtualEnvironmentGroupCreateRequestBody) error {
16 | return c.DoRequest(hmPOST, "access/groups", d, nil)
17 | }
18 |
19 | // DeleteGroup deletes an access group.
20 | func (c *VirtualEnvironmentClient) DeleteGroup(id string) error {
21 | return c.DoRequest(hmDELETE, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), nil, nil)
22 | }
23 |
24 | // GetGroup retrieves an access group.
25 | func (c *VirtualEnvironmentClient) GetGroup(id string) (*VirtualEnvironmentGroupGetResponseData, error) {
26 | resBody := &VirtualEnvironmentGroupGetResponseBody{}
27 | err := c.DoRequest(hmGET, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), nil, resBody)
28 |
29 | if err != nil {
30 | return nil, err
31 | }
32 |
33 | if resBody.Data == nil {
34 | return nil, errors.New("The server did not include a data object in the response")
35 | }
36 |
37 | sort.Strings(resBody.Data.Members)
38 |
39 | return resBody.Data, nil
40 | }
41 |
42 | // ListGroups retrieves a list of access groups.
43 | func (c *VirtualEnvironmentClient) ListGroups() ([]*VirtualEnvironmentGroupListResponseData, error) {
44 | resBody := &VirtualEnvironmentGroupListResponseBody{}
45 | err := c.DoRequest(hmGET, "access/groups", nil, resBody)
46 |
47 | if err != nil {
48 | return nil, err
49 | }
50 |
51 | if resBody.Data == nil {
52 | return nil, errors.New("The server did not include a data object in the response")
53 | }
54 |
55 | sort.Slice(resBody.Data, func(i, j int) bool {
56 | return resBody.Data[i].ID < resBody.Data[j].ID
57 | })
58 |
59 | return resBody.Data, nil
60 | }
61 |
62 | // UpdateGroup updates an access group.
63 | func (c *VirtualEnvironmentClient) UpdateGroup(id string, d *VirtualEnvironmentGroupUpdateRequestBody) error {
64 | return c.DoRequest(hmPUT, fmt.Sprintf("access/groups/%s", url.PathEscape(id)), d, nil)
65 | }
66 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_groups_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentGroupCreateRequestBody contains the data for an access group create request.
8 | type VirtualEnvironmentGroupCreateRequestBody struct {
9 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
10 | ID string `json:"groupid" url:"groupid"`
11 | }
12 |
13 | // VirtualEnvironmentGroupGetResponseBody contains the body from an access group get response.
14 | type VirtualEnvironmentGroupGetResponseBody struct {
15 | Data *VirtualEnvironmentGroupGetResponseData `json:"data,omitempty"`
16 | }
17 |
18 | // VirtualEnvironmentGroupGetResponseData contains the data from an access group get response.
19 | type VirtualEnvironmentGroupGetResponseData struct {
20 | Comment *string `json:"comment,omitempty"`
21 | Members []string `json:"members"`
22 | }
23 |
24 | // VirtualEnvironmentGroupListResponseBody contains the body from an access group list response.
25 | type VirtualEnvironmentGroupListResponseBody struct {
26 | Data []*VirtualEnvironmentGroupListResponseData `json:"data,omitempty"`
27 | }
28 |
29 | // VirtualEnvironmentGroupListResponseData contains the data from an access group list response.
30 | type VirtualEnvironmentGroupListResponseData struct {
31 | Comment *string `json:"comment,omitempty"`
32 | ID string `json:"groupid"`
33 | }
34 |
35 | // VirtualEnvironmentGroupUpdateRequestBody contains the data for an access group update request.
36 | type VirtualEnvironmentGroupUpdateRequestBody struct {
37 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
38 | }
39 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_hosts.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | )
12 |
13 | // GetHosts retrieves the Hosts configuration for a node.
14 | func (c *VirtualEnvironmentClient) GetHosts(nodeName string) (*VirtualEnvironmentHostsGetResponseData, error) {
15 | resBody := &VirtualEnvironmentHostsGetResponseBody{}
16 | err := c.DoRequest(hmGET, fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)), nil, resBody)
17 |
18 | if err != nil {
19 | return nil, err
20 | }
21 |
22 | if resBody.Data == nil {
23 | return nil, errors.New("The server did not include a data object in the response")
24 | }
25 |
26 | return resBody.Data, nil
27 | }
28 |
29 | // UpdateHosts updates the Hosts configuration for a node.
30 | func (c *VirtualEnvironmentClient) UpdateHosts(nodeName string, d *VirtualEnvironmentHostsUpdateRequestBody) error {
31 | return c.DoRequest(hmPOST, fmt.Sprintf("nodes/%s/hosts", url.PathEscape(nodeName)), d, nil)
32 | }
33 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_hosts_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentHostsGetResponseBody contains the body from a hosts get response.
8 | type VirtualEnvironmentHostsGetResponseBody struct {
9 | Data *VirtualEnvironmentHostsGetResponseData `json:"data,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentHostsGetResponseData contains the data from a hosts get response.
13 | type VirtualEnvironmentHostsGetResponseData struct {
14 | Data string `json:"data"`
15 | Digest *string `json:"digest,omitempty"`
16 | }
17 |
18 | // VirtualEnvironmentHostsUpdateRequestBody contains the body for a hosts update request.
19 | type VirtualEnvironmentHostsUpdateRequestBody struct {
20 | Data string `json:"data" url:"data"`
21 | Digest *string `json:"digest,omitempty" url:"digest,omitempty"`
22 | }
23 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_pools.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | )
13 |
14 | // CreatePool creates an pool.
15 | func (c *VirtualEnvironmentClient) CreatePool(d *VirtualEnvironmentPoolCreateRequestBody) error {
16 | return c.DoRequest(hmPOST, "pools", d, nil)
17 | }
18 |
19 | // DeletePool deletes an pool.
20 | func (c *VirtualEnvironmentClient) DeletePool(id string) error {
21 | return c.DoRequest(hmDELETE, fmt.Sprintf("pools/%s", url.PathEscape(id)), nil, nil)
22 | }
23 |
24 | // GetPool retrieves an pool.
25 | func (c *VirtualEnvironmentClient) GetPool(id string) (*VirtualEnvironmentPoolGetResponseData, error) {
26 | resBody := &VirtualEnvironmentPoolGetResponseBody{}
27 | err := c.DoRequest(hmGET, fmt.Sprintf("pools/%s", url.PathEscape(id)), nil, resBody)
28 |
29 | if err != nil {
30 | return nil, err
31 | }
32 |
33 | if resBody.Data == nil {
34 | return nil, errors.New("The server did not include a data object in the response")
35 | }
36 |
37 | sort.Slice(resBody.Data.Members, func(i, j int) bool {
38 | return resBody.Data.Members[i].ID < resBody.Data.Members[j].ID
39 | })
40 |
41 | return resBody.Data, nil
42 | }
43 |
44 | // ListPools retrieves a list of pools.
45 | func (c *VirtualEnvironmentClient) ListPools() ([]*VirtualEnvironmentPoolListResponseData, error) {
46 | resBody := &VirtualEnvironmentPoolListResponseBody{}
47 | err := c.DoRequest(hmGET, "pools", nil, resBody)
48 |
49 | if err != nil {
50 | return nil, err
51 | }
52 |
53 | if resBody.Data == nil {
54 | return nil, errors.New("The server did not include a data object in the response")
55 | }
56 |
57 | sort.Slice(resBody.Data, func(i, j int) bool {
58 | return resBody.Data[i].ID < resBody.Data[j].ID
59 | })
60 |
61 | return resBody.Data, nil
62 | }
63 |
64 | // UpdatePool updates an pool.
65 | func (c *VirtualEnvironmentClient) UpdatePool(id string, d *VirtualEnvironmentPoolUpdateRequestBody) error {
66 | return c.DoRequest(hmPUT, fmt.Sprintf("pools/%s", url.PathEscape(id)), d, nil)
67 | }
68 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_pools_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentPoolCreateRequestBody contains the data for an pool create request.
8 | type VirtualEnvironmentPoolCreateRequestBody struct {
9 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
10 | ID string `json:"groupid" url:"poolid"`
11 | }
12 |
13 | // VirtualEnvironmentPoolGetResponseBody contains the body from an pool get response.
14 | type VirtualEnvironmentPoolGetResponseBody struct {
15 | Data *VirtualEnvironmentPoolGetResponseData `json:"data,omitempty"`
16 | }
17 |
18 | // VirtualEnvironmentPoolGetResponseData contains the data from an pool get response.
19 | type VirtualEnvironmentPoolGetResponseData struct {
20 | Comment *string `json:"comment,omitempty"`
21 | Members []VirtualEnvironmentPoolGetResponseMembers `json:"members,omitempty"`
22 | }
23 |
24 | // VirtualEnvironmentPoolGetResponseMembers contains the members data from an pool get response.
25 | type VirtualEnvironmentPoolGetResponseMembers struct {
26 | ID string `json:"id"`
27 | Node string `json:"node"`
28 | DatastoreID *string `json:"storage,omitempty"`
29 | Type string `json:"type"`
30 | VMID *int `json:"vmid"`
31 | }
32 |
33 | // VirtualEnvironmentPoolListResponseBody contains the body from an pool list response.
34 | type VirtualEnvironmentPoolListResponseBody struct {
35 | Data []*VirtualEnvironmentPoolListResponseData `json:"data,omitempty"`
36 | }
37 |
38 | // VirtualEnvironmentPoolListResponseData contains the data from an pool list response.
39 | type VirtualEnvironmentPoolListResponseData struct {
40 | Comment *string `json:"comment,omitempty"`
41 | ID string `json:"poolid"`
42 | }
43 |
44 | // VirtualEnvironmentPoolUpdateRequestBody contains the data for an pool update request.
45 | type VirtualEnvironmentPoolUpdateRequestBody struct {
46 | Comment *string `json:"comment,omitempty" url:"comment,omitempty"`
47 | }
48 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_roles.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | )
13 |
14 | // CreateRole creates an access role.
15 | func (c *VirtualEnvironmentClient) CreateRole(d *VirtualEnvironmentRoleCreateRequestBody) error {
16 | return c.DoRequest(hmPOST, "access/roles", d, nil)
17 | }
18 |
19 | // DeleteRole deletes an access role.
20 | func (c *VirtualEnvironmentClient) DeleteRole(id string) error {
21 | return c.DoRequest(hmDELETE, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), nil, nil)
22 | }
23 |
24 | // GetRole retrieves an access role.
25 | func (c *VirtualEnvironmentClient) GetRole(id string) (*CustomPrivileges, error) {
26 | resBody := &VirtualEnvironmentRoleGetResponseBody{}
27 | err := c.DoRequest(hmGET, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), nil, resBody)
28 |
29 | if err != nil {
30 | return nil, err
31 | }
32 |
33 | if resBody.Data == nil {
34 | return nil, errors.New("The server did not include a data object in the response")
35 | }
36 |
37 | sort.Strings(*resBody.Data)
38 |
39 | return resBody.Data, nil
40 | }
41 |
42 | // ListRoles retrieves a list of access roles.
43 | func (c *VirtualEnvironmentClient) ListRoles() ([]*VirtualEnvironmentRoleListResponseData, error) {
44 | resBody := &VirtualEnvironmentRoleListResponseBody{}
45 | err := c.DoRequest(hmGET, "access/roles", nil, resBody)
46 |
47 | if err != nil {
48 | return nil, err
49 | }
50 |
51 | if resBody.Data == nil {
52 | return nil, errors.New("The server did not include a data object in the response")
53 | }
54 |
55 | sort.Slice(resBody.Data, func(i, j int) bool {
56 | return resBody.Data[i].ID < resBody.Data[j].ID
57 | })
58 |
59 | for i := range resBody.Data {
60 | if resBody.Data[i].Privileges != nil {
61 | sort.Strings(*resBody.Data[i].Privileges)
62 | }
63 | }
64 |
65 | return resBody.Data, nil
66 | }
67 |
68 | // UpdateRole updates an access role.
69 | func (c *VirtualEnvironmentClient) UpdateRole(id string, d *VirtualEnvironmentRoleUpdateRequestBody) error {
70 | return c.DoRequest(hmPUT, fmt.Sprintf("access/roles/%s", url.PathEscape(id)), d, nil)
71 | }
72 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_roles_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentRoleCreateRequestBody contains the data for an access group create request.
8 | type VirtualEnvironmentRoleCreateRequestBody struct {
9 | ID string `json:"roleid" url:"roleid"`
10 | Privileges CustomPrivileges `json:"privs" url:"privs,comma"`
11 | }
12 |
13 | // VirtualEnvironmentRoleGetResponseBody contains the body from an access group get response.
14 | type VirtualEnvironmentRoleGetResponseBody struct {
15 | Data *CustomPrivileges `json:"data,omitempty"`
16 | }
17 |
18 | // VirtualEnvironmentRoleListResponseBody contains the body from an access group list response.
19 | type VirtualEnvironmentRoleListResponseBody struct {
20 | Data []*VirtualEnvironmentRoleListResponseData `json:"data,omitempty"`
21 | }
22 |
23 | // VirtualEnvironmentRoleListResponseData contains the data from an access group list response.
24 | type VirtualEnvironmentRoleListResponseData struct {
25 | ID string `json:"roleid"`
26 | Privileges *CustomPrivileges `json:"privs,omitempty"`
27 | Special *CustomBool `json:"special,omitempty"`
28 | }
29 |
30 | // VirtualEnvironmentRoleUpdateRequestBody contains the data for an access group update request.
31 | type VirtualEnvironmentRoleUpdateRequestBody struct {
32 | Privileges CustomPrivileges `json:"privs" url:"privs,comma"`
33 | }
34 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_users.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | "fmt"
10 | "net/url"
11 | "sort"
12 | "time"
13 | )
14 |
15 | // ChangeUserPassword changes a user's password.
16 | func (c *VirtualEnvironmentClient) ChangeUserPassword(id, password string) error {
17 | d := VirtualEnvironmentUserChangePasswordRequestBody{
18 | ID: id,
19 | Password: password,
20 | }
21 |
22 | return c.DoRequest(hmPUT, "access/password", d, nil)
23 | }
24 |
25 | // CreateUser creates an user.
26 | func (c *VirtualEnvironmentClient) CreateUser(d *VirtualEnvironmentUserCreateRequestBody) error {
27 | return c.DoRequest(hmPOST, "access/users", d, nil)
28 | }
29 |
30 | // DeleteUser deletes an user.
31 | func (c *VirtualEnvironmentClient) DeleteUser(id string) error {
32 | return c.DoRequest(hmDELETE, fmt.Sprintf("access/users/%s", url.PathEscape(id)), nil, nil)
33 | }
34 |
35 | // GetUser retrieves an user.
36 | func (c *VirtualEnvironmentClient) GetUser(id string) (*VirtualEnvironmentUserGetResponseData, error) {
37 | resBody := &VirtualEnvironmentUserGetResponseBody{}
38 | err := c.DoRequest(hmGET, fmt.Sprintf("access/users/%s", url.PathEscape(id)), nil, resBody)
39 |
40 | if err != nil {
41 | return nil, err
42 | }
43 |
44 | if resBody.Data == nil {
45 | return nil, errors.New("The server did not include a data object in the response")
46 | }
47 |
48 | if resBody.Data.ExpirationDate != nil {
49 | expirationDate := CustomTimestamp(time.Time(*resBody.Data.ExpirationDate).UTC())
50 | resBody.Data.ExpirationDate = &expirationDate
51 | }
52 |
53 | if resBody.Data.Groups != nil {
54 | sort.Strings(*resBody.Data.Groups)
55 | }
56 |
57 | return resBody.Data, nil
58 | }
59 |
60 | // ListUsers retrieves a list of users.
61 | func (c *VirtualEnvironmentClient) ListUsers() ([]*VirtualEnvironmentUserListResponseData, error) {
62 | resBody := &VirtualEnvironmentUserListResponseBody{}
63 | err := c.DoRequest(hmGET, "access/users", nil, resBody)
64 |
65 | if err != nil {
66 | return nil, err
67 | }
68 |
69 | if resBody.Data == nil {
70 | return nil, errors.New("The server did not include a data object in the response")
71 | }
72 |
73 | sort.Slice(resBody.Data, func(i, j int) bool {
74 | return resBody.Data[i].ID < resBody.Data[j].ID
75 | })
76 |
77 | for i := range resBody.Data {
78 | if resBody.Data[i].ExpirationDate != nil {
79 | expirationDate := CustomTimestamp(time.Time(*resBody.Data[i].ExpirationDate).UTC())
80 | resBody.Data[i].ExpirationDate = &expirationDate
81 | }
82 |
83 | if resBody.Data[i].Groups != nil {
84 | sort.Strings(*resBody.Data[i].Groups)
85 | }
86 | }
87 |
88 | return resBody.Data, nil
89 | }
90 |
91 | // UpdateUser updates an user.
92 | func (c *VirtualEnvironmentClient) UpdateUser(id string, d *VirtualEnvironmentUserUpdateRequestBody) error {
93 | return c.DoRequest(hmPUT, fmt.Sprintf("access/users/%s", url.PathEscape(id)), d, nil)
94 | }
95 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_version.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | import (
8 | "errors"
9 | )
10 |
11 | // Version retrieves the version information.
12 | func (c *VirtualEnvironmentClient) Version() (*VirtualEnvironmentVersionResponseData, error) {
13 | resBody := &VirtualEnvironmentVersionResponseBody{}
14 | err := c.DoRequest(hmGET, "version", nil, resBody)
15 |
16 | if err != nil {
17 | return nil, err
18 | }
19 |
20 | if resBody.Data == nil {
21 | return nil, errors.New("The server did not include a data object in the response")
22 | }
23 |
24 | return resBody.Data, nil
25 | }
26 |
--------------------------------------------------------------------------------
/proxmox/virtual_environment_version_types.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmox
6 |
7 | // VirtualEnvironmentVersionResponseBody contains the body from a version response.
8 | type VirtualEnvironmentVersionResponseBody struct {
9 | Data *VirtualEnvironmentVersionResponseData `json:"data,omitempty"`
10 | }
11 |
12 | // VirtualEnvironmentVersionResponseData contains the data from a version response.
13 | type VirtualEnvironmentVersionResponseData struct {
14 | Keyboard string `json:"keyboard"`
15 | Release string `json:"release"`
16 | RepositoryID string `json:"repoid"`
17 | Version string `json:"version"`
18 | }
19 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_cluster_alias.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | dvDataVirtualEnvironmentClusterAliasComment = ""
13 |
14 | mkDataSourceVirtualEnvironmentClusterAliasName = "name"
15 | mkDataSourceVirtualEnvironmentClusterAliasCIDR = "cidr"
16 | mkDataSourceVirtualEnvironmentClusterAliasComment = "comment"
17 | )
18 |
19 | func dataSourceVirtualEnvironmentClusterAlias() *schema.Resource {
20 | return &schema.Resource{
21 | Schema: map[string]*schema.Schema{
22 | mkDataSourceVirtualEnvironmentClusterAliasName: {
23 | Type: schema.TypeString,
24 | Description: "Alias name",
25 | Required: true,
26 | },
27 | mkDataSourceVirtualEnvironmentClusterAliasCIDR: {
28 | Type: schema.TypeString,
29 | Description: "IP/CIDR block",
30 | Computed: true,
31 | },
32 | mkDataSourceVirtualEnvironmentClusterAliasComment: {
33 | Type: schema.TypeString,
34 | Description: "Alias comment",
35 | Computed: true,
36 | },
37 | },
38 | Read: dataSourceVirtualEnvironmentAliasRead,
39 | }
40 | }
41 |
42 | func dataSourceVirtualEnvironmentAliasRead(d *schema.ResourceData, m interface{}) error {
43 | config := m.(providerConfiguration)
44 | veClient, err := config.GetVEClient()
45 |
46 | if err != nil {
47 | return err
48 | }
49 |
50 | AliasID := d.Get(mkDataSourceVirtualEnvironmentClusterAliasName).(string)
51 | Alias, err := veClient.GetAlias(AliasID)
52 |
53 | if err != nil {
54 | return err
55 | }
56 |
57 | d.SetId(AliasID)
58 |
59 | d.Set(mkDataSourceVirtualEnvironmentClusterAliasCIDR, Alias.CIDR)
60 |
61 | if Alias.Comment != nil {
62 | d.Set(mkDataSourceVirtualEnvironmentClusterAliasComment, Alias.Comment)
63 | } else {
64 | d.Set(mkDataSourceVirtualEnvironmentClusterAliasComment, dvDataVirtualEnvironmentClusterAliasComment)
65 | }
66 |
67 | return nil
68 | }
69 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_cluster_alias_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentAliasInstantiation tests whether the DataSourceVirtualEnvironmentAlias instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentAliasInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentClusterAlias()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentAlias")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentAliasSchema tests the dataSourceVirtualEnvironmentAlias schema.
23 | func TestDataSourceVirtualEnvironmentAliasSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentClusterAlias()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentClusterAliasName,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentClusterAliasCIDR,
32 | mkDataSourceVirtualEnvironmentClusterAliasComment,
33 | })
34 |
35 | testValueTypes(t, s, map[string]schema.ValueType{
36 | mkDataSourceVirtualEnvironmentClusterAliasName: schema.TypeString,
37 | mkDataSourceVirtualEnvironmentClusterAliasCIDR: schema.TypeString,
38 | mkDataSourceVirtualEnvironmentClusterAliasComment: schema.TypeString,
39 | })
40 | }
41 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_cluster_aliases.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentClusterAliasesAliasIDs = "alias_ids"
13 | )
14 |
15 | func dataSourceVirtualEnvironmentClusterAliases() *schema.Resource {
16 | return &schema.Resource{
17 | Schema: map[string]*schema.Schema{
18 | mkDataSourceVirtualEnvironmentClusterAliasesAliasIDs: {
19 | Type: schema.TypeList,
20 | Description: "Alias IDs",
21 | Computed: true,
22 | Elem: &schema.Schema{Type: schema.TypeString},
23 | },
24 | },
25 | Read: dataSourceVirtualEnvironmentClusterAliasesRead,
26 | }
27 | }
28 |
29 | func dataSourceVirtualEnvironmentClusterAliasesRead(d *schema.ResourceData, m interface{}) error {
30 | config := m.(providerConfiguration)
31 | veClient, err := config.GetVEClient()
32 |
33 | if err != nil {
34 | return err
35 | }
36 |
37 | list, err := veClient.ListPools()
38 |
39 | if err != nil {
40 | return err
41 | }
42 |
43 | aliasIDs := make([]interface{}, len(list))
44 |
45 | for i, v := range list {
46 | aliasIDs[i] = v.ID
47 | }
48 |
49 | d.SetId("aliases")
50 |
51 | d.Set(mkDataSourceVirtualEnvironmentClusterAliasesAliasIDs, aliasIDs)
52 |
53 | return nil
54 | }
55 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_cluster_aliases_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentAliasesInstantiation tests whether the DataSourceVirtualEnvironmentAliases instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentAliasesInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentClusterAliases()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentAliases")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentAliasesSchema tests the dataSourceVirtualEnvironmentAliases schema.
23 | func TestDataSourceVirtualEnvironmentAliasesSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentClusterAliases()
25 |
26 | testComputedAttributes(t, s, []string{
27 | mkDataSourceVirtualEnvironmentClusterAliasesAliasIDs,
28 | })
29 |
30 | testValueTypes(t, s, map[string]schema.ValueType{
31 | mkDataSourceVirtualEnvironmentClusterAliasesAliasIDs: schema.TypeList,
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_datastores_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | "testing"
10 | )
11 |
12 | // TestDataSourceVirtualEnvironmentDatastoresInstantiation tests whether the DataSourceVirtualEnvironmentDatastores instance can be instantiated.
13 | func TestDataSourceVirtualEnvironmentDatastoresInstantiation(t *testing.T) {
14 | s := dataSourceVirtualEnvironmentDatastores()
15 |
16 | if s == nil {
17 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentDatastores")
18 | }
19 | }
20 |
21 | // TestDataSourceVirtualEnvironmentDatastoresSchema tests the dataSourceVirtualEnvironmentDatastores schema.
22 | func TestDataSourceVirtualEnvironmentDatastoresSchema(t *testing.T) {
23 | s := dataSourceVirtualEnvironmentDatastores()
24 |
25 | testRequiredArguments(t, s, []string{
26 | mkDataSourceVirtualEnvironmentDatastoresNodeName,
27 | })
28 |
29 | testComputedAttributes(t, s, []string{
30 | mkDataSourceVirtualEnvironmentDatastoresActive,
31 | mkDataSourceVirtualEnvironmentDatastoresContentTypes,
32 | mkDataSourceVirtualEnvironmentDatastoresDatastoreIDs,
33 | mkDataSourceVirtualEnvironmentDatastoresEnabled,
34 | mkDataSourceVirtualEnvironmentDatastoresShared,
35 | mkDataSourceVirtualEnvironmentDatastoresSpaceAvailable,
36 | mkDataSourceVirtualEnvironmentDatastoresSpaceTotal,
37 | mkDataSourceVirtualEnvironmentDatastoresSpaceUsed,
38 | mkDataSourceVirtualEnvironmentDatastoresTypes,
39 | })
40 |
41 | testValueTypes(t, s, map[string]schema.ValueType{
42 | mkDataSourceVirtualEnvironmentDatastoresActive: schema.TypeList,
43 | mkDataSourceVirtualEnvironmentDatastoresContentTypes: schema.TypeList,
44 | mkDataSourceVirtualEnvironmentDatastoresDatastoreIDs: schema.TypeList,
45 | mkDataSourceVirtualEnvironmentDatastoresEnabled: schema.TypeList,
46 | mkDataSourceVirtualEnvironmentDatastoresNodeName: schema.TypeString,
47 | mkDataSourceVirtualEnvironmentDatastoresShared: schema.TypeList,
48 | mkDataSourceVirtualEnvironmentDatastoresSpaceAvailable: schema.TypeList,
49 | mkDataSourceVirtualEnvironmentDatastoresSpaceTotal: schema.TypeList,
50 | mkDataSourceVirtualEnvironmentDatastoresSpaceUsed: schema.TypeList,
51 | mkDataSourceVirtualEnvironmentDatastoresTypes: schema.TypeList,
52 | })
53 | }
54 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_dns.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "fmt"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | const (
14 | mkDataSourceVirtualEnvironmentDNSDomain = "domain"
15 | mkDataSourceVirtualEnvironmentDNSNodeName = "node_name"
16 | mkDataSourceVirtualEnvironmentDNSServers = "servers"
17 | )
18 |
19 | func dataSourceVirtualEnvironmentDNS() *schema.Resource {
20 | return &schema.Resource{
21 | Schema: map[string]*schema.Schema{
22 | mkDataSourceVirtualEnvironmentDNSDomain: {
23 | Type: schema.TypeString,
24 | Description: "The DNS search domain",
25 | Computed: true,
26 | },
27 | mkDataSourceVirtualEnvironmentDNSNodeName: {
28 | Type: schema.TypeString,
29 | Description: "The node name",
30 | Required: true,
31 | },
32 | mkDataSourceVirtualEnvironmentDNSServers: {
33 | Type: schema.TypeList,
34 | Description: "The DNS servers",
35 | Computed: true,
36 | Elem: &schema.Schema{Type: schema.TypeString},
37 | },
38 | },
39 | Read: dataSourceVirtualEnvironmentDNSRead,
40 | }
41 | }
42 |
43 | func dataSourceVirtualEnvironmentDNSRead(d *schema.ResourceData, m interface{}) error {
44 | config := m.(providerConfiguration)
45 | veClient, err := config.GetVEClient()
46 |
47 | if err != nil {
48 | return err
49 | }
50 |
51 | nodeName := d.Get(mkDataSourceVirtualEnvironmentDNSNodeName).(string)
52 | dns, err := veClient.GetDNS(nodeName)
53 |
54 | if err != nil {
55 | return err
56 | }
57 |
58 | d.SetId(fmt.Sprintf("%s_dns", nodeName))
59 |
60 | if dns.SearchDomain != nil {
61 | d.Set(mkDataSourceVirtualEnvironmentDNSDomain, *dns.SearchDomain)
62 | } else {
63 | d.Set(mkDataSourceVirtualEnvironmentDNSDomain, "")
64 | }
65 |
66 | servers := []interface{}{}
67 |
68 | if dns.Server1 != nil {
69 | servers = append(servers, *dns.Server1)
70 | }
71 |
72 | if dns.Server2 != nil {
73 | servers = append(servers, *dns.Server2)
74 | }
75 |
76 | if dns.Server3 != nil {
77 | servers = append(servers, *dns.Server3)
78 | }
79 |
80 | d.Set(mkDataSourceVirtualEnvironmentDNSServers, servers)
81 |
82 | return nil
83 | }
84 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_dns_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | "testing"
10 | )
11 |
12 | // TestDataSourceVirtualEnvironmentDNSInstantiation tests whether the DataSourceVirtualEnvironmentDNS instance can be instantiated.
13 | func TestDataSourceVirtualEnvironmentDNSInstantiation(t *testing.T) {
14 | s := dataSourceVirtualEnvironmentDNS()
15 |
16 | if s == nil {
17 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentDNS")
18 | }
19 | }
20 |
21 | // TestDataSourceVirtualEnvironmentDNSSchema tests the dataSourceVirtualEnvironmentDNS schema.
22 | func TestDataSourceVirtualEnvironmentDNSSchema(t *testing.T) {
23 | s := dataSourceVirtualEnvironmentDNS()
24 |
25 | testRequiredArguments(t, s, []string{
26 | mkDataSourceVirtualEnvironmentDNSNodeName,
27 | })
28 |
29 | testComputedAttributes(t, s, []string{
30 | mkDataSourceVirtualEnvironmentDNSDomain,
31 | mkDataSourceVirtualEnvironmentDNSServers,
32 | })
33 |
34 | testValueTypes(t, s, map[string]schema.ValueType{
35 | mkDataSourceVirtualEnvironmentDNSDomain: schema.TypeString,
36 | mkDataSourceVirtualEnvironmentDNSNodeName: schema.TypeString,
37 | mkDataSourceVirtualEnvironmentDNSServers: schema.TypeList,
38 | })
39 | }
40 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_group.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentGroupACL = "acl"
13 | mkDataSourceVirtualEnvironmentGroupACLPath = "path"
14 | mkDataSourceVirtualEnvironmentGroupACLPropagate = "propagate"
15 | mkDataSourceVirtualEnvironmentGroupACLRoleID = "role_id"
16 | mkDataSourceVirtualEnvironmentGroupComment = "comment"
17 | mkDataSourceVirtualEnvironmentGroupID = "group_id"
18 | mkDataSourceVirtualEnvironmentGroupMembers = "members"
19 | )
20 |
21 | func dataSourceVirtualEnvironmentGroup() *schema.Resource {
22 | return &schema.Resource{
23 | Schema: map[string]*schema.Schema{
24 | mkDataSourceVirtualEnvironmentGroupACL: {
25 | Type: schema.TypeSet,
26 | Description: "The access control list",
27 | Computed: true,
28 | Elem: &schema.Resource{
29 | Schema: map[string]*schema.Schema{
30 | mkDataSourceVirtualEnvironmentGroupACLPath: {
31 | Type: schema.TypeString,
32 | Computed: true,
33 | Description: "The path",
34 | },
35 | mkDataSourceVirtualEnvironmentGroupACLPropagate: {
36 | Type: schema.TypeBool,
37 | Computed: true,
38 | Description: "Whether to propagate to child paths",
39 | },
40 | mkDataSourceVirtualEnvironmentGroupACLRoleID: {
41 | Type: schema.TypeString,
42 | Computed: true,
43 | Description: "The role id",
44 | },
45 | },
46 | },
47 | },
48 | mkDataSourceVirtualEnvironmentGroupComment: {
49 | Type: schema.TypeString,
50 | Description: "The group comment",
51 | Computed: true,
52 | },
53 | mkDataSourceVirtualEnvironmentGroupID: {
54 | Type: schema.TypeString,
55 | Description: "The group id",
56 | Required: true,
57 | },
58 | mkDataSourceVirtualEnvironmentGroupMembers: {
59 | Type: schema.TypeSet,
60 | Description: "The group members",
61 | Computed: true,
62 | Elem: &schema.Schema{Type: schema.TypeString},
63 | },
64 | },
65 | Read: dataSourceVirtualEnvironmentGroupRead,
66 | }
67 | }
68 |
69 | func dataSourceVirtualEnvironmentGroupRead(d *schema.ResourceData, m interface{}) error {
70 | config := m.(providerConfiguration)
71 | veClient, err := config.GetVEClient()
72 |
73 | if err != nil {
74 | return err
75 | }
76 |
77 | groupID := d.Get(mkDataSourceVirtualEnvironmentGroupID).(string)
78 | group, err := veClient.GetGroup(groupID)
79 |
80 | if err != nil {
81 | return err
82 | }
83 |
84 | acl, err := veClient.GetACL()
85 |
86 | if err != nil {
87 | return err
88 | }
89 |
90 | d.SetId(groupID)
91 |
92 | aclParsed := []interface{}{}
93 |
94 | for _, v := range acl {
95 | if v.Type == "group" && v.UserOrGroupID == groupID {
96 | aclEntry := map[string]interface{}{}
97 |
98 | aclEntry[mkDataSourceVirtualEnvironmentGroupACLPath] = v.Path
99 |
100 | if v.Propagate != nil {
101 | aclEntry[mkDataSourceVirtualEnvironmentGroupACLPropagate] = bool(*v.Propagate)
102 | } else {
103 | aclEntry[mkDataSourceVirtualEnvironmentGroupACLPropagate] = false
104 | }
105 |
106 | aclEntry[mkDataSourceVirtualEnvironmentGroupACLRoleID] = v.RoleID
107 |
108 | aclParsed = append(aclParsed, aclEntry)
109 | }
110 | }
111 |
112 | d.Set(mkDataSourceVirtualEnvironmentGroupACL, aclParsed)
113 |
114 | if group.Comment != nil {
115 | d.Set(mkDataSourceVirtualEnvironmentGroupComment, group.Comment)
116 | } else {
117 | d.Set(mkDataSourceVirtualEnvironmentGroupComment, "")
118 | }
119 |
120 | d.Set(mkDataSourceVirtualEnvironmentGroupMembers, group.Members)
121 |
122 | return nil
123 | }
124 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_group_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentGroupInstantiation tests whether the DataSourceVirtualEnvironmentGroup instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentGroupInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentGroup()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentGroup")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentGroupSchema tests the dataSourceVirtualEnvironmentGroup schema.
23 | func TestDataSourceVirtualEnvironmentGroupSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentGroup()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentGroupID,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentGroupACL,
32 | mkDataSourceVirtualEnvironmentGroupComment,
33 | mkDataSourceVirtualEnvironmentGroupMembers,
34 | })
35 |
36 | testValueTypes(t, s, map[string]schema.ValueType{
37 | mkDataSourceVirtualEnvironmentGroupACL: schema.TypeSet,
38 | mkDataSourceVirtualEnvironmentGroupID: schema.TypeString,
39 | mkDataSourceVirtualEnvironmentGroupComment: schema.TypeString,
40 | mkDataSourceVirtualEnvironmentGroupMembers: schema.TypeSet,
41 | })
42 |
43 | aclSchema := testNestedSchemaExistence(t, s, mkDataSourceVirtualEnvironmentGroupACL)
44 |
45 | testComputedAttributes(t, aclSchema, []string{
46 | mkDataSourceVirtualEnvironmentGroupACLPath,
47 | mkDataSourceVirtualEnvironmentGroupACLPropagate,
48 | mkDataSourceVirtualEnvironmentGroupACLRoleID,
49 | })
50 |
51 | testValueTypes(t, aclSchema, map[string]schema.ValueType{
52 | mkDataSourceVirtualEnvironmentGroupACLPath: schema.TypeString,
53 | mkDataSourceVirtualEnvironmentGroupACLPropagate: schema.TypeBool,
54 | mkDataSourceVirtualEnvironmentGroupACLRoleID: schema.TypeString,
55 | })
56 | }
57 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_groups.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentGroupsComments = "comments"
13 | mkDataSourceVirtualEnvironmentGroupsGroupIDs = "group_ids"
14 | )
15 |
16 | func dataSourceVirtualEnvironmentGroups() *schema.Resource {
17 | return &schema.Resource{
18 | Schema: map[string]*schema.Schema{
19 | mkDataSourceVirtualEnvironmentGroupsComments: {
20 | Type: schema.TypeList,
21 | Description: "The group comments",
22 | Computed: true,
23 | Elem: &schema.Schema{Type: schema.TypeString},
24 | },
25 | mkDataSourceVirtualEnvironmentGroupsGroupIDs: {
26 | Type: schema.TypeList,
27 | Description: "The group ids",
28 | Computed: true,
29 | Elem: &schema.Schema{Type: schema.TypeString},
30 | },
31 | },
32 | Read: dataSourceVirtualEnvironmentGroupsRead,
33 | }
34 | }
35 |
36 | func dataSourceVirtualEnvironmentGroupsRead(d *schema.ResourceData, m interface{}) error {
37 | config := m.(providerConfiguration)
38 | veClient, err := config.GetVEClient()
39 |
40 | if err != nil {
41 | return err
42 | }
43 |
44 | list, err := veClient.ListGroups()
45 |
46 | if err != nil {
47 | return err
48 | }
49 |
50 | comments := make([]interface{}, len(list))
51 | groupIDs := make([]interface{}, len(list))
52 |
53 | for i, v := range list {
54 | if v.Comment != nil {
55 | comments[i] = v.Comment
56 | } else {
57 | comments[i] = ""
58 | }
59 |
60 | groupIDs[i] = v.ID
61 | }
62 |
63 | d.SetId("groups")
64 |
65 | d.Set(mkDataSourceVirtualEnvironmentGroupsComments, comments)
66 | d.Set(mkDataSourceVirtualEnvironmentGroupsGroupIDs, groupIDs)
67 |
68 | return nil
69 | }
70 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_groups_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | "testing"
10 | )
11 |
12 | // TestDataSourceVirtualEnvironmentGroupsInstantiation tests whether the DataSourceVirtualEnvironmentGroups instance can be instantiated.
13 | func TestDataSourceVirtualEnvironmentGroupsInstantiation(t *testing.T) {
14 | s := dataSourceVirtualEnvironmentGroups()
15 |
16 | if s == nil {
17 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentGroups")
18 | }
19 | }
20 |
21 | // TestDataSourceVirtualEnvironmentGroupsSchema tests the dataSourceVirtualEnvironmentGroups schema.
22 | func TestDataSourceVirtualEnvironmentGroupsSchema(t *testing.T) {
23 | s := dataSourceVirtualEnvironmentGroups()
24 |
25 | testComputedAttributes(t, s, []string{
26 | mkDataSourceVirtualEnvironmentGroupsComments,
27 | mkDataSourceVirtualEnvironmentGroupsGroupIDs,
28 | })
29 |
30 | testValueTypes(t, s, map[string]schema.ValueType{
31 | mkDataSourceVirtualEnvironmentGroupsComments: schema.TypeList,
32 | mkDataSourceVirtualEnvironmentGroupsGroupIDs: schema.TypeList,
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_hosts_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | "testing"
10 | )
11 |
12 | // TestDataSourceVirtualEnvironmentHostsInstantiation tests whether the DataSourceVirtualEnvironmentHosts instance can be instantiated.
13 | func TestDataSourceVirtualEnvironmentHostsInstantiation(t *testing.T) {
14 | s := dataSourceVirtualEnvironmentHosts()
15 |
16 | if s == nil {
17 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentHosts")
18 | }
19 | }
20 |
21 | // TestDataSourceVirtualEnvironmentHostsSchema tests the dataSourceVirtualEnvironmentHosts schema.
22 | func TestDataSourceVirtualEnvironmentHostsSchema(t *testing.T) {
23 | s := dataSourceVirtualEnvironmentHosts()
24 |
25 | testRequiredArguments(t, s, []string{
26 | mkDataSourceVirtualEnvironmentHostsNodeName,
27 | })
28 |
29 | testComputedAttributes(t, s, []string{
30 | mkDataSourceVirtualEnvironmentHostsAddresses,
31 | mkDataSourceVirtualEnvironmentHostsDigest,
32 | mkDataSourceVirtualEnvironmentHostsEntries,
33 | mkDataSourceVirtualEnvironmentHostsHostnames,
34 | })
35 |
36 | testValueTypes(t, s, map[string]schema.ValueType{
37 | mkDataSourceVirtualEnvironmentHostsAddresses: schema.TypeList,
38 | mkDataSourceVirtualEnvironmentHostsDigest: schema.TypeString,
39 | mkDataSourceVirtualEnvironmentHostsEntries: schema.TypeList,
40 | mkDataSourceVirtualEnvironmentHostsHostnames: schema.TypeList,
41 | mkDataSourceVirtualEnvironmentHostsNodeName: schema.TypeString,
42 | })
43 |
44 | entriesSchema := testNestedSchemaExistence(t, s, mkDataSourceVirtualEnvironmentHostsEntries)
45 |
46 | testComputedAttributes(t, entriesSchema, []string{
47 | mkDataSourceVirtualEnvironmentHostsEntriesAddress,
48 | mkDataSourceVirtualEnvironmentHostsEntriesHostnames,
49 | })
50 |
51 | testValueTypes(t, entriesSchema, map[string]schema.ValueType{
52 | mkDataSourceVirtualEnvironmentHostsEntriesAddress: schema.TypeString,
53 | mkDataSourceVirtualEnvironmentHostsEntriesHostnames: schema.TypeList,
54 | })
55 | }
56 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_nodes_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentNodesInstantiation tests whether the DataSourceVirtualEnvironmentNodes instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentNodesInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentNodes()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentNodes")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentNodesSchema tests the dataSourceVirtualEnvironmentNodes schema.
23 | func TestDataSourceVirtualEnvironmentNodesSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentNodes()
25 |
26 | testComputedAttributes(t, s, []string{
27 | mkDataSourceVirtualEnvironmentNodesCPUCount,
28 | mkDataSourceVirtualEnvironmentNodesCPUUtilization,
29 | mkDataSourceVirtualEnvironmentNodesMemoryAvailable,
30 | mkDataSourceVirtualEnvironmentNodesMemoryUsed,
31 | mkDataSourceVirtualEnvironmentNodesNames,
32 | mkDataSourceVirtualEnvironmentNodesOnline,
33 | mkDataSourceVirtualEnvironmentNodesSSLFingerprints,
34 | mkDataSourceVirtualEnvironmentNodesSupportLevels,
35 | mkDataSourceVirtualEnvironmentNodesUptime,
36 | })
37 |
38 | testValueTypes(t, s, map[string]schema.ValueType{
39 | mkDataSourceVirtualEnvironmentNodesCPUCount: schema.TypeList,
40 | mkDataSourceVirtualEnvironmentNodesCPUUtilization: schema.TypeList,
41 | mkDataSourceVirtualEnvironmentNodesMemoryAvailable: schema.TypeList,
42 | mkDataSourceVirtualEnvironmentNodesMemoryUsed: schema.TypeList,
43 | mkDataSourceVirtualEnvironmentNodesNames: schema.TypeList,
44 | mkDataSourceVirtualEnvironmentNodesOnline: schema.TypeList,
45 | mkDataSourceVirtualEnvironmentNodesSSLFingerprints: schema.TypeList,
46 | mkDataSourceVirtualEnvironmentNodesSupportLevels: schema.TypeList,
47 | mkDataSourceVirtualEnvironmentNodesUptime: schema.TypeList,
48 | })
49 | }
50 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_pool_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentPoolInstantiation tests whether the DataSourceVirtualEnvironmentPool instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentPoolInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentPool()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentPool")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentPoolSchema tests the dataSourceVirtualEnvironmentPool schema.
23 | func TestDataSourceVirtualEnvironmentPoolSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentPool()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentPoolPoolID,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentPoolComment,
32 | mkDataSourceVirtualEnvironmentPoolMembers,
33 | })
34 |
35 | testValueTypes(t, s, map[string]schema.ValueType{
36 | mkDataSourceVirtualEnvironmentPoolComment: schema.TypeString,
37 | mkDataSourceVirtualEnvironmentPoolMembers: schema.TypeList,
38 | mkDataSourceVirtualEnvironmentPoolPoolID: schema.TypeString,
39 | })
40 |
41 | membersSchema := testNestedSchemaExistence(t, s, mkDataSourceVirtualEnvironmentPoolMembers)
42 |
43 | testComputedAttributes(t, membersSchema, []string{
44 | mkDataSourceVirtualEnvironmentPoolMembersDatastoreID,
45 | mkDataSourceVirtualEnvironmentPoolMembersID,
46 | mkDataSourceVirtualEnvironmentPoolMembersNodeName,
47 | mkDataSourceVirtualEnvironmentPoolMembersType,
48 | mkDataSourceVirtualEnvironmentPoolMembersVMID,
49 | })
50 |
51 | testValueTypes(t, membersSchema, map[string]schema.ValueType{
52 | mkDataSourceVirtualEnvironmentPoolMembersDatastoreID: schema.TypeString,
53 | mkDataSourceVirtualEnvironmentPoolMembersID: schema.TypeString,
54 | mkDataSourceVirtualEnvironmentPoolMembersNodeName: schema.TypeString,
55 | mkDataSourceVirtualEnvironmentPoolMembersType: schema.TypeString,
56 | mkDataSourceVirtualEnvironmentPoolMembersVMID: schema.TypeInt,
57 | })
58 | }
59 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_pools.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentPoolsPoolIDs = "pool_ids"
13 | )
14 |
15 | func dataSourceVirtualEnvironmentPools() *schema.Resource {
16 | return &schema.Resource{
17 | Schema: map[string]*schema.Schema{
18 | mkDataSourceVirtualEnvironmentPoolsPoolIDs: {
19 | Type: schema.TypeList,
20 | Description: "The pool ids",
21 | Computed: true,
22 | Elem: &schema.Schema{Type: schema.TypeString},
23 | },
24 | },
25 | Read: dataSourceVirtualEnvironmentPoolsRead,
26 | }
27 | }
28 |
29 | func dataSourceVirtualEnvironmentPoolsRead(d *schema.ResourceData, m interface{}) error {
30 | config := m.(providerConfiguration)
31 | veClient, err := config.GetVEClient()
32 |
33 | if err != nil {
34 | return err
35 | }
36 |
37 | list, err := veClient.ListPools()
38 |
39 | if err != nil {
40 | return err
41 | }
42 |
43 | poolIDs := make([]interface{}, len(list))
44 |
45 | for i, v := range list {
46 | poolIDs[i] = v.ID
47 | }
48 |
49 | d.SetId("pools")
50 |
51 | d.Set(mkDataSourceVirtualEnvironmentPoolsPoolIDs, poolIDs)
52 |
53 | return nil
54 | }
55 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_pools_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentPoolsInstantiation tests whether the DataSourceVirtualEnvironmentPools instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentPoolsInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentPools()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentPools")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentPoolsSchema tests the dataSourceVirtualEnvironmentPools schema.
23 | func TestDataSourceVirtualEnvironmentPoolsSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentPools()
25 |
26 | testComputedAttributes(t, s, []string{
27 | mkDataSourceVirtualEnvironmentPoolsPoolIDs,
28 | })
29 |
30 | testValueTypes(t, s, map[string]schema.ValueType{
31 | mkDataSourceVirtualEnvironmentPoolsPoolIDs: schema.TypeList,
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_role.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentRoleID = "role_id"
13 | mkDataSourceVirtualEnvironmentRolePrivileges = "privileges"
14 | )
15 |
16 | func dataSourceVirtualEnvironmentRole() *schema.Resource {
17 | return &schema.Resource{
18 | Schema: map[string]*schema.Schema{
19 | mkDataSourceVirtualEnvironmentRoleID: {
20 | Type: schema.TypeString,
21 | Description: "The role id",
22 | Required: true,
23 | },
24 | mkDataSourceVirtualEnvironmentRolePrivileges: {
25 | Type: schema.TypeSet,
26 | Description: "The role privileges",
27 | Computed: true,
28 | Elem: &schema.Schema{Type: schema.TypeString},
29 | },
30 | },
31 | Read: dataSourceVirtualEnvironmentRoleRead,
32 | }
33 | }
34 |
35 | func dataSourceVirtualEnvironmentRoleRead(d *schema.ResourceData, m interface{}) error {
36 | config := m.(providerConfiguration)
37 | veClient, err := config.GetVEClient()
38 |
39 | if err != nil {
40 | return err
41 | }
42 |
43 | roleID := d.Get(mkDataSourceVirtualEnvironmentRoleID).(string)
44 | accessRole, err := veClient.GetRole(roleID)
45 |
46 | if err != nil {
47 | return err
48 | }
49 |
50 | privileges := schema.NewSet(schema.HashString, []interface{}{})
51 |
52 | if *accessRole != nil {
53 | for _, v := range *accessRole {
54 | privileges.Add(v)
55 | }
56 | }
57 |
58 | d.SetId(roleID)
59 |
60 | d.Set(mkDataSourceVirtualEnvironmentRolePrivileges, privileges)
61 |
62 | return nil
63 | }
64 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_role_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentRoleInstantiation tests whether the DataSourceVirtualEnvironmentRole instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentRoleInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentRole()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentRole")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentRoleSchema tests the dataSourceVirtualEnvironmentRole schema.
23 | func TestDataSourceVirtualEnvironmentRoleSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentRole()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentRoleID,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentRolePrivileges,
32 | })
33 |
34 | testValueTypes(t, s, map[string]schema.ValueType{
35 | mkDataSourceVirtualEnvironmentRoleID: schema.TypeString,
36 | mkDataSourceVirtualEnvironmentRolePrivileges: schema.TypeSet,
37 | })
38 | }
39 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_roles.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentRolesPrivileges = "privileges"
13 | mkDataSourceVirtualEnvironmentRolesRoleIDs = "role_ids"
14 | mkDataSourceVirtualEnvironmentRolesSpecial = "special"
15 | )
16 |
17 | func dataSourceVirtualEnvironmentRoles() *schema.Resource {
18 | return &schema.Resource{
19 | Schema: map[string]*schema.Schema{
20 | mkDataSourceVirtualEnvironmentRolesPrivileges: {
21 | Type: schema.TypeList,
22 | Description: "The role privileges",
23 | Computed: true,
24 | Elem: &schema.Schema{
25 | Type: schema.TypeSet,
26 | Elem: &schema.Schema{Type: schema.TypeString},
27 | },
28 | },
29 | mkDataSourceVirtualEnvironmentRolesRoleIDs: {
30 | Type: schema.TypeList,
31 | Description: "The role ids",
32 | Computed: true,
33 | Elem: &schema.Schema{Type: schema.TypeString},
34 | },
35 | mkDataSourceVirtualEnvironmentRolesSpecial: {
36 | Type: schema.TypeList,
37 | Description: "Whether the role is special (built-in)",
38 | Computed: true,
39 | Elem: &schema.Schema{Type: schema.TypeBool},
40 | },
41 | },
42 | Read: dataSourceVirtualEnvironmentRolesRead,
43 | }
44 | }
45 |
46 | func dataSourceVirtualEnvironmentRolesRead(d *schema.ResourceData, m interface{}) error {
47 | config := m.(providerConfiguration)
48 | veClient, err := config.GetVEClient()
49 |
50 | if err != nil {
51 | return err
52 | }
53 |
54 | list, err := veClient.ListRoles()
55 |
56 | if err != nil {
57 | return err
58 | }
59 |
60 | privileges := make([]interface{}, len(list))
61 | roleIDs := make([]interface{}, len(list))
62 | special := make([]interface{}, len(list))
63 |
64 | for i, v := range list {
65 | if v.Privileges != nil {
66 | p := schema.NewSet(schema.HashString, []interface{}{})
67 |
68 | for _, v := range *v.Privileges {
69 | p.Add(v)
70 | }
71 |
72 | privileges[i] = p
73 | } else {
74 | privileges[i] = map[string]interface{}{}
75 | }
76 |
77 | roleIDs[i] = v.ID
78 |
79 | if v.Special != nil {
80 | special[i] = v.Special
81 | } else {
82 | special[i] = false
83 | }
84 | }
85 |
86 | d.SetId("roles")
87 |
88 | d.Set(mkDataSourceVirtualEnvironmentRolesPrivileges, privileges)
89 | d.Set(mkDataSourceVirtualEnvironmentRolesRoleIDs, roleIDs)
90 | d.Set(mkDataSourceVirtualEnvironmentRolesSpecial, special)
91 |
92 | return nil
93 | }
94 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_roles_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | "testing"
10 | )
11 |
12 | // TestDataSourceVirtualEnvironmentRolesInstantiation tests whether the DataSourceVirtualEnvironmentRoles instance can be instantiated.
13 | func TestDataSourceVirtualEnvironmentRolesInstantiation(t *testing.T) {
14 | s := dataSourceVirtualEnvironmentRoles()
15 |
16 | if s == nil {
17 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentRoles")
18 | }
19 | }
20 |
21 | // TestDataSourceVirtualEnvironmentRolesSchema tests the dataSourceVirtualEnvironmentRoles schema.
22 | func TestDataSourceVirtualEnvironmentRolesSchema(t *testing.T) {
23 | s := dataSourceVirtualEnvironmentRoles()
24 |
25 | testComputedAttributes(t, s, []string{
26 | mkDataSourceVirtualEnvironmentRolesPrivileges,
27 | mkDataSourceVirtualEnvironmentRolesRoleIDs,
28 | mkDataSourceVirtualEnvironmentRolesSpecial,
29 | })
30 |
31 | testValueTypes(t, s, map[string]schema.ValueType{
32 | mkDataSourceVirtualEnvironmentRolesPrivileges: schema.TypeList,
33 | mkDataSourceVirtualEnvironmentRolesRoleIDs: schema.TypeList,
34 | mkDataSourceVirtualEnvironmentRolesSpecial: schema.TypeList,
35 | })
36 | }
37 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_time.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "fmt"
9 | "time"
10 |
11 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
12 | )
13 |
14 | const (
15 | mkDataSourceVirtualEnvironmentTimeLocalTime = "local_time"
16 | mkDataSourceVirtualEnvironmentTimeNodeName = "node_name"
17 | mkDataSourceVirtualEnvironmentTimeTimeZone = "time_zone"
18 | mkDataSourceVirtualEnvironmentTimeUTCTime = "utc_time"
19 | )
20 |
21 | func dataSourceVirtualEnvironmentTime() *schema.Resource {
22 | return &schema.Resource{
23 | Schema: map[string]*schema.Schema{
24 | mkDataSourceVirtualEnvironmentTimeLocalTime: {
25 | Type: schema.TypeString,
26 | Description: "The local timestamp",
27 | Computed: true,
28 | },
29 | mkDataSourceVirtualEnvironmentTimeNodeName: {
30 | Type: schema.TypeString,
31 | Description: "The node name",
32 | Required: true,
33 | },
34 | mkDataSourceVirtualEnvironmentTimeTimeZone: {
35 | Type: schema.TypeString,
36 | Description: "The time zone",
37 | Computed: true,
38 | },
39 | mkDataSourceVirtualEnvironmentTimeUTCTime: {
40 | Type: schema.TypeString,
41 | Description: "The UTC timestamp",
42 | Computed: true,
43 | },
44 | },
45 | Read: dataSourceVirtualEnvironmentTimeRead,
46 | }
47 | }
48 |
49 | func dataSourceVirtualEnvironmentTimeRead(d *schema.ResourceData, m interface{}) error {
50 | config := m.(providerConfiguration)
51 | veClient, err := config.GetVEClient()
52 |
53 | if err != nil {
54 | return err
55 | }
56 |
57 | nodeName := d.Get(mkDataSourceVirtualEnvironmentTimeNodeName).(string)
58 | nodeTime, err := veClient.GetNodeTime(nodeName)
59 |
60 | if err != nil {
61 | return err
62 | }
63 |
64 | localLocation, err := time.LoadLocation(nodeTime.TimeZone)
65 |
66 | if err != nil {
67 | return err
68 | }
69 |
70 | d.SetId(fmt.Sprintf("%s_time", nodeName))
71 |
72 | localTimeOffset := time.Time(nodeTime.LocalTime).Sub(time.Now().UTC())
73 | localTime := time.Time(nodeTime.LocalTime).Add(-localTimeOffset).In(localLocation)
74 |
75 | d.Set(mkDataSourceVirtualEnvironmentTimeLocalTime, localTime.Format(time.RFC3339))
76 | d.Set(mkDataSourceVirtualEnvironmentTimeTimeZone, nodeTime.TimeZone)
77 | d.Set(mkDataSourceVirtualEnvironmentTimeUTCTime, time.Time(nodeTime.UTCTime).Format(time.RFC3339))
78 |
79 | return nil
80 | }
81 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_time_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentTimeInstantiation tests whether the DataSourceVirtualEnvironmentRoles instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentTimeInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentTime()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentTime")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentTimeSchema tests the dataSourceVirtualEnvironmentTime schema.
23 | func TestDataSourceVirtualEnvironmentTimeSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentTime()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentTimeNodeName,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentTimeLocalTime,
32 | mkDataSourceVirtualEnvironmentTimeTimeZone,
33 | mkDataSourceVirtualEnvironmentTimeUTCTime,
34 | })
35 |
36 | testValueTypes(t, s, map[string]schema.ValueType{
37 | mkDataSourceVirtualEnvironmentTimeLocalTime: schema.TypeString,
38 | mkDataSourceVirtualEnvironmentTimeNodeName: schema.TypeString,
39 | mkDataSourceVirtualEnvironmentTimeTimeZone: schema.TypeString,
40 | mkDataSourceVirtualEnvironmentTimeUTCTime: schema.TypeString,
41 | })
42 | }
43 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_user_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentUserInstantiation tests whether the DataSourceVirtualEnvironmentUser instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentUserInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentUser()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentUser")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentUserSchema tests the dataSourceVirtualEnvironmentUser schema.
23 | func TestDataSourceVirtualEnvironmentUserSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentUser()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkDataSourceVirtualEnvironmentUserUserID,
28 | })
29 |
30 | testComputedAttributes(t, s, []string{
31 | mkDataSourceVirtualEnvironmentUserACL,
32 | mkDataSourceVirtualEnvironmentUserComment,
33 | mkDataSourceVirtualEnvironmentUserEmail,
34 | mkDataSourceVirtualEnvironmentUserEnabled,
35 | mkDataSourceVirtualEnvironmentUserExpirationDate,
36 | mkDataSourceVirtualEnvironmentUserFirstName,
37 | mkDataSourceVirtualEnvironmentUserGroups,
38 | mkDataSourceVirtualEnvironmentUserKeys,
39 | mkDataSourceVirtualEnvironmentUserLastName,
40 | })
41 |
42 | testValueTypes(t, s, map[string]schema.ValueType{
43 | mkDataSourceVirtualEnvironmentUserACL: schema.TypeSet,
44 | mkDataSourceVirtualEnvironmentUserComment: schema.TypeString,
45 | mkDataSourceVirtualEnvironmentUserEmail: schema.TypeString,
46 | mkDataSourceVirtualEnvironmentUserEnabled: schema.TypeBool,
47 | mkDataSourceVirtualEnvironmentUserExpirationDate: schema.TypeString,
48 | mkDataSourceVirtualEnvironmentUserFirstName: schema.TypeString,
49 | mkDataSourceVirtualEnvironmentUserGroups: schema.TypeList,
50 | mkDataSourceVirtualEnvironmentUserKeys: schema.TypeString,
51 | mkDataSourceVirtualEnvironmentUserLastName: schema.TypeString,
52 | })
53 |
54 | aclSchema := testNestedSchemaExistence(t, s, mkDataSourceVirtualEnvironmentGroupACL)
55 |
56 | testComputedAttributes(t, aclSchema, []string{
57 | mkDataSourceVirtualEnvironmentUserACLPath,
58 | mkDataSourceVirtualEnvironmentUserACLPropagate,
59 | mkDataSourceVirtualEnvironmentUserACLRoleID,
60 | })
61 |
62 | testValueTypes(t, aclSchema, map[string]schema.ValueType{
63 | mkDataSourceVirtualEnvironmentUserACLPath: schema.TypeString,
64 | mkDataSourceVirtualEnvironmentUserACLPropagate: schema.TypeBool,
65 | mkDataSourceVirtualEnvironmentUserACLRoleID: schema.TypeString,
66 | })
67 | }
68 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_users_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentUsersInstantiation tests whether the DataSourceVirtualEnvironmentUsers instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentUsersInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentUsers()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentUsers")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentUsersSchema tests the dataSourceVirtualEnvironmentUsers schema.
23 | func TestDataSourceVirtualEnvironmentUsersSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentUsers()
25 |
26 | testComputedAttributes(t, s, []string{
27 | mkDataSourceVirtualEnvironmentUsersComments,
28 | mkDataSourceVirtualEnvironmentUsersEmails,
29 | mkDataSourceVirtualEnvironmentUsersEnabled,
30 | mkDataSourceVirtualEnvironmentUsersExpirationDates,
31 | mkDataSourceVirtualEnvironmentUsersFirstNames,
32 | mkDataSourceVirtualEnvironmentUsersGroups,
33 | mkDataSourceVirtualEnvironmentUsersKeys,
34 | mkDataSourceVirtualEnvironmentUsersLastNames,
35 | mkDataSourceVirtualEnvironmentUsersUserIDs,
36 | })
37 |
38 | testValueTypes(t, s, map[string]schema.ValueType{
39 | mkDataSourceVirtualEnvironmentUsersComments: schema.TypeList,
40 | mkDataSourceVirtualEnvironmentUsersEmails: schema.TypeList,
41 | mkDataSourceVirtualEnvironmentUsersEnabled: schema.TypeList,
42 | mkDataSourceVirtualEnvironmentUsersExpirationDates: schema.TypeList,
43 | mkDataSourceVirtualEnvironmentUsersFirstNames: schema.TypeList,
44 | mkDataSourceVirtualEnvironmentUsersGroups: schema.TypeList,
45 | mkDataSourceVirtualEnvironmentUsersKeys: schema.TypeList,
46 | mkDataSourceVirtualEnvironmentUsersLastNames: schema.TypeList,
47 | mkDataSourceVirtualEnvironmentUsersUserIDs: schema.TypeList,
48 | })
49 | }
50 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_version.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9 | )
10 |
11 | const (
12 | mkDataSourceVirtualEnvironmentVersionKeyboardLayout = "keyboard_layout"
13 | mkDataSourceVirtualEnvironmentVersionRelease = "release"
14 | mkDataSourceVirtualEnvironmentVersionRepositoryID = "repository_id"
15 | mkDataSourceVirtualEnvironmentVersionVersion = "version"
16 | )
17 |
18 | func dataSourceVirtualEnvironmentVersion() *schema.Resource {
19 | return &schema.Resource{
20 | Schema: map[string]*schema.Schema{
21 | mkDataSourceVirtualEnvironmentVersionKeyboardLayout: {
22 | Type: schema.TypeString,
23 | Description: "The keyboard layout",
24 | Computed: true,
25 | ForceNew: true,
26 | },
27 | mkDataSourceVirtualEnvironmentVersionRelease: {
28 | Type: schema.TypeString,
29 | Description: "The release information",
30 | Computed: true,
31 | ForceNew: true,
32 | },
33 | mkDataSourceVirtualEnvironmentVersionRepositoryID: {
34 | Type: schema.TypeString,
35 | Description: "The repository id",
36 | Computed: true,
37 | ForceNew: true,
38 | },
39 | mkDataSourceVirtualEnvironmentVersionVersion: {
40 | Type: schema.TypeString,
41 | Description: "The version information",
42 | Computed: true,
43 | ForceNew: true,
44 | },
45 | },
46 | Read: dataSourceVirtualEnvironmentVersionRead,
47 | }
48 | }
49 |
50 | func dataSourceVirtualEnvironmentVersionRead(d *schema.ResourceData, m interface{}) error {
51 | config := m.(providerConfiguration)
52 | veClient, err := config.GetVEClient()
53 |
54 | if err != nil {
55 | return err
56 | }
57 |
58 | version, err := veClient.Version()
59 |
60 | if err != nil {
61 | return err
62 | }
63 |
64 | d.SetId("version")
65 |
66 | d.Set(mkDataSourceVirtualEnvironmentVersionKeyboardLayout, version.Keyboard)
67 | d.Set(mkDataSourceVirtualEnvironmentVersionRelease, version.Release)
68 | d.Set(mkDataSourceVirtualEnvironmentVersionRepositoryID, version.RepositoryID)
69 | d.Set(mkDataSourceVirtualEnvironmentVersionVersion, version.Version)
70 |
71 | return nil
72 | }
73 |
--------------------------------------------------------------------------------
/proxmoxtf/data_source_virtual_environment_version_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestDataSourceVirtualEnvironmentVersionInstantiation tests whether the DataSourceVirtualEnvironmentVersion instance can be instantiated.
14 | func TestDataSourceVirtualEnvironmentVersionInstantiation(t *testing.T) {
15 | s := dataSourceVirtualEnvironmentVersion()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate dataSourceVirtualEnvironmentVersion")
19 | }
20 | }
21 |
22 | // TestDataSourceVirtualEnvironmentVersionSchema tests the dataSourceVirtualEnvironmentVersion schema.
23 | func TestDataSourceVirtualEnvironmentVersionSchema(t *testing.T) {
24 | s := dataSourceVirtualEnvironmentVersion()
25 |
26 | testComputedAttributes(t, s, []string{
27 | mkDataSourceVirtualEnvironmentVersionKeyboardLayout,
28 | mkDataSourceVirtualEnvironmentVersionRelease,
29 | mkDataSourceVirtualEnvironmentVersionRepositoryID,
30 | mkDataSourceVirtualEnvironmentVersionVersion,
31 | })
32 |
33 | testValueTypes(t, s, map[string]schema.ValueType{
34 | mkDataSourceVirtualEnvironmentVersionKeyboardLayout: schema.TypeString,
35 | mkDataSourceVirtualEnvironmentVersionRelease: schema.TypeString,
36 | mkDataSourceVirtualEnvironmentVersionRepositoryID: schema.TypeString,
37 | mkDataSourceVirtualEnvironmentVersionVersion: schema.TypeString,
38 | })
39 | }
40 |
--------------------------------------------------------------------------------
/proxmoxtf/provider_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestProviderInstantiation() tests whether the Provider instance can be instantiated.
14 | func TestProviderInstantiation(t *testing.T) {
15 | s := Provider()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate Provider")
19 | }
20 | }
21 |
22 | // TestProviderSchema() tests the Provider schema.
23 | func TestProviderSchema(t *testing.T) {
24 | s := &schema.Resource{
25 | Schema: Provider().Schema,
26 | }
27 |
28 | testOptionalArguments(t, s, []string{
29 | mkProviderVirtualEnvironment,
30 | })
31 |
32 | testValueTypes(t, s, map[string]schema.ValueType{
33 | mkProviderVirtualEnvironment: schema.TypeList,
34 | })
35 |
36 | veSchema := testNestedSchemaExistence(t, s, mkProviderVirtualEnvironment)
37 |
38 | testOptionalArguments(t, veSchema, []string{
39 | mkProviderVirtualEnvironmentEndpoint,
40 | mkProviderVirtualEnvironmentInsecure,
41 | mkProviderVirtualEnvironmentOTP,
42 | mkProviderVirtualEnvironmentPassword,
43 | mkProviderVirtualEnvironmentUsername,
44 | })
45 |
46 | testValueTypes(t, veSchema, map[string]schema.ValueType{
47 | mkProviderVirtualEnvironmentEndpoint: schema.TypeString,
48 | mkProviderVirtualEnvironmentInsecure: schema.TypeBool,
49 | mkProviderVirtualEnvironmentOTP: schema.TypeString,
50 | mkProviderVirtualEnvironmentPassword: schema.TypeString,
51 | mkProviderVirtualEnvironmentUsername: schema.TypeString,
52 | })
53 | }
54 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_certificate_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentCertificateInstantiation tests whether the ResourceVirtualEnvironmentCertificate instance can be instantiated.
14 | func TestResourceVirtualEnvironmentCertificateInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentCertificate()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentCertificate")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentCertificateSchema tests the resourceVirtualEnvironmentCertificate schema.
23 | func TestResourceVirtualEnvironmentCertificateSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentCertificate()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentCertificateCertificate,
28 | mkResourceVirtualEnvironmentCertificateNodeName,
29 | mkResourceVirtualEnvironmentCertificatePrivateKey,
30 | })
31 |
32 | testOptionalArguments(t, s, []string{
33 | mkResourceVirtualEnvironmentCertificateCertificateChain,
34 | })
35 |
36 | testComputedAttributes(t, s, []string{
37 | mkResourceVirtualEnvironmentCertificateExpirationDate,
38 | mkResourceVirtualEnvironmentCertificateFileName,
39 | mkResourceVirtualEnvironmentCertificateIssuer,
40 | mkResourceVirtualEnvironmentCertificatePublicKeySize,
41 | mkResourceVirtualEnvironmentCertificatePublicKeyType,
42 | mkResourceVirtualEnvironmentCertificateSSLFingerprint,
43 | mkResourceVirtualEnvironmentCertificateStartDate,
44 | mkResourceVirtualEnvironmentCertificateSubject,
45 | mkResourceVirtualEnvironmentCertificateSubjectAlternativeNames,
46 | })
47 |
48 | testValueTypes(t, s, map[string]schema.ValueType{
49 | mkResourceVirtualEnvironmentCertificateCertificate: schema.TypeString,
50 | mkResourceVirtualEnvironmentCertificateCertificateChain: schema.TypeString,
51 | mkResourceVirtualEnvironmentCertificateExpirationDate: schema.TypeString,
52 | mkResourceVirtualEnvironmentCertificateFileName: schema.TypeString,
53 | mkResourceVirtualEnvironmentCertificateIssuer: schema.TypeString,
54 | mkResourceVirtualEnvironmentCertificateNodeName: schema.TypeString,
55 | mkResourceVirtualEnvironmentCertificatePrivateKey: schema.TypeString,
56 | mkResourceVirtualEnvironmentCertificatePublicKeySize: schema.TypeInt,
57 | mkResourceVirtualEnvironmentCertificatePublicKeyType: schema.TypeString,
58 | mkResourceVirtualEnvironmentCertificateSSLFingerprint: schema.TypeString,
59 | mkResourceVirtualEnvironmentCertificateStartDate: schema.TypeString,
60 | mkResourceVirtualEnvironmentCertificateSubject: schema.TypeString,
61 | mkResourceVirtualEnvironmentCertificateSubjectAlternativeNames: schema.TypeList,
62 | })
63 | }
64 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_cluster_alias_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentAliasInstantiation tests whether the ResourceVirtualEnvironmentAlias instance can be instantiated.
14 | func TestResourceVirtualEnvironmentAliasInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentClusterAlias()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentAlias")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentAliasSchema tests the resourceVirtualEnvironmentAlias schema.
23 | func TestResourceVirtualEnvironmentAliasSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentClusterAlias()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentClusterAliasName,
28 | mkResourceVirtualEnvironmentClusterAliasCIDR,
29 | })
30 |
31 | testOptionalArguments(t, s, []string{
32 | mkResourceVirtualEnvironmentClusterAliasComment,
33 | })
34 |
35 | testValueTypes(t, s, map[string]schema.ValueType{
36 | mkResourceVirtualEnvironmentClusterAliasName: schema.TypeString,
37 | mkResourceVirtualEnvironmentClusterAliasCIDR: schema.TypeString,
38 | mkResourceVirtualEnvironmentClusterAliasComment: schema.TypeString,
39 | })
40 | }
41 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_cluster_ipset_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentIPSetInstantiation tests whether the resourceVirtualEnvironmentClusterIPSet
14 | // instance can be instantiated.
15 | func TestResourceVirtualEnvironmentIPSetInstantiation(t *testing.T) {
16 | s := resourceVirtualEnvironmentClusterIPSet()
17 |
18 | if s == nil {
19 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentAlias")
20 | }
21 | }
22 |
23 | // TestResourceVirtualEnvironmentIPSetSchema tests the resourceVirtualEnvironmentClusterIPSet schema.
24 | func TestResourceVirtualEnvironmentIPSetSchema(t *testing.T) {
25 | s := resourceVirtualEnvironmentClusterIPSet()
26 |
27 | testRequiredArguments(t, s, []string{
28 | mkResourceVirtualEnvironmentClusterIPSetName,
29 | })
30 |
31 | testOptionalArguments(t, s, []string{
32 | mkResourceVirtualEnvironmentClusterIPSetCIDR,
33 | mkResourceVirtualEnvironmentClusterIPSetCIDRComment,
34 | })
35 |
36 | testValueTypes(t, s, map[string]schema.ValueType{
37 | mkResourceVirtualEnvironmentClusterIPSetName: schema.TypeString,
38 | mkResourceVirtualEnvironmentClusterIPSetCIDR: schema.TypeList,
39 | mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
40 | })
41 |
42 | IPSetSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentClusterIPSetCIDR)
43 |
44 | testRequiredArguments(t, IPSetSchema, []string{
45 | mkResourceVirtualEnvironmentClusterIPSetCIDRName,
46 | })
47 |
48 | testOptionalArguments(t, IPSetSchema, []string{
49 | mkResourceVirtualEnvironmentClusterIPSetCIDRComment,
50 | mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch,
51 | })
52 |
53 | testValueTypes(t, IPSetSchema, map[string]schema.ValueType{
54 | mkResourceVirtualEnvironmentClusterIPSetCIDRName: schema.TypeString,
55 | mkResourceVirtualEnvironmentClusterIPSetCIDRComment: schema.TypeString,
56 | mkResourceVirtualEnvironmentClusterIPSetCIDRNoMatch: schema.TypeBool,
57 | })
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_dns_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentDNSInstantiation tests whether the ResourceVirtualEnvironmentDNS instance can be instantiated.
14 | func TestResourceVirtualEnvironmentDNSInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentDNS()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentDNS")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentDNSSchema tests the resourceVirtualEnvironmentDNS schema.
23 | func TestResourceVirtualEnvironmentDNSSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentDNS()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentDNSDomain,
28 | mkResourceVirtualEnvironmentDNSNodeName,
29 | })
30 |
31 | testOptionalArguments(t, s, []string{
32 | mkResourceVirtualEnvironmentDNSServers,
33 | })
34 |
35 | testValueTypes(t, s, map[string]schema.ValueType{
36 | mkResourceVirtualEnvironmentDNSDomain: schema.TypeString,
37 | mkResourceVirtualEnvironmentDNSNodeName: schema.TypeString,
38 | mkResourceVirtualEnvironmentDNSServers: schema.TypeList,
39 | })
40 | }
41 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_file_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentFileInstantiation tests whether the ResourceVirtualEnvironmentFile instance can be instantiated.
14 | func TestResourceVirtualEnvironmentFileInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentFile()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentFile")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentFileSchema tests the resourceVirtualEnvironmentFile schema.
23 | func TestResourceVirtualEnvironmentFileSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentFile()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentFileDatastoreID,
28 | mkResourceVirtualEnvironmentFileNodeName,
29 | })
30 |
31 | testOptionalArguments(t, s, []string{
32 | mkResourceVirtualEnvironmentFileContentType,
33 | mkResourceVirtualEnvironmentFileSourceFile,
34 | mkResourceVirtualEnvironmentFileSourceRaw,
35 | })
36 |
37 | testComputedAttributes(t, s, []string{
38 | mkResourceVirtualEnvironmentFileFileModificationDate,
39 | mkResourceVirtualEnvironmentFileFileName,
40 | mkResourceVirtualEnvironmentFileFileSize,
41 | mkResourceVirtualEnvironmentFileFileTag,
42 | })
43 |
44 | testValueTypes(t, s, map[string]schema.ValueType{
45 | mkResourceVirtualEnvironmentFileContentType: schema.TypeString,
46 | mkResourceVirtualEnvironmentFileDatastoreID: schema.TypeString,
47 | mkResourceVirtualEnvironmentFileFileModificationDate: schema.TypeString,
48 | mkResourceVirtualEnvironmentFileFileName: schema.TypeString,
49 | mkResourceVirtualEnvironmentFileFileSize: schema.TypeInt,
50 | mkResourceVirtualEnvironmentFileFileTag: schema.TypeString,
51 | mkResourceVirtualEnvironmentFileNodeName: schema.TypeString,
52 | mkResourceVirtualEnvironmentFileSourceFile: schema.TypeList,
53 | mkResourceVirtualEnvironmentFileSourceRaw: schema.TypeList,
54 | })
55 |
56 | sourceFileSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentFileSourceFile)
57 |
58 | testRequiredArguments(t, sourceFileSchema, []string{
59 | mkResourceVirtualEnvironmentFileSourceFilePath,
60 | })
61 |
62 | testOptionalArguments(t, sourceFileSchema, []string{
63 | mkResourceVirtualEnvironmentFileSourceFileChanged,
64 | mkResourceVirtualEnvironmentFileSourceFileChecksum,
65 | mkResourceVirtualEnvironmentFileSourceFileFileName,
66 | mkResourceVirtualEnvironmentFileSourceFileInsecure,
67 | })
68 |
69 | testValueTypes(t, sourceFileSchema, map[string]schema.ValueType{
70 | mkResourceVirtualEnvironmentFileSourceFileChanged: schema.TypeBool,
71 | mkResourceVirtualEnvironmentFileSourceFileChecksum: schema.TypeString,
72 | mkResourceVirtualEnvironmentFileSourceFileFileName: schema.TypeString,
73 | mkResourceVirtualEnvironmentFileSourceFileInsecure: schema.TypeBool,
74 | mkResourceVirtualEnvironmentFileSourceFilePath: schema.TypeString,
75 | })
76 |
77 | sourceRawSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentFileSourceRaw)
78 |
79 | testRequiredArguments(t, sourceRawSchema, []string{
80 | mkResourceVirtualEnvironmentFileSourceRawData,
81 | mkResourceVirtualEnvironmentFileSourceRawFileName,
82 | })
83 |
84 | testOptionalArguments(t, sourceRawSchema, []string{
85 | mkResourceVirtualEnvironmentFileSourceRawResize,
86 | })
87 |
88 | testValueTypes(t, sourceRawSchema, map[string]schema.ValueType{
89 | mkResourceVirtualEnvironmentFileSourceRawData: schema.TypeString,
90 | mkResourceVirtualEnvironmentFileSourceRawFileName: schema.TypeString,
91 | mkResourceVirtualEnvironmentFileSourceRawResize: schema.TypeInt,
92 | })
93 | }
94 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_group_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentGroupInstantiation tests whether the ResourceVirtualEnvironmentGroup instance can be instantiated.
14 | func TestResourceVirtualEnvironmentGroupInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentGroup()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentGroup")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentGroupSchema tests the resourceVirtualEnvironmentGroup schema.
23 | func TestResourceVirtualEnvironmentGroupSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentGroup()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentGroupID,
28 | })
29 |
30 | testOptionalArguments(t, s, []string{
31 | mkResourceVirtualEnvironmentGroupACL,
32 | mkResourceVirtualEnvironmentGroupComment,
33 | })
34 |
35 | testComputedAttributes(t, s, []string{
36 | mkResourceVirtualEnvironmentGroupMembers,
37 | })
38 |
39 | testValueTypes(t, s, map[string]schema.ValueType{
40 | mkResourceVirtualEnvironmentGroupACL: schema.TypeSet,
41 | mkResourceVirtualEnvironmentGroupComment: schema.TypeString,
42 | mkResourceVirtualEnvironmentGroupID: schema.TypeString,
43 | mkResourceVirtualEnvironmentGroupMembers: schema.TypeSet,
44 | })
45 |
46 | aclSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentGroupACL)
47 |
48 | testRequiredArguments(t, aclSchema, []string{
49 | mkResourceVirtualEnvironmentGroupACLPath,
50 | mkResourceVirtualEnvironmentGroupACLRoleID,
51 | })
52 |
53 | testOptionalArguments(t, aclSchema, []string{
54 | mkResourceVirtualEnvironmentGroupACLPropagate,
55 | })
56 |
57 | testValueTypes(t, aclSchema, map[string]schema.ValueType{
58 | mkResourceVirtualEnvironmentGroupACLPath: schema.TypeString,
59 | mkResourceVirtualEnvironmentGroupACLPropagate: schema.TypeBool,
60 | mkResourceVirtualEnvironmentGroupACLRoleID: schema.TypeString,
61 | })
62 | }
63 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_hosts_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentHostsInstantiation tests whether the ResourceVirtualEnvironmentHosts instance can be instantiated.
14 | func TestResourceVirtualEnvironmentHostsInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentHosts()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentHosts")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentHostsSchema tests the resourceVirtualEnvironmentHosts schema.
23 | func TestResourceVirtualEnvironmentHostsSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentHosts()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentHostsEntry,
28 | mkResourceVirtualEnvironmentHostsNodeName,
29 | })
30 |
31 | testComputedAttributes(t, s, []string{
32 | mkResourceVirtualEnvironmentHostsAddresses,
33 | mkResourceVirtualEnvironmentHostsDigest,
34 | mkResourceVirtualEnvironmentHostsEntries,
35 | mkResourceVirtualEnvironmentHostsHostnames,
36 | })
37 |
38 | testValueTypes(t, s, map[string]schema.ValueType{
39 | mkResourceVirtualEnvironmentHostsAddresses: schema.TypeList,
40 | mkResourceVirtualEnvironmentHostsDigest: schema.TypeString,
41 | mkResourceVirtualEnvironmentHostsEntries: schema.TypeList,
42 | mkResourceVirtualEnvironmentHostsEntry: schema.TypeList,
43 | mkResourceVirtualEnvironmentHostsHostnames: schema.TypeList,
44 | mkResourceVirtualEnvironmentHostsNodeName: schema.TypeString,
45 | })
46 |
47 | entriesSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentHostsEntries)
48 |
49 | testComputedAttributes(t, entriesSchema, []string{
50 | mkResourceVirtualEnvironmentHostsEntriesAddress,
51 | mkResourceVirtualEnvironmentHostsEntriesHostnames,
52 | })
53 |
54 | testValueTypes(t, entriesSchema, map[string]schema.ValueType{
55 | mkResourceVirtualEnvironmentHostsEntriesAddress: schema.TypeString,
56 | mkResourceVirtualEnvironmentHostsEntriesHostnames: schema.TypeList,
57 | })
58 |
59 | entrySchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentHostsEntry)
60 |
61 | testRequiredArguments(t, entrySchema, []string{
62 | mkResourceVirtualEnvironmentHostsEntryAddress,
63 | mkResourceVirtualEnvironmentHostsEntryHostnames,
64 | })
65 |
66 | testValueTypes(t, entrySchema, map[string]schema.ValueType{
67 | mkResourceVirtualEnvironmentHostsEntryAddress: schema.TypeString,
68 | mkResourceVirtualEnvironmentHostsEntryHostnames: schema.TypeList,
69 | })
70 | }
71 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_pool_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentPoolInstantiation tests whether the ResourceVirtualEnvironmentPool instance can be instantiated.
14 | func TestResourceVirtualEnvironmentPoolInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentPool()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentPool")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentPoolSchema tests the resourceVirtualEnvironmentPool schema.
23 | func TestResourceVirtualEnvironmentPoolSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentPool()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentPoolPoolID,
28 | })
29 |
30 | testOptionalArguments(t, s, []string{
31 | mkResourceVirtualEnvironmentPoolComment,
32 | })
33 |
34 | testComputedAttributes(t, s, []string{
35 | mkResourceVirtualEnvironmentPoolMembers,
36 | })
37 |
38 | membersSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentPoolMembers)
39 |
40 | testComputedAttributes(t, membersSchema, []string{
41 | mkResourceVirtualEnvironmentPoolMembersDatastoreID,
42 | mkResourceVirtualEnvironmentPoolMembersID,
43 | mkResourceVirtualEnvironmentPoolMembersNodeName,
44 | mkResourceVirtualEnvironmentPoolMembersType,
45 | mkResourceVirtualEnvironmentPoolMembersVMID,
46 | })
47 |
48 | testValueTypes(t, membersSchema, map[string]schema.ValueType{
49 | mkResourceVirtualEnvironmentPoolMembersDatastoreID: schema.TypeString,
50 | mkResourceVirtualEnvironmentPoolMembersID: schema.TypeString,
51 | mkResourceVirtualEnvironmentPoolMembersNodeName: schema.TypeString,
52 | mkResourceVirtualEnvironmentPoolMembersType: schema.TypeString,
53 | mkResourceVirtualEnvironmentPoolMembersVMID: schema.TypeInt,
54 | })
55 | }
56 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_role_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentRoleInstantiation tests whether the ResourceVirtualEnvironmentRole instance can be instantiated.
14 | func TestResourceVirtualEnvironmentRoleInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentRole()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentRole")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentRoleSchema tests the resourceVirtualEnvironmentRole schema.
23 | func TestResourceVirtualEnvironmentRoleSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentRole()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentRolePrivileges,
28 | mkResourceVirtualEnvironmentRoleRoleID,
29 | })
30 |
31 | testValueTypes(t, s, map[string]schema.ValueType{
32 | mkResourceVirtualEnvironmentRolePrivileges: schema.TypeSet,
33 | mkResourceVirtualEnvironmentRoleRoleID: schema.TypeString,
34 | })
35 | }
36 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_time_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentTimeInstantiation tests whether the ResourceVirtualEnvironmentTime instance can be instantiated.
14 | func TestResourceVirtualEnvironmentTimeInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentTime()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentTime")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentTimeSchema tests the resourceVirtualEnvironmentTime schema.
23 | func TestResourceVirtualEnvironmentTimeSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentTime()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentTimeNodeName,
28 | mkResourceVirtualEnvironmentTimeTimeZone,
29 | })
30 |
31 | testComputedAttributes(t, s, []string{
32 | mkResourceVirtualEnvironmentTimeLocalTime,
33 | mkResourceVirtualEnvironmentTimeUTCTime,
34 | })
35 |
36 | testValueTypes(t, s, map[string]schema.ValueType{
37 | mkResourceVirtualEnvironmentTimeLocalTime: schema.TypeString,
38 | mkResourceVirtualEnvironmentTimeNodeName: schema.TypeString,
39 | mkResourceVirtualEnvironmentTimeTimeZone: schema.TypeString,
40 | mkResourceVirtualEnvironmentTimeUTCTime: schema.TypeString,
41 | })
42 | }
43 |
--------------------------------------------------------------------------------
/proxmoxtf/resource_virtual_environment_user_test.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | import (
8 | "testing"
9 |
10 | "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
11 | )
12 |
13 | // TestResourceVirtualEnvironmentUserInstantiation tests whether the ResourceVirtualEnvironmentUser instance can be instantiated.
14 | func TestResourceVirtualEnvironmentUserInstantiation(t *testing.T) {
15 | s := resourceVirtualEnvironmentUser()
16 |
17 | if s == nil {
18 | t.Fatalf("Cannot instantiate resourceVirtualEnvironmentUser")
19 | }
20 | }
21 |
22 | // TestResourceVirtualEnvironmentUserSchema tests the resourceVirtualEnvironmentUser schema.
23 | func TestResourceVirtualEnvironmentUserSchema(t *testing.T) {
24 | s := resourceVirtualEnvironmentUser()
25 |
26 | testRequiredArguments(t, s, []string{
27 | mkResourceVirtualEnvironmentUserPassword,
28 | mkResourceVirtualEnvironmentUserUserID,
29 | })
30 |
31 | testOptionalArguments(t, s, []string{
32 | mkResourceVirtualEnvironmentUserACL,
33 | mkResourceVirtualEnvironmentUserComment,
34 | mkResourceVirtualEnvironmentUserEmail,
35 | mkResourceVirtualEnvironmentUserEnabled,
36 | mkResourceVirtualEnvironmentUserExpirationDate,
37 | mkResourceVirtualEnvironmentUserFirstName,
38 | mkResourceVirtualEnvironmentUserGroups,
39 | mkResourceVirtualEnvironmentUserKeys,
40 | mkResourceVirtualEnvironmentUserLastName,
41 | })
42 |
43 | testValueTypes(t, s, map[string]schema.ValueType{
44 | mkResourceVirtualEnvironmentUserACL: schema.TypeSet,
45 | mkResourceVirtualEnvironmentUserComment: schema.TypeString,
46 | mkResourceVirtualEnvironmentUserEmail: schema.TypeString,
47 | mkResourceVirtualEnvironmentUserEnabled: schema.TypeBool,
48 | mkResourceVirtualEnvironmentUserExpirationDate: schema.TypeString,
49 | mkResourceVirtualEnvironmentUserFirstName: schema.TypeString,
50 | mkResourceVirtualEnvironmentUserGroups: schema.TypeSet,
51 | mkResourceVirtualEnvironmentUserKeys: schema.TypeString,
52 | mkResourceVirtualEnvironmentUserLastName: schema.TypeString,
53 | mkResourceVirtualEnvironmentUserPassword: schema.TypeString,
54 | mkResourceVirtualEnvironmentUserUserID: schema.TypeString,
55 | })
56 |
57 | aclSchema := testNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentUserACL)
58 |
59 | testRequiredArguments(t, aclSchema, []string{
60 | mkResourceVirtualEnvironmentUserACLPath,
61 | mkResourceVirtualEnvironmentUserACLRoleID,
62 | })
63 |
64 | testOptionalArguments(t, aclSchema, []string{
65 | mkResourceVirtualEnvironmentUserACLPropagate,
66 | })
67 |
68 | testValueTypes(t, aclSchema, map[string]schema.ValueType{
69 | mkResourceVirtualEnvironmentUserACLPath: schema.TypeString,
70 | mkResourceVirtualEnvironmentUserACLPropagate: schema.TypeBool,
71 | mkResourceVirtualEnvironmentUserACLRoleID: schema.TypeString,
72 | })
73 | }
74 |
--------------------------------------------------------------------------------
/proxmoxtf/version.go:
--------------------------------------------------------------------------------
1 | /* This Source Code Form is subject to the terms of the Mozilla Public
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this
3 | * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 |
5 | package proxmoxtf
6 |
7 | const (
8 | // TerraformProviderName specifies the full name of this provider.
9 | TerraformProviderName = "terraform-provider-proxmox"
10 |
11 | // TerraformProviderVersion specifies the version number.
12 | TerraformProviderVersion = "0.4.4"
13 | )
14 |
--------------------------------------------------------------------------------