Skip to content

Commit

Permalink
Docs, self review
Browse files Browse the repository at this point in the history
Signed-off-by: Dainius Serplis <[email protected]>
  • Loading branch information
Didainius committed Nov 14, 2024
1 parent 3048a5a commit 8cbf89f
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 15 deletions.
4 changes: 2 additions & 2 deletions vcd/datasource_vcd_tm_org_vdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ var tmVdcDsZoneResourceAllocation = &schema.Resource{
"zone_name": {
Type: schema.TypeString,
Computed: true,
Description: "Region Zone Name",
Description: fmt.Sprintf("%s Name", labelTmRegionZone),
},
"zone_id": {
Type: schema.TypeString,
Computed: true,
Description: "Region Zone ID",
Description: fmt.Sprintf("%s ID", labelTmRegionZone),
},
"memory_limit_mib": {
Type: schema.TypeInt,
Expand Down
26 changes: 15 additions & 11 deletions vcd/datasource_vcd_tm_region_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,32 @@ func datasourceVcdTmRegionZone() *schema.Resource {
},
"memory_limit_mib": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "Memory limit in MiB",
},
"memory_reservation_used_mib": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "Memory reservation in MiB",
},
"memory_reservation_mib": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "Memory reservation in MiB",
},
"cpu_limit_mhz": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "CPU limit in MHz",
},
"cpu_reservation_mhz": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "CPU reservation in MHz",
},
"cpu_reservation_used_mhz": {
Type: schema.TypeInt,
Required: true,
Computed: true,
Description: "CPU reservation in MHz",
},
},
Expand All @@ -68,27 +68,31 @@ func resourceVcdTmRegionZoneRead(ctx context.Context, d *schema.ResourceData, me
if err != nil {
return diag.Errorf("error retrieving %s: %s", labelTmRegion, err)
}

getZone := func() func(name string) (*govcd.Zone, error) {
getRegionZone := func() func(name string) (*govcd.Zone, error) {
return func(name string) (*govcd.Zone, error) {
return region.GetZoneByName(name)
}
}()

c := dsCrudConfig[*govcd.Zone, types.Zone]{
entityLabel: labelTmRegionZone,
getEntityFunc: getZone,
getEntityFunc: getRegionZone,
stateStoreFunc: setZoneData,
}
return readDatasource(ctx, d, meta, c)
}

func setZoneData(d *schema.ResourceData, z *govcd.Zone) error {
if z == nil {
return fmt.Errorf("nil Zone")
return fmt.Errorf("nil %s", labelTmRegionZone)
}
d.SetId(z.Zone.ID)
dSet(d, "memory_limit_mib", z.Zone.MemoryLimitMiB)
dSet(d, "memory_reservation_used_mib", z.Zone.MemoryReservationUsedMiB)
dSet(d, "memory_reservation_mib", z.Zone.MemoryReservationMiB)
dSet(d, "cpu_limit_mhz", z.Zone.CPULimitMhz)
dSet(d, "cpu_reservation_mhz", z.Zone.CPUReservationMhz)
dSet(d, "cpu_reservation_used_mhz", z.Zone.CPUReservationUsedMhz)

// IMPLEMENT
return nil
}
1 change: 0 additions & 1 deletion vcd/resource_vcd_tm_org_vdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ const testAccVcdTmOrgVdcStep1 = `
data "vcd_tm_supervisor" "test" {
name = "{{.SupervisorName}}"
vcenter_id = {{.VcenterRef}}.id
depends_on = [{{.VcenterRef}}]
}
data "vcd_tm_region_zone" "test" {
Expand Down
42 changes: 42 additions & 0 deletions website/docs/d/tm_region_zone.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
layout: "vcd"
page_title: "VMware Cloud Director: vcd_tm_region_zone"
sidebar_current: "docs-vcd-datasource-tm-region-zone"
description: |-
Provides a data source to read Tenant Manager Region Zone that can be used when creating VDC.
---

# vcd\_tm\_region\_zone

Provides a data source to read Tenant Manager Region Zone that can be used when creating VDC.

## Example Usage

```hcl
data "vcd_tm_region_zone" "my" {
region_id = vcd_tm_region.region.id
name = "my-zone"
}
```

## Argument Reference

The following arguments are supported:

* `region_id` - (Required) Parent Region ID
* `name` - (Required) Name of Region Zone

## Attribute Reference

* `cpu_limit_mhz` - Total amount of reserved and unreserved CPU resources allocated in MHz
* `cpu_reservation_mhz` - Total amount of CPU resources reserved in MHz
* `cpu_reservation_used_mhz` - The amount of CPU resources used in MHz. For Tenants, this value
represents the total given to all of a Tenant's Namespaces. For Providers, this value represents
the total given to all Tenants
* `memory_limit_mib` - Total amount of reserved and unreserved memory resources allocated in MiB
* `memory_reservation_used_mib` - Total amount of reserved memory resources used in MiB. For
Tenants, this value represents the total given to all of a Tenant's Namespaces. For Providers,
this value represents the total given to all Tenants
* `memory_reservation_mib` - Total amount of reserved and unreserved memory resources used in MiB.
For Tenants, this value represents the total given to all of a Tenant's Namespaces. For Providers,
this value represents the total given to all Tenants
11 changes: 10 additions & 1 deletion website/docs/r/tm_org_vdc.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ description: |-

Provides a resource to manage VMware Cloud Foundation Tenant Manager Organization VDC.

## Example Usage ()
## Example Usage

```hcl
data "vcd_vcenter" "vc" {
name = "my-vcenter"
}
data "vcd_tm_supervisor" "supervisor" {
name = "my-supervisor"
vcenter_id = vcd_vcenter.vc.id
}
data "vcd_tm_region_zone" "test" {
region_id = vcd_tm_region.region.id
name = "my-zone"
Expand Down
3 changes: 3 additions & 0 deletions website/vcd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@
<li<%= sidebar_current("docs-vcd-datasource-tm-org-vdc") %>>
<a href="/docs/providers/vcd/d/tm_org_vdc.html">vcd_tm_org_vdc</a>
</li>
<li<%= sidebar_current("docs-vcd-datasource-tm-region-zone") %>>
<a href="/docs/providers/vcd/d/tm_region_zone.html">vcd_tm_region_zone</a>
</li>
</ul>
</li>
<li<%= sidebar_current("docs-vcd-resource") %>>
Expand Down

0 comments on commit 8cbf89f

Please sign in to comment.