Skip to content

Commit

Permalink
Added support for defined_performance changes in is_volume (#5694)
Browse files Browse the repository at this point in the history
* Added support for defined_performance changes in is_volume

* updated volume attachments test cases
  • Loading branch information
ujjwal-ibm authored Oct 18, 2024
1 parent 16d8f92 commit 3c3af9b
Show file tree
Hide file tree
Showing 20 changed files with 1,885 additions and 109 deletions.
6 changes: 3 additions & 3 deletions ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -3039,11 +3039,11 @@ func ResourceVolumeValidate(diff *schema.ResourceDiff) error {
}
}

if profile != "custom" {
if profile != "custom" && profile != "sdp" {
if iops != 0 && diff.NewValueKnown("iops") && diff.HasChange("iops") {
return fmt.Errorf("VolumeError : iops is applicable for only custom volume profiles")
return fmt.Errorf("VolumeError : iops is applicable for only custom/sdp volume profiles")
}
} else {
} else if profile != "sdp" {
if capacity == 0 {
capacity = int64(100)
}
Expand Down
26 changes: 26 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ func DataSourceIBMISVolume() *schema.Resource {
Computed: true,
Description: "Indicates whether a running virtual server instance has an attachment to this volume.",
},
// defined_performance changes
"adjustable_capacity_states": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "The attachment states that support adjustable capacity for this volume.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"adjustable_iops_states": &schema.Schema{
Type: schema.TypeList,
Computed: true,
Description: "The attachment states that support adjustable IOPS for this volume.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
isVolumeAttachmentState: {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -467,6 +484,15 @@ func volumeGet(d *schema.ResourceData, meta interface{}, name string) error {
if vol.HealthState != nil {
d.Set(isVolumeHealthState, *vol.HealthState)
}

if err = d.Set("adjustable_capacity_states", vol.AdjustableCapacityStates); err != nil {
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting adjustable_capacity_states: %s", err), "(Data) ibm_is_volume", "read", "set-adjustable_capacity_states")
}

if err = d.Set("adjustable_iops_states", vol.AdjustableIopsStates); err != nil {
return flex.DiscriminatedTerraformErrorf(err, fmt.Sprintf("Error setting adjustable_iops_states: %s", err), "(Data) ibm_is_volume", "read", "set-adjustable_iops_states")
}

return nil
}

Expand Down
Loading

0 comments on commit 3c3af9b

Please sign in to comment.