Skip to content

Commit

Permalink
Merge pull request #1224 from citrix/1196-bug-gslb-backup-vserver-not…
Browse files Browse the repository at this point in the history
…-configured-on-first-attempt

Updated gslbvserver resource to handle backupvserver attribute
  • Loading branch information
rohit-myali authored Nov 21, 2024
2 parents 107679b + d147e92 commit 1710d6e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 45 deletions.
29 changes: 16 additions & 13 deletions citrixadc/resource_citrixadc_gslbvserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/mitchellh/mapstructure"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"

"fmt"
Expand Down Expand Up @@ -121,8 +120,7 @@ func resourceCitrixAdcGslbvserver() *schema.Resource {
},
"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
ForceNew: true,
},
"netmask": {
Expand Down Expand Up @@ -152,8 +150,7 @@ func resourceCitrixAdcGslbvserver() *schema.Resource {
},
"servicetype": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Required: true,
ForceNew: true,
},
"sitedomainttl": {
Expand Down Expand Up @@ -304,19 +301,13 @@ func resourceCitrixAdcGslbvserver() *schema.Resource {
func createGslbvserverFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] netscaler-provider: In createGslbvserverFunc")
client := meta.(*NetScalerNitroClient).client
var gslbvserverName string
if v, ok := d.GetOk("name"); ok {
gslbvserverName = v.(string)
} else {
gslbvserverName = resource.PrefixedUniqueId("tf-gslbvserver-")
d.Set("name", gslbvserverName)
}
gslbvserverName := d.Get("name").(string)

gslbvserver := gslb.Gslbvserver{
Appflowlog: d.Get("appflowlog").(string),
Backupip: d.Get("backupip").(string),
Backuplbmethod: d.Get("backuplbmethod").(string),
Backupsessiontimeout: d.Get("backupsessiontimeout").(int),
Backupvserver: d.Get("backupvserver").(string),
Comment: d.Get("comment").(string),
Considereffectivestate: d.Get("considereffectivestate").(string),
Cookiedomain: d.Get("cookiedomain").(string),
Expand Down Expand Up @@ -358,6 +349,18 @@ func createGslbvserverFunc(d *schema.ResourceData, meta interface{}) error {
return err
}

if _, ok := d.GetOk("backupvserver"); ok {

backupvserverData := make(map[string]string)
backupvserverData["backupvserver"] = d.Get("backupvserver").(string)
backupvserverData["name"] = gslbvserverName

_, err := client.UpdateResource(service.Gslbvserver.Type(), gslbvserverName, backupvserverData)
if err != nil {
return err
}
}

d.SetId(gslbvserverName)
domains := d.Get("domain").(*schema.Set).List()
for _, val := range domains {
Expand Down
48 changes: 16 additions & 32 deletions docs/resources/gslbvserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,21 @@ This resource is used to manage Global Service Load Balancing vserver.
## Example usage

```hcl
resource "citrixadc_gslbservice" "gslb_svc2" {
ip = "172.16.17.121"
port = "80"
servicename = "gslb2vservice"
servicetype = "HTTP"
sitename = citrixadc_gslbsite.site_remote.sitename
}
resource "citrixadc_gslbvserver" "tf_gslbvserver" {
dnsrecordtype = "A"
name = "GSLB_East_Coast_Vserver"
servicetype = "HTTP"
domain {
domainname = "www.fooco.co"
ttl = "60"
}
domain {
domainname = "www.barco.com"
ttl = "65"
}
service {
servicename = "tf_gslbservice1"
weight = "75"
}
service {
servicename = "tf_gslbservice2"
weight = "100"
}
name = "GSLB_East_Coast_Vserver"
servicetype = "HTTP"
state = "ENABLED"
edr = "ENABLED"
mir = "DISABLED"
lbmethod = "ROUNDROBIN"
}
```


## Argument Reference

* `name` - (Optional) Name for the GSLB virtual server.
* `servicetype` - (Optional) Protocol used by services bound to the virtual server. Possible values: [ HTTP, FTP, TCP, UDP, SSL, SSL\_BRIDGE, SSL\_TCP, NNTP, ANY, SIP\_UDP, SIP\_TCP, SIP\_SSL, RADIUS, RDP, RTSP, MYSQL, MSSQL, ORACLE ]
* `name` - (Required) Name for the GSLB virtual server.
* `servicetype` - (Required) Protocol used by services bound to the virtual server. Possible values: [ HTTP, FTP, TCP, UDP, SSL, SSL\_BRIDGE, SSL\_TCP, NNTP, ANY, SIP\_UDP, SIP\_TCP, SIP\_SSL, RADIUS, RDP, RTSP, MYSQL, MSSQL, ORACLE ]
* `iptype` - (Optional) The IP type for this GSLB vserver. Possible values: [ IPV4, IPV6 ]
* `dnsrecordtype` - (Optional) DNS record type to associate with the GSLB virtual server's domain name. Possible values: [ A, AAAA, CNAME, NAPTR ]
* `lbmethod` - (Optional) Load balancing method for the GSLB virtual server. Possible values: [ ROUNDROBIN, LEASTCONNECTION, LEASTRESPONSETIME, SOURCEIPHASH, LEASTBANDWIDTH, LEASTPACKETS, STATICPROXIMITY, RTT, CUSTOMLOAD, API ]
Expand Down Expand Up @@ -89,8 +67,14 @@ resource "citrixadc_gslbvserver" "tf_gslbvserver" {
* `cookiedomain` - (Optional) The cookie domain for the GSLB site. Used when inserting the GSLB site cookie in the HTTP response.
* `cookietimeout` - (Optional) Timeout, in minutes, for the GSLB site cookie.
* `sitedomainttl` - (Optional) TTL, in seconds, for all internally created site domains (created when a site prefix is configured on a GSLB service) that are associated with this virtual server.
* `domain` - (Optional) A set of domain binding blocks. Documented below.
* `service` - (Optional) A set of GSLB service biding blocks. Documented below.
* `domain` - (Optional) A set of domain binding blocks. Documented below. (deprecates soon)
* `service` - (Optional) A set of GSLB service biding blocks. Documented below. (deprecates soon)

!>
[**DEPRECATED**] Please use [`gslbvserver_domain_binding`](https://registry.terraform.io/providers/citrix/citrixadc/latest/docs/resources/gslbvserver_domain_binding) to bind `domain` to `gslbvserver` instead of this resource. Support for binding `domain` to `gslbvserver` in this resource will be deprecated soon.

!>
[**DEPRECATED**] Please use [`gslbvserver_gslbservice_binding`](https://registry.terraform.io/providers/citrix/citrixadc/latest/docs/resources/gslbvserver_gslbservice_binding) to bind `gslbservice` to `gslbvserver` instead of this resource. Support for binding `gslbservice` to `gslbvserver` in this resource will be deprecated soon.

A domain binding supports the following:

Expand Down

0 comments on commit 1710d6e

Please sign in to comment.