Skip to content

Commit

Permalink
Merge pull request #73 from smutel/ResolveIssue72
Browse files Browse the repository at this point in the history
fix: Terraform crashes when ip address not affected to vm/device
  • Loading branch information
smutel authored Sep 30, 2021
2 parents cd2cc61 + 21d283a commit 6ad255e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/tenancy_tenant_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Get info about tenancy tenant groups from netbox.
## Example Usage

```hcl
data "netbox_tenancy_tenant_groups" "tenant_group_test" {
data "netbox_tenancy_tenant_group" "tenant_group_test" {
slug = "TestTenantGroup"
}
```
Expand Down
7 changes: 5 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ Terraform provider for [Netbox.](https://netbox.readthedocs.io/en/stable/)

## Compatibility with Netbox

Version 0.x.y => Netbox 2.8
Version 1.x.y => Netbox 2.9
| Netbox version | Provider version |
|:--------------:|:----------------:|
| 2.8 | 0.x.y |
| 2.9 | 1.x.y |
| 2.11 | 2.x.y |

## Example Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/ipam_ip_addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The following arguments are supported:
* ``nat_inside_id`` - (Optional) The ID of the NAT inside of this object.
* ``object_id`` - (Optional) The ID of the object where this resource is attached to.
* ``object_type`` - (Optional) The object type among virtualization.vminterface
or dcim.interface (virtualization.vminterface by default)
or dcim.interface (empty by default)
* ``primary_ip4`` - (Optional) Set this resource as primary IPv4 (false by default)
* ``role`` - (Optional) The role among loopback, secondary, anycast, vip, vrrp, hsrp, glbp, carp of this object.
* ``status`` - (Optional) The status among container, active, reserved, deprecated (active by default).
Expand Down
15 changes: 10 additions & 5 deletions netbox/resource_netbox_ipam_ip_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func resourceNetboxIpamIPAddresses() *schema.Resource {
"object_type": {
Type: schema.TypeString,
Optional: true,
Default: VMInterfaceType,
Default: "",
ValidateFunc: validation.StringInSlice([]string{
VMInterfaceType, "dcim.interface"}, false),
},
Expand Down Expand Up @@ -296,11 +296,16 @@ func resourceNetboxIpamIPAddressesRead(d *schema.ResourceData,
}

objectType := resource.AssignedObjectType
if *objectType == "" {
if objectType != nil {
*objectType = VMInterfaceType
}
if err = d.Set("object_type", objectType); err != nil {
return err

if err = d.Set("object_type", *objectType); err != nil {
return err
}
} else {
if err = d.Set("object_type", nil); err != nil {
return err
}
}

if resource.Role == nil {
Expand Down

0 comments on commit 6ad255e

Please sign in to comment.