Skip to content

Commit e383696

Browse files
committed
[R] Volume Group
1 parent f8b0f72 commit e383696

File tree

9 files changed

+37
-17
lines changed

9 files changed

+37
-17
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.24.2
55
require (
66
github.com/IBM-Cloud/bluemix-go v0.0.0-20250324085928-caa6511f0c13
77
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
8-
github.com/IBM-Cloud/power-go-client v1.12.0
8+
github.com/IBM-Cloud/power-go-client v1.13.0-beta9
99
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4
1010
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
1111
github.com/IBM/cloud-databases-go-sdk v0.8.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae2311
9696
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
9797
github.com/IBM-Cloud/power-go-client v1.12.0 h1:tF9Mq5GLYHebpzQT6IYB89lIxEST1E9teuchjxSAaw0=
9898
github.com/IBM-Cloud/power-go-client v1.12.0/go.mod h1:SpTK1ttW8bfMNUVQS8qOEuWn2KOkzaCLyzfze8MG1JE=
99+
github.com/IBM-Cloud/power-go-client v1.13.0-beta8 h1:SU7ZW9oxBZgvGzcu8oCyzmn6hHSeDHy0WeUnU6omiFA=
100+
github.com/IBM-Cloud/power-go-client v1.13.0-beta8/go.mod h1:SpTK1ttW8bfMNUVQS8qOEuWn2KOkzaCLyzfze8MG1JE=
101+
github.com/IBM-Cloud/power-go-client v1.13.0-beta9 h1:RYwG71ucJGr3FHoPpFgBx8ak6pVwiEgRg3W/u9HxgTM=
102+
github.com/IBM-Cloud/power-go-client v1.13.0-beta9/go.mod h1:SpTK1ttW8bfMNUVQS8qOEuWn2KOkzaCLyzfze8MG1JE=
99103
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
100104
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
101105
github.com/IBM/appconfiguration-go-admin-sdk v0.4.4 h1:VQ+mVavoo3/xrBaVSyxE+B6Uef+m33RcbropwpTRBy4=

ibm/service/power/data_source_ibm_pi_network_peers.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@ func dataSourceIBMPINetworkPeersRead(ctx context.Context, d *schema.ResourceData
9393

9494
func dataSourceIBMPINetworkPeersNetworkPeerToMap(np *models.NetworkPeer) map[string]interface{} {
9595
npMap := make(map[string]interface{})
96-
if np.Description != nil {
97-
npMap[Attr_Description] = np.Description
98-
}
9996
if np.ID != nil {
10097
npMap[Attr_ID] = np.ID
10198
}

ibm/service/power/ibm_pi_constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ const (
4343
Arg_DeploymentType = "pi_deployment_type"
4444
Arg_Description = "pi_description"
4545
Arg_Destination = "pi_destination"
46-
Arg_DestinationType = "pi_destination_type"
4746
Arg_DestinationPort = "pi_destination_port"
4847
Arg_DestinationPorts = "pi_destination_ports"
48+
Arg_DestinationType = "pi_destination_type"
4949
Arg_DhcpID = "pi_dhcp_id"
5050
Arg_DhcpName = "pi_dhcp_name"
5151
Arg_DhcpSnatEnabled = "pi_dhcp_snat_enabled"
@@ -152,6 +152,7 @@ const (
152152
Arg_StorageType = "pi_storage_type"
153153
Arg_SysType = "pi_sys_type"
154154
Arg_Target = "pi_target"
155+
Arg_TargetCRN = "pi_target_crn"
155156
Arg_TargetStorageTier = "pi_target_storage_tier"
156157
Arg_Type = "pi_type"
157158
Arg_UserData = "pi_user_data"

ibm/service/power/resource_ibm_pi_instance_snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func resourceIBMPIInstanceSnapshotUpdate(ctx context.Context, d *schema.Resource
224224
if d.HasChange(Arg_SnapshotName) || d.HasChange(Arg_Description) {
225225
name := d.Get(Arg_SnapshotName).(string)
226226
description := d.Get(Arg_Description).(string)
227-
snapshotBody := &models.SnapshotUpdate{Name: name, Description: description}
227+
snapshotBody := &models.SnapshotUpdate{Name: &name, Description: &description}
228228

229229
_, err := client.Update(snapshotID, snapshotBody)
230230
if err != nil {

ibm/service/power/resource_ibm_pi_network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ func networkMapToNetworkCreatePeer(networkCreatePeerMap map[string]interface{})
752752
ncp := &models.NetworkCreatePeer{}
753753
if networkCreatePeerMap[Attr_ID].(string) != "" {
754754
id := networkCreatePeerMap[Attr_ID].(string)
755-
ncp.ID = &id
755+
ncp.ID = id
756756
}
757757
if networkCreatePeerMap[Attr_NetworkAddressTranslation] != nil && len(networkCreatePeerMap[Attr_NetworkAddressTranslation].([]interface{})) > 0 {
758758
networkAddressTranslationModel := natMapToNetworkAddressTranslation(networkCreatePeerMap[Attr_NetworkAddressTranslation].([]interface{})[0].(map[string]interface{}))

ibm/service/power/resource_ibm_pi_snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func resourceIBMPISnapshotUpdate(ctx context.Context, d *schema.ResourceData, me
228228
if d.HasChange(Arg_SnapShotName) || d.HasChange(Arg_Description) {
229229
name := d.Get(Arg_SnapShotName).(string)
230230
description := d.Get(Arg_Description).(string)
231-
snapshotBody := &models.SnapshotUpdate{Name: name, Description: description}
231+
snapshotBody := &models.SnapshotUpdate{Name: &name, Description: &description}
232232

233233
_, err := client.Update(snapshotID, snapshotBody)
234234
if err != nil {

ibm/service/power/resource_ibm_pi_volume_group.go

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ func ResourceIBMPIVolumeGroup() *schema.Resource {
4949
Optional: true,
5050
Type: schema.TypeString,
5151
},
52+
Arg_TargetCRN: {
53+
Description: "Target CRN of the secondary workspace where the auxiliary data resides; optional; if specified, the auxiliary volumes for the primary volumes getting added to the new volume group will be automatically onboarded into the secondary workspace and added to the corresponding auxiliary consistency group.",
54+
Optional: true,
55+
Type: schema.TypeString,
56+
},
5257
Arg_VolumeGroupName: {
5358
ConflictsWith: []string{Arg_ConsistencyGroupName},
5459
Description: "Volume Group Name to create",
@@ -130,7 +135,9 @@ func resourceIBMPIVolumeGroupCreate(ctx context.Context, d *schema.ResourceData,
130135
body := &models.VolumeGroupCreate{
131136
Name: vgName,
132137
}
133-
138+
if v, ok := d.GetOk(Arg_TargetCRN); ok {
139+
body.TargetCRN = v.(string)
140+
}
134141
volids := flex.ExpandStringList((d.Get(Arg_VolumeIDs).(*schema.Set)).List())
135142
body.VolumeIDs = volids
136143

@@ -199,15 +206,22 @@ func resourceIBMPIVolumeGroupUpdate(ctx context.Context, d *schema.ResourceData,
199206
}
200207

201208
client := instance.NewIBMPIVolumeGroupClient(ctx, sess, cloudInstanceID)
209+
body := &models.VolumeGroupUpdate{}
210+
hasChange := false
202211
if d.HasChanges(Arg_VolumeIDs) {
203212
old, new := d.GetChange(Arg_VolumeIDs)
204213
oldList := old.(*schema.Set)
205214
newList := new.(*schema.Set)
206-
body := &models.VolumeGroupUpdate{
207-
AddVolumes: flex.ExpandStringList(newList.Difference(oldList).List()),
208-
RemoveVolumes: flex.ExpandStringList(oldList.Difference(newList).List()),
209-
}
210-
err := client.UpdateVolumeGroup(vgID, body)
215+
body.AddVolumes = flex.ExpandStringList(newList.Difference(oldList).List())
216+
body.RemoveVolumes = flex.ExpandStringList(oldList.Difference(newList).List())
217+
hasChange = true
218+
}
219+
if d.HasChanges(Arg_TargetCRN) {
220+
body.TargetCRN = d.Get(Arg_TargetCRN).(string)
221+
hasChange = true
222+
}
223+
if hasChange {
224+
err = client.UpdateVolumeGroup(vgID, body)
211225
if err != nil {
212226
return diag.FromErr(err)
213227
}
@@ -216,7 +230,6 @@ func resourceIBMPIVolumeGroupUpdate(ctx context.Context, d *schema.ResourceData,
216230
return diag.FromErr(err)
217231
}
218232
}
219-
220233
return resourceIBMPIVolumeGroupRead(ctx, d, meta)
221234
}
222235
func resourceIBMPIVolumeGroupDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
@@ -246,8 +259,12 @@ func resourceIBMPIVolumeGroupDelete(ctx context.Context, d *schema.ResourceData,
246259
return diag.FromErr(err)
247260
}
248261
}
249-
250-
err = client.DeleteVolumeGroup(vgID)
262+
body := &models.VolumeGroupDelete{}
263+
if v, ok := d.GetOk(Arg_TargetCRN); ok {
264+
targetCRN := v.(string)
265+
body.TargetCRN = &targetCRN
266+
}
267+
err = client.DeleteVolumeGroupWithBody(vgID, body)
251268
if err != nil {
252269
return diag.FromErr(err)
253270
}

website/docs/r/pi_volume_group.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Review the argument references that you can specify for your resource.
5252

5353
- `pi_cloud_instance_id` - (Required, String) The GUID of the service instance associated with an account.
5454
- `pi_consistency_group_name` - (Optional, String) The name of consistency group at storage controller level, required if `pi_volume_group_name` is not provided.
55+
- `pi_target_crn` - (Optional, String) Target CRN of the secondary workspace where the auxiliary data resides; if specified, the auxiliary volumes for the primary volumes getting added to the new volume group will be automatically onboarded into the secondary workspace and added to the corresponding auxiliary consistency group.
5556
- `pi_volume_group_name` - (Optional, String) The name of the volume group, required if `pi_consistency_group_name` is not provided.
5657
- `pi_volume_ids` - (Required, Set of String) List of volume IDs to add in volume group.
5758

0 commit comments

Comments
 (0)