Skip to content

Commit

Permalink
promote netapp regional flex storage pool and volume to GA (#12082) (#…
Browse files Browse the repository at this point in the history
…19980)

[upstream:c8c87cda41ff00115de88cb3cde699accfe1ff8b]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Oct 23, 2024
1 parent ff3219e commit 58f0b86
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changelog/12082.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note:enhancement
netapp: promoted `zone` and `replica_zone` fields to GA in `google_netapp_storage_pool` resource
```
```release-note:enhancement
netapp: promoted `zone` and `replica_zone` fields to GA in `google_netapp_volume` resource
```
67 changes: 67 additions & 0 deletions google/services/netapp/resource_netapp_storage_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,19 @@ Please refer to the field 'effective_labels' for all of the labels present on th
ForceNew: true,
Description: `When enabled, the volumes uses Active Directory as LDAP name service for UID/GID lookups. Required to enable extended group support for NFSv3,
using security identifiers for NFSv4.1 or principal names for kerberized NFSv4.1.`,
},
"replica_zone": {
Type: schema.TypeString,
Optional: true,
Description: `Specifies the replica zone for regional Flex pools. 'zone' and 'replica_zone' values can be swapped to initiate a
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones).`,
},
"zone": {
Type: schema.TypeString,
Optional: true,
Description: `Specifies the active zone for regional Flex pools. 'zone' and 'replica_zone' values can be swapped to initiate a
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones).
If you want to create a zonal Flex pool, specify a zone name for 'location' and omit 'zone'.`,
},
"effective_labels": {
Type: schema.TypeMap,
Expand Down Expand Up @@ -218,6 +231,18 @@ func resourceNetappStoragePoolCreate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("ldap_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(ldapEnabledProp)) && (ok || !reflect.DeepEqual(v, ldapEnabledProp)) {
obj["ldapEnabled"] = ldapEnabledProp
}
zoneProp, err := expandNetappStoragePoolZone(d.Get("zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(zoneProp)) && (ok || !reflect.DeepEqual(v, zoneProp)) {
obj["zone"] = zoneProp
}
replicaZoneProp, err := expandNetappStoragePoolReplicaZone(d.Get("replica_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("replica_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(replicaZoneProp)) && (ok || !reflect.DeepEqual(v, replicaZoneProp)) {
obj["replicaZone"] = replicaZoneProp
}
allowAutoTieringProp, err := expandNetappStoragePoolAllowAutoTiering(d.Get("allow_auto_tiering"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -362,6 +387,12 @@ func resourceNetappStoragePoolRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("encryption_type", flattenNetappStoragePoolEncryptionType(res["encryptionType"], d, config)); err != nil {
return fmt.Errorf("Error reading StoragePool: %s", err)
}
if err := d.Set("zone", flattenNetappStoragePoolZone(res["zone"], d, config)); err != nil {
return fmt.Errorf("Error reading StoragePool: %s", err)
}
if err := d.Set("replica_zone", flattenNetappStoragePoolReplicaZone(res["replicaZone"], d, config)); err != nil {
return fmt.Errorf("Error reading StoragePool: %s", err)
}
if err := d.Set("allow_auto_tiering", flattenNetappStoragePoolAllowAutoTiering(res["allowAutoTiering"], d, config)); err != nil {
return fmt.Errorf("Error reading StoragePool: %s", err)
}
Expand Down Expand Up @@ -409,6 +440,18 @@ func resourceNetappStoragePoolUpdate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("active_directory"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, activeDirectoryProp)) {
obj["activeDirectory"] = activeDirectoryProp
}
zoneProp, err := expandNetappStoragePoolZone(d.Get("zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, zoneProp)) {
obj["zone"] = zoneProp
}
replicaZoneProp, err := expandNetappStoragePoolReplicaZone(d.Get("replica_zone"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("replica_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, replicaZoneProp)) {
obj["replicaZone"] = replicaZoneProp
}
labelsProp, err := expandNetappStoragePoolEffectiveLabels(d.Get("effective_labels"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -437,6 +480,14 @@ func resourceNetappStoragePoolUpdate(d *schema.ResourceData, meta interface{}) e
updateMask = append(updateMask, "activeDirectory")
}

if d.HasChange("zone") {
updateMask = append(updateMask, "zone")
}

if d.HasChange("replica_zone") {
updateMask = append(updateMask, "replicaZone")
}

if d.HasChange("effective_labels") {
updateMask = append(updateMask, "labels")
}
Expand Down Expand Up @@ -692,6 +743,14 @@ func flattenNetappStoragePoolEncryptionType(v interface{}, d *schema.ResourceDat
return v
}

func flattenNetappStoragePoolZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenNetappStoragePoolReplicaZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenNetappStoragePoolAllowAutoTiering(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down Expand Up @@ -743,6 +802,14 @@ func expandNetappStoragePoolLdapEnabled(v interface{}, d tpgresource.TerraformRe
return v, nil
}

func expandNetappStoragePoolZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetappStoragePoolReplicaZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandNetappStoragePoolAllowAutoTiering(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}
Expand Down
128 changes: 126 additions & 2 deletions google/services/netapp/resource_netapp_storage_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
package netapp_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"testing"
"time"
)

func TestAccNetappStoragePool_storagePoolCreateExample_update(t *testing.T) {
Expand Down Expand Up @@ -193,3 +194,126 @@ resource "google_netapp_storage_pool" "test_pool" {
}
`, context)
}

func TestAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_update(t *testing.T) {
context := map[string]interface{}{
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "gcnv-network-config-1", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")),
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckNetappStoragePoolDestroyProducer(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
Steps: []resource.TestStep{
{
Config: testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_full(context),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
{
Config: testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_switchZone(context),
Check: testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_sleep_5_mins(),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
{
Config: testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_switchBackZone(context),
},
{
ResourceName: "google_netapp_storage_pool.test_pool",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
},
},
})
}

func testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_full(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-east1"
service_level = "FLEX"
capacity_gib = "2048"
network = data.google_compute_network.default.id
zone = "us-east1-c"
replica_zone = "us-east1-b"
}
resource "time_sleep" "wait_5_minutes" {
depends_on = [google_netapp_storage_pool.test_pool]
destroy_duration = "5m"
}
data "google_compute_network" "default" {
name = "%{network_name}"
}
`, context)
}

func testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_switchZone(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-east1"
service_level = "FLEX"
capacity_gib = "2048"
network = data.google_compute_network.default.id
zone = "us-east1-b"
replica_zone = "us-east1-c"
}
resource "time_sleep" "wait_5_minutes" {
depends_on = [google_netapp_storage_pool.test_pool]
destroy_duration = "5m"
}
data "google_compute_network" "default" {
name = "%{network_name}"
}
`, context)
}

func testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_sleep_5_mins() resource.TestCheckFunc {
return func(s *terraform.State) error {
// wait 5 minutes before executing the switchback due to api zone switch issues
time.Sleep(5 * time.Minute)
return nil
}
}

func testAccNetappStoragePool_FlexRegionalStoragePoolCreateExample_switchBackZone(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_netapp_storage_pool" "test_pool" {
name = "tf-test-pool%{random_suffix}"
location = "us-east1"
service_level = "FLEX"
capacity_gib = "2048"
network = data.google_compute_network.default.id
zone = "us-east1-c"
replica_zone = "us-east1-b"
}
resource "time_sleep" "wait_5_minutes" {
depends_on = [google_netapp_storage_pool.test_pool]
destroy_duration = "5m"
}
data "google_compute_network" "default" {
name = "%{network_name}"
}
`, context)
}
24 changes: 24 additions & 0 deletions google/services/netapp/resource_netapp_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ Format for SMB volumes: '\\\\netbios_prefix-four_random_hex_letters.domain_name\
Computed: true,
Description: `Name of the Private Service Access allocated range. Inherited from storage pool.`,
},
"replica_zone": {
Type: schema.TypeString,
Computed: true,
Description: `Specifies the replica zone for regional volume.`,
},
"service_level": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -565,6 +570,11 @@ Format for SMB volumes: '\\\\netbios_prefix-four_random_hex_letters.domain_name\
Computed: true,
Description: `Used capacity of the volume (in GiB). This is computed periodically and it does not represent the realtime usage.`,
},
"zone": {
Type: schema.TypeString,
Computed: true,
Description: `Specifies the active zone for regional volume.`,
},
"deletion_policy": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -896,6 +906,12 @@ func resourceNetappVolumeRead(d *schema.ResourceData, meta interface{}) error {
if err := d.Set("backup_config", flattenNetappVolumeBackupConfig(res["backupConfig"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("zone", flattenNetappVolumeZone(res["zone"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("replica_zone", flattenNetappVolumeReplicaZone(res["replicaZone"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
if err := d.Set("large_capacity", flattenNetappVolumeLargeCapacity(res["largeCapacity"], d, config)); err != nil {
return fmt.Errorf("Error reading Volume: %s", err)
}
Expand Down Expand Up @@ -1762,6 +1778,14 @@ func flattenNetappVolumeBackupConfigScheduledBackupEnabled(v interface{}, d *sch
return v
}

func flattenNetappVolumeZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenNetappVolumeReplicaZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenNetappVolumeLargeCapacity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down
5 changes: 2 additions & 3 deletions website/docs/r/netapp_storage_pool.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ and `replica_zone` values to reflect the current state, or Terraform will initia
the next apply. You can trigger a manual
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones)
via Terraform by swapping the value of the `zone` and `replica_zone` parameters in your HCL code.
Note : Regional FLEX storage pool are supported in beta provider currently.


To get more information about StoragePool, see:
Expand Down Expand Up @@ -161,13 +160,13 @@ The following arguments are supported:
using security identifiers for NFSv4.1 or principal names for kerberized NFSv4.1.

* `zone` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
(Optional)
Specifies the active zone for regional Flex pools. `zone` and `replica_zone` values can be swapped to initiate a
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones).
If you want to create a zonal Flex pool, specify a zone name for `location` and omit `zone`.

* `replica_zone` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
(Optional)
Specifies the replica zone for regional Flex pools. `zone` and `replica_zone` values can be swapped to initiate a
[zone switch](https://cloud.google.com/netapp/volumes/docs/configure-and-use/storage-pools/edit-or-delete-storage-pool#switch_active_and_replica_zones).

Expand Down
2 changes: 0 additions & 2 deletions website/docs/r/netapp_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,9 @@ In addition to the arguments listed above, the following computed attributes are
Structure is [documented below](#nested_mount_options).

* `zone` -
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Specifies the active zone for regional volume.

* `replica_zone` -
([Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html))
Specifies the replica zone for regional volume.

* `cold_tier_size_gib` -
Expand Down

0 comments on commit 58f0b86

Please sign in to comment.