Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GRS Attributes/Arguments to pi_volume resource #5668

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const (
Arg_Remove = "pi_remove"
Arg_Replicants = "pi_replicants"
Arg_ReplicationEnabled = "pi_replication_enabled"
Arg_ReplicationSites = "pi_replication_sites"
Arg_ReplicationPolicy = "pi_replication_policy"
Arg_ReplicationScheme = "pi_replication_scheme"
Arg_ResourceGroupID = "pi_resource_group_id"
Expand Down
22 changes: 22 additions & 0 deletions ibm/service/power/resource_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ func ResourceIBMPIVolume() *schema.Resource {
Optional: true,
Type: schema.TypeBool,
},
Arg_ReplicationSites: {
Description: "List of replication sites for volume replication.",
Elem: &schema.Schema{Type: schema.TypeString},
ForceNew: true,
Optional: true,
Set: schema.HashString,
Type: schema.TypeSet,
},
Arg_UserTags: {
Description: "The user tags attached to this resource.",
Elem: &schema.Schema{Type: schema.TypeString},
Expand Down Expand Up @@ -183,6 +191,12 @@ func ResourceIBMPIVolume() *schema.Resource {
Description: "The replication status of the volume.",
Type: schema.TypeString,
},
Attr_ReplicationSites: {
Computed: true,
Description: "List of replication sites for volume replication.",
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeList,
},
Attr_ReplicationType: {
Computed: true,
Description: "The replication type of the volume 'metro' or 'global'.",
Expand Down Expand Up @@ -252,6 +266,13 @@ func resourceIBMPIVolumeCreate(ctx context.Context, d *schema.ResourceData, meta
replicationEnabled := v.(bool)
body.ReplicationEnabled = &replicationEnabled
}
if v, ok := d.GetOk(Arg_ReplicationSites); ok {
if d.Get(Arg_ReplicationEnabled).(bool) {
body.ReplicationSites = flex.FlattenSet(v.(*schema.Set))
} else {
return diag.Errorf("Replication (%s) must be enabled if replication sites are specified.", Arg_ReplicationEnabled)
}
}
if ap, ok := d.GetOk(Arg_AffinityPolicy); ok {
policy := ap.(string)
body.AffinityPolicy = &policy
Expand Down Expand Up @@ -355,6 +376,7 @@ func resourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta i
d.Set(Attr_MirroringState, vol.MirroringState)
d.Set(Attr_PrimaryRole, vol.PrimaryRole)
d.Set(Arg_ReplicationEnabled, vol.ReplicationEnabled)
d.Set(Attr_ReplicationSites, vol.ReplicationSites)
d.Set(Attr_ReplicationStatus, vol.ReplicationStatus)
d.Set(Attr_ReplicationType, vol.ReplicationType)
d.Set(Attr_VolumeStatus, vol.State)
Expand Down
5 changes: 5 additions & 0 deletions website/docs/r/pi_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Review the argument references that you can specify for your resource.
- `pi_anti_affinity_volumes`- (Optional, String) List of volumes to base volume anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_instances` is not provided.
- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.
- `pi_replication_enabled` - (Optional, Boolean) Indicates if the volume should be replication enabled or not.

**Note:** `replication_sites` will be populated automatically with default sites if set to true and sites are not specified.

- `pi_replication_sites` - (Optional, List) List of replication sites for volume replication. Must set `pi_replication_enabled` to true to use.
- `pi_user_tags` - (Optional, List) The user tags attached to this resource.
- `pi_volume_name` - (Required, String) The name of the volume.
- `pi_volume_pool` - (Optional, String) Volume pool where the volume will be created; if provided then `pi_affinity_policy` values will be ignored.
Expand All @@ -82,6 +86,7 @@ In addition to all argument reference list, you can access the following attribu
- `mirroring_state` - (String) Mirroring state for replication enabled volume.
- `primary_role` - (String) Indicates whether `master`/`auxiliary` volume is playing the primary role.
- `replication_status` - (String) The replication status of the volume.
- `replication_sites` - (List) List of replication sites for volume replication.
- `replication_type` - (String) The replication type of the volume `metro` or `global`.
- `volume_id` - (String) The unique identifier of the volume.
- `volume_status` - (String) The status of the volume.
Expand Down
Loading