Skip to content

Commit

Permalink
Merge pull request #174 from citrix/enhancements
Browse files Browse the repository at this point in the history
Enhancements
  • Loading branch information
George Nikolopoulos authored Jul 13, 2021
2 parents 61acb43 + e58143f commit 62396b6
Show file tree
Hide file tree
Showing 25 changed files with 1,460 additions and 16 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## 1.4.0 (July 13, 2021)

FEATURES

* **New Resource** `vlan_nsip_binding`
* **New Resource** `vlan_interface_binding`
* **New Resource** `nsmode`

ENHANCEMENTS

* Extra cluster configuration options. Now a SNIP and vtysh commands can be added per node added to the cluster.
* Update to latest adc-nitro-go library.

BUG FIXES

* Correct the way the `route` resource is read from the ADC. Now takes into account the `ownergroup` attribute.
* Correct `ownernode` argument of `nsip` resource to TypeString. Now ownernode will be applied correctly.

## 1.3.0 (July 6, 2021)

ENHANCEMENTS
Expand Down
3 changes: 3 additions & 0 deletions citrixadc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func providerResources() map[string]*schema.Resource {
"citrixadc_lbparameter": resourceCitrixAdcLbparameter(),
"citrixadc_iptunnel": resourceCitrixAdcIptunnel(),
"citrixadc_vlan": resourceCitrixAdcVlan(),
"citrixadc_vlan_interface_binding": resourceCitrixAdcVlan_interface_binding(),
"citrixadc_vlan_nsip_binding": resourceCitrixAdcVlan_nsip_binding(),
"citrixadc_nsmode": resourceCitrixAdcNsmode(),
}
}

Expand Down
60 changes: 60 additions & 0 deletions citrixadc/resource_citrixadc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package citrixadc
import (
"github.com/citrix/adc-nitro-go/resource/config/cluster"
"github.com/citrix/adc-nitro-go/resource/config/ns"
"github.com/citrix/adc-nitro-go/resource/config/router"
"github.com/citrix/adc-nitro-go/service"

"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
Expand Down Expand Up @@ -256,6 +257,33 @@ func resourceCitrixAdcCluster() *schema.Resource {
Description: "Ignore validity of endpoint TLS certificate if true",
Default: false,
},
// Flags for adding node SNIP to CLIP before joining
"snip_netmask": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: false,
},
"snip_ipaddress": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: false,
},
"addsnip": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
// Optional VTYSH commands
"vtysh_enable": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"vtysh": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
},
},
Expand Down Expand Up @@ -1352,6 +1380,38 @@ func addSingleClusterNode(d *schema.ResourceData, meta interface{}, nodeData map
return err
}

// Register node ip to the CLIP if flag is set
if nodeData["addsnip"].(bool) {
nodeNsip := nsip{
Ownernode: strconv.Itoa(nodeData["nodeid"].(int)),
Ipaddress: nodeData["snip_ipaddress"].(string),
Mgmtaccess: "ENABLED",
Netmask: nodeData["snip_netmask"].(string),
Type: "SNIP",
}
log.Printf("[DEBUG] citrixadc-provider: registering node ip %v", nodeNsip)
_, err := client.AddResource(service.Nsip.Type(), nodeData["ipaddress"].(string), &nodeNsip)
if err != nil {
return err
}
}

// Do the VTYSH commands if flag is set
if nodeData["vtysh_enable"].(bool) {
cmdList := nodeData["vtysh"].([]interface{})
for _, val := range cmdList {
vtyshCmdString := val.(string)

routerdynamicrouting := router.Routerdynamicrouting{
Commandstring: vtyshCmdString,
}
err := client.ActOnResource("routerdynamicrouting", &routerdynamicrouting, "apply")
if err != nil {
return err
}
}
}

// Instantiate node client
nodeClient, err := instantiateNodeClient(d, meta, nodeData)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions citrixadc/resource_citrixadc_nsip.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type nsip struct {
Ospfareaval int `json:"ospfareaval,omitempty"`
Ospflsatype string `json:"ospflsatype,omitempty"`
Ownerdownresponse string `json:"ownerdownresponse,omitempty"`
Ownernode int `json:"ownernode,omitempty"`
Ownernode string `json:"ownernode,omitempty"`
Restrictaccess string `json:"restrictaccess,omitempty"`
Rip string `json:"rip,omitempty"`
Riserhimsgcode int `json:"riserhimsgcode,omitempty"`
Expand Down Expand Up @@ -183,7 +183,7 @@ func resourceCitrixAdcNsip() *schema.Resource {
Computed: true,
},
"ownernode": &schema.Schema{
Type: schema.TypeInt,
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Expand Down Expand Up @@ -295,7 +295,7 @@ func createNsipFunc(d *schema.ResourceData, meta interface{}) error {
Ospfarea: d.Get("ospfarea").(int),
Ospflsatype: d.Get("ospflsatype").(string),
Ownerdownresponse: d.Get("ownerdownresponse").(string),
Ownernode: d.Get("ownernode").(int),
Ownernode: d.Get("ownernode").(string),
Restrictaccess: d.Get("restrictaccess").(string),
Rip: d.Get("rip").(string),
Snmp: d.Get("snmp").(string),
Expand Down Expand Up @@ -497,7 +497,7 @@ func updateNsipFunc(d *schema.ResourceData, meta interface{}) error {
}
if d.HasChange("ownernode") {
log.Printf("[DEBUG] citrixadc-provider: Ownernode has changed for nsip %s, starting update", ipaddress)
nsip.Ownernode = d.Get("ownernode").(int)
nsip.Ownernode = d.Get("ownernode").(string)
hasChange = true
}
if d.HasChange("restrictaccess") {
Expand Down
Loading

0 comments on commit 62396b6

Please sign in to comment.