Skip to content

Commit

Permalink
feat: add optional parameters for setting up vsan esa mode (#190)
Browse files Browse the repository at this point in the history
Adds optional parameters for setting up vSAN in ESA mode.

Signed-off-by: Stoyan Zhelyazkov <[email protected]>
  • Loading branch information
spacegospod authored Jun 28, 2024
1 parent 926cdd9 commit 4ad8d1f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 35 deletions.
7 changes: 4 additions & 3 deletions docs/resources/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
page_title: "vcf_cluster Resource - terraform-provider-vcf"
subcategory: ""
description: |-
---

# vcf_cluster (Resource)
Expand Down Expand Up @@ -232,8 +232,9 @@ Required:

Optional:

- `dedup_and_compression_enabled` (Boolean) Enable vSAN deduplication and compression
- `failures_to_tolerate` (Number) Number of ESXi host failures to tolerate in the vSAN cluster. One of 0, 1, or 2.
- `dedup_and_compression_enabled` (Boolean) Enable vSAN deduplication and compression. Cannot be set when `esa_enabled` is `true`.
- `esa_enabled` (Boolean) Enable vSAN ESA. `dedup_and_compression_enabled` and `failures_to_tolerate` cannot be set when using this attribute.
- `failures_to_tolerate` (Number) Number of ESXi host failures to tolerate in the vSAN cluster. One of 0, 1, or 2. Cannot be set when `esa_enabled` is `true`.
- `license_key` (String, Sensitive) vSAN license key to be used


Expand Down
55 changes: 26 additions & 29 deletions docs/resources/host.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,39 @@
page_title: "vcf_host Resource - terraform-provider-vcf"
subcategory: ""
description: |-
---

# vcf_host (Resource)


Prerequisites for commissioning Hosts
* The following data is required:
* Username of each host
* Password of each host
* FQDN of each host
* Network pool ID to which each host has to be associated with


* The host, if intended to be used for a vSAN domain, should be vSAN compliant and certified as per the VMware Hardware Compatibility Guide.
BIOS, HBA, SSD, HDD, etc. of the host must match the VMware Hardware Compatibility Guide.
* The host must have the drivers and firmware versions specified in the VMware Hardware Compatibility Guide.
* The host must have the supported version of ESXi (i.e 6.7.0-13006603) pre-installed on it.
* SSH and syslog must be enabled on the host.
* The host must be configured with DNS server for forward and reverse lookup and FQDN.
* The host name must be same as the FQDN.
* The host must have a standard switch with two NIC ports with a minimum 10 Gbps speed.
* The management IP must be configured to the first NIC port.
* Ensure that the host has a standard switch and the default uplinks with 10Gb speed are configured starting with traditional numbering (e.g., vmnic0) and increasing sequentially.
* Ensure that the host hardware health status is healthy without any errors.
* All disk partitions on HDD / SSD are deleted.
* The hosts, if intended to be used for vSAN, domain must be associated with vSAN enabled network pool.
* The hosts, if intended to be used for NFS, domain must be associated with NFS enabled network pool.
* The hosts, if intended to be used for VMFS on FC, domain must be associated with either a NFS enabled or vMotion enabled network pool.
* The hosts, if intended to be used for VVOL, domain must be associated with either a NFS enabled or vMotion enabled network pool.
* The hosts, if intended to be used for vSAN HCI Mesh(VSAN_REMOTE), domain must be associated with vSAN enabled network pool.


- The following data is required:

- Username of each host
- Password of each host
- FQDN of each host
- Network pool ID to which each host has to be associated with

- The host, if intended to be used for a vSAN domain, should be vSAN compliant and certified as per the VMware Hardware Compatibility Guide.
BIOS, HBA, SSD, HDD, etc. of the host must match the VMware Hardware Compatibility Guide.
- The host must have the drivers and firmware versions specified in the VMware Hardware Compatibility Guide.
- The host must have the supported version of ESXi (i.e 6.7.0-13006603) pre-installed on it.
- SSH and syslog must be enabled on the host.
- The host must be configured with DNS server for forward and reverse lookup and FQDN.
- The host name must be same as the FQDN.
- The host must have a standard switch with two NIC ports with a minimum 10 Gbps speed.
- The management IP must be configured to the first NIC port.
- Ensure that the host has a standard switch and the default uplinks with 10Gb speed are configured starting with traditional numbering (e.g., vmnic0) and increasing sequentially.
- Ensure that the host hardware health status is healthy without any errors.
- All disk partitions on HDD / SSD are deleted.
- The hosts, if intended to be used for vSAN, domain must be associated with vSAN enabled network pool.
- The hosts, if intended to be used for NFS, domain must be associated with NFS enabled network pool.
- The hosts, if intended to be used for VMFS on FC, domain must be associated with either a NFS enabled or vMotion enabled network pool.
- The hosts, if intended to be used for VVOL, domain must be associated with either a NFS enabled or vMotion enabled network pool.
- The hosts, if intended to be used for vSAN HCI Mesh(VSAN_REMOTE), domain must be associated with vSAN enabled network pool.

<!-- schema generated by tfplugindocs -->

## Schema

### Required
Expand All @@ -59,10 +57,9 @@ BIOS, HBA, SSD, HDD, etc. of the host must match the VMware Hardware Compatibili
- `status` (String) Assignable status of the host.

<a id="nestedblock--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `create` (String)


1 change: 1 addition & 0 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ Required:

Optional:

- `esa_enabled` (Boolean) Enable vSAN ESA
- `hcl_file` (String) A path (URL or local path) to an HCL file that will be uploaded to vCenter prior to configuring vSAN
- `license` (String) VSAN License
- `vsan_dedup` (Boolean) VSAN feature Deduplication and Compression flag, one flag for both features
Expand Down
10 changes: 10 additions & 0 deletions internal/datastores/vsan_datastore_subresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ func VsanDatastoreSchema() *schema.Resource {
Optional: true,
Description: "Enable vSAN deduplication and compression",
},
"esa_enabled": {
Type: schema.TypeBool,
Optional: true,
Description: "Enable vSAN ESA",
},
},
}
}
Expand All @@ -59,6 +64,11 @@ func TryConvertToVsanDatastoreSpec(object map[string]interface{}) (*models.VSAND
if dedupAndCompressionEnabled, ok := object["dedup_and_compression_enabled"]; ok && !validationutils.IsEmpty(dedupAndCompressionEnabled) {
result.DedupAndCompressionEnabled = dedupAndCompressionEnabled.(bool)
}
if esaEnabled, ok := object["esa_enabled"]; ok && !validationutils.IsEmpty(esaEnabled) {
value := esaEnabled.(bool)
esaConfig := models.EsaConfig{Enabled: &value}
result.EsaConfig = &esaConfig
}
if failuresToTolerate, ok := object["failures_to_tolerate"]; ok && !validationutils.IsEmpty(failuresToTolerate) {
failuresToTolerateInt := int32(failuresToTolerate.(int))
result.FailuresToTolerate = failuresToTolerateInt
Expand Down
8 changes: 5 additions & 3 deletions internal/provider/resource_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/vmware/terraform-provider-vcf/internal/api_client"
"github.com/vmware/terraform-provider-vcf/internal/constants"
"github.com/vmware/terraform-provider-vcf/internal/resource_utils"
Expand Down Expand Up @@ -58,9 +59,10 @@ func ResourceHost() *schema.Resource {
ConflictsWith: []string{"network_pool_name"},
},
"storage_type": {
Type: schema.TypeString,
Required: true,
Description: "Storage Type. One among: VSAN, VSAN_REMOTE, NFS, VMFS_FC, VVOL",
Type: schema.TypeString,
Required: true,
Description: "Storage Type. One among: VSAN, VSAN_ESA, VSAN_REMOTE, NFS, VMFS_FC, VVOL",
ValidateFunc: validation.StringInSlice([]string{"VSAN", "VSAN_ESA", "VSAN_REMOTE", "NFS", "VMFS_FC", "VVOL"}, false),
},
"username": {
Type: schema.TypeString,
Expand Down
13 changes: 13 additions & 0 deletions internal/sddc/sddc_vsan_subresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package sddc
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
utils "github.com/vmware/terraform-provider-vcf/internal/resource_utils"
validationutils "github.com/vmware/terraform-provider-vcf/internal/validation"
"github.com/vmware/vcf-sdk-go/models"
)

Expand Down Expand Up @@ -36,6 +37,11 @@ func GetVsanSchema() *schema.Schema {
Description: "VSAN feature Deduplication and Compression flag, one flag for both features",
Optional: true,
},
"esa_enabled": {
Type: schema.TypeBool,
Optional: true,
Description: "Enable vSAN ESA",
},
},
},
}
Expand All @@ -57,5 +63,12 @@ func GetVsanSpecFromSchema(rawData []interface{}) *models.VSANSpec {
LicenseFile: license,
VSANDedup: vsanDedup,
}

if esaEnabled, ok := data["esa_enabled"]; ok && !validationutils.IsEmpty(esaEnabled) {
value := esaEnabled.(bool)
esaConfig := models.VSANEsaConfig{Enabled: value}
vsanSpecBinding.EsaConfig = &esaConfig
}

return vsanSpecBinding
}

0 comments on commit 4ad8d1f

Please sign in to comment.