Skip to content

Commit 1aa8a76

Browse files
[BLOCK] Add storage pool type field (#15415) (#24867)
[upstream:d1a715bc733f477e0d5ff2f2953a76a83a221730] Signed-off-by: Modular Magician <[email protected]>
1 parent 1d65d35 commit 1aa8a76

File tree

5 files changed

+124
-4
lines changed

5 files changed

+124
-4
lines changed

.changelog/15415.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
netapp: added additional field `type` in `google_netapp_storage_pool` resource
3+
```

google/services/netapp/resource_netapp_storage_pool.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func ResourceNetappStoragePool() *schema.Resource {
4848

4949
Timeouts: &schema.ResourceTimeout{
5050
Create: schema.DefaultTimeout(45 * time.Minute),
51-
Update: schema.DefaultTimeout(20 * time.Minute),
52-
Delete: schema.DefaultTimeout(20 * time.Minute),
51+
Update: schema.DefaultTimeout(60 * time.Minute),
52+
Delete: schema.DefaultTimeout(45 * time.Minute),
5353
},
5454

5555
CustomizeDiff: customdiff.All(
@@ -103,6 +103,7 @@ Auto-tiering can be enabled after storage pool creation but it can't be disabled
103103
},
104104
"custom_performance_enabled": {
105105
Type: schema.TypeBool,
106+
Computed: true,
106107
Optional: true,
107108
ForceNew: true,
108109
Description: `Optional. True if using Independent Scaling of capacity and performance (Hyperdisk). Default is false.`,
@@ -174,6 +175,16 @@ Possible values are: AUTO, MANUAL. Possible values: ["QOS_TYPE_UNSPECIFIED", "AU
174175
Optional: true,
175176
Description: `Optional. Custom Performance Total Throughput of the pool (in MiB/s).`,
176177
},
178+
"type": {
179+
Type: schema.TypeString,
180+
Computed: true,
181+
Optional: true,
182+
ForceNew: true,
183+
ValidateFunc: verify.ValidateEnum([]string{"STORAGE_POOL_TYPE_UNSPECIFIED", "FILE", "UNIFIED", ""}),
184+
Description: `Type of the storage pool.
185+
This field is used to control whether the pool supports FILE based volumes only or UNIFIED (both FILE and BLOCK) volumes.
186+
If not specified during creation, it defaults to FILE. Possible values: ["STORAGE_POOL_TYPE_UNSPECIFIED", "FILE", "UNIFIED"]`,
187+
},
177188
"zone": {
178189
Type: schema.TypeString,
179190
Computed: true,
@@ -340,6 +351,12 @@ func resourceNetappStoragePoolCreate(d *schema.ResourceData, meta interface{}) e
340351
} else if v, ok := d.GetOkExists("qos_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(qosTypeProp)) && (ok || !reflect.DeepEqual(v, qosTypeProp)) {
341352
obj["qosType"] = qosTypeProp
342353
}
354+
typeProp, err := expandNetappStoragePoolType(d.Get("type"), d, config)
355+
if err != nil {
356+
return err
357+
} else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) {
358+
obj["type"] = typeProp
359+
}
343360
effectiveLabelsProp, err := expandNetappStoragePoolEffectiveLabels(d.Get("effective_labels"), d, config)
344361
if err != nil {
345362
return err
@@ -511,6 +528,9 @@ func resourceNetappStoragePoolRead(d *schema.ResourceData, meta interface{}) err
511528
if err := d.Set("hot_tier_size_used_gib", flattenNetappStoragePoolHotTierSizeUsedGib(res["hotTierSizeUsedGib"], d, config)); err != nil {
512529
return fmt.Errorf("Error reading StoragePool: %s", err)
513530
}
531+
if err := d.Set("type", flattenNetappStoragePoolType(res["type"], d, config)); err != nil {
532+
return fmt.Errorf("Error reading StoragePool: %s", err)
533+
}
514534
if err := d.Set("terraform_labels", flattenNetappStoragePoolTerraformLabels(res["labels"], d, config)); err != nil {
515535
return fmt.Errorf("Error reading StoragePool: %s", err)
516536
}
@@ -962,6 +982,10 @@ func flattenNetappStoragePoolHotTierSizeUsedGib(v interface{}, d *schema.Resourc
962982
return v
963983
}
964984

985+
func flattenNetappStoragePoolType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
986+
return v
987+
}
988+
965989
func flattenNetappStoragePoolTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
966990
if v == nil {
967991
return v
@@ -1045,6 +1069,10 @@ func expandNetappStoragePoolQosType(v interface{}, d tpgresource.TerraformResour
10451069
return v, nil
10461070
}
10471071

1072+
func expandNetappStoragePoolType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1073+
return v, nil
1074+
}
1075+
10481076
func expandNetappStoragePoolEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
10491077
if v == nil {
10501078
return map[string]string{}, nil

google/services/netapp/resource_netapp_storage_pool_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fields:
3333
provider_only: true
3434
- api_field: 'totalIops'
3535
- api_field: 'totalThroughputMibps'
36+
- api_field: 'type'
3637
- api_field: 'volumeCapacityGib'
3738
- api_field: 'volumeCount'
3839
- api_field: 'zone'

google/services/netapp/resource_netapp_storage_pool_test.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,84 @@ data "google_compute_network" "default" {
743743
}
744744
`, context)
745745
}
746+
747+
func TestAccNetappStoragePool_unifiedStoragePoolCreate(t *testing.T) {
748+
t.Parallel()
749+
750+
context := map[string]interface{}{
751+
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "gcnv-network-config-3", acctest.ServiceNetworkWithParentService("netapp.servicenetworking.goog")),
752+
"random_suffix": acctest.RandString(t, 10),
753+
}
754+
755+
acctest.VcrTest(t, resource.TestCase{
756+
PreCheck: func() { acctest.AccTestPreCheck(t) },
757+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
758+
Steps: []resource.TestStep{
759+
{
760+
Config: testAccNetappStoragePool_unifiedStoragePoolCreate(context),
761+
},
762+
{
763+
ResourceName: "google_netapp_storage_pool.test_pool",
764+
ImportState: true,
765+
ImportStateVerify: true,
766+
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
767+
},
768+
{
769+
Config: testAccNetappStoragePool_unifiedStoragePoolCreate_update(context),
770+
},
771+
{
772+
ResourceName: "google_netapp_storage_pool.test_pool",
773+
ImportState: true,
774+
ImportStateVerify: true,
775+
ImportStateVerifyIgnore: []string{"location", "name", "labels", "terraform_labels"},
776+
},
777+
},
778+
})
779+
}
780+
781+
func testAccNetappStoragePool_unifiedStoragePoolCreate(context map[string]interface{}) string {
782+
return acctest.Nprintf(`
783+
784+
data "google_compute_network" "default" {
785+
name = "%{network_name}"
786+
}
787+
788+
resource "google_netapp_storage_pool" "test_pool" {
789+
name = "tf-test-pool%{random_suffix}"
790+
location = "us-central1-a"
791+
service_level = "FLEX"
792+
type = "UNIFIED"
793+
capacity_gib = "2048"
794+
network = data.google_compute_network.default.id
795+
description = "this is a test description"
796+
labels = {
797+
key = "test"
798+
value = "pool"
799+
}
800+
}
801+
`, context)
802+
}
803+
804+
func testAccNetappStoragePool_unifiedStoragePoolCreate_update(context map[string]interface{}) string {
805+
return acctest.Nprintf(`
806+
807+
data "google_compute_network" "default" {
808+
name = "%{network_name}"
809+
}
810+
811+
resource "google_netapp_storage_pool" "test_pool" {
812+
name = "tf-test-pool%{random_suffix}"
813+
location = "us-central1-a"
814+
service_level = "FLEX"
815+
type = "UNIFIED"
816+
capacity_gib = "2048"
817+
network = data.google_compute_network.default.id
818+
description = "this is a test description"
819+
labels = {
820+
key = "test"
821+
value = "pool"
822+
}
823+
total_throughput_mibps = "200"
824+
}
825+
`, context)
826+
}

website/docs/r/netapp_storage_pool.html.markdown

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ The following arguments are supported:
197197
Possible values are: AUTO, MANUAL.
198198
Possible values are: `QOS_TYPE_UNSPECIFIED`, `AUTO`, `MANUAL`.
199199

200+
* `type` -
201+
(Optional)
202+
Type of the storage pool.
203+
This field is used to control whether the pool supports FILE based volumes only or UNIFIED (both FILE and BLOCK) volumes.
204+
If not specified during creation, it defaults to FILE.
205+
Possible values are: `STORAGE_POOL_TYPE_UNSPECIFIED`, `FILE`, `UNIFIED`.
206+
200207
* `project` - (Optional) The ID of the project in which the resource belongs.
201208
If it is not provided, the provider project is used.
202209

@@ -240,8 +247,8 @@ This resource provides the following
240247
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options:
241248

242249
- `create` - Default is 45 minutes.
243-
- `update` - Default is 20 minutes.
244-
- `delete` - Default is 20 minutes.
250+
- `update` - Default is 60 minutes.
251+
- `delete` - Default is 45 minutes.
245252

246253
## Import
247254

0 commit comments

Comments
 (0)