Skip to content

Commit

Permalink
CP-49366: Implement xenserver_sr provider data source
Browse files Browse the repository at this point in the history
Signed-off-by: xueqingz <[email protected]>
  • Loading branch information
xueqingz committed Jun 11, 2024
1 parent 83ba2d0 commit d8c6f41
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 6 deletions.
62 changes: 62 additions & 0 deletions docs/data-sources/sr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "xenserver_sr Data Source - xenserver"
subcategory: ""
description: |-
The data source of XenServer storage repository
---

# xenserver_sr (Data Source)

The data source of XenServer storage repository

## Example Usage

```terraform
data "xenserver_sr" "sr" {
name_label = "Local storage"
}
output "local_storage_output" {
value = data.xenserver_sr.sr.data_items
}
```

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

### Optional

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

### Read-Only

- `data_items` (Attributes List) The return items of storage repositories (see [below for nested schema](#nestedatt--data_items))

<a id="nestedatt--data_items"></a>
### Nested Schema for `data_items`

Read-Only:

- `allowed_operations` (List of String) The list of the operations allowed in this state
- `blobs` (Map of String) The binary blobs associated with this SR
- `clustered` (Boolean) True if the SR is using aggregated local storage
- `content_type` (String) The type of the SR's content, if required (e.g. ISOs)
- `current_operations` (Map of String) The links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task
- `introduced_by` (String) The disaster recovery task which introduced this SR
- `is_tools_sr` (Boolean) True if this is the SR that contains the Tools ISO VDIs
- `local_cache_enabled` (Boolean) True if this SR is assigned to be the local cache for its host
- `name_description` (String) The human-readable description of the storage repository
- `name_label` (String) The name of the storage repository
- `other_config` (Map of String) The additional configuration
- `pbds` (List of String) Describes how particular hosts can see this storage repository
- `physical_size` (Number) The total physical size of the storage repository (in bytes)
- `physical_utilisation` (Number) The physical space currently utilised on this storage repository (in bytes)
- `shared` (Boolean) True if this SR is (capable of being) shared between multiple hosts
- `sm_config` (Map of String) The SM dependent data
- `tags` (List of String) The user-specified tags for categorization purposes
- `type` (String) The type of the storage repository
- `uuid` (String) The UUID of the storage repository
- `vdis` (List of String) The all virtual disks known to this storage repository
- `virtual_allocation` (Number) The sum of virtual_sizes of all VDIs in this storage repository (in bytes)
7 changes: 7 additions & 0 deletions examples/data-sources/xenserver_sr/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "xenserver_sr" "sr" {
name_label = "Local storage"
}

output "local_storage_output" {
value = data.xenserver_sr.sr.data_items
}
8 changes: 8 additions & 0 deletions examples/terraform-main/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ resource "xenserver_vm" "vm" {
output "vm_out" {
value = xenserver_vm.vm
}

data "xenserver_sr" "sr" {
name_label = "Local storage"
}

output "local_storage_output" {
value = data.xenserver_sr.sr.data_items
}
6 changes: 0 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,8 @@ github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVW
github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec=
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-plugin-docs v0.19.2 h1:YjdKa1vuqt9EnPYkkrv9HnGZz175HhSJ7Vsn8yZeWus=
github.com/hashicorp/terraform-plugin-docs v0.19.2/go.mod h1:gad2aP6uObFKhgNE8DR9nsEuEQnibp7il0jZYYOunWY=
github.com/hashicorp/terraform-plugin-docs v0.19.3 h1:xoxpeIuBfnoGxXY0dTajdj4GjEv6TihZdj0lHNXbKew=
github.com/hashicorp/terraform-plugin-docs v0.19.3/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c=
github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-framework v1.8.0 h1:P07qy8RKLcoBkCrY2RHJer5AEvJnDuXomBgou6fD8kI=
github.com/hashicorp/terraform-plugin-framework v1.8.0/go.mod h1:/CpTukO88PcL/62noU7cuyaSJ4Rsim+A/pa+3rUVufY=
github.com/hashicorp/terraform-plugin-framework v1.9.0 h1:caLcDoxiRucNi2hk8+j3kJwkKfvHznubyFsJMWfZqKU=
github.com/hashicorp/terraform-plugin-framework v1.9.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
Expand Down
1 change: 1 addition & 0 deletions xenserver/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (p *Provider) Resources(_ context.Context) []func() resource.Resource {
func (p *Provider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewPIFDataSource,
NewSRDataSource,
}
}

Expand Down
Loading

0 comments on commit d8c6f41

Please sign in to comment.