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

Flexible IOPs Changes #10

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20231017073329-75ebe90c98ba
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230822142550-30562e113de9
github.com/IBM-Cloud/power-go-client v1.2.4
github.com/IBM-Cloud/power-go-client v1.5.2
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down Expand Up @@ -97,15 +97,16 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.1 // indirect
github.com/go-openapi/runtime v0.23.0 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/validate v0.20.3 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/spec v0.20.8 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
Expand Down Expand Up @@ -198,6 +199,8 @@ require (
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.11.0 // indirect
go.mongodb.org/mongo-driver v1.11.6 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
Expand Down
92 changes: 26 additions & 66 deletions go.sum

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions ibm/service/power/data_source_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ func DataSourceIBMPIVolume() *schema.Resource {
Computed: true,
Description: "Indicates master volume name",
},
"io_throttle_rate": {
Type: schema.TypeString,
Computed: true,
Description: "Amount of iops assigned to the volume",
},
},
}
}
Expand Down Expand Up @@ -145,6 +150,7 @@ func dataSourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta
d.Set("primary_role", volumedata.PrimaryRole)
d.Set("auxiliary_volume_name", volumedata.AuxVolumeName)
d.Set("master_volume_name", volumedata.MasterVolumeName)
d.Set("io_throttle_rate", volumedata.IoThrottleRate)

return nil
}
4 changes: 2 additions & 2 deletions ibm/service/power/resource_ibm_pi_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ func ResourceIBMPIImage() *schema.Resource {
helpers.PIImageStorageType: {
Type: schema.TypeString,
Optional: true,
Description: "Type of storage",
Description: "Type of storage; If not specified, default is tier3",
ForceNew: true,
},
helpers.PIImageStoragePool: {
Type: schema.TypeString,
Optional: true,
Description: "Storage pool where the image will be loaded, if provided then pi_image_storage_type and pi_affinity_policy will be ignored",
Description: "Storage pool where the image will be loaded, if provided then pi_affinity_policy will be ignored",
ForceNew: true,
},
PIAffinityPolicy: {
Expand Down
4 changes: 2 additions & 2 deletions ibm/service/power/resource_ibm_pi_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func ResourceIBMPIInstance() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Storage type for server deployment",
Description: "Storage type for server deployment; If not specified, default is tier3",
},
PIInstanceStoragePool: {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Storage Pool for server deployment; if provided then pi_affinity_policy and pi_storage_type will be ignored",
Description: "Storage Pool for server deployment; if provided then storageAffinity will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage pool for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage pool the image was created in",
},
PIAffinityPolicy: {
Type: schema.TypeString,
Expand Down
4 changes: 3 additions & 1 deletion ibm/service/power/resource_ibm_pi_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func testAccCheckIBMPIInstanceConfig(name, instanceHealthStatus string) string {
pi_volume_name = "%[2]s"
pi_volume_shareable = true
pi_volume_pool = data.ibm_pi_image.power_image.storage_pool
pi_volume_type = "%[6]s"
pi_cloud_instance_id = "%[1]s"
}
resource "ibm_pi_instance" "power_instance" {
Expand All @@ -53,13 +54,14 @@ func testAccCheckIBMPIInstanceConfig(name, instanceHealthStatus string) string {
pi_sys_type = "s922"
pi_cloud_instance_id = "%[1]s"
pi_storage_pool = data.ibm_pi_image.power_image.storage_pool
pi_storage_type = "%[6]s"
pi_health_status = "%[5]s"
pi_volume_ids = [ibm_pi_volume.power_volume.volume_id]
pi_network {
network_id = data.ibm_pi_network.power_networks.id
}
}
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus)
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, acc.PiStorageType)
}

func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus string) string {
Expand Down
28 changes: 19 additions & 9 deletions ibm/service/power/resource_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func ResourceIBMPIVolume() *schema.Resource {
helpers.PIVolumeShareable: {
Type: schema.TypeBool,
Optional: true,
Description: "Flag to indicate if the volume can be shared across multiple instances?",
Description: "Flag to indicate if the volume can be shared across multiple instances.",
},
helpers.PIVolumeSize: {
Type: schema.TypeFloat,
Expand All @@ -62,16 +62,16 @@ func ResourceIBMPIVolume() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.ValidateAllowedStringValues([]string{"ssd", "standard", "tier1", "tier3"}),
ValidateFunc: validate.ValidateAllowedStringValues([]string{"tier0", "tier1", "tier3", "tier5k"}),
DiffSuppressFunc: flex.ApplyOnce,
Description: "Type of Disk, required if pi_affinity_policy and pi_volume_pool not provided, otherwise ignored",
Description: "Type of disk, If not specified, default is tier3.",
},
helpers.PIVolumePool: {
Type: schema.TypeString,
Optional: true,
Computed: true,
DiffSuppressFunc: flex.ApplyOnce,
Description: "Volume pool where the volume will be created; if provided then pi_volume_type and pi_affinity_policy values will be ignored",
Description: "Volume pool where the volume will be created; if provided then pi_affinity_policy values will be ignored",
},
PIAffinityPolicy: {
Type: schema.TypeString,
Expand Down Expand Up @@ -184,6 +184,11 @@ func ResourceIBMPIVolume() *schema.Resource {
Computed: true,
Description: "Indicates master volume name",
},
"io_throttle_rate": {
Type: schema.TypeString,
Computed: true,
Description: "Amount of iops assigned to the volume",
},
},
}
}
Expand Down Expand Up @@ -320,6 +325,7 @@ func resourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta i
}
d.Set("wwn", vol.Wwn)
d.Set(helpers.PICloudInstanceId, cloudInstanceID)
d.Set("io_throttle_rate", vol.IoThrottleRate)

return nil
}
Expand Down Expand Up @@ -357,12 +363,16 @@ 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,
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 v, ok := d.GetOk(helpers.PIVolumeType); ok {
volActionBody.TargetStorageTier = flex.PtrToString(v.(string))
}

err = client.VolumeAction(volumeID, &volActionBody)
if err != nil {
return diag.FromErr(err)
Expand Down
49 changes: 49 additions & 0 deletions ibm/service/power/resource_ibm_pi_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,55 @@ func testAccCheckIBMPIVolumeGRSBasicConfig(name, piCloudInstanceId, piStoragePoo
pi_volume_shareable = true
pi_cloud_instance_id = "%[2]s"
pi_replication_enabled = %[4]v
pi_volume_type = "tier3"
}
`, name, piCloudInstanceId, piStoragePool, replicationEnabled)
}

// TestAccIBMPIVolumeUpdate test the volume update
func TestAccIBMPIVolumeUpdate(t *testing.T) {
name := fmt.Sprintf("tf-pi-volume-%d", acctest.RandIntRange(10, 100))
sType := acc.PiStorageType // tier 3
sTypeUpdate := "tier1"
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPIVolumeDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIVolumeUpdateStorageConfig(name, sType),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIVolumeExists("ibm_pi_volume.power_volume"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_volume_name", name),
),
},
{
Config: testAccCheckIBMPIVolumeUpdateStorageConfig(name, sTypeUpdate),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIVolumeExists("ibm_pi_volume.power_volume"),
resource.TestCheckResourceAttr(
"ibm_pi_volume.power_volume", "pi_volume_name", name),
resource.TestCheckResourceAttrSet("ibm_pi_volume.power_volume", "pi_volume_type"),
),
},
},
})
}

func testAccCheckIBMPIVolumeUpdateStorageConfig(name, piStorageType string) string {
return testAccCheckIBMPIVolumeUpdateBasicConfig(name, acc.Pi_cloud_instance_id, acc.PiStoragePool, piStorageType)
}

func testAccCheckIBMPIVolumeUpdateBasicConfig(name, piCloudInstanceId, piStoragePool, piStorageType string) 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_volume_type = "%[4]v"
}
`, name, piCloudInstanceId, piStoragePool, piStorageType)
}
1 change: 1 addition & 0 deletions website/docs/d/pi_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ In addition to all argument reference list, you can access the following attribu
- `state` - (String) The state of the volume.
- `volume_pool` - (String) Volume pool, name of storage pool where the volume is located.
- `wwn` - (String) The world wide name of the volume.
- `io_throttle_rate` -(String) Amount of iops assigned to the volume.
5 changes: 2 additions & 3 deletions website/docs/r/pi_image.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ Review the argument references that you can specify for your resource.
- `pi_image_bucket_region` is required with `pi_image_bucket_name`
- `pi_image_secret_key` - (Optional, String, Sensitive) Cloud Object Storage secret key; required for buckets with private access.
- `pi_image_secret_key` is required with `pi_image_access_key`
- `pi_image_storage_pool` - (Optional, String) Storage pool where the image will be loaded, if provided then `pi_image_storage_type` and `pi_affinity_policy` will be ignored.
- `pi_image_storage_type` - (Optional, String) Type of storage. Will be ignored if `pi_image_storage_pool` or `pi_affinity_policy` is provided. If only using `pi_image_storage_type` for storage selection then the storage pool with the most available space will be selected.

- `pi_image_storage_pool` - (Optional, String) Storage pool where the image will be loaded, if provided then `pi_affinity_policy` will be ignored.
- `pi_image_storage_type` - (Optional, String) Type of storage; If not specified, default is tier3.

## Attribute reference
In addition to all argument reference list, you can access the following attribute reference after your resource is created.
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/pi_instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ Review the argument references that you can specify for your resource.
- Required only when creating SAP instances.
- `pi_sap_deployment_type` - (Optional, String) Custom SAP deployment type information (For Internal Use Only).
- `pi_shared_processor_pool` - (Optional, String) The shared processor pool for instance deployment. Conflicts with `pi_sap_profile_id`.
- `pi_storage_pool` - (Optional, String) Storage Pool for server deployment; if provided then `pi_affinity_policy` and `pi_storage_type` will be ignored.
- `pi_storage_pool` - (Optional, String) Storage Pool for server deployment; if provided then `pi_affinity_policy` will be ignored; Only valid when you deploy one of the IBM supplied stock images. Storage pool for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage pool the image was created in.
- `pi_storage_pool_affinity` - (Optional, Bool) Indicates if all volumes attached to the server must reside in the same storage pool. The default value is `true`. To attach data volumes from a different storage pool (mixed storage) set to `false` and use `pi_volume_attach` resource. Once set to `false`, cannot be set back to `true` unless all volumes attached reside in the same storage type and pool.
- `pi_storage_type` - (Optional, String) - Storage type for server deployment. Only valid when you deploy one of the IBM supplied stock images. Storage type for a custom image (an imported image or an image that is created from a VM capture) defaults to the storage type the image was created in
- `pi_storage_type` - (Optional, String) - Storage type for server deployment; If not specified, default is `tier3`.
- `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Only supported value is `vSCSI`.
- `pi_sys_type` - (Optional, String) The type of system on which to create the VM (s922/e880/e980/s1022).
- Supported SAP system types are (e880/e980).
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/pi_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ Review the argument references that you can specify for your resource.
- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.
- `pi_replication_enabled` - (Optional, 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_pool` - (Optional, String) Volume pool where the volume will be created; if provided then `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.
- `pi_volume_size` - (Required, Integer) The size of the volume in gigabytes.
- `pi_volume_type` - (Optional, String) Type of Disk, required if `pi_affinity_policy` and `pi_volume_pool` not provided, otherwise ignored. Supported values are `ssd`, `standard`, `tier1`, and `tier3`.
- `pi_volume_type` - (Optional, String) Type of disk, If not specified, default is `tier3`.

## Attribute reference
In addition to all argument reference list, you can access the following attribute reference after your resource is created.
Expand Down
Loading