Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLANs whose attrs are integers have the attrs returned as an IPRecord #90

Closed
explody opened this issue Aug 17, 2018 · 1 comment
Closed
Labels
type: bug A confirmed report of unexpected behavior in the application
Milestone

Comments

@explody
Copy link
Contributor

explody commented Aug 17, 2018

Version: 3.4.5

I haven't dug up the cause of this yet, but we found that when fetching a VLAN whose name is a number, the 'name' attribute comes back as an IPRecord. No such issue with any vlan whose name is a string or > 255.

This also appears to happen with 'description' and perhaps other attrs, but those are the two we found. It also appears to happen before serialization as we get an IPRecord for the attr before calling serialize().

Upon fetching a vlan whose 'name' and description are both '60', we got this:

From print(type(vlan.name))

<class 'netaddr.ip.IPNetwork'>

After serializing:

{'created': '2017-12-14',
 'custom_fields': {'vlan_type': None},
 'description': '60.0.0.0/32',
 'display_name': '60 (99)',
 'group': 58,
 'id': 1085,
 'last_updated': '2018-08-17T20:47:02.961994Z',
 'name': '60.0.0.0/32',
 'role': None,
 'site': 17,
 'status': 1,
 'tags': [],
 'tenant': None,
 'vid': 60}
@explody
Copy link
Contributor Author

explody commented Aug 17, 2018

It's related to https://github.com/digitalocean/pynetbox/blob/40dbd682f49bdd9cab9b8ee71f9e400595f5b21f/pynetbox/lib/endpoint.py#L82

Looks like all attrs for ipam are presumed to be IPRecords, and netaddr has that annoying "feature" of considering e.g. '60' to be '60.0.0.0/32'.

@zachmoody zachmoody added this to the v4.0.0 milestone Aug 22, 2018
zachmoody pushed a commit that referenced this issue Nov 20, 2018
Removed netaddr and the features that returned IPAddress and Prefix responses into netaddr objects.
@zachmoody zachmoody added the type: bug A confirmed report of unexpected behavior in the application label Nov 23, 2018
zachmoody pushed a commit that referenced this issue Nov 26, 2018
Removed netaddr and the features that returned IPAddress and Prefix responses into netaddr objects.
zachmoody pushed a commit that referenced this issue Dec 4, 2018
Removed netaddr and the features that returned IPAddress and Prefix responses into netaddr objects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants