Skip to content

Commit 71c26e1

Browse files
keerthi-gpuibm
andauthored
enhancement(is_lb_pool_member): alb as ppnlb (IBM-Cloud#6131)
* enhancement(is_lb_pool_member): alb as ppnlb * enhancement(is_lb_pool_member): Update sdk version to v0.67.1 * enhancement(is_lb_pool_member): Fix doc * enhancement(is_lb_pool_member): Fix test * Added doc update for attached_load_balancer_pool_members in is_lb --------- Co-authored-by: Ujjwal Kumar <[email protected]>
1 parent 19f6bf4 commit 71c26e1

16 files changed

+363
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
github.com/IBM/secrets-manager-go-sdk/v2 v2.0.10
4444
github.com/IBM/vmware-go-sdk v0.1.3
4545
github.com/IBM/vpc-beta-go-sdk v0.8.0
46-
github.com/IBM/vpc-go-sdk v0.67.0
46+
github.com/IBM/vpc-go-sdk v0.67.1
4747
github.com/ScaleFT/sshkeys v0.0.0-20200327173127-6142f742bca5
4848
github.com/akamai/AkamaiOPEN-edgegrid-golang v1.2.2
4949
github.com/akamai/AkamaiOPEN-edgegrid-golang/v5 v5.0.0

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ github.com/IBM/vmware-go-sdk v0.1.3 h1:uJL3kwzM0jAKsT6Gj9tE5xT9SZBVXVaJvZdxrSMx8
176176
github.com/IBM/vmware-go-sdk v0.1.3/go.mod h1:OyQKRInGGsBaOyE5LIZCqH7b1DZ01BvIYa8BgGy+wWo=
177177
github.com/IBM/vpc-beta-go-sdk v0.8.0 h1:cEPpv4iw3Ba5W2d0AWg3TIbKeJ8y1nPuUuibR5Jt9eE=
178178
github.com/IBM/vpc-beta-go-sdk v0.8.0/go.mod h1:hORgIyTFRzXrZIK9IohaWmCRBBlYiDRagsufi7M6akE=
179-
github.com/IBM/vpc-go-sdk v0.66.0 h1:S0HW+f6Qf6OLSGESQ7WRgWLq1bDgvs+vvOJ7AWgUMbw=
180-
github.com/IBM/vpc-go-sdk v0.66.0/go.mod h1:VL7sy61ybg6tvA60SepoQx7TFe20m7JyNUt+se2tHP4=
181-
github.com/IBM/vpc-go-sdk v0.67.0 h1:p8G5bqTUyVheBrJpT+pLpoZoA/Yu1R2xX4xJLM4tT9w=
182-
github.com/IBM/vpc-go-sdk v0.67.0/go.mod h1:VL7sy61ybg6tvA60SepoQx7TFe20m7JyNUt+se2tHP4=
179+
github.com/IBM/vpc-go-sdk v0.67.1 h1:z0q1af1iItV4kHgreM21vzZtw6XQ13og2GBkX7WCJ8c=
180+
github.com/IBM/vpc-go-sdk v0.67.1/go.mod h1:VL7sy61ybg6tvA60SepoQx7TFe20m7JyNUt+se2tHP4=
183181
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0=
184182
github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:Zb3OT4l0mf7P/GOs2w2Ilj5sdm5Whoq3pa24dAEBHFc=
185183
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=

ibm/service/vpc/data_source_ibm_is_lb.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,40 @@ func DataSourceIBMISLB() *schema.Resource {
151151
Description: "Load Balancer subnets list",
152152
},
153153

154+
isAttachedLoadBalancerPoolMembers: {
155+
Type: schema.TypeList,
156+
Computed: true,
157+
Description: "The load balancer pool members attached to this load balancer.",
158+
Elem: &schema.Resource{
159+
Schema: map[string]*schema.Schema{
160+
"deleted": {
161+
Type: schema.TypeList,
162+
Computed: true,
163+
Description: "If present, this property indicates the referenced resource has been deleted and providessome supplementary information.",
164+
Elem: &schema.Resource{
165+
Schema: map[string]*schema.Schema{
166+
"more_info": {
167+
Type: schema.TypeString,
168+
Computed: true,
169+
Description: "Link to documentation about deleted resources.",
170+
},
171+
},
172+
},
173+
},
174+
"href": {
175+
Type: schema.TypeString,
176+
Computed: true,
177+
Description: "The URL for this load balancer pool member.",
178+
},
179+
"id": {
180+
Type: schema.TypeString,
181+
Computed: true,
182+
Description: "The unique identifier for this load balancer pool member.",
183+
},
184+
},
185+
},
186+
},
187+
154188
isLBSecurityGroups: {
155189
Type: schema.TypeSet,
156190
Computed: true,
@@ -483,6 +517,9 @@ func lbGetByName(d *schema.ResourceData, meta interface{}, name string) error {
483517
d.Set(isLBSubnets, subnetList)
484518
}
485519

520+
if lb.AttachedLoadBalancerPoolMembers != nil {
521+
d.Set(isAttachedLoadBalancerPoolMembers, dataSourceAttachedLoadBalancerPoolFlattenMembers(lb.AttachedLoadBalancerPoolMembers))
522+
}
486523
d.Set(isLBSecurityGroupsSupported, false)
487524
if lb.SecurityGroups != nil {
488525
securitygroupList := make([]string, 0)
@@ -599,3 +636,40 @@ func lbGetByName(d *schema.ResourceData, meta interface{}, name string) error {
599636
}
600637
return fmt.Errorf("[ERROR] No Load balancer found with name %s", name)
601638
}
639+
640+
func dataSourceAttachedLoadBalancerPoolFlattenMembers(result []vpcv1.LoadBalancerPoolMemberReference) (members []map[string]interface{}) {
641+
for _, membersItem := range result {
642+
members = append(members, dataSourceAttachedLoadBalancerPoolMembersToMap(membersItem))
643+
}
644+
645+
return members
646+
}
647+
648+
func dataSourceAttachedLoadBalancerPoolMembersToMap(membersItem vpcv1.LoadBalancerPoolMemberReference) (membersMap map[string]interface{}) {
649+
membersMap = map[string]interface{}{}
650+
651+
if membersItem.Deleted != nil {
652+
deletedList := []map[string]interface{}{}
653+
deletedMap := dataSourceAttachedLoadBalancerPoolMembersDeletedToMap(*membersItem.Deleted)
654+
deletedList = append(deletedList, deletedMap)
655+
membersMap["deleted"] = deletedList
656+
}
657+
if membersItem.Href != nil {
658+
membersMap["href"] = membersItem.Href
659+
}
660+
if membersItem.ID != nil {
661+
membersMap["id"] = membersItem.ID
662+
}
663+
664+
return membersMap
665+
}
666+
667+
func dataSourceAttachedLoadBalancerPoolMembersDeletedToMap(deletedItem vpcv1.Deleted) (deletedMap map[string]interface{}) {
668+
deletedMap = map[string]interface{}{}
669+
670+
if deletedItem.MoreInfo != nil {
671+
deletedMap["more_info"] = deletedItem.MoreInfo
672+
}
673+
674+
return deletedMap
675+
}

ibm/service/vpc/data_source_ibm_is_lb_profile.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,30 @@ func DataSourceIBMISLbProfile() *schema.Resource {
5252
},
5353
},
5454
},
55+
"targetable_load_balancer_profiles": {
56+
Type: schema.TypeList,
57+
Computed: true,
58+
Description: "The load balancer profiles that load balancers with this profile can target",
59+
Elem: &schema.Resource{
60+
Schema: map[string]*schema.Schema{
61+
"family": {
62+
Type: schema.TypeString,
63+
Computed: true,
64+
Description: "The product family this load balancer profile belongs to",
65+
},
66+
"href": {
67+
Type: schema.TypeString,
68+
Computed: true,
69+
Description: "The URL for this load balancer profile",
70+
},
71+
"name": {
72+
Type: schema.TypeString,
73+
Computed: true,
74+
Description: "The globally unique name for this load balancer profile",
75+
},
76+
},
77+
},
78+
},
5579
"href": {
5680
Type: schema.TypeString,
5781
Computed: true,
@@ -143,6 +167,10 @@ func dataSourceIBMISLbProfileRead(context context.Context, d *schema.ResourceDat
143167
AccessModesList = append(AccessModesList, AccessModesMap)
144168
d.Set(isLBAccessModes, AccessModesList)
145169
}
170+
171+
if lbProfile.TargetableLoadBalancerProfiles != nil {
172+
d.Set("targetable_load_balancer_profiles", dataSourceLbProfileFlattenTargetableLoadBalancerProfiles(lbProfile.TargetableLoadBalancerProfiles))
173+
}
146174
log.Printf("[INFO] lbprofile udp %v", lbProfile.UDPSupported)
147175
if lbProfile.UDPSupported != nil {
148176
udpSupport := lbProfile.UDPSupported
@@ -254,3 +282,29 @@ func dataSourceIBMIsLbProfileLoadBalancerProfileFailsafePolicyActionsDependentTo
254282
modelMap["type"] = *model.Type
255283
return modelMap, nil
256284
}
285+
286+
func dataSourceLbProfileFlattenTargetableLoadBalancerProfiles(result []vpcv1.LoadBalancerProfileReference) (targetableLoadBalancerProfiles []map[string]interface{}) {
287+
for _, targetableLoadBalancerProfileItem := range result {
288+
targetableLoadBalancerProfiles = append(targetableLoadBalancerProfiles, dataSourceLbProfileTargetableLoadBalancerProfilesToMap(targetableLoadBalancerProfileItem))
289+
}
290+
291+
return targetableLoadBalancerProfiles
292+
}
293+
294+
func dataSourceLbProfileTargetableLoadBalancerProfilesToMap(targetableLoadBalancerProfileItem vpcv1.LoadBalancerProfileReference) (targetableLoadBalancerProfileMap map[string]interface{}) {
295+
targetableLoadBalancerProfileMap = map[string]interface{}{}
296+
297+
if targetableLoadBalancerProfileItem.Family != nil {
298+
targetableLoadBalancerProfileMap["family"] = targetableLoadBalancerProfileItem.Family
299+
}
300+
301+
if targetableLoadBalancerProfileItem.Href != nil {
302+
targetableLoadBalancerProfileMap["href"] = targetableLoadBalancerProfileItem.Href
303+
}
304+
305+
if targetableLoadBalancerProfileItem.Name != nil {
306+
targetableLoadBalancerProfileMap["name"] = targetableLoadBalancerProfileItem.Name
307+
}
308+
309+
return targetableLoadBalancerProfileMap
310+
}

ibm/service/vpc/data_source_ibm_is_lb_profile_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func TestAccIBMISLBProfileDatasource_basic(t *testing.T) {
2727
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "href"),
2828
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "udp_supported"),
2929
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "access_modes.0.values.#"),
30+
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profile.test_profile", "targetable_load_balancer_profiles.#"),
3031
),
3132
},
3233
},

ibm/service/vpc/data_source_ibm_is_lb_profiles.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ func DataSourceIBMISLbProfiles() *schema.Resource {
6161
},
6262
},
6363
},
64+
"targetable_load_balancer_profiles": {
65+
Type: schema.TypeList,
66+
Computed: true,
67+
Description: "The load balancer profiles that load balancers with this profile can target",
68+
Elem: &schema.Resource{
69+
Schema: map[string]*schema.Schema{
70+
"family": {
71+
Type: schema.TypeString,
72+
Computed: true,
73+
Description: "The product family this load balancer profile belongs to",
74+
},
75+
"href": {
76+
Type: schema.TypeString,
77+
Computed: true,
78+
Description: "The URL for this load balancer profile",
79+
},
80+
"name": {
81+
Type: schema.TypeString,
82+
Computed: true,
83+
Description: "The globally unique name for this load balancer profile",
84+
},
85+
},
86+
},
87+
},
6488
"availability": {
6589
Type: schema.TypeList,
6690
Computed: true,
@@ -304,6 +328,11 @@ func dataSourceIBMISLbProfilesRead(d *schema.ResourceData, meta interface{}) err
304328
AccessModesList = append(AccessModesList, AccessModesMap)
305329
l[isLBAccessModes] = AccessModesList
306330
}
331+
332+
if profileCollector.TargetableLoadBalancerProfiles != nil {
333+
l["targetable_load_balancer_profiles"] = dataSourceLbProfileFlattenTargetableLoadBalancerProfiles(profileCollector.TargetableLoadBalancerProfiles)
334+
}
335+
307336
if profileCollector.Availability != nil {
308337
availabilitySupport := profileCollector.Availability.(*vpcv1.LoadBalancerProfileAvailability)
309338
availabilitySupportMap := map[string]interface{}{}

ibm/service/vpc/data_source_ibm_is_lb_profiles_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestAccIBMISLBProfilesDatasource_basic(t *testing.T) {
2424
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.#"),
2525
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.#"),
2626
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.access_modes.0.values.#"),
27+
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.targetable_load_balancer_profiles.#"),
2728
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.route_mode_supported"),
2829
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.href"),
2930
resource.TestCheckResourceAttrSet("data.ibm_is_lb_profiles.test_profiles", "lb_profiles.0.udp_supported"),

ibm/service/vpc/data_source_ibm_is_lbs.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,39 @@ func DataSourceIBMISLBS() *schema.Resource {
3737
Computed: true,
3838
Description: "The access mode of this load balancer",
3939
},
40+
isAttachedLoadBalancerPoolMembers: {
41+
Type: schema.TypeList,
42+
Computed: true,
43+
Description: "The load balancer pool members attached to this load balancer.",
44+
Elem: &schema.Resource{
45+
Schema: map[string]*schema.Schema{
46+
"deleted": {
47+
Type: schema.TypeList,
48+
Computed: true,
49+
Description: "If present, this property indicates the referenced resource has been deleted and providessome supplementary information.",
50+
Elem: &schema.Resource{
51+
Schema: map[string]*schema.Schema{
52+
"more_info": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
Description: "Link to documentation about deleted resources.",
56+
},
57+
},
58+
},
59+
},
60+
"href": {
61+
Type: schema.TypeString,
62+
Computed: true,
63+
Description: "The URL for this load balancer pool member.",
64+
},
65+
"id": {
66+
Type: schema.TypeString,
67+
Computed: true,
68+
Description: "The unique identifier for this load balancer pool member.",
69+
},
70+
},
71+
},
72+
},
4073
ID: {
4174
Type: schema.TypeString,
4275
Computed: true,
@@ -353,6 +386,9 @@ func getLbs(d *schema.ResourceData, meta interface{}) error {
353386
if lb.AccessMode != nil {
354387
lbInfo[isLBAccessMode] = *lb.AccessMode
355388
}
389+
if lb.AttachedLoadBalancerPoolMembers != nil {
390+
lbInfo[isAttachedLoadBalancerPoolMembers] = dataSourceAttachedLoadBalancerPoolFlattenMembers(lb.AttachedLoadBalancerPoolMembers)
391+
}
356392
if lb.InstanceGroupsSupported != nil {
357393
lbInfo[isLBInstanceGroupsSupported] = *lb.InstanceGroupsSupported
358394
}

ibm/service/vpc/resource_ibm_is_lb.go

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const (
4848
isLBSecurityGroups = "security_groups"
4949
isLBSecurityGroupsSupported = "security_group_supported"
5050

51-
isLBAccessTags = "access_tags"
51+
isAttachedLoadBalancerPoolMembers = "attached_load_balancer_pool_members"
52+
isLBAccessTags = "access_tags"
5253
)
5354

5455
func ResourceIBMISLB() *schema.Resource {
@@ -100,7 +101,39 @@ func ResourceIBMISLB() *schema.Resource {
100101
ValidateFunc: validate.InvokeValidator("ibm_is_lb", isLBType),
101102
Description: "Load Balancer type",
102103
},
103-
104+
isAttachedLoadBalancerPoolMembers: {
105+
Type: schema.TypeList,
106+
Computed: true,
107+
Description: "The load balancer pool members attached to this load balancer.",
108+
Elem: &schema.Resource{
109+
Schema: map[string]*schema.Schema{
110+
"deleted": {
111+
Type: schema.TypeList,
112+
Computed: true,
113+
Description: "If present, this property indicates the referenced resource has been deleted and providessome supplementary information.",
114+
Elem: &schema.Resource{
115+
Schema: map[string]*schema.Schema{
116+
"more_info": {
117+
Type: schema.TypeString,
118+
Computed: true,
119+
Description: "Link to documentation about deleted resources.",
120+
},
121+
},
122+
},
123+
},
124+
"href": {
125+
Type: schema.TypeString,
126+
Computed: true,
127+
Description: "The URL for this load balancer pool member.",
128+
},
129+
"id": {
130+
Type: schema.TypeString,
131+
Computed: true,
132+
Description: "The unique identifier for this load balancer pool member.",
133+
},
134+
},
135+
},
136+
},
104137
isLBAvailability: {
105138
Type: schema.TypeString,
106139
Computed: true,
@@ -558,6 +591,9 @@ func lbGet(d *schema.ResourceData, meta interface{}, id string) error {
558591
if lb.Availability != nil {
559592
d.Set(isLBAvailability, *lb.Availability)
560593
}
594+
if lb.AttachedLoadBalancerPoolMembers != nil {
595+
d.Set(isAttachedLoadBalancerPoolMembers, dataSourceAttachedLoadBalancerPoolFlattenMembers(lb.AttachedLoadBalancerPoolMembers))
596+
}
561597
if lb.AccessMode != nil {
562598
d.Set(isLBAccessMode, *lb.AccessMode)
563599
}

0 commit comments

Comments
 (0)