Skip to content

Commit

Permalink
Added some use case scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
dhirendersingh19 committed Jan 3, 2024
1 parent 4b661c5 commit 512b6fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 4 additions & 0 deletions ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 4 additions & 6 deletions ibm/service/power/resource_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions ibm/service/power/resource_ibm_pi_volume_clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/power/resource_ibm_pi_volume_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 512b6fc

Please sign in to comment.