Skip to content

Commit

Permalink
Merge branch 'master' into private/feis/CP-49367
Browse files Browse the repository at this point in the history
  • Loading branch information
acefei authored Jun 19, 2024
2 parents 76c720f + 2c041bc commit 645de26
Show file tree
Hide file tree
Showing 15 changed files with 1,231 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ In order to run the full suite of acceptance tests, prepare a local `.env` file
export XENSERVER_HOST=https://<xenserver-host-ip>
export XENSERVER_USERNAME=<username>
export XENSERVER_PASSWORD=<password>
export NFS_SERVER=<nfs-server-ip>
export NFS_SERVER_PATH=<nfs-server-path>
```

Run `"make testacc"`. *Note:* Acceptance tests create real resources, and often cost money to run.
Expand Down
76 changes: 76 additions & 0 deletions docs/resources/sr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "xenserver_sr Resource - xenserver"
subcategory: ""
description: |-
SR resource
---

# xenserver_sr (Resource)

SR resource

## Example Usage

```terraform
// A simple example of creating a local storage on XenServer
resource "xenserver_sr" "local" {
name_label = "Test Local SR"
name_description = "A test local storage repository"
type = "dummy"
shared = false
host = "cbdad2c6-b181-4047-ba2a-b4914bdecdbd"
}
output "local_out" {
value = xenserver_sr.local
}
// A simple example of creating a NFS SR on XenServer
resource "xenserver_sr" "nfs" {
name_label = "Test NFS SR"
type = "nfs"
content_type = ""
device_config = {
server = "10.70.58.9"
serverpath = "/xenrtnfs"
nfsversion = "3"
}
sm_config = {
shared = "true"
}
}
output "nfs_out" {
value = xenserver_sr.nfs
}
```

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

### Required

- `name_label` (String) The name of the storage repository

### Optional

- `content_type` (String) The type of the SR's content, if required (e.g. ISOs), default to be ""
- `device_config` (Map of String) The device config that will be passed to backend SR driver, default to be {}
- `host` (String) The UUID of the host to create/make the SR on
- `name_description` (String) The human-readable description of the storage repository, default to be ""
- `shared` (Boolean) True if this SR is (capable of being) shared between multiple hosts, default to be true
- `sm_config` (Map of String) The SM dependent data, default to be {}
- `type` (String) The type of the storage repository, default to be ""

### Read-Only

- `id` (String) The UUID of the storage repository

## Import

Import is supported using the following syntax:

```shell
terraform import xenserver_sr.local <xenserver_sr.local.id>
```
52 changes: 52 additions & 0 deletions docs/resources/sr_nfs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "xenserver_sr_nfs Resource - xenserver"
subcategory: ""
description: |-
NFS SR resource
---

# xenserver_sr_nfs (Resource)

NFS SR resource

## Example Usage

```terraform
resource "xenserver_sr_nfs" "nfs_test" {
name_label = "NFS virtual disk storage"
name_description = "A test NFS storage repository"
version = "3"
storage_location = "10.70.58.9:/xenrtnfs"
}
output "nfs_test_out" {
value = xenserver_sr_nfs.nfs_test
}
```

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

### Required

- `name_label` (String) The name of the NFS storage repository
- `storage_location` (String) The server and server patch of the NFS storage repository, for example: "10.70.58.9:/xenrtnfs"
- `version` (String) The version of NFS storage repository, for example: "3"

### Optional

- `advanced_options` (String) The advanced options of the NFS storage repository, default to be ""
- `name_description` (String) The human-readable description of the NFS storage repository, default to be ""

### Read-Only

- `id` (String) The UUID of the NFS storage repository

## Import

Import is supported using the following syntax:

```shell
terraform import xenserver_sr_nfs.nfs_test <xenserver_sr_nfs.nfs_test.id>
```
1 change: 1 addition & 0 deletions examples/resources/xenserver_sr/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import xenserver_sr.local <xenserver_sr.local.id>
31 changes: 31 additions & 0 deletions examples/resources/xenserver_sr/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// A simple example of creating a local storage on XenServer
resource "xenserver_sr" "local" {
name_label = "Test Local SR"
name_description = "A test local storage repository"
type = "dummy"
shared = false
host = "cbdad2c6-b181-4047-ba2a-b4914bdecdbd"
}

output "local_out" {
value = xenserver_sr.local
}

// A simple example of creating a NFS SR on XenServer
resource "xenserver_sr" "nfs" {
name_label = "Test NFS SR"
type = "nfs"
content_type = ""
device_config = {
server = "10.70.58.9"
serverpath = "/xenrtnfs"
nfsversion = "3"
}
sm_config = {
shared = "true"
}
}

output "nfs_out" {
value = xenserver_sr.nfs
}
1 change: 1 addition & 0 deletions examples/resources/xenserver_sr_nfs/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import xenserver_sr_nfs.nfs_test <xenserver_sr_nfs.nfs_test.id>
10 changes: 10 additions & 0 deletions examples/resources/xenserver_sr_nfs/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "xenserver_sr_nfs" "nfs_test" {
name_label = "NFS virtual disk storage"
name_description = "A test NFS storage repository"
version = "3"
storage_location = "10.70.58.9:/xenrtnfs"
}

output "nfs_test_out" {
value = xenserver_sr_nfs.nfs_test
}
35 changes: 35 additions & 0 deletions examples/terraform-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,41 @@ output "local_storage_output" {
value = data.xenserver_sr.sr.data_items
}

resource "xenserver_sr" "local" {
name_label = "Test Local SR"
type = "dummy"
shared = false
}

output "sr_local_out" {
value = xenserver_sr.local
}

resource "xenserver_sr" "nfs" {
name_label = "Test NFS SR"
type = "nfs"
device_config = {
serverpath = local.env_vars["NFS_SERVER_PATH"]
server = local.env_vars["NFS_SERVER"]
nfsversion = "3"
}
}

output "sr_nfs_out" {
value = xenserver_sr.nfs
}

resource "xenserver_sr_nfs" "nfs_test" {
name_label = "NFS virtual disk storage"
name_description = "A test NFS storage repository"
version = "3"
storage_location = format("%s:%s", local.env_vars["NFS_SERVER"], local.env_vars["NFS_SERVER_PATH"])
}

output "nfs_test_out" {
value = xenserver_sr_nfs.nfs_test
}

resource "xenserver_network" "network" {
name_label = "Network Object on Pool"
name_description = "VM and Host objects that are attached to the Network object"
Expand Down
2 changes: 2 additions & 0 deletions xenserver/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func (p *xsProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewVMResource,
NewNetworkResource,
NewSRResource,
NewNFSResource,
}
}

Expand Down
Loading

0 comments on commit 645de26

Please sign in to comment.