Skip to content

Commit

Permalink
Merge pull request #140 from citrix/quicbridge
Browse files Browse the repository at this point in the history
Quicbridge
  • Loading branch information
George Nikolopoulos authored Mar 3, 2021
2 parents b050ac9 + 510a637 commit 1925f9b
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 4 deletions.
1 change: 1 addition & 0 deletions citrixadc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func providerResources() map[string]*schema.Resource {
"citrixadc_csvserver_transformpolicy_binding": resourceCitrixAdcCsvserver_transformpolicy_binding(),
"citrixadc_sslvserver_sslcertkey_binding": resourceCitrixAdcSslvserver_sslcertkey_binding(),
"citrixadc_servicegroup_servicegroupmember_binding": resourceCitrixAdcServicegroup_servicegroupmember_binding(),
"citrixadc_quicbridgeprofile": resourceCitrixAdcQuicbridgeprofile(),
}
}

Expand Down
156 changes: 152 additions & 4 deletions citrixadc/resource_citrixadc_lbvserver.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package citrixadc

import (
"github.com/chiradeep/go-nitro/config/lb"
"github.com/chiradeep/go-nitro/config/ssl"

"github.com/chiradeep/go-nitro/netscaler"
Expand All @@ -12,6 +11,144 @@ import (
"log"
)

// TODO: update go-nitro with quicbridgeprofilename attribute
type lbvserver struct {
Activeservices int `json:"activeservices,omitempty"`
Adfsproxyprofile string `json:"adfsproxyprofile,omitempty"`
Appflowlog string `json:"appflowlog,omitempty"`
Authentication string `json:"authentication,omitempty"`
Authenticationhost string `json:"authenticationhost,omitempty"`
Authn401 string `json:"authn401,omitempty"`
Authnprofile string `json:"authnprofile,omitempty"`
Authnvsname string `json:"authnvsname,omitempty"`
Backuplbmethod string `json:"backuplbmethod,omitempty"`
Backuppersistencetimeout int `json:"backuppersistencetimeout,omitempty"`
Backupvserver string `json:"backupvserver,omitempty"`
Backupvserverstatus string `json:"backupvserverstatus,omitempty"`
Bindpoint string `json:"bindpoint,omitempty"`
Bypassaaaa string `json:"bypassaaaa,omitempty"`
Cacheable string `json:"cacheable,omitempty"`
Cachevserver string `json:"cachevserver,omitempty"`
Clttimeout int `json:"clttimeout,omitempty"`
Comment string `json:"comment,omitempty"`
Connfailover string `json:"connfailover,omitempty"`
Consolidatedlconn string `json:"consolidatedlconn,omitempty"`
Consolidatedlconngbl string `json:"consolidatedlconngbl,omitempty"`
Cookiedomain string `json:"cookiedomain,omitempty"`
Cookiename string `json:"cookiename,omitempty"`
Curstate string `json:"curstate,omitempty"`
Datalength int `json:"datalength,omitempty"`
Dataoffset int `json:"dataoffset,omitempty"`
Dbprofilename string `json:"dbprofilename,omitempty"`
Dbslb string `json:"dbslb,omitempty"`
Disableprimaryondown string `json:"disableprimaryondown,omitempty"`
Dns64 string `json:"dns64,omitempty"`
Dnsprofilename string `json:"dnsprofilename,omitempty"`
Dnsvservername string `json:"dnsvservername,omitempty"`
Domain string `json:"domain,omitempty"`
Downstateflush string `json:"downstateflush,omitempty"`
Effectivestate string `json:"effectivestate,omitempty"`
Groupname string `json:"groupname,omitempty"`
Gt2gb string `json:"gt2gb,omitempty"`
Hashlength int `json:"hashlength,omitempty"`
Health int `json:"health,omitempty"`
Healththreshold int `json:"healththreshold,omitempty"`
Homepage string `json:"homepage,omitempty"`
Httpprofilename string `json:"httpprofilename,omitempty"`
Httpsredirecturl string `json:"httpsredirecturl,omitempty"`
Icmpvsrresponse string `json:"icmpvsrresponse,omitempty"`
Insertvserveripport string `json:"insertvserveripport,omitempty"`
Ipmapping string `json:"ipmapping,omitempty"`
Ipmask string `json:"ipmask,omitempty"`
Ippattern string `json:"ippattern,omitempty"`
Ipset string `json:"ipset,omitempty"`
Ipv46 string `json:"ipv46,omitempty"`
Isgslb bool `json:"isgslb,omitempty"`
L2conn string `json:"l2conn,omitempty"`
Lbmethod string `json:"lbmethod,omitempty"`
Lbprofilename string `json:"lbprofilename,omitempty"`
Lbrrreason int `json:"lbrrreason,omitempty"`
Listenpolicy string `json:"listenpolicy,omitempty"`
Listenpriority int `json:"listenpriority,omitempty"`
M string `json:"m,omitempty"`
Macmoderetainvlan string `json:"macmoderetainvlan,omitempty"`
Map string `json:"map,omitempty"`
Maxautoscalemembers int `json:"maxautoscalemembers,omitempty"`
Minautoscalemembers int `json:"minautoscalemembers,omitempty"`
Mssqlserverversion string `json:"mssqlserverversion,omitempty"`
Mysqlcharacterset int `json:"mysqlcharacterset,omitempty"`
Mysqlprotocolversion int `json:"mysqlprotocolversion,omitempty"`
Mysqlservercapabilities int `json:"mysqlservercapabilities,omitempty"`
Mysqlserverversion string `json:"mysqlserverversion,omitempty"`
Name string `json:"name,omitempty"`
Netmask string `json:"netmask,omitempty"`
Netprofile string `json:"netprofile,omitempty"`
Newname string `json:"newname,omitempty"`
Newservicerequest int `json:"newservicerequest,omitempty"`
Newservicerequestincrementinterval int `json:"newservicerequestincrementinterval,omitempty"`
Newservicerequestunit string `json:"newservicerequestunit,omitempty"`
Ngname string `json:"ngname,omitempty"`
Nodefaultbindings string `json:"nodefaultbindings,omitempty"`
Oracleserverversion string `json:"oracleserverversion,omitempty"`
Persistavpno interface{} `json:"persistavpno,omitempty"`
Persistencebackup string `json:"persistencebackup,omitempty"`
Persistencetype string `json:"persistencetype,omitempty"`
Persistmask string `json:"persistmask,omitempty"`
Port int `json:"port,omitempty"`
Pq string `json:"pq,omitempty"`
Precedence string `json:"precedence,omitempty"`
Processlocal string `json:"processlocal,omitempty"`
Push string `json:"push,omitempty"`
Pushlabel string `json:"pushlabel,omitempty"`
Pushmulticlients string `json:"pushmulticlients,omitempty"`
Pushvserver string `json:"pushvserver,omitempty"`
Range int `json:"range,omitempty"`
Recursionavailable string `json:"recursionavailable,omitempty"`
Redirect string `json:"redirect,omitempty"`
Redirectfromport int `json:"redirectfromport,omitempty"`
Redirectportrewrite string `json:"redirectportrewrite,omitempty"`
Redirurl string `json:"redirurl,omitempty"`
Redirurlflags bool `json:"redirurlflags,omitempty"`
Resrule string `json:"resrule,omitempty"`
Retainconnectionsoncluster string `json:"retainconnectionsoncluster,omitempty"`
Rhistate string `json:"rhistate,omitempty"`
Rtspnat string `json:"rtspnat,omitempty"`
Rule string `json:"rule,omitempty"`
Ruletype int `json:"ruletype,omitempty"`
Sc string `json:"sc,omitempty"`
Servicename string `json:"servicename,omitempty"`
Servicetype string `json:"servicetype,omitempty"`
Sessionless string `json:"sessionless,omitempty"`
Skippersistency string `json:"skippersistency,omitempty"`
Sobackupaction string `json:"sobackupaction,omitempty"`
Somethod string `json:"somethod,omitempty"`
Sopersistence string `json:"sopersistence,omitempty"`
Sopersistencetimeout int `json:"sopersistencetimeout,omitempty"`
Sothreshold int `json:"sothreshold,omitempty"`
State string `json:"state,omitempty"`
Statechangetimemsec int `json:"statechangetimemsec,omitempty"`
Statechangetimesec string `json:"statechangetimesec,omitempty"`
Statechangetimeseconds int `json:"statechangetimeseconds,omitempty"`
Status int `json:"status,omitempty"`
Tcpprofilename string `json:"tcpprofilename,omitempty"`
Td int `json:"td,omitempty"`
Thresholdvalue int `json:"thresholdvalue,omitempty"`
Tickssincelaststatechange int `json:"tickssincelaststatechange,omitempty"`
Timeout int `json:"timeout,omitempty"`
Tosid int `json:"tosid,omitempty"`
Totalservices int `json:"totalservices,omitempty"`
Trofspersistence string `json:"trofspersistence,omitempty"`
Type string `json:"type,omitempty"`
V6netmasklen int `json:"v6netmasklen,omitempty"`
V6persistmasklen int `json:"v6persistmasklen,omitempty"`
Value string `json:"value,omitempty"`
Version int `json:"version,omitempty"`
Vipheader string `json:"vipheader,omitempty"`
Vsvrdynconnsothreshold int `json:"vsvrdynconnsothreshold,omitempty"`
Weight int `json:"weight,omitempty"`
Quicbridgeprofilename string `json:"quicbridgeprofilename,omitempty"`
}

func resourceCitrixAdcLbvserver() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Expand Down Expand Up @@ -522,6 +659,10 @@ func resourceCitrixAdcLbvserver() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"quicbridgeprofilename": &schema.Schema{
Type: schema.TypeString,
Optional: true,
},
"ciphers": &schema.Schema{
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -608,7 +749,7 @@ func createLbvserverFunc(d *schema.ResourceData, meta interface{}) error {
}
}

lbvserver := lb.Lbvserver{
lbvserver := lbvserver{
Name: lbvserverName,
Appflowlog: d.Get("appflowlog").(string),
Authentication: d.Get("authentication").(string),
Expand Down Expand Up @@ -705,6 +846,7 @@ func createLbvserverFunc(d *schema.ResourceData, meta interface{}) error {
V6persistmasklen: d.Get("v6persistmasklen").(int),
Vipheader: d.Get("vipheader").(string),
Weight: d.Get("weight").(int),
Quicbridgeprofilename: d.Get("quicbridgeprofilename").(string),
}

_, err := client.AddResource(netscaler.Lbvserver.Type(), lbvserverName, &lbvserver)
Expand Down Expand Up @@ -889,6 +1031,7 @@ func readLbvserverFunc(d *schema.ResourceData, meta interface{}) error {
d.Set("v6persistmasklen", data["v6persistmasklen"])
d.Set("vipheader", data["vipheader"])
d.Set("weight", data["weight"])
d.Set("quicbridgeprofilename", data["quicbridgeprofilename"])

_, sslok := d.GetOk("sslcertkey")
_, sniok := d.GetOk("snisslcertkeys")
Expand Down Expand Up @@ -920,7 +1063,7 @@ func updateLbvserverFunc(d *schema.ResourceData, meta interface{}) error {
client := meta.(*NetScalerNitroClient).client
lbvserverName := d.Get("name").(string)

lbvserver := lb.Lbvserver{
lbvserver := lbvserver{
Name: d.Get("name").(string),
}
stateChange := false
Expand Down Expand Up @@ -1404,6 +1547,11 @@ func updateLbvserverFunc(d *schema.ResourceData, meta interface{}) error {
lbvserver.Vipheader = d.Get("vipheader").(string)
hasChange = true
}
if d.HasChange("quicbridgeprofilename") {
log.Printf("[DEBUG] netscaler-provider: Quicbridgeprofilename has changed for lbvserver %s, starting update", lbvserverName)
lbvserver.Quicbridgeprofilename = d.Get("quicbridgeprofilename").(string)
hasChange = true
}
if d.HasChange("weight") {
log.Printf("[DEBUG] netscaler-provider: Weight has changed for lbvserver %s, starting update", lbvserverName)
lbvserver.Weight = d.Get("weight").(int)
Expand Down Expand Up @@ -1553,7 +1701,7 @@ func doLbvserverStateChange(d *schema.ResourceData, client *netscaler.NitroClien

// We need a new instance of the struct since
// ActOnResource will fail if we put in superfluous attributes
lbvserver := lb.Lbvserver{
lbvserver := lbvserver{
Name: d.Get("name").(string),
}

Expand Down
38 changes: 38 additions & 0 deletions citrixadc/resource_citrixadc_lbvserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,44 @@ func TestAccLbvserver_basic(t *testing.T) {
})
}

const testAccLbvserver_quicbridgeprofile = `
resource citrixadc_quicbridgeprofile demo_quicbridge {
name = "demo_quicbridge"
routingalgorithm = "PLAINTEXT"
serveridlength = 4
}
resource "citrixadc_lbvserver" "tfAcc_lbvserver" {
name = "demo_quicbridge_vserver"
ipv46 = "10.202.11.11"
lbmethod = "TOKEN"
persistencetype = "CUSTOMSERVERID"
port = 8080
servicetype = "QUIC_BRIDGE"
quicbridgeprofilename = citrixadc_quicbridgeprofile.demo_quicbridge.name
}
`

func TestAccLbvserver_quicbridgeprofile(t *testing.T) {
if isCpxRun {
t.Skip("No support in CPX")
}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckLbvserverDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccLbvserver_quicbridgeprofile,
Check: resource.ComposeTestCheckFunc(testAccCheckLbvserverExist("citrixadc_lbvserver.tfAcc_lbvserver", nil),
resource.TestCheckResourceAttr("citrixadc_lbvserver.tfAcc_lbvserver", "servicetype", "QUIC_BRIDGE"),
resource.TestCheckResourceAttr("citrixadc_lbvserver.tfAcc_lbvserver", "persistencetype", "CUSTOMSERVERID"),
resource.TestCheckResourceAttr("citrixadc_lbvserver.tfAcc_lbvserver", "quicbridgeprofilename", "demo_quicbridge"),
),
},
},
})
}

func TestAccLbvserver_snicerts(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { doPreChecks(t) },
Expand Down
Loading

0 comments on commit 1925f9b

Please sign in to comment.