Skip to content

Commit

Permalink
adding fix for jira-1414
Browse files Browse the repository at this point in the history
  • Loading branch information
RavinderReddyF5 committed Jan 23, 2024
1 parent a2cefee commit 827e046
Show file tree
Hide file tree
Showing 4 changed files with 209 additions and 17 deletions.
23 changes: 9 additions & 14 deletions bigip/resource_bigip_as3.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func resourceBigipAs3() *schema.Resource {
delete(rec, "id")
delete(rec, "label")
delete(rec, "remark")
delete(rec, "Common")
}
}
}
Expand All @@ -85,6 +86,7 @@ func resourceBigipAs3() *schema.Resource {
delete(rec, "id")
delete(rec, "label")
delete(rec, "remark")
delete(rec, "Common")
}
}
}
Expand Down Expand Up @@ -155,7 +157,7 @@ func resourceBigipAs3() *schema.Resource {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Name of Application",
Description: "Application deployed through AS3 Declaration",
},
"task_id": {
Type: schema.TypeString,
Expand All @@ -166,7 +168,7 @@ func resourceBigipAs3() *schema.Resource {
"per_app_mode": {
Type: schema.TypeBool,
Computed: true,
Description: "Set True if Per-Application Mode is true",
Description: "Will define Perapp mode enabled on BIG-IP or not",
},
},
}
Expand All @@ -191,20 +193,18 @@ func resourceBigipAs3Create(ctx context.Context, d *schema.ResourceData, meta in
tenant, err := GenerateRandomString(10)
log.Printf("[DEBUG] tenant name generated:%+v", tenant)
if err != nil {
// fmt.Println("Error:", err)
return diag.FromErr(fmt.Errorf("could not generate random tenant name"))
}

applicationList := client.GetAppsList(as3Json)

Check failure on line 198 in bigip/resource_bigip_as3.go

View workflow job for this annotation

GitHub Actions / golint

client.GetAppsList undefined (type *"github.com/f5devcentral/go-bigip".BigIP has no field or method GetAppsList)
err, taskID := client.PostPerAppBigIp(as3Json, tenant)

Check failure on line 199 in bigip/resource_bigip_as3.go

View workflow job for this annotation

GitHub Actions / golint

client.PostPerAppBigIp undefined (type *"github.com/f5devcentral/go-bigip".BigIP has no field or method PostPerAppBigIp)

log.Printf("[DEBUG] task Id from deployment :%+v", taskID)

if err != nil {
return diag.FromErr(fmt.Errorf("posting as3 config failed for tenants:(%s) with error: %v", tenantFilter, err))
}
tenantCount = append(tenantCount, tenant)
_ = d.Set("tenant_list", tenant)
_ = d.Set("task_id", taskID)
_ = d.Set("application_list", applicationList)
_ = d.Set("per_app_mode", true)
} else {
log.Printf("[INFO] Creating As3 config for tenants:%+v", tenantList)
Expand Down Expand Up @@ -276,7 +276,7 @@ func resourceBigipAs3Read(ctx context.Context, d *schema.ResourceData, meta inte
var name string
var tList string
as3Json := d.Get("as3_json").(string)

log.Printf("[INFO] AS3 config:%+v", as3Json)
if d.Get("as3_json") != nil {
tList, _, _ = client.GetTenantList(as3Json)
if createdTenants != "" && createdTenants != tList {
Expand All @@ -288,9 +288,9 @@ func resourceBigipAs3Read(ctx context.Context, d *schema.ResourceData, meta inte
} else {
name = d.Id()
}

applicationList := d.Get("application_list").(string)
log.Printf("[DEBUG] Tenants in AS3 get call : %s", name)
log.Printf("[DEBUG] Applications in AS3 get call : %s", applicationList)
if name != "" {
as3Resp, err := client.GetAs3(name, applicationList)
log.Printf("[DEBUG] AS3 json retreived from the GET call in Read function : %s", as3Resp)
Expand Down Expand Up @@ -337,16 +337,11 @@ func resourceBigipAs3Update(ctx context.Context, d *schema.ResourceData, meta in
}
log.Printf("[DEBUG] perApplication:%+v", perApplication)
if d.Get("per_app_mode").(bool) {

if perApplication && len(tenantList) == 0 {
oldTenantList := d.Get("tenant_list").(string)

log.Printf("[INFO] Updating As3 Config for tenant:%s with Per-Application Mode:%v", oldTenantList, perApplication)

err, res := client.PostPerAppBigIp(as3Json, oldTenantList)

log.Printf("[DEBUG] res from PostPerAppBigIp:%+v", res)

if err != nil {
return diag.FromErr(fmt.Errorf("posting as3 config failed for tenant:(%s) with error: %v", oldTenantList, err))
}
Expand All @@ -356,7 +351,7 @@ func resourceBigipAs3Update(ctx context.Context, d *schema.ResourceData, meta in
if !perApplication {
return diag.FromErr(fmt.Errorf("Per-Application should be true in Big-IP Setting"))
} else {
return diag.FromErr(fmt.Errorf("Declartion not valid for Per-Application deployment"))
return diag.FromErr(fmt.Errorf("declartion not valid for Per-Application deployment"))
}
}
} else {
Expand Down
140 changes: 140 additions & 0 deletions examples/as3/issue869.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"class": "AS3",
"action": "deploy",
"persist": true,
"declaration":
{
"class": "ADC",
"schemaVersion": "3.37.0",
"id": "GSLB_Sample",
"Sample_non_http_05": {
"class": "Tenant",
"Application": {
"class": "Application",
"testDomain": {
"class": "GSLB_Domain",
"domainName": "example.edu",
"aliases": [
"another.example*" ],
"resourceRecordType": "A",
"poolLbMode": "ratio",
"pools": [
{
"ratio": 2,
"use": "testPool"
},
{
"ratio": 3,
"use": "testPool2"
}
],
"iRules": [
"testGSLB_iRule"
]
},
"testPool": {
"class": "GSLB_Pool",
"enabled": false,
"lbModeAlternate": "ratio",
"lbModeFallback": "ratio",
"manualResumeEnabled": true,
"verifyMemberEnabled": false,
"qosHitRatio": 10,
"qosHops": 11,
"qosKbps": 8,
"qosLinkCapacity": 35,
"qosPacketRate": 5,
"qosRoundTripTime": 75,
"qosTopology": 3,
"qosVirtualServerCapacity": 2,
"qosVirtualServerScore": 1,
"members": [
{
"ratio": 10,
"server": {
"use": "/Common/Shared/testServer"
},
"virtualServer": "0"
}
],
"bpsLimit": 5,
"bpsLimitEnabled": true,
"ppsLimit": 4,
"ppsLimitEnabled": true,
"connectionsLimit": 3,
"connectionsLimitEnabled": true,
"maxAnswersReturned": 10,
"monitors": [
{
"bigip": "/Common/http"
},
{
"bigip": "/Common/https"
}
],
"resourceRecordType": "A",
"fallbackIP": "2.2.2.2"
},
"testPool2": {
"class": "GSLB_Pool",
"resourceRecordType": "A"
},
"testGSLB_iRule": {
"class": "GSLB_iRule",
"iRule": {
"base64": "d2hlbiBETlNfUkVRVUVTVCB7CiAgICBsb2cgbG9jYWwyLiAiR1RNIGlydWxlOiBBIEROUyByZXF1ZXN0IHdhcyBzZWVuIGZvciBbRE5TOjpxdWVzdGlvbiBuYW1lXSBzZWVuIGZyb20gW0lQOjpjbGllbnRfYWRkcl0iCn0="
}
}
}
},
"Common": {
"class": "Tenant",
"Shared": {
"class": "Application",
"template": "shared",
"testDataCenter": {
"class": "GSLB_Data_Center"
},
"testProberPool": {
"class": "GSLB_Prober_Pool",
"enabled": true,
"lbMode": "round-robin",
"members": [
{
"server": {
"use": "testServer"
},
"memberOrder": 0
}
]
},
"testServer": {
"class": "GSLB_Server",
"dataCenter": {
"use": "testDataCenter"
},
"devices": [
{
"address": "1.2.3.7"
}
],
"proberPreferred": "pool",
"proberPool": {
"use": "testProberPool"
},
"virtualServers": [
{
"address": "1.2.4.8",
"port": 5050
},
{
"address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"port": 5051
}
]
}

}
}
}
}
29 changes: 29 additions & 0 deletions examples/as3/jira1401.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"controls": {
"class": "Controls",
"logLevel": "debug",
"trace": true
},
"PerappA1": {
"class": "Application",
"service": {
"class": "Service_HTTP",
"virtualAddresses": [
"192.0.2.1"
],
"pool": "pool"
},
"pool": {
"class": "Pool",
"members": [
{
"servicePort": 80,
"serverAddresses": [
"192.0.2.10",
"192.0.2.20"
]
}
]
}
}
}
34 changes: 31 additions & 3 deletions vendor/github.com/f5devcentral/go-bigip/as3bigip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 827e046

Please sign in to comment.