From 76f89f4bf169dd153874d8a1f99256e2e829e4c5 Mon Sep 17 00:00:00 2001 From: Axel Ismirlian Date: Fri, 11 Oct 2024 13:08:41 -0500 Subject: [PATCH] Update Storage Connection --- ibm/acctest/acctest.go | 6 ++- .../power/data_source_ibm_pi_instance.go | 6 +++ .../power/data_source_ibm_pi_instances.go | 6 +++ ibm/service/power/ibm_pi_constants.go | 2 + ibm/service/power/resource_ibm_pi_instance.go | 2 +- .../power/resource_ibm_pi_instance_test.go | 50 +++++++++++++++++-- website/docs/d/pi_instance.html.markdown | 1 + website/docs/d/pi_instances.html.markdown | 1 + website/docs/r/pi_instance.html.markdown | 2 +- 9 files changed, 69 insertions(+), 7 deletions(-) diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index e2e6e53a62..e7d3b73350 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -227,6 +227,7 @@ var ( Pi_shared_processor_pool_id string Pi_snapshot_id string Pi_spp_placement_group_id string + Pi_storage_connection string Pi_target_storage_tier string Pi_volume_clone_task_id string Pi_volume_group_id string @@ -1208,7 +1209,10 @@ func init() { Pi_shared_processor_pool_id = "tf-pi-shared-processor-pool" fmt.Println("[WARN] Set the environment variable PI_SHARED_PROCESSOR_POOL_ID for testing ibm_pi_shared_processor_pool resource else it is set to default value 'tf-pi-shared-processor-pool'") } - + Pi_storage_connection = os.Getenv("PI_STORAGE_CONNECTION") + if Pi_storage_connection == "" { + fmt.Println("[WARN] Set the environment variable PI_STORAGE_CONNECTION for testing pi_storage_connection resource else it is empty") + } Pi_target_storage_tier = os.Getenv("PI_TARGET_STORAGE_TIER") if Pi_target_storage_tier == "" { Pi_target_storage_tier = "terraform-test-tier" diff --git a/ibm/service/power/data_source_ibm_pi_instance.go b/ibm/service/power/data_source_ibm_pi_instance.go index 5795286900..95d20b330e 100644 --- a/ibm/service/power/data_source_ibm_pi_instance.go +++ b/ibm/service/power/data_source_ibm_pi_instance.go @@ -200,6 +200,11 @@ func DataSourceIBMPIInstance() *schema.Resource { Description: "The status of the instance.", Type: schema.TypeString, }, + Attr_StorageConnection: { + Computed: true, + Description: "The storage connection type.", + Type: schema.TypeString, + }, Attr_StoragePool: { Computed: true, Description: "The storage Pool where server is deployed.", @@ -278,6 +283,7 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m d.Set(Attr_SharedProcessorPool, powervmdata.SharedProcessorPool) d.Set(Attr_SharedProcessorPoolID, powervmdata.SharedProcessorPoolID) d.Set(Attr_Status, powervmdata.Status) + d.Set(Attr_StorageConnection, powervmdata.StorageConnection) d.Set(Attr_StorageType, powervmdata.StorageType) d.Set(Attr_StoragePool, powervmdata.StoragePool) d.Set(Attr_StoragePoolAffinity, powervmdata.StoragePoolAffinity) diff --git a/ibm/service/power/data_source_ibm_pi_instances.go b/ibm/service/power/data_source_ibm_pi_instances.go index b6913fd3f4..fcfc9ff25c 100644 --- a/ibm/service/power/data_source_ibm_pi_instances.go +++ b/ibm/service/power/data_source_ibm_pi_instances.go @@ -181,6 +181,11 @@ func DataSourceIBMPIInstances() *schema.Resource { Description: "The status of the instance.", Type: schema.TypeString, }, + Attr_StorageConnection: { + Computed: true, + Description: "The storage connection type.", + Type: schema.TypeString, + }, Attr_StoragePool: { Computed: true, Description: "The storage Pool where server is deployed.", @@ -261,6 +266,7 @@ func flattenPvmInstances(list []*models.PVMInstanceReference, meta interface{}) Attr_SharedProcessorPool: i.SharedProcessorPool, Attr_SharedProcessorPoolID: i.SharedProcessorPoolID, Attr_Status: *i.Status, + Attr_StorageConnection: i.StorageConnection, Attr_StoragePool: i.StoragePool, Attr_StoragePoolAffinity: i.StoragePoolAffinity, Attr_StorageType: i.StorageType, diff --git a/ibm/service/power/ibm_pi_constants.go b/ibm/service/power/ibm_pi_constants.go index d082603e68..dc68945132 100644 --- a/ibm/service/power/ibm_pi_constants.go +++ b/ibm/service/power/ibm_pi_constants.go @@ -361,6 +361,7 @@ const ( Attr_Status = "status" Attr_StatusDescriptionErrors = "status_description_errors" Attr_StatusDetail = "status_detail" + Attr_StorageConnection = "storage_connection" Attr_StoragePool = "storage_pool" Attr_StoragePoolAffinity = "storage_pool_affinity" Attr_StoragePoolsCapacity = "storage_pools_capacity" @@ -458,6 +459,7 @@ const ( Hard = "hard" Host = "host" HostGroup = "hostGroup" + MaxVolumeSupport = "maxVolumeSupport" Netweaver = "Netweaver" None = "none" OK = "OK" diff --git a/ibm/service/power/resource_ibm_pi_instance.go b/ibm/service/power/resource_ibm_pi_instance.go index d09678d648..c73c01bd14 100644 --- a/ibm/service/power/resource_ibm_pi_instance.go +++ b/ibm/service/power/resource_ibm_pi_instance.go @@ -299,7 +299,7 @@ func ResourceIBMPIInstance() *schema.Resource { Description: "Storage Connectivity Group for server deployment", Optional: true, Type: schema.TypeString, - ValidateFunc: validate.ValidateAllowedStringValues([]string{vSCSI}), + ValidateFunc: validate.ValidateAllowedStringValues([]string{vSCSI, MaxVolumeSupport}), }, Arg_SysType: { Computed: true, diff --git a/ibm/service/power/resource_ibm_pi_instance_test.go b/ibm/service/power/resource_ibm_pi_instance_test.go index f3bc0fd330..7c2974f1d2 100644 --- a/ibm/service/power/resource_ibm_pi_instance_test.go +++ b/ibm/service/power/resource_ibm_pi_instance_test.go @@ -96,7 +96,6 @@ func testAccCheckIBMPIInstanceDeploymentTypeConfig(name, instanceHealthStatus, e 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, epic, systype, acc.PiStorageType) } @@ -133,7 +132,6 @@ func testAccCheckIBMPIInstanceIBMiLicense(name, instanceHealthStatus string, IBM 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, IBMiCSS, IBMiRDSUsers) } @@ -300,6 +298,31 @@ func testAccCheckIBMPIInstanceUserTagsConfig(name, instanceHealthStatus string, `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, instanceHealthStatus, acc.PiStorageType, userTagsString) } +func testAccCheckIBMPIInstanceStorageConnectionConfig(name, instanceHealthStatus string) string { + return fmt.Sprintf(` + resource "ibm_pi_volume" "power_volume" { + pi_cloud_instance_id = "%[1]s" + pi_volume_size = 1 + pi_volume_name = "%[2]s" + pi_volume_type = "tier3" + } + resource "ibm_pi_instance" "power_instance" { + pi_cloud_instance_id = "%[1]s" + pi_memory = "2" + pi_processors = "1" + pi_instance_name = "%[2]s" + pi_proc_type = "shared" + pi_image_id = "%[3]s" + pi_sys_type = "s922" + pi_network { + network_id = "%[4]s" + } + pi_storage_connection = "%[5]s" + pi_health_status = "%[6]s" + pi_volume_ids = [ibm_pi_volume.power_volume.volume_id] + } + `, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_storage_connection, instanceHealthStatus) +} func testAccCheckIBMPIInstanceDestroy(s *terraform.State) error { sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession() if err != nil { @@ -380,6 +403,25 @@ func TestAccIBMPIInstanceBasic(t *testing.T) { }, }) } +func TestAccIBMPIInstanceStorageConnection(t *testing.T) { + instanceRes := "ibm_pi_instance.power_instance" + name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheck(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIBMPIInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIBMPIInstanceStorageConnectionConfig(name, power.OK), + Check: resource.ComposeTestCheckFunc( + testAccCheckIBMPIInstanceExists(instanceRes), + resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name), + resource.TestCheckResourceAttr(instanceRes, "pi_storage_connection", acc.Pi_storage_connection), + ), + }, + }, + }) +} func TestAccIBMPIInstanceDeploymentTarget(t *testing.T) { instanceRes := "ibm_pi_instance.power_instance" name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100)) @@ -570,7 +612,7 @@ func testAccIBMPISAPInstanceConfig(name, sapProfile string) string { pi_storage_type = "tier1" pi_network { network_id = resource.ibm_pi_network.power_network.network_id - } + } } `, acc.Pi_cloud_instance_id, name, sapProfile, acc.Pi_sap_image) } @@ -747,7 +789,7 @@ func testAccCheckIBMPIStoppedInstanceConfigUpdate(name, instanceHealthStatus, pr pi_volume_pool = data.ibm_pi_image.power_image.storage_pool pi_volume_shareable = true pi_volume_size = 20 - } + } resource "ibm_pi_instance" "power_instance" { pi_cloud_instance_id = "%[1]s" pi_health_status = "%[5]s" diff --git a/website/docs/d/pi_instance.html.markdown b/website/docs/d/pi_instance.html.markdown index f1118c974d..1b5785f36f 100644 --- a/website/docs/d/pi_instance.html.markdown +++ b/website/docs/d/pi_instance.html.markdown @@ -92,6 +92,7 @@ In addition to all argument reference list, you can access the following attribu - `shared_processor_pool`- (String) The name of the shared processor pool for the instance. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. +- `storage_connection` - (String) The storage connection type for the instance. - `storage_pool` - (String) The storage Pool where server is deployed. - `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. - `storage_type` - (String) The storage type where server is deployed. diff --git a/website/docs/d/pi_instances.html.markdown b/website/docs/d/pi_instances.html.markdown index 364f130ce8..0897d28cf3 100644 --- a/website/docs/d/pi_instances.html.markdown +++ b/website/docs/d/pi_instances.html.markdown @@ -85,6 +85,7 @@ In addition to all argument reference list, you can access the following attribu - `shared_processor_pool`- (String) The name of the shared processor pool for the instance. - `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance. - `status` - (String) The status of the instance. + - `storage_connection` - (String) The storage connection type for the instance - `storage_pool` - (String) The storage Pool where server is deployed. - `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool. - `storage_type` - (String) The storage type where server is deployed. diff --git a/website/docs/r/pi_instance.html.markdown b/website/docs/r/pi_instance.html.markdown index 0985e49459..1761b45f43 100644 --- a/website/docs/r/pi_instance.html.markdown +++ b/website/docs/r/pi_instance.html.markdown @@ -115,7 +115,7 @@ Review the argument references that you can specify for your resource. - `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, Boolean) 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; If storage type is not provided the storage type will default to `tier3`. To get a list of available storage types, please use the [ibm_pi_storage_types_capacity](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/pi_storage_types_capacity) data source. -- `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Only supported value is `vSCSI`. +- `pi_storage_connection` - (Optional, String) - Storage Connectivity Group (SCG) for server deployment. Supported values are `vSCSI`, `maxVolumeSupport`. - `pi_sys_type` - (Optional, String) The type of system on which to create the VM (e880/e980/e1080/s922/s1022). - Supported SAP system types are (e880/e980/e1080). - `pi_user_data` - (Optional, String) The user data `cloud-init` to pass to the instance during creation. It can be a base64 encoded or an unencoded string. If it is an unencoded string, the provider will encode it before it passing it down.