-
Hello, my netbox version : 3.1.11 I have modeled all vlans, prefixes, ip adresses, devices and virtual machines (and their interfaces) of our network in our netbox. It works great! I'm now searching for a way to use REST API to get all servers (devices + virtual machines) inside a vlan. regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There's no direct link between device or virtual machine and VLAN. The relationships you have are:
So you need to first do a query which finds all prefixes in the VLAN of interest:
Then you need to do a query to find all the IP addresses within each prefix, and see which ones have been assigned to a device interface or vm interface.
There is also a filter "assigned_to_interface" which will eliminate the addresses not assigned to any interface. On my system this reveals a minor anomaly: look at the the number of addresses assigned to 'dcim.interface', it has fallen from 10 to 8.
There are two IP addresses in this prefix which have assigned_object_type as Digging a bit further into the database:
Somehow, these IP addresses, which are not attached to any device instance, still have |
Beta Was this translation helpful? Give feedback.
There's no direct link between device or virtual machine and VLAN. The relationships you have are:
So you need to first do a query which finds all prefixes in the VLAN of interest:
Then you need to do a query to find all the IP addresses within each prefix, and see which ones have been assigned to a device interface or vm interface.