Skip to content

Commit

Permalink
bugFix for hostRecord ip_addr_type and disable fields (infobloxopen#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aish-sp authored and Chaithra001 committed Oct 24, 2024
1 parent 281af3f commit 99bc33d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion infoblox/resource_infoblox_aaaa_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func resourceAAAARecordCreate(d *schema.ResourceData, m interface{}) error {
eaMap map[string]string
)

if nextAvailableFilter != "" {
if cidr == "" && ipv6Addr == "" && nextAvailableFilter != "" {
err = json.Unmarshal([]byte(nextAvailableFilter), &eaMap)
if err != nil {
return fmt.Errorf("error unmarshalling extra attributes of network: %s", err)
Expand Down
18 changes: 12 additions & 6 deletions infoblox/resource_infoblox_ip_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ func resourceIPAllocation() *schema.Resource {
"ip_address_type": {
Type: schema.TypeString,
Optional: true,
Default: "IPV6",
Description: "The type of IP address to allocate. Valid values are: IPV4, IPV6, Both",
DefaultFunc: func() (interface{}, error) {
if filterParams, ok := resourceIPAllocation().Schema["filter_params"]; ok && filterParams.Default == nil {
return nil, nil
}
return "IPV4", nil
},
ValidateFunc: validation.StringInSlice([]string{
"IPV4", "IPV6", "Both",
}, false),
Expand All @@ -136,7 +141,7 @@ func resourceIPAllocation() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "Disables the AAAA-record if set to 'true'.",
Description: "Disables the Host-record if set to 'true'.",
},
"internal_id": {
Type: schema.TypeString,
Expand Down Expand Up @@ -277,10 +282,9 @@ func resourceAllocationRequest(d *schema.ResourceData, m interface{}) error {
var (
newRecordHost interface{}
eaMap map[string]string
//err error
)

if nextAvailableFilter != "" {
if ipv4Addr == "" && ipv4Cidr == "" && ipv6Cidr == "" && ipv6Addr == "" && nextAvailableFilter != "" {
err = json.Unmarshal([]byte(nextAvailableFilter), &eaMap)
if err != nil {
return fmt.Errorf("error unmarshalling extra attributes of network: %s", err)
Expand All @@ -292,7 +296,7 @@ func resourceAllocationRequest(d *schema.ResourceData, m interface{}) error {
// enableDns and enableDhcp flags used to create host record with respective flags.
// By default, enableDns is true.
newRecordHost, err = objMgr.CreateHostRecord(enableDns, false, fqdn, networkView, dnsView, ipv4Cidr,
ipv6Cidr, ipv4Addr, ipv6Addr, macAddr, "", useTtl, ttl, comment, extAttrs, aliasStrs)
ipv6Cidr, ipv4Addr, ipv6Addr, macAddr, "", useTtl, ttl, comment, extAttrs, aliasStrs, disable)
}

if err != nil {
Expand Down Expand Up @@ -574,6 +578,7 @@ func resourceAllocationUpdate(d *schema.ResourceData, m interface{}) (err error)
}

comment := d.Get("comment").(string)
disable := d.Get("disable").(bool)

oldExtAttrsJSON, newExtAttrsJSON := d.GetChange("ext_attrs")

Expand Down Expand Up @@ -666,7 +671,8 @@ func resourceAllocationUpdate(d *schema.ResourceData, m interface{}) (err error)
macAddr, duid,
useTtl, ttl,
comment,
mergedEAs, aliasStrs)
mergedEAs,
aliasStrs, disable)
if err != nil {
return fmt.Errorf(
"error while updating the host record with ID '%s': %s", d.Id(), err.Error())
Expand Down
6 changes: 5 additions & 1 deletion infoblox/resource_infoblox_ip_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func resourceIpAssociationCreateUpdateCommon(

var (
comment string
disable bool
)

if hostRec.Ea != nil {
Expand All @@ -235,6 +236,9 @@ func resourceIpAssociationCreateUpdateCommon(
if hostRec.Comment != nil {
comment = *hostRec.Comment
}
if hostRec.Disable != nil {
disable = *hostRec.Disable
}

alias := hostRec.Aliases

Expand All @@ -250,7 +254,7 @@ func resourceIpAssociationCreateUpdateCommon(
mac, duid,
*hostRec.UseTtl, *hostRec.Ttl,
comment,
hostRec.Ea, alias)
hostRec.Ea, alias, disable)
if err != nil {
return fmt.Errorf(
"failed to update the resource with ID '%s' (host record with internal ID '%s'): %s",
Expand Down

0 comments on commit 99bc33d

Please sign in to comment.