Adding an IP to a device throws an error #312

Closed
opened 2025-12-29 16:20:46 +01:00 by adam · 7 comments
Owner

Originally created by @JamesHarrison on GitHub (Aug 1, 2016).

When adding an IP at /dcim/devices/1/ip-addresses/assign/ I get the following error:

<type 'exceptions.AttributeError'>

'unicode' object has no attribute 'ip'

This is on CentOS 7 with Python 2.7.5 and nginx/gunicorn.

Originally created by @JamesHarrison on GitHub (Aug 1, 2016). When adding an IP at /dcim/devices/1/ip-addresses/assign/ I get the following error: ``` <type 'exceptions.AttributeError'> 'unicode' object has no attribute 'ip' ``` This is on CentOS 7 with Python 2.7.5 and nginx/gunicorn.
adam closed this issue 2025-12-29 16:20:47 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 1, 2016):

What version of NetBox?

@jeremystretch commented on GitHub (Aug 1, 2016): What version of NetBox?
Author
Owner

@JamesHarrison commented on GitHub (Aug 1, 2016):

Sorry, should've said - 1.3.2.

@JamesHarrison commented on GitHub (Aug 1, 2016): Sorry, should've said - 1.3.2.
Author
Owner

@JamesHarrison commented on GitHub (Aug 1, 2016):

Having enabled DEBUG, it's in this line in ipam/models.py:

            duplicate_ips = IPAddress.objects.filter(vrf=self.vrf, address__net_host=str(self.address.ip))\ 
@JamesHarrison commented on GitHub (Aug 1, 2016): Having enabled DEBUG, it's in this line in ipam/models.py: ``` python duplicate_ips = IPAddress.objects.filter(vrf=self.vrf, address__net_host=str(self.address.ip))\ ```
Author
Owner

@JamesHarrison commented on GitHub (Aug 1, 2016):

OK - if I actually specify ip/mask instead of just ip, no error. Probably should enforce mask being specified in the form, or assume /32 for v4 or /128 for v6 if no mask is specified.

@JamesHarrison commented on GitHub (Aug 1, 2016): OK - if I actually specify ip/mask instead of just ip, no error. Probably should enforce mask being specified in the form, or assume /32 for v4 or /128 for v6 if no mask is specified.
Author
Owner

@jeremystretch commented on GitHub (Aug 1, 2016):

The IP address creation form does validate that a mask has been provided:

netbox_-add_an_ip_address-_2016-08-01_10 40 37

IIRC even if you created an IP without a mask, it should default to /32. I'm not sure what could be causing this error. Could you post the full traceback please?

@jeremystretch commented on GitHub (Aug 1, 2016): The IP address creation form does validate that a mask has been provided: ![netbox_-_add_an_ip_address_-_2016-08-01_10 40 37](https://cloud.githubusercontent.com/assets/13487278/17297600/666addba-57d4-11e6-9c0e-4af8362a7dd0.png) IIRC even if you created an IP without a mask, it should default to /32. I'm not sure what could be causing this error. Could you post the full traceback please?
Author
Owner

@hnk commented on GitHub (Aug 2, 2016):

I think I ran into this as well and it happened when I did not have any Aggregates or Prefixes defined.

Though I did just test that scenario against the master branch and it seems to work now. I may be able to test against the older version tomorrow.

@hnk commented on GitHub (Aug 2, 2016): I think I ran into this as well and it happened when I did not have any Aggregates or Prefixes defined. Though I did just test that scenario against the master branch and it seems to work now. I may be able to test against the older version tomorrow.
Author
Owner

@JamesHarrison commented on GitHub (Aug 2, 2016):

Yeah, lack of aggs/prefixes looks to be it, it's all good if I have some aggregates and prefixes defined - if that's fixed in master then I guess this is done.

@JamesHarrison commented on GitHub (Aug 2, 2016): Yeah, lack of aggs/prefixes looks to be it, it's all good if I have some aggregates and prefixes defined - if that's fixed in master then I guess this is done.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#312