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 replication_pool_map to disaster recovery data sources #147

Closed
wants to merge 5 commits into from
Closed
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
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
8 changes: 2 additions & 6 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 All @@ -138,8 +138,6 @@ github.com/IBM/container-registry-go-sdk v1.1.0 h1:sYyknIod8R4RJZQqAheiduP6wbSTp
github.com/IBM/container-registry-go-sdk v1.1.0/go.mod h1:4TwsCnQtVfZ4Vkapy/KPvQBKFc3VOyUZYkwRU4FTPrs=
github.com/IBM/continuous-delivery-go-sdk v1.6.0 h1:eAL/jIWHrDFlWDF+Qd9Y5UN99Pr5Mjd/H/bvTbXUbz4=
github.com/IBM/continuous-delivery-go-sdk v1.6.0/go.mod h1:nZdKUnubXNLo+zo28R4Rd+TGDqiJ/xoE8WO/A3kLw1E=
github.com/IBM/event-notifications-go-admin-sdk v0.8.0 h1:xk2CYTayQtKi6LSgGGFRxFJfWUxyM5SY8Rs64ducAhw=
github.com/IBM/event-notifications-go-admin-sdk v0.8.0/go.mod h1:OByvqfrNVxs7G6ggv8pwQCEVw10/TBJCLh7NM3z707w=
github.com/IBM/event-notifications-go-admin-sdk v0.9.0 h1:eaCd+GkxhNyot+8rA9WkAQdlVYrRD20LYiXjEytFO6M=
github.com/IBM/event-notifications-go-admin-sdk v0.9.0/go.mod h1:OByvqfrNVxs7G6ggv8pwQCEVw10/TBJCLh7NM3z707w=
github.com/IBM/eventstreams-go-sdk v1.4.0 h1:yS/Ns29sBOe8W2tynQmz9HTKqQZ0ckse4Py5Oy/F2rM=
Expand Down Expand Up @@ -187,8 +185,6 @@ github.com/IBM/scc-go-sdk/v5 v5.4.1 h1:RXIuxOo9/hxkWyHCI69ae+KIJgSbXcAkJwTEl+fO3
github.com/IBM/scc-go-sdk/v5 v5.4.1/go.mod h1:2xQTDgNXG5QMEfQxBDKB067z+5ha6OgcaKCTcdGDAo8=
github.com/IBM/schematics-go-sdk v0.2.3 h1:lgTt0Sbudii3cuSk1YSQgrtiZAXDbBABAoVj3eQuBrU=
github.com/IBM/schematics-go-sdk v0.2.3/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.5 h1:VMc/Zd6RzB8j60CqZekkwYT2wQsCfrkGV2n01Gviuaw=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.5/go.mod h1:5kUgJ1dG9cdiAcPDqVz46m362bPnoqZQSth24NiowSg=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.6 h1:bF6bAdI4wDZSje6+Yx1mJxvirboxO+uMuKhzgfRCNxE=
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.6/go.mod h1:XWYnbcc5vN1RnKwk/fCzfD8aZd7At/Y1/b6c+oDyliU=
github.com/IBM/vmware-go-sdk v0.1.2 h1:5lKWFyInWz9e2hwGsoFTEoLa1jYkD30SReN0fQ10w9M=
Expand Down
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 @@ -290,7 +290,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
4 changes: 4 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,7 @@ 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.
5 changes: 4 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,10 @@ 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.
Loading