diff --git a/ibm/flex/structures.go b/ibm/flex/structures.go index f4370020f9..aaa54458d1 100644 --- a/ibm/flex/structures.go +++ b/ibm/flex/structures.go @@ -1171,6 +1171,10 @@ func PtrToString(s string) *string { return &s } +func PtrToBool(b bool) *bool { + return &b +} + func IntValue(i64 *int64) (i int) { if i64 != nil { i = int(*i64) diff --git a/ibm/service/power/resource_ibm_pi_volume.go b/ibm/service/power/resource_ibm_pi_volume.go index c80b9c2790..63f8d4e1f0 100644 --- a/ibm/service/power/resource_ibm_pi_volume.go +++ b/ibm/service/power/resource_ibm_pi_volume.go @@ -364,14 +364,12 @@ func resourceIBMPIVolumeUpdate(ctx context.Context, d *schema.ResourceData, meta } if d.HasChanges(helpers.PIReplicationEnabled, helpers.PIVolumeType) { - var replicationEnabled bool volActionBody := models.VolumeAction{} - if v, ok := d.GetOk(helpers.PIReplicationEnabled); ok { - replicationEnabled = v.(bool) - volActionBody.ReplicationEnabled = &replicationEnabled + if d.HasChange(helpers.PIReplicationEnabled) { + volActionBody.ReplicationEnabled = flex.PtrToBool(d.Get(helpers.PIReplicationEnabled).(bool)) } - if v, ok := d.GetOk(helpers.PIVolumeType); ok { - volActionBody.TargetStorageTier = flex.PtrToString(v.(string)) + if d.HasChange(helpers.PIVolumeType) { + volActionBody.TargetStorageTier = flex.PtrToString(d.Get(helpers.PIVolumeType).(string)) } err = client.VolumeAction(volumeID, &volActionBody) if err != nil { diff --git a/ibm/service/power/resource_ibm_pi_volume_clone.go b/ibm/service/power/resource_ibm_pi_volume_clone.go index 20b6e68ed6..05a64f7d16 100644 --- a/ibm/service/power/resource_ibm_pi_volume_clone.go +++ b/ibm/service/power/resource_ibm_pi_volume_clone.go @@ -111,8 +111,7 @@ func resourceIBMPIVolumeCloneCreate(ctx context.Context, d *schema.ResourceData, } if !d.GetRawConfig().GetAttr(helpers.PIReplicationEnabled).IsNull() { - value := d.Get(helpers.PIReplicationEnabled).(bool) - body.TargetReplicationEnabled = &value + body.TargetReplicationEnabled = flex.PtrToBool(d.Get(helpers.PIReplicationEnabled).(bool)) } client := st.NewIBMPICloneVolumeClient(ctx, sess, cloudInstanceID) diff --git a/ibm/service/power/resource_ibm_pi_volume_group_test.go b/ibm/service/power/resource_ibm_pi_volume_group_test.go index 5b05f8a096..5d55c1981b 100644 --- a/ibm/service/power/resource_ibm_pi_volume_group_test.go +++ b/ibm/service/power/resource_ibm_pi_volume_group_test.go @@ -146,9 +146,9 @@ func volumeConfig(name, cloud_instance_id string) string { pi_volume_size = 2 pi_volume_name = "%[1]s-${count.index}" pi_volume_shareable = true - pi_volume_pool = "Tier1-Flash-1" + pi_volume_pool = "%[3]s" pi_cloud_instance_id = "%[2]s" pi_replication_enabled = true } - `, name, cloud_instance_id) + `, name, cloud_instance_id, acc.PiStoragePool) }