Skip to content

Commit

Permalink
Merge pull request #431 from F5Networks/1.7_release
Browse files Browse the repository at this point in the history
1.7 release
  • Loading branch information
papineni87 authored Feb 18, 2021
2 parents 2b971db + e2b651e commit 259a15d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
41 changes: 33 additions & 8 deletions bigip/datasource_bigip_ltm_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ package bigip

import (
"fmt"
"log"

"github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"log"
"regexp"
)

func dataSourceBigipLtmNode() *schema.Resource {
Expand Down Expand Up @@ -123,20 +123,45 @@ func dataSourceBigipLtmNodeRead(d *schema.ResourceData, meta interface{}) error
return nil
}

if node.FQDN.Name != "" {
if err := d.Set("address", node.FQDN.Name); err != nil {
return fmt.Errorf("[DEBUG] Error saving address to state for Node (%s): %s", d.Id(), err)
}
} else {
// xxx.xxx.xxx.xxx(%x)
// x:x(%x)
regex := regexp.MustCompile(`((?:(?:[0-9]{1,3}\.){3}[0-9]{1,3})|(?:.*:[^%]*))(?:\%\d+)?`)
address := regex.FindStringSubmatch(node.Address)
log.Println("[INFO] Address: " + address[1])
if err := d.Set("address", node.Address); err != nil {
return fmt.Errorf("[DEBUG] Error saving address to state for Node (%s): %s", d.Id(), err)
}
}

_ = d.Set("name", node.Name)
_ = d.Set("partition", node.Partition)
_ = d.Set("address", node.Address)
_ = d.Set("connection_limit", node.ConnectionLimit)
_ = d.Set("dynamic_ratio", node.DynamicRatio)
_ = d.Set("monitor", node.Monitor)
_ = d.Set("rate_limit", node.RateLimit)
_ = d.Set("ratio", node.Ratio)
_ = d.Set("state", node.State)
_ = d.Set("fqdn.0.interval", node.FQDN.Interval)
_ = d.Set("fqdn.0.downinterval", node.FQDN.DownInterval)
_ = d.Set("fqdn.0.autopopulate", node.FQDN.AutoPopulate)
_ = d.Set("fqdn.0.address_family", node.FQDN.AddressFamily)
_ = d.Set("fqdn.0.name", node.FQDN.Name)

var fqdn []map[string]interface{}

fqdnelements := map[string]interface{}{
"interval": node.FQDN.Interval,
"downinterval": node.FQDN.DownInterval,
"autopopulate": node.FQDN.AutoPopulate,
"address_family": node.FQDN.AddressFamily,
}
fqdn = append(fqdn, fqdnelements)
_ = d.Set("fqdn", fqdn)

// _ = d.Set("fqdn.0.interval", node.FQDN.Interval)
// _ = d.Set("fqdn.0.downinterval", node.FQDN.DownInterval)
// _ = d.Set("fqdn.0.autopopulate", node.FQDN.AutoPopulate)
// _ = d.Set("fqdn.0.address_family", node.FQDN.AddressFamily)
d.SetId(node.Name)

return nil
Expand Down
8 changes: 4 additions & 4 deletions bigip/resource_bigip_ltm_profile_fasthttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ var TEST_FASTHTTP_NAME = fmt.Sprintf("/%s/test-fasthttp", TEST_PARTITION)
var TEST_FASTHTTP_RESOURCE = `
resource "bigip_ltm_profile_fasthttp" "test-fasthttp" {
name = "` + TEST_FASTHTTP_NAME + `"
defaults_from = ""
defaults_from = "/Common/fasthttp"
idle_timeout = 0
connpoolidle_timeoutoverride = 0
connpool_maxreuse = 0
connpool_maxsize = 0
connpool_minsize = 0
connpool_replenish = ""
connpool_replenish = "enabled"
connpool_step = 0
maxheader_size = 0
}
Expand All @@ -45,13 +45,13 @@ func TestAccBigipLtmfasthttp_create(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testCheckfasthttpProfileExists(TEST_FASTHTTP_NAME, true),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "name", TEST_FASTHTTP_NAME),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "defaults_from", ""),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "defaults_from", "/Common/fasthttp"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "idle_timeout", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpoolidle_timeoutoverride", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_maxreuse", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_maxsize", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_minsize", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_replenish", ""),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_replenish", "enabled"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "connpool_step", "0"),
resource.TestCheckResourceAttr("bigip_ltm_profile_fasthttp.test-fasthttp", "maxheader_size", "0"),
),
Expand Down
10 changes: 8 additions & 2 deletions website/docs/d/bigip_ltm_node.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ Use this data source (`bigip_ltm_node`) to get the ltm node details available on
data "bigip_ltm_node" "test" {
name = "terraform_node"
address = "192.168.1.1"
partition = "Common"
}
output "bigip_node" {
value = "${data.bigip_ltm_node.test.address}"
}
if it is fqdn address we can get fqdn elements as below
output "bigip_node" {
value = "${data.bigip_ltm_node.test.fqdn[0].address_family}"
}
```

## Argument Reference
Expand Down Expand Up @@ -55,7 +62,6 @@ Additionally, the following attributes are exported:
The `fqdn` block contains:

* `address_family` - The FQDN node's address family.
* `name` - The fully qualified domain name of the node.
* `interval` - The amount of time before sending the next DNS query.
* `downinterval` - The number of attempts to resolve a domain name.
* `autopopulate` - Specifies if the node should scale to the IP address set returned by DNS.
Expand Down

0 comments on commit 259a15d

Please sign in to comment.