Skip to content

Commit 2ad486a

Browse files
Diptipowervsmichaelkad
authored andcommitted
Add Storage connection to datasource and resource
1 parent 6c7c7d9 commit 2ad486a

11 files changed

+111
-52
lines changed

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.19
44

55
require (
66
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b
7-
github.com/IBM-Cloud/power-go-client v1.6.0
7+
github.com/IBM-Cloud/power-go-client v1.6.0-beta9
88
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
99
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
1010
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
@@ -65,6 +65,7 @@ require (
6565
github.com/IBM/go-sdk-core v1.1.0
6666
github.com/IBM/mqcloud-go-sdk v0.0.4
6767
github.com/IBM/sarama v1.41.2
68+
github.com/IBM/vmware-go-sdk v0.1.2
6869
github.com/stretchr/testify v1.9.0
6970
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749
7071
sigs.k8s.io/controller-runtime v0.14.1

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240402122236-5c5b994a3f1a/go.mod h1:/7h
106106
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b h1:Wnq0BuprazpP41+nQlRpxpmAs8+8jyOqU50KrvFdJQ4=
107107
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240216115622-a311507b4b5b/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
108108
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
109-
github.com/IBM-Cloud/power-go-client v1.6.0 h1:X+QX+WSF66+aouyaf4r+IeBLXUurAJj9+Bd+vH7G5I0=
110-
github.com/IBM-Cloud/power-go-client v1.6.0/go.mod h1:0ad5Lcq1utoYVJx0uqooMjCpUaYaK0ItP9QJYtY6k0Y=
109+
github.com/IBM-Cloud/power-go-client v1.6.0-beta9 h1:yMF53vAVoxapFEqJEIFCqx8bAjC/ZA6gbPqId3Gj4NI=
110+
github.com/IBM-Cloud/power-go-client v1.6.0-beta9/go.mod h1:ucyaXsQxyssFFIbWT01uAA5784aKcU7u+q31yu04Rs4=
111111
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
112112
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
113113
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
@@ -172,6 +172,8 @@ github.com/IBM/schematics-go-sdk v0.2.3 h1:lgTt0Sbudii3cuSk1YSQgrtiZAXDbBABAoVj3
172172
github.com/IBM/schematics-go-sdk v0.2.3/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
173173
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4 h1:xa9e+POVqaXxXHXkSMCOVAbKdUNEu86jQmo5hcpd+L4=
174174
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.4/go.mod h1:5gq8D8uWOIbqOm1uztay6lpOysgJaxxEsaVZLWGWb40=
175+
github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w9M=
176+
github.com/IBM/vmware-go-sdk v0.1.2/go.mod h1:2UGPBJju3jiv5VKKBBm9a5L6bzF/aJdKOKAzJ7HaOjA=
175177
github.com/IBM/vpc-beta-go-sdk v0.6.0 h1:wfM3AcW3zOM3xsRtZ+EA6+sESlGUjQ6Yf4n5QQyz4uc=
176178
github.com/IBM/vpc-beta-go-sdk v0.6.0/go.mod h1:fzHDAQIqH/5yJmYsKodKHLcqxMDT+yfH6vZjdiw8CQA=
177179
github.com/IBM/vpc-go-sdk v0.50.0 h1:+vnXYK0FXFXYqaS/5/X1XEqH0bbRotkzkerRk21ZEjE=

ibm/acctest/acctest.go

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -188,37 +188,38 @@ var (
188188
// For Power Colo
189189

190190
var (
191+
Pi_auxiliary_volume_name string
192+
Pi_cloud_instance_id string
193+
Pi_dhcp_id string
191194
Pi_image string
192-
Pi_sap_image string
193-
Pi_image_bucket_name string
194-
Pi_image_bucket_file_name string
195195
Pi_image_bucket_access_key string
196-
Pi_image_bucket_secret_key string
196+
Pi_image_bucket_file_name string
197+
Pi_image_bucket_name string
197198
Pi_image_bucket_region string
199+
Pi_image_bucket_secret_key string
200+
Pi_instance_name string
198201
Pi_key_name string
199-
Pi_volume_name string
200-
Pi_volume_id string
202+
Pi_network_name string
203+
Pi_placement_group_name string
201204
Pi_replication_volume_name string
202-
Pi_volume_onboarding_source_crn string
203-
Pi_auxiliary_volume_name string
204-
Pi_volume_group_name string
205+
Pi_resource_group_id string
206+
Pi_sap_image string
207+
Pi_shared_processor_pool_id string
208+
Pi_snapshot_id string
209+
Pi_spp_placement_group_id string
210+
Pi_storage_connection string
211+
Pi_target_storage_tier string
212+
Pi_volume_clone_task_id string
205213
Pi_volume_group_id string
214+
Pi_volume_group_name string
215+
Pi_volume_id string
216+
Pi_volume_name string
206217
Pi_volume_onboarding_id string
207-
Pi_network_name string
208-
Pi_cloud_instance_id string
209-
Pi_snapshot_id string
210-
Pi_instance_name string
211-
Pi_dhcp_id string
218+
Pi_volume_onboarding_source_crn string
212219
PiCloudConnectionName string
213220
PiSAPProfileID string
214-
Pi_placement_group_name string
215-
Pi_spp_placement_group_id string
216221
PiStoragePool string
217222
PiStorageType string
218-
Pi_shared_processor_pool_id string
219-
Pi_target_storage_tier string
220-
Pi_volume_clone_task_id string
221-
Pi_resource_group_id string
222223
)
223224

224225
var (
@@ -1136,7 +1137,10 @@ func init() {
11361137
Pi_shared_processor_pool_id = "tf-pi-shared-processor-pool"
11371138
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'")
11381139
}
1139-
1140+
Pi_storage_connection = os.Getenv("PI_STORAGE_CONNECTION")
1141+
if Pi_storage_connection == "" {
1142+
fmt.Println("[WARN] Set the environment variable PI_STORAGE_CONNECTION for testing pi_storage_connection resource else it is empty")
1143+
}
11401144
Pi_target_storage_tier = os.Getenv("PI_TARGET_STORAGE_TIER")
11411145
if Pi_target_storage_tier == "" {
11421146
Pi_target_storage_tier = "terraform-test-tier"

ibm/service/power/data_source_ibm_pi_instance.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func DataSourceIBMPIInstance() *schema.Resource {
6464
},
6565
Attr_LicenseRepositoryCapacity: {
6666
Computed: true,
67-
Deprecated: "This field is deprecated.",
6867
Description: "The VTL license repository capacity TB value.",
6968
Type: schema.TypeInt,
7069
},
@@ -182,6 +181,11 @@ func DataSourceIBMPIInstance() *schema.Resource {
182181
Description: "The status of the instance.",
183182
Type: schema.TypeString,
184183
},
184+
Attr_StorageConnection: {
185+
Computed: true,
186+
Description: "The storage connection type.",
187+
Type: schema.TypeString,
188+
},
185189
Attr_StoragePool: {
186190
Computed: true,
187191
Description: "The storage Pool where server is deployed.",
@@ -245,6 +249,7 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
245249
d.Set(Attr_SharedProcessorPool, powervmdata.SharedProcessorPool)
246250
d.Set(Attr_SharedProcessorPoolID, powervmdata.SharedProcessorPoolID)
247251
d.Set(Attr_Status, powervmdata.Status)
252+
d.Set(Attr_StorageConnection, powervmdata.StorageConnection)
248253
d.Set(Attr_StorageType, powervmdata.StorageType)
249254
d.Set(Attr_StoragePool, powervmdata.StoragePool)
250255
d.Set(Attr_StoragePoolAffinity, powervmdata.StoragePoolAffinity)
@@ -259,16 +264,5 @@ func dataSourceIBMPIInstancesRead(ctx context.Context, d *schema.ResourceData, m
259264
d.Set(Attr_HealthStatus, powervmdata.Health.Status)
260265
}
261266

262-
if powervmdata.SoftwareLicenses != nil {
263-
d.Set(Attr_IBMiCSS, powervmdata.SoftwareLicenses.IbmiCSS)
264-
d.Set(Attr_IBMiPHA, powervmdata.SoftwareLicenses.IbmiPHA)
265-
d.Set(Attr_IBMiRDS, powervmdata.SoftwareLicenses.IbmiRDS)
266-
if *powervmdata.SoftwareLicenses.IbmiRDS {
267-
d.Set(Attr_IBMiRDSUsers, powervmdata.SoftwareLicenses.IbmiRDSUsers)
268-
} else {
269-
d.Set(Attr_IBMiRDSUsers, 0)
270-
}
271-
}
272-
273267
return nil
274268
}

ibm/service/power/data_source_ibm_pi_instances.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func DataSourceIBMPIInstances() *schema.Resource {
4040
},
4141
Attr_LicenseRepositoryCapacity: {
4242
Computed: true,
43-
Deprecated: "This field is deprecated.",
4443
Description: "The VTL license repository capacity TB value.",
4544
Type: schema.TypeInt,
4645
},
@@ -162,6 +161,11 @@ func DataSourceIBMPIInstances() *schema.Resource {
162161
Description: "The status of the instance.",
163162
Type: schema.TypeString,
164163
},
164+
Attr_StorageConnection: {
165+
Computed: true,
166+
Description: "The storage connection type.",
167+
Type: schema.TypeString,
168+
},
165169
Attr_StoragePool: {
166170
Computed: true,
167171
Description: "The storage Pool where server is deployed.",
@@ -235,6 +239,7 @@ func flattenPvmInstances(list []*models.PVMInstanceReference) []map[string]inter
235239
Attr_SharedProcessorPool: i.SharedProcessorPool,
236240
Attr_SharedProcessorPoolID: i.SharedProcessorPoolID,
237241
Attr_Status: *i.Status,
242+
Attr_StorageConnection: i.StorageConnection,
238243
Attr_StoragePool: i.StoragePool,
239244
Attr_StoragePoolAffinity: i.StoragePoolAffinity,
240245
Attr_StorageType: i.StorageType,

ibm/service/power/ibm_pi_constants.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
Arg_IBMiPHA = "pi_ibmi_pha"
1818
Arg_IBMiRDSUsers = "pi_ibmi_rds_users"
1919
Arg_ImageName = "pi_image_name"
20+
Arg_ImportDetails = "pi_image_import_details"
2021
Arg_InstanceName = "pi_instance_name"
2122
Arg_KeyName = "pi_key_name"
2223
Arg_NetworkName = "pi_network_name"
@@ -153,6 +154,7 @@ const (
153154
Attr_LastUpdatedDate = "last_updated_date"
154155
Attr_Leases = "leases"
155156
Attr_LicenseRepositoryCapacity = "license_repository_capacity"
157+
Attr_LicenseType = "license_type"
156158
Attr_Location = "location"
157159
Attr_MacAddress = "macaddress"
158160
Attr_MasterChangedVolumeName = "master_changed_volume_name"
@@ -200,6 +202,7 @@ const (
200202
Attr_PrimaryRole = "primary_role"
201203
Attr_Processors = "processors"
202204
Attr_ProcType = "proctype"
205+
Attr_Product = "product"
203206
Attr_ProfileID = "profile_id"
204207
Attr_Profiles = "profiles"
205208
Attr_Progress = "progress"
@@ -255,6 +258,7 @@ const (
255258
Attr_Status = "status"
256259
Attr_StatusDescriptionErrors = "status_description_errors"
257260
Attr_StatusDetail = "status_detail"
261+
Attr_StorageConnection = "storage_connection"
258262
Attr_StoragePool = "storage_pool"
259263
Attr_StoragePoolAffinity = "storage_pool_affinity"
260264
Attr_StoragePoolsCapacity = "storage_pools_capacity"
@@ -281,6 +285,7 @@ const (
281285
Attr_UsedIPPercent = "used_ip_percent"
282286
Attr_UserIPAddress = "user_ip_address"
283287
Attr_VCPUs = "vcpus"
288+
Attr_Vendor = "vendor"
284289
Attr_VirtualCoresAssigned = "virtual_cores_assigned"
285290
Attr_VLanID = "vlan_id"
286291
Attr_VolumeGroupName = "volume_group_name"
@@ -300,7 +305,9 @@ const (
300305
Attr_WorkspaceStatus = "pi_workspace_status"
301306
Attr_WorkspaceType = "pi_workspace_type"
302307
Attr_WWN = "wwn"
303-
OS_IBMI = "ibmi"
308+
309+
MaxVolumeSupport = "maxVolumeSupport"
310+
OS_IBMI = "ibmi"
304311

305312
// TODO: Second Half Cleanup, remove extra variables
306313

ibm/service/power/resource_ibm_pi_instance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func ResourceIBMPIInstance() *schema.Resource {
138138
helpers.PIInstanceStorageConnection: {
139139
Type: schema.TypeString,
140140
Optional: true,
141-
ValidateFunc: validate.ValidateAllowedStringValues([]string{"vSCSI"}),
141+
ValidateFunc: validate.ValidateAllowedStringValues([]string{"vSCSI", MaxVolumeSupport}),
142142
Description: "Storage Connectivity Group for server deployment",
143143
},
144144
PIInstanceStoragePoolAffinity: {
@@ -1450,7 +1450,7 @@ func createPVMInstance(d *schema.ResourceData, client *st.IBMPIInstanceClient, i
14501450
}
14511451

14521452
if sc, ok := d.GetOk(helpers.PIInstanceStorageConnection); ok {
1453-
body.StorageConnection = sc.(string)
1453+
body.StorageConnectionV2 = sc.(string)
14541454
}
14551455

14561456
if pg, ok := d.GetOk(helpers.PIPlacementGroupID); ok {

ibm/service/power/resource_ibm_pi_instance_test.go

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,31 @@ func testAccCheckIBMPIInstanceReplicantConfig(name string) string {
224224
}
225225
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_volume_name)
226226
}
227-
227+
func testAccCheckIBMPIInstanceStorageConnectionConfig(name, instanceHealthStatus string) string {
228+
return fmt.Sprintf(`
229+
resource "ibm_pi_volume" "power_volume" {
230+
pi_cloud_instance_id = "%[1]s"
231+
pi_volume_size = 1
232+
pi_volume_name = "%[2]s"
233+
pi_volume_type = "tier3"
234+
}
235+
resource "ibm_pi_instance" "power_instance" {
236+
pi_cloud_instance_id = "%[1]s"
237+
pi_memory = "2"
238+
pi_processors = "1"
239+
pi_instance_name = "%[2]s"
240+
pi_proc_type = "shared"
241+
pi_image_id = "%[3]s"
242+
pi_sys_type = "s922"
243+
pi_network {
244+
network_id = "%[4]s"
245+
}
246+
pi_storage_connection = "%[5]s"
247+
pi_health_status = "%[6]s"
248+
pi_volume_ids = [ibm_pi_volume.power_volume.volume_id]
249+
}
250+
`, acc.Pi_cloud_instance_id, name, acc.Pi_image, acc.Pi_network_name, acc.Pi_storage_connection, instanceHealthStatus)
251+
}
228252
func testAccCheckIBMPIInstanceDestroy(s *terraform.State) error {
229253
sess, err := acc.TestAccProvider.Meta().(conns.ClientSession).IBMPISession()
230254
if err != nil {
@@ -305,7 +329,25 @@ func TestAccIBMPIInstanceBasic(t *testing.T) {
305329
},
306330
})
307331
}
308-
332+
func TestAccIBMPIInstanceStorageConnection(t *testing.T) {
333+
instanceRes := "ibm_pi_instance.power_instance"
334+
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))
335+
resource.Test(t, resource.TestCase{
336+
PreCheck: func() { acc.TestAccPreCheck(t) },
337+
Providers: acc.TestAccProviders,
338+
CheckDestroy: testAccCheckIBMPIInstanceDestroy,
339+
Steps: []resource.TestStep{
340+
{
341+
Config: testAccCheckIBMPIInstanceStorageConnectionConfig(name, helpers.PIInstanceHealthOk),
342+
Check: resource.ComposeTestCheckFunc(
343+
testAccCheckIBMPIInstanceExists(instanceRes),
344+
resource.TestCheckResourceAttr(instanceRes, "pi_instance_name", name),
345+
resource.TestCheckResourceAttr(instanceRes, "pi_storage_connection", acc.Pi_storage_connection),
346+
),
347+
},
348+
},
349+
})
350+
}
309351
func TestAccIBMPIInstanceDeploymentType(t *testing.T) {
310352
instanceRes := "ibm_pi_instance.power_instance"
311353
name := fmt.Sprintf("tf-pi-instance-%d", acctest.RandIntRange(10, 100))

website/docs/d/pi_instance.html.markdown

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,19 @@ Review the argument references that you can specify for your data source.
4040
## Attribute reference
4141
In addition to all argument reference list, you can access the following attribute references after your data source is created.
4242

43+
- `addresses` - (Deprecated, List of objects) - The address associated with this instance.
44+
45+
Nested scheme for `addresses`:
46+
- `external_ip` - (String) The external IP address of the instance.
47+
- `ip` - (String) The IP address of the instance.
48+
- `macaddress` - (String) The MAC address of the instance.
49+
- `network_id` - (String) The network ID of the instance.
50+
- `network_name` - (String) The network name of the instance.
51+
- `type` - (String) The type of the network.
4352
- `deployment_type` - (String) The custom deployment type.
4453
- `health_status` - (String) The health of the instance.
45-
46-
**Notes** IBM i software licenses for IBM i virtual server instances -- only for IBM i instances
47-
- `ibmi_css` - (Boolean) IBM i Cloud Storage Solution.
48-
- `ibmi_pha` - (Boolean) IBM i Power High Availability.
49-
- `ibmi_rds` - (Boolean) IBM i Rational Dev Studio.
50-
- `ibmi_rds_users` - (Integer) IBM i Rational Dev Studio Number of User Licenses.
5154
- `id` - (String) The unique identifier of the instance.
52-
- `license_repository_capacity` - (Deprecated, Integer) The VTL license repository capacity TB value. Only available with VTL instances.
55+
- `license_repository_capacity` - (Integer) The VTL license repository capacity TB value. Only available with VTL instances.
5356
- `maxmem`- (Float) The maximum amount of memory that can be allocated to the instance without shutting down or rebooting the `LPAR`.
5457
- `maxproc`- (Float) The maximum number of processors that can be allocated to the instance without shutting down or rebooting the `LPAR`.
5558
- `max_virtual_cores` - (Integer) The maximum number of virtual cores that can be assigned without rebooting the instance.
@@ -71,10 +74,10 @@ In addition to all argument reference list, you can access the following attribu
7174
- `placement_group_id`- (String) The ID of the placement group that the instance is a member.
7275
- `processors` - (Float) The number of processors that are allocated to the instance.
7376
- `proctype` - (String) The procurement type of the instance. Supported values are `shared` and `dedicated`.
74-
- `server_name` - (String) The name of the instance.
7577
- `shared_processor_pool`- (String) The name of the shared processor pool for the instance.
7678
- `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance.
7779
- `status` - (String) The status of the instance.
80+
- `storage_connection` - (String) The storage connection type for the instance.
7881
- `storage_pool` - (String) The storage Pool where server is deployed.
7982
- `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool.
8083
- `storage_type` - (String) The storage type where server is deployed.

website/docs/d/pi_instances.html.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ In addition to all argument reference list, you can access the following attribu
4242

4343
Nested scheme for `pvm_instances`:
4444
- `health_status` - (String) The health of the instance.
45-
- `license_repository_capacity` - (Deprecated, Integer) The VTL license repository capacity TB value. Only available with VTL instances.
45+
- `license_repository_capacity` - The VTL license repository capacity TB value. Only available with VTL instances.
4646
- `memory` - (Float) The amount of memory that is allocated to the instance.
4747
- `minproc`- (Float) The minimum number of processors that must be allocated to the instance.
4848
- `maxproc`- (Float) The maximum number of processors that can be allocated to the instance without shutting down or rebooting the `LPAR`.
@@ -69,6 +69,7 @@ In addition to all argument reference list, you can access the following attribu
6969
- `shared_processor_pool`- (String) The name of the shared processor pool for the instance.
7070
- `shared_processor_pool_id` - (String) The ID of the shared processor pool for the instance.
7171
- `status` - (String) The status of the instance.
72+
- `storage_connection` - (String) The storage connection type for the instance.
7273
- `storage_pool` - (String) The storage Pool where server is deployed.
7374
- `storage_pool_affinity` - (Boolean) Indicates if all volumes attached to the server must reside in the same storage pool.
7475
- `storage_type` - (String) The storage type where server is deployed.

0 commit comments

Comments
 (0)