Skip to content

Commit

Permalink
Merge pull request #205 from vasilsatanasov/topic/vasilsatanasov/issu…
Browse files Browse the repository at this point in the history
…e-204

Remove support for r5.metal and storage_capacity
  • Loading branch information
vasilsatanasov authored Sep 29, 2023
2 parents ad4ece4 + 489aec0 commit 71a32a8
Show file tree
Hide file tree
Showing 17 changed files with 9 additions and 91 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.14 (TBA)

Breaking changes
* Removing support for r5.metal instances [\#205](https://github.com/vmware/terraform-provider-vmc/pull/205)
* removing `storage_capacity` field from sddc and cluster resources schema [\#205](https://github.com/vmware/terraform-provider-vmc/pull/205)

## 1.13.3 (Aug 21, 2023)

BUG FIXES:
Expand Down
2 changes: 0 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ To add delay after SDDC has been created, update SDDC resource in [main.tf](http

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
2 changes: 0 additions & 2 deletions examples/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ resource "vmc_sddc" "sddc_1" {

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
2 changes: 0 additions & 2 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ resource "vmc_sddc" "sddc_1" {

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
2 changes: 0 additions & 2 deletions examples/public_ip/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ resource "vmc_sddc" "sddc_1" {

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
1 change: 0 additions & 1 deletion examples/sddc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ resource "vmc_sddc" "sddc_1" {
deployment_type = var.deployment_type
size = var.size
host_instance_type = var.host_instance_type
storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
Expand Down
2 changes: 0 additions & 2 deletions examples/site_recovery/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ resource "vmc_sddc" "sddc_1" {

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
2 changes: 0 additions & 2 deletions examples/srm_node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ resource "vmc_sddc" "sddc_1" {

host_instance_type = var.host_instance_type

storage_capacity = var.storage_capacity

account_link_sddc_config {
customer_subnet_ids = [data.vmc_customer_subnets.my_subnets.ids[0]]
connected_account_id = data.vmc_connected_accounts.my_accounts.id
Expand Down
1 change: 0 additions & 1 deletion vmc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (

// ESX Host instance types supported for SDDC creation.
HostInstancetypeI3 string = "I3_METAL"
HostInstancetypeR5 string = "R5_METAL"
HostInstancetypeI3EN string = "I3EN_METAL"
HostInstancetypeI4I string = "I4I_METAL"

Expand Down
32 changes: 2 additions & 30 deletions vmc/resource_vmc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@ func resourceCluster() *schema.Resource {
Update: schema.DefaultTimeout(20 * time.Minute),
},
Schema: clusterSchema(),
CustomizeDiff: func(c context.Context, d *schema.ResourceDiff, meta interface{}) error {
newInstanceType := d.Get("host_instance_type").(string)

switch newInstanceType {
case constants.HostInstancetypeI3, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I:
if d.Get("storage_capacity").(string) != "" {
return fmt.Errorf("storage_capacity is not supported for host_instance_type %q", newInstanceType)
}
case constants.HostInstancetypeR5:
if d.Get("storage_capacity").(string) == "" {
return fmt.Errorf("storage_capacity is required for host_instance_type %q "+
"Possible values are 15TB, 20TB, 25TB, 30TB, 35TB per host", newInstanceType)
}
}
return nil
},
}
}

Expand Down Expand Up @@ -100,14 +84,7 @@ func clusterSchema() map[string]*schema.Schema {
Optional: true,
Description: "The instance type for the esx hosts added to this cluster.",
ValidateFunc: validation.StringInSlice(
[]string{constants.HostInstancetypeI3, constants.HostInstancetypeR5, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I}, false),
},
"storage_capacity": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"15TB", "20TB", "25TB", "30TB", "35TB"}, false),
[]string{constants.HostInstancetypeI3, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I}, false),
},
"edrs_policy_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -449,17 +426,12 @@ func buildClusterConfig(d *schema.ResourceData) (*model.ClusterConfig, error) {
// since host_instance_type field is optional in schema
return nil, err
}
var storageCapacityConverted int64
storageCapacity := d.Get("storage_capacity").(string)
if len(strings.TrimSpace(storageCapacity)) > 0 {
storageCapacityConverted = ConvertStorageCapacityToInt(storageCapacity)
}

msftLicensingConfig := expandMsftLicenseConfig(d.Get("microsoft_licensing_config").([]interface{}))
return &model.ClusterConfig{
NumHosts: numHosts,
HostCpuCoresCount: &hostCPUCoresCount,
HostInstanceType: &hostInstanceType,
StorageCapacity: &storageCapacityConverted,
MsftLicenseConfig: msftLicensingConfig,
}, nil
}
3 changes: 0 additions & 3 deletions vmc/resource_vmc_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ func TestBuildClusterConfig(t *testing.T) {
{instanceType: constants.HostInstancetypeI4I,
expectedHostInstanceType: model.SddcConfig_HOST_INSTANCE_TYPE_I4I_METAL,
expectedErr: nil},
{instanceType: constants.HostInstancetypeR5,
expectedHostInstanceType: model.SddcConfig_HOST_INSTANCE_TYPE_R5_METAL,
expectedErr: nil},
{instanceType: "RandomString",
expectedHostInstanceType: "",
expectedErr: fmt.Errorf("unknown host instance type: RandomString"),
Expand Down
31 changes: 1 addition & 30 deletions vmc/resource_vmc_sddc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,13 @@ func resourceSddc() *schema.Resource {
Delete: schema.DefaultTimeout(180 * time.Minute),
},
Schema: sddcSchema(),
CustomizeDiff: func(c context.Context, d *schema.ResourceDiff, meta interface{}) error {
newInstanceType := d.Get("host_instance_type").(string)
switch newInstanceType {
case constants.HostInstancetypeI3, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I:
if d.Get("storage_capacity").(string) != "" {
return fmt.Errorf("storage_capacity is not supported for host_instance_type %q", newInstanceType)
}
case constants.HostInstancetypeR5:
if d.Get("storage_capacity").(string) == "" {
return fmt.Errorf("storage_capacity is required for host_instance_type %q "+
"Possible values are 15TB, 20TB, 25TB, 30TB, 35TB per host", newInstanceType)
}
}
return nil
},
}
}

// sddcSchema this helper function extracts the creation of the SDDC schema, so that
// it's made available for mocking in tests.
func sddcSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"storage_capacity": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
"15TB", "20TB", "25TB", "30TB", "35TB"}, false),
},
"sddc_name": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -183,7 +161,7 @@ func sddcSchema() map[string]*schema.Schema {
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice(
[]string{constants.HostInstancetypeI3, constants.HostInstancetypeR5, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I}, false),
[]string{constants.HostInstancetypeI3, constants.HostInstancetypeI3EN, constants.HostInstancetypeI4I}, false),
},
"edrs_policy_type": {
Type: schema.TypeString,
Expand Down Expand Up @@ -775,12 +753,6 @@ func updateMsftLicenseConfig(d *schema.ResourceData, m interface{}, msftLicenseC
// buildAwsSddcConfig extracts the creation of the model.AwsSddcConfig, so that it's
// available for testing
func buildAwsSddcConfig(d *schema.ResourceData) (*model.AwsSddcConfig, error) {
var storageCapacityConverted int64
storageCapacity := d.Get("storage_capacity").(string)
if len(strings.TrimSpace(storageCapacity)) > 0 {
storageCapacityConverted = ConvertStorageCapacityToInt(storageCapacity)
}

sddcName := d.Get("sddc_name").(string)
vpcCidr := d.Get("vpc_cidr").(string)
numHost := d.Get("num_host").(int)
Expand Down Expand Up @@ -826,7 +798,6 @@ func buildAwsSddcConfig(d *schema.ResourceData) (*model.AwsSddcConfig, error) {
}

return &model.AwsSddcConfig{
StorageCapacity: &storageCapacityConverted,
Name: sddcName,
VpcCidr: &vpcCidr,
NumHosts: int64(numHost),
Expand Down
6 changes: 0 additions & 6 deletions vmc/resource_vmc_sddc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,6 @@ func TestBuildAwsSddcConfigHostInstanceType(t *testing.T) {
expected: model.SddcConfig_HOST_INSTANCE_TYPE_I4I_METAL,
err: nil,
},
{input: map[string]interface{}{
"host_instance_type": constants.HostInstancetypeR5,
},
expected: model.SddcConfig_HOST_INSTANCE_TYPE_R5_METAL,
err: nil,
},
{input: map[string]interface{}{
"host_instance_type": "RandomString",
},
Expand Down
2 changes: 0 additions & 2 deletions vmc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ func toHostInstanceType(userPassedHostInstanceType string) (string, error) {
return model.SddcConfig_HOST_INSTANCE_TYPE_I3EN_METAL, nil
case constants.HostInstancetypeI4I:
return model.SddcConfig_HOST_INSTANCE_TYPE_I4I_METAL, nil
case constants.HostInstancetypeR5:
return model.SddcConfig_HOST_INSTANCE_TYPE_R5_METAL, nil
default:
return "", fmt.Errorf("unknown host instance type: %s", userPassedHostInstanceType)
}
Expand Down
1 change: 0 additions & 1 deletion vmc/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func TestToHostInstanceType(t *testing.T) {
{input: constants.HostInstancetypeI3, want: result{converted: model.SddcConfig_HOST_INSTANCE_TYPE_I3_METAL, err: nil}},
{input: constants.HostInstancetypeI3EN, want: result{converted: model.SddcConfig_HOST_INSTANCE_TYPE_I3EN_METAL, err: nil}},
{input: constants.HostInstancetypeI4I, want: result{converted: model.SddcConfig_HOST_INSTANCE_TYPE_I4I_METAL, err: nil}},
{input: constants.HostInstancetypeR5, want: result{converted: model.SddcConfig_HOST_INSTANCE_TYPE_R5_METAL, err: nil}},
{input: "RandomString", want: result{converted: "", err: fmt.Errorf("unknown host instance type: RandomString")}},
}

Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ The following arguments are supported for vmc_cluster resource:

* `host_instance_type` - (Optional) The instance type for the esx hosts added to this cluster. Possible values are: I3_METAL, I3EN_METAL, I4I_METAL, and R5_METAL. Default value: I3_METAL.

* `storage_capacity` - (Optional) For EBS-backed instances i.e: for R5_METAL only, the requested storage capacity in GiB.

* `microsoft_licensing_config` - (Optional) Indicates the desired licensing support, if any, of Microsoft software.

## Attributes Reference
Expand Down
3 changes: 0 additions & 3 deletions website/docs/r/sddc.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ The following arguments are supported:

* `sddc_name` - (Required) Name of the SDDC.

* `storage_capacity` - (Optional) The storage capacity value to be requested for the SDDC primary cluster.
This variable is only for R5_METAL. Possible values are 15TB, 20TB, 25TB, 30TB, 35TB per host.

* `num_host` - (Required) The number of hosts in the primary Cluster of the SDDC.

* `size` - (Optional) The size of the vCenter and NSX appliances. 'large' or 'LARGE' SDDC size corresponds to a large vCenter appliance and large NSX appliance. 'medium' or 'MEDIUM' SDDC size corresponds to medium vCenter appliance and medium NSX appliance. Default : 'medium'.
Expand Down

0 comments on commit 71a32a8

Please sign in to comment.