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
IP addresses missing from virtual machine interfaces #334
Conversation
Fix not correct see referenced issue for comment. Will look into this. |
Did a correction but happy to get some feedback on that. Feel that there might be some better way of doing it. 😄 |
If I remember correctly, there is a pynetbox function to return the netbox API version, which should be safer than what you tried to do; ie:
|
@ThomasADavis Currently pynetbox is not used in the nb_inventory.py what I can see so your suggestion is to introduce that here? Feels that it can be a bit risky to introduce that dependency now. |
A function to get the version of the netbox that nb_inventory is talking to should be added, for it's also probably going break on 'tags' also. The netbox version is returned on every rest call as part of the header information; see netbox-community/netbox#1223 @FragmentedPacket it's up to you... the inventory use direct REST api calls. |
Keeping it via the API calls is fine. I've been contemplating whether it's worth it to move away from I'll take a look at this PR soon and provide any feedback once I've had time to actually take a good look at it. Thanks for your work on this though! |
interface["ip_addresses"] = list( | ||
self.ipaddresses_lookup[interface["id"]].values() | ||
) | ||
if before_netbox_v29: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need to to determine if it's < 2.9?
Could we just have the two lookups, device and VM ip address lookups? So we handle the difference in versions in the code below by determining which bucket to throw them into?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look in the changes I did in refresh_ipaddresses
then you see that for NetBox v2.9 and later I will know if it is an IP address is connected to a VM or device by looking at the assigned_object_type
. But in earlier NetBox versions this information is not available like that to determine which bucket to throw them into. Or what kind of change do you suggest?
It would have been great if I just could have the the two lookups and skip the ipaddresses_lookup
completely but as said I do not see that I have the information available in earlier version to put IPs in the two buckets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I do see what you're saying now. And we can't act off anything else with the way the inventory is setup to differentiate.
I will approve and merge this in.
Fixes #321