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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert volume replication attribute in pi volume resource #4059

Merged
merged 3 commits into from Sep 26, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
81 changes: 0 additions & 81 deletions ibm/service/power/resource_ibm_pi_volume.go
Expand Up @@ -109,12 +109,6 @@ func ResourceIBMPIVolume() *schema.Resource {
Description: "List of pvmInstances to base volume anti-affinity policy against; required if requesting anti-affinity and pi_anti_affinity_volumes is not provided",
ConflictsWith: []string{PIAntiAffinityVolumes},
},
helpers.PIReplicationEnabled: {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Indicates if the volume should be replication enabled or not",
},

// Computed Attributes
"volume_id": {
Expand All @@ -138,51 +132,6 @@ func ResourceIBMPIVolume() *schema.Resource {
Computed: true,
Description: "WWN Of the volume",
},
"auxiliary": {
Type: schema.TypeBool,
Computed: true,
Description: "true if volume is auxiliary otherwise false",
},
"consistency_group_name": {
Type: schema.TypeString,
Computed: true,
Description: "Consistency Group Name if volume is a part of volume group",
},
"group_id": {
Type: schema.TypeString,
Computed: true,
Description: "Volume Group ID",
},
"replication_type": {
Type: schema.TypeString,
Computed: true,
Description: "Replication type(metro,global)",
},
"replication_status": {
Type: schema.TypeString,
Computed: true,
Description: "Replication status of a volume",
},
"mirroring_state": {
Type: schema.TypeString,
Computed: true,
Description: "Mirroring state for replication enabled volume",
},
"primary_role": {
Type: schema.TypeString,
Computed: true,
Description: "Indicates whether master/aux volume is playing the primary role",
},
"aux_volume_name": {
Type: schema.TypeString,
Computed: true,
Description: "Indicates auxiliary volume name",
},
"master_volume_name": {
Type: schema.TypeString,
Computed: true,
Description: "Indicates master volume name",
},
},
}
}
Expand Down Expand Up @@ -229,10 +178,6 @@ func resourceIBMPIVolumeCreate(ctx context.Context, d *schema.ResourceData, meta
volumePool := v.(string)
body.VolumePool = volumePool
}
if v, ok := d.GetOk(helpers.PIReplicationEnabled); ok {
replicationEnabled := v.(bool)
body.ReplicationEnabled = &replicationEnabled
}
if ap, ok := d.GetOk(PIAffinityPolicy); ok {
policy := ap.(string)
body.AffinityPolicy = &policy
Expand Down Expand Up @@ -304,16 +249,6 @@ func resourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta i
if vol.VolumeID != nil {
d.Set("volume_id", vol.VolumeID)
}
d.Set(helpers.PIReplicationEnabled, vol.ReplicationEnabled)
d.Set("auxiliary", vol.Auxiliary)
d.Set("consistency_group_name", vol.ConsistencyGroupName)
d.Set("group_id", vol.GroupID)
d.Set("replication_type", vol.ReplicationType)
d.Set("replication_status", vol.ReplicationStatus)
d.Set("mirroring_state", vol.MirroringState)
d.Set("primary_role", vol.PrimaryRole)
d.Set("master_volume_name", vol.MasterVolumeName)
d.Set("aux_volume_name", vol.AuxVolumeName)
if vol.DeleteOnTermination != nil {
d.Set("delete_on_termination", vol.DeleteOnTermination)
}
Expand Down Expand Up @@ -356,22 +291,6 @@ func resourceIBMPIVolumeUpdate(ctx context.Context, d *schema.ResourceData, meta
return diag.FromErr(err)
}

if d.HasChange(helpers.PIReplicationEnabled) {
replicationEnabled := d.Get(helpers.PIReplicationEnabled).(bool)
volActionBody := models.VolumeAction{
ReplicationEnabled: &replicationEnabled,
}

err = client.VolumeAction(volumeID, &volActionBody)
if err != nil {
return diag.FromErr(err)
}
_, err = isWaitForIBMPIVolumeAvailable(ctx, client, volumeID, d.Timeout(schema.TimeoutUpdate))
if err != nil {
return diag.FromErr(err)
}
}

return resourceIBMPIVolumeRead(ctx, d, meta)
}

Expand Down
57 changes: 0 additions & 57 deletions ibm/service/power/resource_ibm_pi_volume_test.go
Expand Up @@ -160,60 +160,3 @@ func testAccCheckIBMPIVolumePoolConfig(name string) string {
}
`, name, acc.Pi_cloud_instance_id)
}

//TestAccIBMPIVolumeGRS test the volume replication feature which is part of global replication service(GRS)
func TestAccIBMPIVolumeGRS(t *testing.T) {
name := fmt.Sprintf("tf-pi-volume-%d", acctest.RandIntRange(10, 100))
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPIVolumeDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIVolumeGRSConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIVolumeExists("ibm_pi_volume.power_volume"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_volume_name", name),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_replication_enabled", "true"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "replication_type", "global"),
),
},
{
Config: testAccCheckIBMPIVolumeGRSUpdateConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIVolumeExists("ibm_pi_volume.power_volume"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_volume_name", name),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_replication_enabled", "false"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "replication_type", ""),
),
},
},
})
}

func testAccCheckIBMPIVolumeGRSConfig(name string) string {
return testAccCheckIBMPIVolumeGRSBasicConfig(name, acc.Pi_cloud_instance_id, acc.PiStoragePool, true)
}

func testAccCheckIBMPIVolumeGRSUpdateConfig(name string) string {
return testAccCheckIBMPIVolumeGRSBasicConfig(name, acc.Pi_cloud_instance_id, acc.PiStoragePool, false)
}

func testAccCheckIBMPIVolumeGRSBasicConfig(name, piCloudInstanceId, piStoragePool string, replicationEnabled bool) string {
return fmt.Sprintf(`
resource "ibm_pi_volume" "power_volume"{
pi_volume_size = 20
pi_volume_name = "%[1]s"
pi_volume_pool = "%[3]s"
pi_volume_shareable = true
pi_cloud_instance_id = "%[2]s"
pi_replication_enabled = %[4]v
}
`, name, piCloudInstanceId, piStoragePool, replicationEnabled)
}
10 changes: 0 additions & 10 deletions website/docs/r/pi_volume.html.markdown
Expand Up @@ -55,7 +55,6 @@ Review the argument references that you can specify for your resource.
- `pi_anti_affinity_instances` - (Optional, String) List of pvmInstances to base volume anti-affinity policy against; required if requesting `anti-affinity` and `pi_anti_affinity_volumes` is not provided.
- `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` - (Opttional, Bool) Indicates if the volume should be replication enabled or not.
- `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_volume_type` and `pi_affinity_policy` values will be ignored.
- `pi_volume_shareable` - (Required, Bool) If set to **true**, the volume can be shared across Power Systems Virtual Server instances. If set to **false**, you can attach it only to one instance.
Expand All @@ -65,17 +64,8 @@ Review the argument references that you can specify for your resource.
## Attribute reference
In addition to all argument reference list, you can access the following attribute reference after your resource is created.

- `auxiliary` - (Bool) Indicates if the volume is auxiliary or not.
- `aux_volume_name` - (String) The auxiliary volume name.
- `consistency_group_name` - (String) The consistency group name if volume is a part of volume group.
- `delete_on_termination` - (Bool) Indicates if the volume should be deleted when the server terminates.
- `group_id` - (String) The volume group id in which the volume belongs.
- `id` - (String) The unique identifier of the volume. The ID is composed of `<power_instance_id>/<volume_id>`.
- `master_volume_name` - (String) The master volume name.
- `mirroring_state` - (String) The 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_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.
- `wwn` - (String) The world wide name of the volume.
Expand Down