Skip to content

Commit

Permalink
Add GRS for volume data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kita committed Oct 10, 2024
1 parent 924fe87 commit 440835c
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 14 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.5
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.7.0
github.com/IBM-Cloud/power-go-client v1.8.1
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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be/go.mod h1:/7h
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 h1:f2Erqfea1dKpaTFagTJM6W/wnD3JGq/Vn9URh8nuRwk=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.7.0 h1:/GuGwPMTKoCZACfnwt7b6wKr4v32q1VO1AMFGNETRN4=
github.com/IBM-Cloud/power-go-client v1.7.0/go.mod h1:9izycYAmNQ+NAdVPXDC3fHYxqWLjlR2YiwqKYveMv5Y=
github.com/IBM-Cloud/power-go-client v1.8.1 h1:tx1aPJmIQrNru1MD1VHGNasGx3eRIs0zzPZ0KvdFQrg=
github.com/IBM-Cloud/power-go-client v1.8.1/go.mod h1:N4RxrsMUvBQjSQ/qPk0iMZ8zK+fZPRTnHi/gTaASw0g=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand Down
55 changes: 46 additions & 9 deletions ibm/service/power/data_source_ibm_pi_instance_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func DataSourceIBMPIInstanceVolumes() *schema.Resource {
Description: "Indicates if the volume is boot capable.",
Type: schema.TypeBool,
},
Attr_CreationDate: {
Computed: true,
Description: "Date volume was created.",
Type: schema.TypeString,
},
Attr_FreezeTime: {
Computed: true,
Description: "The freeze time of remote copy.",
Type: schema.TypeString,
},
Attr_Href: {
Computed: true,
Description: "The hyper link of the volume.",
Expand All @@ -59,6 +69,11 @@ func DataSourceIBMPIInstanceVolumes() *schema.Resource {
Description: "The unique identifier of the volume.",
Type: schema.TypeString,
},
Attr_LastUpdateDate: {
Computed: true,
Description: "The last updated date of the volume.",
Type: schema.TypeString,
},
Attr_Name: {
Computed: true,
Description: "The name of the volume.",
Expand All @@ -69,6 +84,17 @@ func DataSourceIBMPIInstanceVolumes() *schema.Resource {
Description: "Volume pool, name of storage pool where the volume is located.",
Type: schema.TypeString,
},
Attr_ReplicationEnabled: {
Computed: true,
Description: "Indicates if the volume should be replication enabled or not.",
Type: schema.TypeBool,
},
Attr_ReplicationSites: {
Computed: true,
Description: "List of replication sites for volume replication.",
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeList,
},
Attr_Shareable: {
Computed: true,
Description: "Indicates if the volume is shareable between VMs.",
Expand Down Expand Up @@ -122,17 +148,28 @@ func dataSourceIBMPIInstanceVolumesRead(ctx context.Context, d *schema.ResourceD
func flattenVolumesInstances(list []*models.VolumeReference) []map[string]interface{} {
result := make([]map[string]interface{}, 0, len(list))
for _, i := range list {

l := map[string]interface{}{
Attr_Bootable: *i.Bootable,
Attr_Href: *i.Href,
Attr_ID: *i.VolumeID,
Attr_Name: *i.Name,
Attr_Pool: i.VolumePool,
Attr_Shareable: *i.Shareable,
Attr_Size: *i.Size,
Attr_State: *i.State,
Attr_Type: *i.DiskType,
Attr_Bootable: *i.Bootable,
Attr_CreationDate: i.CreationDate.String(),
Attr_Href: *i.Href,
Attr_ID: *i.VolumeID,
Attr_LastUpdateDate: i.LastUpdateDate.String(),
Attr_Name: *i.Name,
Attr_Pool: i.VolumePool,
Attr_ReplicationEnabled: i.ReplicationEnabled,
Attr_Shareable: *i.Shareable,
Attr_Size: *i.Size,
Attr_State: *i.State,
Attr_Type: *i.DiskType,
}
if i.FreezeTime != nil {
l[Attr_FreezeTime] = i.FreezeTime.String()
}
if len(i.ReplicationSites) > 0 {
l[Attr_ReplicationSites] = i.ReplicationSites
}

result = append(result, l)
}
return result
Expand Down
29 changes: 29 additions & 0 deletions ibm/service/power/data_source_ibm_pi_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@ func DataSourceIBMPIVolume() *schema.Resource {
Description: "Consistency group name if volume is a part of volume group.",
Type: schema.TypeString,
},
Attr_CreationDate: {
Computed: true,
Description: "Date volume was created.",
Type: schema.TypeString,
},
Attr_DiskType: {
Computed: true,
Description: "The disk type that is used for the volume.",
Type: schema.TypeString,
},
Attr_FreezeTime: {
Computed: true,
Description: "The freeze time of remote copy.",
Type: schema.TypeString,
},
Attr_GroupID: {
Computed: true,
Description: "The volume group id in which the volume belongs.",
Expand All @@ -67,6 +77,11 @@ func DataSourceIBMPIVolume() *schema.Resource {
Description: "Amount of iops assigned to the volume",
Type: schema.TypeString,
},
Attr_LastUpdateDate: {
Computed: true,
Description: "The last updated date of the volume.",
Type: schema.TypeString,
},
Attr_MasterVolumeName: {
Computed: true,
Description: "The master volume name.",
Expand All @@ -87,6 +102,12 @@ func DataSourceIBMPIVolume() *schema.Resource {
Description: "Indicates if the volume should be replication enabled or not.",
Type: schema.TypeBool,
},
Attr_ReplicationSites: {
Computed: true,
Description: "List of replication sites for volume replication.",
Elem: &schema.Schema{Type: schema.TypeString},
Type: schema.TypeList,
},
Attr_ReplicationStatus: {
Computed: true,
Description: "The replication status of the volume.",
Expand Down Expand Up @@ -144,14 +165,22 @@ func dataSourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta
d.Set(Attr_AuxiliaryVolumeName, volumedata.AuxVolumeName)
d.Set(Attr_Bootable, volumedata.Bootable)
d.Set(Attr_ConsistencyGroupName, volumedata.ConsistencyGroupName)
d.Set(Attr_CreationDate, volumedata.CreationDate.String())
d.Set(Attr_DiskType, volumedata.DiskType)
if volumedata.FreezeTime != nil {
d.Set(Attr_FreezeTime, volumedata.FreezeTime.String())
}
d.Set(Attr_GroupID, volumedata.GroupID)
d.Set(Attr_IOThrottleRate, volumedata.IoThrottleRate)
d.Set(Attr_LastUpdateDate, volumedata.LastUpdateDate.String())
d.Set(Attr_MasterVolumeName, volumedata.MasterVolumeName)
d.Set(Attr_MirroringState, volumedata.MirroringState)
d.Set(Attr_PrimaryRole, volumedata.PrimaryRole)
d.Set(Attr_ReplicationEnabled, volumedata.ReplicationEnabled)
d.Set(Attr_ReplicationType, volumedata.ReplicationType)
if len(volumedata.ReplicationSites) > 0 {
d.Set(Attr_ReplicationSites, volumedata.ReplicationSites)
}
d.Set(Attr_ReplicationStatus, volumedata.ReplicationStatus)
d.Set(Attr_State, volumedata.State)
d.Set(Attr_Shareable, volumedata.Shareable)
Expand Down
5 changes: 5 additions & 0 deletions website/docs/d/pi_instance_volumes.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ In addition to all argument reference list, you can access the following attribu

Nested scheme for `instance_volumes`:
- `bootable`- (Boolean) Indicates if the volume is boot capable.
- `creation_date` - (String) Date of volume creation.
- `freeze_time` - (String) Time of remote copy relationship.
- `href` - (String) The hyper link of the volume.
- `id` - (String) The unique identifier of the volume.
- `last_update_date` - (String) The date when the volume last updated.
- `name` - (String) The name of the volume.
- `pool` - (String) Volume pool, name of storage pool where the volume is located.
- `replication_enabled` - (Boolean) Indicates whether replication is enabled on the volume.
- `replication_sites` - (List) List of replication sites for volume replication.
- `shareable` - (Boolean) Indicates if the volume is shareable between VMs.
- `size` - (Integer) The size of this volume in GB.
- `state` - (String) The state of the volume.
Expand Down
8 changes: 6 additions & 2 deletions website/docs/d/pi_volume.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,23 @@ Review the argument references that you can specify for your data source.

In addition to all argument reference list, you can access the following attribute references after your data source is created.

- `auxiliary` - (Boolean) Indicates if the volume is auxiliary or not.
- `auxiliary` - (Boolean) Indicates if the volume is auxiliary.
- `auxiliary_volume_name` - (String) The auxiliary volume name.
- `bootable` - (Boolean) Indicates if the volume is boot capable.
- `consistency_group_name` - (String) Consistency group name if volume is a part of volume group.
- `creation_date` - (String) Date of volume creation.
- `disk_type` - (String) The disk type that is used for the volume.
- `freeze_time` - (String) Time of remote copy relationship.
- `group_id` - (String) The volume group id in which the volume belongs.
- `id` - (String) The unique identifier of the volume.
- `io_throttle_rate` - (String) Amount of iops assigned to the volume.
- `last_update_date` - (String) The date when the volume last updated.
- `master_volume_name` - (String) The master volume name.
- `mirroring_state` - (String) Mirroring state for replication enabled volume.
- `primary_role` - (String) Indicates whether `master`/`auxiliary` volume is playing the primary role.
- `replication_enabled` - (Boolean) Indicates if the volume should be replication enabled or not.
- `replication_status` - (String) The replication status of the volume.
- `replication_sites` - (List) List of replication sites for volume replication.
- `replication_status` - (String) The replication status of the volume.
- `replication_type` - (String) The replication type of the volume, `metro` or `global`.
- `shareable` - (String) Indicates if the volume is shareable between VMs.
- `size` - (Integer) The size of the volume in GB.
Expand Down

0 comments on commit 440835c

Please sign in to comment.