Skip to content

Commit 3db489a

Browse files
add tiering_policy to volume replication create (#13515) (#9716)
[upstream:0c08ea13fb8cae0839dd6d98a781a566b4f96a97] Signed-off-by: Modular Magician <[email protected]>
1 parent 363fe32 commit 3db489a

8 files changed

+120
-2
lines changed

.changelog/13515.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
netapp: added `tiering_policy` to google_netapp_volume_replication resource
3+
```

google-beta/services/netapp/resource_netapp_volume.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ To disable automatic snapshot creation you have to remove the whole snapshot_pol
437437
"cooling_threshold_days": {
438438
Type: schema.TypeInt,
439439
Optional: true,
440-
Description: `Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 7-183.
440+
Description: `Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 2-183.
441441
Default is 31.`,
442442
},
443443
"tier_action": {

google-beta/services/netapp/resource_netapp_volume_replication.go

+64
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,29 @@ func ResourceNetappVolumeReplication() *schema.Resource {
165165
ForceNew: true,
166166
Description: `Share name for destination volume. If not specified, name of source volume's share name will be used.`,
167167
},
168+
"tiering_policy": {
169+
Type: schema.TypeList,
170+
Optional: true,
171+
Description: `Tiering policy for the volume.`,
172+
MaxItems: 1,
173+
Elem: &schema.Resource{
174+
Schema: map[string]*schema.Schema{
175+
"cooling_threshold_days": {
176+
Type: schema.TypeInt,
177+
Optional: true,
178+
Description: `Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 2-183.
179+
Default is 31.`,
180+
},
181+
"tier_action": {
182+
Type: schema.TypeString,
183+
Optional: true,
184+
ValidateFunc: verify.ValidateEnum([]string{"ENABLED", "PAUSED", ""}),
185+
Description: `Optional. Flag indicating if the volume has tiering policy enable/pause. Default is PAUSED. Default value: "PAUSED" Possible values: ["ENABLED", "PAUSED"]`,
186+
Default: "PAUSED",
187+
},
188+
},
189+
},
190+
},
168191
"volume_id": {
169192
Type: schema.TypeString,
170193
Computed: true,
@@ -1096,6 +1119,13 @@ func expandNetappVolumeReplicationDestinationVolumeParameters(v interface{}, d t
10961119
transformed["description"] = transformedDescription
10971120
}
10981121

1122+
transformedTieringPolicy, err := expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicy(original["tiering_policy"], d, config)
1123+
if err != nil {
1124+
return nil, err
1125+
} else if val := reflect.ValueOf(transformedTieringPolicy); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1126+
transformed["tieringPolicy"] = transformedTieringPolicy
1127+
}
1128+
10991129
return transformed, nil
11001130
}
11011131

@@ -1115,6 +1145,40 @@ func expandNetappVolumeReplicationDestinationVolumeParametersDescription(v inter
11151145
return v, nil
11161146
}
11171147

1148+
func expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1149+
l := v.([]interface{})
1150+
if len(l) == 0 || l[0] == nil {
1151+
return nil, nil
1152+
}
1153+
raw := l[0]
1154+
original := raw.(map[string]interface{})
1155+
transformed := make(map[string]interface{})
1156+
1157+
transformedCoolingThresholdDays, err := expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicyCoolingThresholdDays(original["cooling_threshold_days"], d, config)
1158+
if err != nil {
1159+
return nil, err
1160+
} else if val := reflect.ValueOf(transformedCoolingThresholdDays); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1161+
transformed["coolingThresholdDays"] = transformedCoolingThresholdDays
1162+
}
1163+
1164+
transformedTierAction, err := expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicyTierAction(original["tier_action"], d, config)
1165+
if err != nil {
1166+
return nil, err
1167+
} else if val := reflect.ValueOf(transformedTierAction); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1168+
transformed["tierAction"] = transformedTierAction
1169+
}
1170+
1171+
return transformed, nil
1172+
}
1173+
1174+
func expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicyCoolingThresholdDays(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1175+
return v, nil
1176+
}
1177+
1178+
func expandNetappVolumeReplicationDestinationVolumeParametersTieringPolicyTierAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1179+
return v, nil
1180+
}
1181+
11181182
func expandNetappVolumeReplicationDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11191183
return v, nil
11201184
}

google-beta/services/netapp/resource_netapp_volume_replication_generated_meta.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ fields:
1313
- field: 'destination_volume_parameters.description'
1414
- field: 'destination_volume_parameters.share_name'
1515
- field: 'destination_volume_parameters.storage_pool'
16+
- field: 'destination_volume_parameters.tiering_policy.cooling_threshold_days'
17+
- field: 'destination_volume_parameters.tiering_policy.tier_action'
1618
- field: 'destination_volume_parameters.volume_id'
1719
- field: 'effective_labels'
1820
provider_only: true

google-beta/services/netapp/resource_netapp_volume_replication_generated_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
7777
service_level = "PREMIUM"
7878
capacity_gib = 2048
7979
network = data.google_compute_network.default.id
80+
allow_auto_tiering = true
8081
}
8182
8283
resource "google_netapp_volume" "source_volume" {
@@ -105,6 +106,10 @@ resource "google_netapp_volume_replication" "test_replication" {
105106
# simplifies implementing client failover concepts
106107
share_name = "tf-test-source-volume%{random_suffix}"
107108
description = "This is a replicated volume"
109+
tiering_policy {
110+
cooling_threshold_days = 20
111+
tier_action = "ENABLED"
112+
}
108113
}
109114
# WARNING: Setting delete_destination_volume to true, will delete the
110115
# CURRENT destination volume if the replication is deleted. Omit the field

google-beta/services/netapp/resource_netapp_volume_replication_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
8787
service_level = "PREMIUM"
8888
capacity_gib = 2048
8989
network = data.google_compute_network.default.id
90+
allow_auto_tiering = true
9091
}
9192
9293
resource "google_netapp_volume" "source_volume" {
@@ -114,6 +115,10 @@ resource "google_netapp_volume_replication" "test_replication" {
114115
# simplifies implementing client failover concepts
115116
share_name = "tf-test-source-volume%{random_suffix}"
116117
description = "This is a replicated volume"
118+
tiering_policy {
119+
cooling_threshold_days = 20
120+
tier_action = "ENABLED"
121+
}
117122
}
118123
delete_destination_volume = true
119124
wait_for_mirror = true
@@ -142,6 +147,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
142147
service_level = "PREMIUM"
143148
capacity_gib = 2048
144149
network = data.google_compute_network.default.id
150+
allow_auto_tiering = true
145151
}
146152
147153
resource "google_netapp_volume" "source_volume" {
@@ -174,6 +180,10 @@ resource "google_netapp_volume_replication" "test_replication" {
174180
# simplifies implementing client failover concepts
175181
share_name = "tf-test-source-volume%{random_suffix}"
176182
description = "This is a replicated volume"
183+
tiering_policy {
184+
cooling_threshold_days = 20
185+
tier_action = "ENABLED"
186+
}
177187
}
178188
replication_enabled = true
179189
delete_destination_volume = true
@@ -204,6 +214,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
204214
service_level = "PREMIUM"
205215
capacity_gib = 2048
206216
network = data.google_compute_network.default.id
217+
allow_auto_tiering = true
207218
}
208219
209220
resource "google_netapp_volume" "source_volume" {
@@ -236,6 +247,10 @@ resource "google_netapp_volume_replication" "test_replication" {
236247
# simplifies implementing client failover concepts
237248
share_name = "tf-test-source-volume%{random_suffix}"
238249
description = "This is a replicated volume"
250+
tiering_policy {
251+
cooling_threshold_days = 20
252+
tier_action = "ENABLED"
253+
}
239254
}
240255
replication_enabled = false
241256
delete_destination_volume = true
@@ -266,6 +281,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
266281
service_level = "PREMIUM"
267282
capacity_gib = 2048
268283
network = data.google_compute_network.default.id
284+
allow_auto_tiering = true
269285
}
270286
271287
resource "google_netapp_volume" "source_volume" {
@@ -298,6 +314,10 @@ resource "google_netapp_volume_replication" "test_replication" {
298314
# simplifies implementing client failover concepts
299315
share_name = "tf-test-source-volume%{random_suffix}"
300316
description = "This is a replicated volume"
317+
tiering_policy {
318+
cooling_threshold_days = 20
319+
tier_action = "ENABLED"
320+
}
301321
}
302322
replication_enabled = true
303323
delete_destination_volume = true

website/docs/r/netapp_volume.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Possible values: DEFAULT, FORCE.
360360

361361
* `cooling_threshold_days` -
362362
(Optional)
363-
Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 7-183.
363+
Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 2-183.
364364
Default is 31.
365365

366366
* `tier_action` -

website/docs/r/netapp_volume_replication.html.markdown

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ resource "google_netapp_storage_pool" "destination_pool" {
7070
service_level = "PREMIUM"
7171
capacity_gib = 2048
7272
network = data.google_compute_network.default.id
73+
allow_auto_tiering = true
7374
}
7475
7576
resource "google_netapp_volume" "source_volume" {
@@ -98,6 +99,10 @@ resource "google_netapp_volume_replication" "test_replication" {
9899
# simplifies implementing client failover concepts
99100
share_name = "source-volume"
100101
description = "This is a replicated volume"
102+
tiering_policy {
103+
cooling_threshold_days = 20
104+
tier_action = "ENABLED"
105+
}
101106
}
102107
# WARNING: Setting delete_destination_volume to true, will delete the
103108
# CURRENT destination volume if the replication is deleted. Omit the field
@@ -193,6 +198,25 @@ create/stop/resume operations, set this parameter to true. Default is false.
193198
(Optional)
194199
Description for the destination volume.
195200

201+
* `tiering_policy` -
202+
(Optional)
203+
Tiering policy for the volume.
204+
Structure is [documented below](#nested_destination_volume_parameters_tiering_policy).
205+
206+
207+
<a name="nested_destination_volume_parameters_tiering_policy"></a>The `tiering_policy` block supports:
208+
209+
* `cooling_threshold_days` -
210+
(Optional)
211+
Optional. Time in days to mark the volume's data block as cold and make it eligible for tiering, can be range from 2-183.
212+
Default is 31.
213+
214+
* `tier_action` -
215+
(Optional)
216+
Optional. Flag indicating if the volume has tiering policy enable/pause. Default is PAUSED.
217+
Default value is `PAUSED`.
218+
Possible values are: `ENABLED`, `PAUSED`.
219+
196220
## Attributes Reference
197221

198222
In addition to the arguments listed above, the following computed attributes are exported:

0 commit comments

Comments
 (0)