DCIM interfaces API endpoint returns VM interfaces #2488

Closed
opened 2025-12-29 18:19:18 +01:00 by adam · 3 comments
Owner

Originally created by @JuergenKammer on GitHub (Apr 3, 2019).

Environment

  • Python version: 3.6.8
  • NetBox version: 2.5.9

Steps to Reproduce

  1. Create a virtual machine with an interface.
  2. Use the API to list interfaces (you may specifically search by name or whatever, just ensure that you get the interface at the virtual machine returned).

Expected Behavior

The API returns the virtual-machine with the corresponding data, just like it does for a device if a returned interface belongs to a device.

Observed Behavior

There is no reference to a virtual-machine returned. Instead the interface is returned with a "device: null" entry.

Background

I realized this when I gathered up all interfaces via the API, keeping track of the devices: surprisingly I encountered multiple interfaces with the same name on the same "device", then realized they all belonged to the device "null". I realized, ok, no devices, these are virtual machines - but no virtual-machine data is returned.

In fact, this may even be deeper buried: "device" is a required field when doing a POST for an interface (see api_dcim_interfaces_create in api/docs/) . No way to specify a virtual machine instead, which should be there.

Originally created by @JuergenKammer on GitHub (Apr 3, 2019). ### Environment * Python version: 3.6.8 * NetBox version: 2.5.9 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Create a virtual machine with an interface. 2. Use the API to list interfaces (you may specifically search by name or whatever, just ensure that you get the interface at the virtual machine returned). <!-- What did you expect to happen? --> ### Expected Behavior The API returns the virtual-machine with the corresponding data, just like it does for a device if a returned interface belongs to a device. <!-- What happened instead? --> ### Observed Behavior There is no reference to a virtual-machine returned. Instead the interface is returned with a "device: null" entry. ### Background I realized this when I gathered up all interfaces via the API, keeping track of the devices: surprisingly I encountered multiple interfaces with the same name on the same "device", then realized they all belonged to the device "null". I realized, ok, no devices, these are virtual machines - but no virtual-machine data is returned. In fact, this may even be deeper buried: "device" is a *required* field when doing a POST for an interface (see api_dcim_interfaces_create in api/docs/) . No way to specify a virtual machine instead, which should be there.
adam added the type: bugstatus: accepted labels 2025-12-29 18:19:18 +01:00
adam closed this issue 2025-12-29 18:19:18 +01:00
Author
Owner

@Xelinor commented on GitHub (Apr 4, 2019):

I believe that is working as intended.

/api/virtualization/interfaces/ is what you are looking for, there is a separate API call for the virtual machine interfaces.

@Xelinor commented on GitHub (Apr 4, 2019): I believe that is working as intended. /api/virtualization/interfaces/ is what you are looking for, there is a separate API call for the virtual machine interfaces.
Author
Owner

@JuergenKammer commented on GitHub (Apr 4, 2019):

Ah, right, I missed that, oups. But...

Should interfaces of virtual machines returned at all when querying for interfaces under /api/dcim/interfaces? To return them under /api/dcim/interfaces (with device = null) when they are under /virtualization/interfaces is not really helping (at least, it fooled me ;-o).

If I query under /api/virtualization/interfaces I only get the interfaces belonging to virtual machines, and not the interfaces under dcim with virtual-machine = null. To have a different behavior in these two trees seems inconsistent.

@JuergenKammer commented on GitHub (Apr 4, 2019): Ah, right, I missed that, oups. But... Should interfaces of virtual machines returned at all when querying for interfaces under /api/dcim/interfaces? To return them under /api/dcim/interfaces (with device = null) when they are under /virtualization/interfaces is not really helping (at least, it fooled me ;-o). If I query under /api/virtualization/interfaces I *only* get the interfaces belonging to virtual machines, and not the interfaces under dcim with virtual-machine = null. To have a different behavior in these two trees seems inconsistent.
Author
Owner

@jeremystretch commented on GitHub (Apr 4, 2019):

Should interfaces of virtual machines returned at all when querying for interfaces under /api/dcim/interfaces?

No. Marking this as a bug.

@jeremystretch commented on GitHub (Apr 4, 2019): > Should interfaces of virtual machines returned at all when querying for interfaces under /api/dcim/interfaces? No. Marking this as a bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2488