Skip to content

Commit 8c51c0c

Browse files
Add Bidirectional Snapmirror fields to Volume and Replication (#15217) (#10813)
[upstream:9b164195983786204ba7eb28a73e50f9322b8082] Signed-off-by: Modular Magician <[email protected]>
1 parent d39902b commit 8c51c0c

File tree

7 files changed

+152
-0
lines changed

7 files changed

+152
-0
lines changed

.changelog/15217.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```release-note:enhancement
2+
netapp: added additional fields `replication_schedule`, `hybrid_replication_type`, `large_volume_constituent_count` to `hybrid_replication_parameters` field in `google_netapp_volume` resource
3+
```
4+
```release-note:enhancement
5+
netapp: added `hybrid_replication_user_commands` field with subfield `commands` to `google_netapp_volume_replication` resource
6+
```

google-beta/services/netapp/resource_netapp_volume.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,24 @@ Format: 'projects/{{projectId}}/locations/{{location}}/backupVaults/{{backupVaul
235235
Optional: true,
236236
Description: `Optional. Description of the replication.`,
237237
},
238+
"hybrid_replication_type": {
239+
Type: schema.TypeString,
240+
Optional: true,
241+
ValidateFunc: verify.ValidateEnum([]string{"MIGRATION", "CONTINUOUS_REPLICATION", "ONPREM_REPLICATION", "REVERSE_ONPREM_REPLICATION", ""}),
242+
Description: `Optional. Type of the volume's hybrid replication. Possible values: ["MIGRATION", "CONTINUOUS_REPLICATION", "ONPREM_REPLICATION", "REVERSE_ONPREM_REPLICATION"]`,
243+
},
238244
"labels": {
239245
Type: schema.TypeMap,
240246
Optional: true,
241247
Description: `Optional. Labels to be added to the replication as the key value pairs.
242248
An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.`,
243249
Elem: &schema.Schema{Type: schema.TypeString},
244250
},
251+
"large_volume_constituent_count": {
252+
Type: schema.TypeInt,
253+
Optional: true,
254+
Description: `Optional. Constituent volume count for large volume.`,
255+
},
245256
"peer_cluster_name": {
246257
Type: schema.TypeString,
247258
Optional: true,
@@ -270,6 +281,12 @@ An object containing a list of "key": value pairs. Example: { "name": "wrench",
270281
Optional: true,
271282
Description: `Required. Desired name for the replication of this volume.`,
272283
},
284+
"replication_schedule": {
285+
Type: schema.TypeString,
286+
Optional: true,
287+
ValidateFunc: verify.ValidateEnum([]string{"EVERY_10_MINUTES", "HOURLY", "DAILY", ""}),
288+
Description: `Optional. Replication Schedule for the replication created. Possible values: ["EVERY_10_MINUTES", "HOURLY", "DAILY"]`,
289+
},
273290
},
274291
},
275292
},
@@ -2018,6 +2035,12 @@ func flattenNetappVolumeHybridReplicationParameters(v interface{}, d *schema.Res
20182035
flattenNetappVolumeHybridReplicationParametersDescription(original["description"], d, config)
20192036
transformed["labels"] =
20202037
flattenNetappVolumeHybridReplicationParametersLabels(original["labels"], d, config)
2038+
transformed["replication_schedule"] =
2039+
flattenNetappVolumeHybridReplicationParametersReplicationSchedule(original["replicationSchedule"], d, config)
2040+
transformed["hybrid_replication_type"] =
2041+
flattenNetappVolumeHybridReplicationParametersHybridReplicationType(original["hybridReplicationType"], d, config)
2042+
transformed["large_volume_constituent_count"] =
2043+
flattenNetappVolumeHybridReplicationParametersLargeVolumeConstituentCount(original["largeVolumeConstituentCount"], d, config)
20212044
return []interface{}{transformed}
20222045
}
20232046
func flattenNetappVolumeHybridReplicationParametersReplication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -2052,6 +2075,31 @@ func flattenNetappVolumeHybridReplicationParametersLabels(v interface{}, d *sche
20522075
return v
20532076
}
20542077

2078+
func flattenNetappVolumeHybridReplicationParametersReplicationSchedule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2079+
return v
2080+
}
2081+
2082+
func flattenNetappVolumeHybridReplicationParametersHybridReplicationType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2083+
return v
2084+
}
2085+
2086+
func flattenNetappVolumeHybridReplicationParametersLargeVolumeConstituentCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
2087+
// Handles the string fixed64 format
2088+
if strVal, ok := v.(string); ok {
2089+
if intVal, err := tpgresource.StringToFixed64(strVal); err == nil {
2090+
return intVal
2091+
}
2092+
}
2093+
2094+
// number values are represented as float64
2095+
if floatVal, ok := v.(float64); ok {
2096+
intVal := int(floatVal)
2097+
return intVal
2098+
}
2099+
2100+
return v // let terraform core handle it otherwise
2101+
}
2102+
20552103
func flattenNetappVolumeThroughputMibps(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
20562104
return v
20572105
}
@@ -2772,6 +2820,27 @@ func expandNetappVolumeHybridReplicationParameters(v interface{}, d tpgresource.
27722820
transformed["labels"] = transformedLabels
27732821
}
27742822

2823+
transformedReplicationSchedule, err := expandNetappVolumeHybridReplicationParametersReplicationSchedule(original["replication_schedule"], d, config)
2824+
if err != nil {
2825+
return nil, err
2826+
} else if val := reflect.ValueOf(transformedReplicationSchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2827+
transformed["replicationSchedule"] = transformedReplicationSchedule
2828+
}
2829+
2830+
transformedHybridReplicationType, err := expandNetappVolumeHybridReplicationParametersHybridReplicationType(original["hybrid_replication_type"], d, config)
2831+
if err != nil {
2832+
return nil, err
2833+
} else if val := reflect.ValueOf(transformedHybridReplicationType); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2834+
transformed["hybridReplicationType"] = transformedHybridReplicationType
2835+
}
2836+
2837+
transformedLargeVolumeConstituentCount, err := expandNetappVolumeHybridReplicationParametersLargeVolumeConstituentCount(original["large_volume_constituent_count"], d, config)
2838+
if err != nil {
2839+
return nil, err
2840+
} else if val := reflect.ValueOf(transformedLargeVolumeConstituentCount); val.IsValid() && !tpgresource.IsEmptyValue(val) {
2841+
transformed["largeVolumeConstituentCount"] = transformedLargeVolumeConstituentCount
2842+
}
2843+
27752844
return transformed, nil
27762845
}
27772846

@@ -2814,6 +2883,18 @@ func expandNetappVolumeHybridReplicationParametersLabels(v interface{}, d tpgres
28142883
return m, nil
28152884
}
28162885

2886+
func expandNetappVolumeHybridReplicationParametersReplicationSchedule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2887+
return v, nil
2888+
}
2889+
2890+
func expandNetappVolumeHybridReplicationParametersHybridReplicationType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2891+
return v, nil
2892+
}
2893+
2894+
func expandNetappVolumeHybridReplicationParametersLargeVolumeConstituentCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
2895+
return v, nil
2896+
}
2897+
28172898
func expandNetappVolumeThroughputMibps(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
28182899
return v, nil
28192900
}

google-beta/services/netapp/resource_netapp_volume_generated_meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ fields:
3535
- field: 'hot_tier_size_used_gib'
3636
- field: 'hybrid_replication_parameters.cluster_location'
3737
- field: 'hybrid_replication_parameters.description'
38+
- field: 'hybrid_replication_parameters.hybrid_replication_type'
3839
- field: 'hybrid_replication_parameters.labels'
40+
- field: 'hybrid_replication_parameters.large_volume_constituent_count'
3941
- field: 'hybrid_replication_parameters.peer_cluster_name'
4042
- field: 'hybrid_replication_parameters.peer_ip_addresses'
4143
- field: 'hybrid_replication_parameters.peer_svm_name'
4244
- field: 'hybrid_replication_parameters.peer_volume_name'
4345
- field: 'hybrid_replication_parameters.replication'
46+
- field: 'hybrid_replication_parameters.replication_schedule'
4447
- field: 'kerberos_enabled'
4548
- field: 'kms_config'
4649
- field: 'labels'

google-beta/services/netapp/resource_netapp_volume_replication.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,23 @@ Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3,
281281
Computed: true,
282282
Description: `Hybrid replication type.`,
283283
},
284+
"hybrid_replication_user_commands": {
285+
Type: schema.TypeList,
286+
Computed: true,
287+
Description: `Copy pastable snapmirror commands to be executed on onprem cluster by the customer.`,
288+
Elem: &schema.Resource{
289+
Schema: map[string]*schema.Schema{
290+
"commands": {
291+
Type: schema.TypeList,
292+
Computed: true,
293+
Description: `List of commands to be executed by the customer.`,
294+
Elem: &schema.Schema{
295+
Type: schema.TypeString,
296+
},
297+
},
298+
},
299+
},
300+
},
284301
"mirror_state": {
285302
Type: schema.TypeString,
286303
Computed: true,
@@ -620,6 +637,9 @@ func resourceNetappVolumeReplicationRead(d *schema.ResourceData, meta interface{
620637
if err := d.Set("hybrid_peering_details", flattenNetappVolumeReplicationHybridPeeringDetails(res["hybridPeeringDetails"], d, config)); err != nil {
621638
return fmt.Errorf("Error reading VolumeReplication: %s", err)
622639
}
640+
if err := d.Set("hybrid_replication_user_commands", flattenNetappVolumeReplicationHybridReplicationUserCommands(res["hybridReplicationUserCommands"], d, config)); err != nil {
641+
return fmt.Errorf("Error reading VolumeReplication: %s", err)
642+
}
623643
if err := d.Set("terraform_labels", flattenNetappVolumeReplicationTerraformLabels(res["labels"], d, config)); err != nil {
624644
return fmt.Errorf("Error reading VolumeReplication: %s", err)
625645
}
@@ -1172,6 +1192,23 @@ func flattenNetappVolumeReplicationHybridPeeringDetailsPeerSvmName(v interface{}
11721192
return v
11731193
}
11741194

1195+
func flattenNetappVolumeReplicationHybridReplicationUserCommands(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1196+
if v == nil {
1197+
return nil
1198+
}
1199+
original := v.(map[string]interface{})
1200+
if len(original) == 0 {
1201+
return nil
1202+
}
1203+
transformed := make(map[string]interface{})
1204+
transformed["commands"] =
1205+
flattenNetappVolumeReplicationHybridReplicationUserCommandsCommands(original["commands"], d, config)
1206+
return []interface{}{transformed}
1207+
}
1208+
func flattenNetappVolumeReplicationHybridReplicationUserCommandsCommands(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1209+
return v
1210+
}
1211+
11751212
func flattenNetappVolumeReplicationTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
11761213
if v == nil {
11771214
return v

google-beta/services/netapp/resource_netapp_volume_replication_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fields:
2929
- field: 'hybrid_peering_details.peer_volume_name'
3030
- field: 'hybrid_peering_details.subnet_ip'
3131
- field: 'hybrid_replication_type'
32+
- field: 'hybrid_replication_user_commands.commands'
3233
- field: 'labels'
3334
- field: 'location'
3435
provider_only: true

website/docs/r/netapp_volume.html.markdown

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,20 @@ Possible values: DEFAULT, FORCE.
425425
Optional. Labels to be added to the replication as the key value pairs.
426426
An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.
427427

428+
* `replication_schedule` -
429+
(Optional)
430+
Optional. Replication Schedule for the replication created.
431+
Possible values are: `EVERY_10_MINUTES`, `HOURLY`, `DAILY`.
432+
433+
* `hybrid_replication_type` -
434+
(Optional)
435+
Optional. Type of the volume's hybrid replication.
436+
Possible values are: `MIGRATION`, `CONTINUOUS_REPLICATION`, `ONPREM_REPLICATION`, `REVERSE_ONPREM_REPLICATION`.
437+
438+
* `large_volume_constituent_count` -
439+
(Optional)
440+
Optional. Constituent volume count for large volume.
441+
428442
## Attributes Reference
429443

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

website/docs/r/netapp_volume_replication.html.markdown

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ In addition to the arguments listed above, the following computed attributes are
263263
HybridPeeringDetails contains details about the hybrid peering.
264264
Structure is [documented below](#nested_hybrid_peering_details).
265265

266+
* `hybrid_replication_user_commands` -
267+
Copy pastable snapmirror commands to be executed on onprem cluster by the customer.
268+
Structure is [documented below](#nested_hybrid_replication_user_commands).
269+
266270
* `terraform_labels` -
267271
The combination of labels configured directly on the resource
268272
and default labels configured on the provider.
@@ -338,6 +342,12 @@ In addition to the arguments listed above, the following computed attributes are
338342
(Output)
339343
Optional. Name of the user's local source vserver svm to be peered with the destination vserver svm.
340344

345+
<a name="nested_hybrid_replication_user_commands"></a>The `hybrid_replication_user_commands` block contains:
346+
347+
* `commands` -
348+
(Output)
349+
List of commands to be executed by the customer.
350+
341351
## Timeouts
342352

343353
This resource provides the following

0 commit comments

Comments
 (0)