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

Adding Flexible IOPS #4992

Merged
merged 6 commits into from
Dec 18, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 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-20231204080125-462fa9e436bc
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20231116055201-2a84da7b9bd6
github.com/IBM-Cloud/power-go-client v1.5.4
github.com/IBM-Cloud/power-go-client v1.5.7
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 All @@ -24,7 +24,7 @@ require (
github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta
github.com/IBM/keyprotect-go-client v0.12.2
github.com/IBM/networking-go-sdk v0.42.2
github.com/IBM/platform-services-go-sdk v0.54.0
github.com/IBM/platform-services-go-sdk v0.55.0
github.com/IBM/project-go-sdk v0.1.4
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/scc-go-sdk/v5 v5.1.3
Expand All @@ -38,10 +38,10 @@ require (
github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105
github.com/apparentlymart/go-cidr v1.1.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-openapi/strfmt v0.21.7
github.com/go-openapi/strfmt v0.21.9
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.0
github.com/google/uuid v1.4.0
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
Expand Down Expand Up @@ -100,17 +100,17 @@ require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // 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/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // 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/spec v0.20.11 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/validate v0.22.1 // indirect
github.com/go-openapi/validate v0.22.3 // 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 @@ -202,7 +202,7 @@ require (
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
go.mongodb.org/mongo-driver v1.13.1 // 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
Expand Down Expand Up @@ -241,4 +241,4 @@ exclude (
github.com/kubernetes-incubator/external-storage v0.20.4-openstorage-rc2
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/client-go v12.0.0+incompatible
)
)
53 changes: 23 additions & 30 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 pi_storage_type is not provided the storage type will default to 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 pi_storage_pool_affinity 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 testAccCheckIBMPIInstanceUserDataConfig(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 disk type is not provided the disk type will default to 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. Used only when importing an image from cloud storage.
- `pi_image_storage_type` - (Optional, String) Type of storage; If not provided the storage type will default to 'tier3'. Used only when importing an image from cloud storage.

## 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 storage type is not provided the storage type will default to `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 diskType is not provided the disk type will default to `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