Skip to content

Commit

Permalink
CP-49724 Implement xenserver_network provider resource
Browse files Browse the repository at this point in the history
Signed-off-by: Fei Su <[email protected]>
  • Loading branch information
acefei committed Jun 14, 2024
1 parent 7054b64 commit d199386
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 1 deletion.
31 changes: 30 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,34 @@ default: testacc

# Run acceptance tests
.PHONY: testacc
testacc:
testacc: ## make testacc
source .env && TF_ACC=1 go test ./xenserver/ -v $(TESTARGS) -timeout 120m

doc: ## make doc for terraform provider documentation
go generate ./...

provider: go.mod ## make provider
if [ -z "$(GOBIN)" ]; then echo "GOBIN is not set" && exit 1; fi
go mod tidy
go install .
ls -l $(GOBIN)/terraform-provider-xenserver

apply: .env provider ## make apply
cd examples/terraform-main && \
terraform plan && \
terraform apply -auto-approve

show_state: .env ## make show_state resource=xenserver_vm.vm
@cd examples/terraform-main && \
if [ -z "$(resource)" ]; then echo "USAGE: make show_state resource=<>" && \
echo "List available resources:" && echo "`terraform state list`" && exit 1; fi && \
terraform state show $(resource)

import: .env ## make import resource=xenserver_vm.vm id=vm-uuid
@cd examples/terraform-main && \
if [ -z "$(resource)" ] || [ -z "$(id)" ]; then echo "USAGE: make import resource=<> id=<>"; exit 1; fi && \
terraform import $(resource) $(id)

destroy:
cd examples/terraform-main && \
terraform destroy -auto-approve
47 changes: 47 additions & 0 deletions docs/resources/network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "xenserver_network Resource - xenserver"
subcategory: ""
description: |-
Network Resource
---

# xenserver_network (Resource)

Network Resource

## Example Usage

```terraform
resource "xenserver_network" "network" {
name_label = "Test VM Network"
}
output "network_out" {
value = xenserver_network.network
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name_label` (String) The name of the virtual network

### Optional

- `name_description` (String) The description of the virtual network
- `other_config` (Map of String) The additional configuration of the virtual network

### Read-Only

- `id` (String) The UUID of the virtual network on xenserver

## Import

Import is supported using the following syntax:

```shell
terraform import xenserver_network.network <xenserver_network.network.id>
```
1 change: 1 addition & 0 deletions examples/resources/xenserver_network/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import xenserver_network.network <xenserver_network.network.id>
7 changes: 7 additions & 0 deletions examples/resources/xenserver_network/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "xenserver_network" "network" {
name_label = "Test VM Network"
}

output "network_out" {
value = xenserver_network.network.id
}
11 changes: 11 additions & 0 deletions examples/terraform-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ data "xenserver_sr" "sr" {
output "local_storage_output" {
value = data.xenserver_sr.sr.data_items
}
resource "xenserver_network" "network" {
name_label = "Network Object on Pool"
name_description = "VM and Host objects that are attached to the Network object"
mtu = 1500
// managed = true // This can be set on create and can't be updated
other_config = {}
}

output "network_out" {
value = xenserver_network.network.id
}
Loading

0 comments on commit d199386

Please sign in to comment.