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

Add GRS attributes to pi_volume (d) and pi_instance_volumes (d) #5671

Merged
merged 1 commit into from
Oct 11, 2024
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
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 @@ -51,11 +51,21 @@ 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_CRN: {
Computed: true,
Description: "The CRN of this resource.",
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 @@ -66,6 +76,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 @@ -76,6 +91,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 @@ -136,16 +162,20 @@ func dataSourceIBMPIInstanceVolumesRead(ctx context.Context, d *schema.ResourceD
func flattenVolumesInstances(list []*models.VolumeReference, meta interface{}) []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.Crn != "" {
l[Attr_CRN] = i.Crn
Expand All @@ -155,6 +185,13 @@ func flattenVolumesInstances(list []*models.VolumeReference, meta interface{}) [
}
l[Attr_UserTags] = tags
}
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 @@ -59,11 +59,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 @@ -74,6 +84,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 @@ -94,6 +109,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 @@ -158,6 +179,7 @@ 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())
if volumedata.Crn != "" {
d.Set(Attr_CRN, volumedata.Crn)
tags, err := flex.GetTagsUsingCRN(meta, string(volumedata.Crn))
Expand All @@ -167,13 +189,20 @@ func dataSourceIBMPIVolumeRead(ctx context.Context, d *schema.ResourceData, meta
d.Set(Attr_UserTags, tags)
}
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,11 +53,16 @@ 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.
- `crn` - (String) The CRN of this resource.
- `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,20 +48,24 @@ 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.
- `crn` - (String) The CRN of this resource.
- `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
Loading