Skip to content

Commit

Permalink
Add replication_pool_map to disaster recovery data sources (GRS)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kita committed Oct 11, 2024
1 parent 040936f commit e2c4487
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 13 deletions.
38 changes: 34 additions & 4 deletions ibm/service/power/data_source_ibm_pi_disaster_recovery_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,25 @@ func DataSourceIBMPIDisasterRecoveryLocation() *schema.Resource {
Description: "The region zone of the location.",
Type: schema.TypeString,
},
Attr_ReplicationPoolMap: {
Computed: true,
Description: "List of replication pool map.",
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Attr_RemotePool: {
Computed: true,
Description: "Remote pool.",
Type: schema.TypeString,
},
Attr_VolumePool: {
Computed: true,
Description: "Volume pool.",
Type: schema.TypeString,
},
},
},
},
},
},
Type: schema.TypeList,
Expand All @@ -69,11 +88,22 @@ func dataSourceIBMPIDisasterRecoveryLocation(ctx context.Context, d *schema.Reso
}

result := make([]map[string]interface{}, 0, len(drLocationSite.ReplicationSites))
for _, i := range drLocationSite.ReplicationSites {
if i != nil {
for _, site := range drLocationSite.ReplicationSites {
if site != nil {
replicationPoolMap := make([]map[string]string, 0)
if site.ReplicationPoolMap != nil {
for _, rMap := range site.ReplicationPoolMap {
replicationPool := make(map[string]string)
replicationPool[Attr_RemotePool] = rMap.RemotePool
replicationPool[Attr_VolumePool] = rMap.VolumePool
replicationPoolMap = append(replicationPoolMap, replicationPool)
}
}

l := map[string]interface{}{
Attr_IsActive: i.IsActive,
Attr_Location: i.Location,
Attr_IsActive: site.IsActive,
Attr_Location: site.Location,
Attr_ReplicationPoolMap: replicationPoolMap,
}
result = append(result, l)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ func DataSourceIBMPIDisasterRecoveryLocations() *schema.Resource {
Description: "The region zone of the location.",
Type: schema.TypeString,
},
Attr_ReplicationPoolMap: {
Computed: true,
Description: "List of replication pool map.",
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Attr_RemotePool: {
Computed: true,
Description: "Remote pool.",
Type: schema.TypeString,
},
Attr_VolumePool: {
Computed: true,
Description: "Volume pool.",
Type: schema.TypeString,
},
},
},
},
},
},
Type: schema.TypeList,
Expand All @@ -67,20 +86,30 @@ func dataSourceIBMPIDisasterRecoveryLocations(ctx context.Context, d *schema.Res
}

results := make([]map[string]interface{}, 0, len(drLocationSites.DisasterRecoveryLocations))
for _, i := range drLocationSites.DisasterRecoveryLocations {
if i != nil {
replicationSites := make([]map[string]interface{}, 0, len(i.ReplicationSites))
for _, j := range i.ReplicationSites {
if j != nil {
for _, drl := range drLocationSites.DisasterRecoveryLocations {
if drl != nil {
replicationSites := make([]map[string]interface{}, 0, len(drl.ReplicationSites))
for _, site := range drl.ReplicationSites {
if site != nil {
replicationPoolMap := make([]map[string]string, 0)
if site.ReplicationPoolMap != nil {
for _, rMap := range site.ReplicationPoolMap {
replicationPool := make(map[string]string)
replicationPool[Attr_RemotePool] = rMap.RemotePool
replicationPool[Attr_VolumePool] = rMap.VolumePool
replicationPoolMap = append(replicationPoolMap, replicationPool)
}
}
r := map[string]interface{}{
Attr_IsActive: j.IsActive,
Attr_Location: j.Location,
Attr_IsActive: site.IsActive,
Attr_Location: site.Location,
Attr_ReplicationPoolMap: replicationPoolMap,
}
replicationSites = append(replicationSites, r)
}
}
l := map[string]interface{}{
Attr_Location: i.Location,
Attr_Location: drl.Location,
Attr_ReplicationSites: replicationSites,
}
results = append(results, l)
Expand Down
2 changes: 2 additions & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ const (
Attr_RemoteCopyID = "remote_copy_id"
Attr_RemoteCopyRelationshipNames = "remote_copy_relationship_names"
Attr_RemoteCopyRelationships = "remote_copy_relationships"
Attr_RemotePool = "remote_pool"
Attr_ReplicationEnabled = "replication_enabled"
Attr_ReplicationPoolMap = "replication_pool_map"
Attr_ReplicationSites = "replication_sites"
Attr_ReplicationStatus = "replication_status"
Attr_ReplicationType = "replication_type"
Expand Down
5 changes: 5 additions & 0 deletions website/docs/d/pi_disaster_recovery_location.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ In addition to all argument reference list, you can access the following attribu
Nested scheme for `replication_sites`:
- `is_active` - (Boolean) Indicates the location is active or not, `true` if location is active , otherwise it is `false`.
- `location` - (String) The region zone of the location.
- `replication_pool_map` - (List) List of replication pool map.

Nested scheme for `replication_pool_map`:
- `remote_pool` - (String) Remote pool.
- `volume_pool` - (String) Volume pool.
7 changes: 6 additions & 1 deletion website/docs/d/pi_disaster_recovery_locations.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ In addition to all argument reference list, you can access the following attribu
Nested scheme for `disaster_recovery_locations`:
- `location` - (String) The region zone of a site.
- `replication_sites` - List of Replication Sites.

Nested scheme for `replication_sites`:
- `is_active` - (Boolean) Indicates the location is active or not, `true` if location is active, otherwise it is `false`.
- `location` - (String) The region zone of the location.
- `replication_pool_map` - (List) List of replication pool maps.

Nested scheme for `replication_pool_map`:
- `remote_pool` - (String) Remote pool.
- `volume_pool` - (String) Volume pool.

0 comments on commit e2c4487

Please sign in to comment.