API - MAC address not found for Virtual interface on Virtual Machines, when requesting the API #3758

Closed
opened 2025-12-29 18:31:05 +01:00 by adam · 2 comments
Owner

Originally created by @etigui on GitHub (Jun 8, 2020).

Environment

  • Python version: 3.6
  • NetBox version: 2.8.4

Steps to Reproduce

  1. GET request to the route /api/dcim/interfaces/?mac_address=<MAC> for a virtual machine

Expected Behavior

  • Virtual machine : https://XXXXXXX/virtualization/virtual-machines/335/

Screenshot from 2020-06-08 17-53-19

  • API output (GET /api/dcim/interfaces/?mac_address=52:54:00:09:02:88) :
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS, TRACE
Content-Type: application/json
Vary: Accept
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 9194,
      "virtual-machines": {
        "id": 335,
        "url": "https://XXXXXXX/api/virtualization/virtual-machines/335/",
        "name": "XXXXXXX",
        "display_name": "XXXXXXX"
      },
      "name": "XXXXXXX",
      "type": {
        "value": "XXXXXXX",
        "label": "XXXXXXX",
        "id": 0
      },
      "enabled": true,
      "lag": null,
      "mtu": null,
      "mac_address": "52:54:00:09:02:88",
      "mgmt_only": false,
      "description": "XXXXXXX",
      "connected_endpoint_type": null,
      "connected_endpoint": null,
      "connection_status": null,
      "cable": null,
      "mode": null,
      "untagged_vlan": null,
      "tagged_vlans": [],
      "tags": [],
      "count_ipaddresses": 0
    }
  ]
}

Data anonymized with XXXXXXX for API output

Observed Behavior

The MAC is present on the interface of the virtual machine, but because it is an Virtual interface I see no result.

  • API output (GET /api/dcim/interfaces/?mac_address=52:54:00:09:02:88) :
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS, TRACE
Content-Type: application/json
Vary: Accept
{
    "count": 0,
    "next": null,
    "previous": null,
    "results": []
}
Originally created by @etigui on GitHub (Jun 8, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.6 * NetBox version: 2.8.4 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. 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 client library such as pynetbox. --> ### Steps to Reproduce 1. GET request to the route `/api/dcim/interfaces/?mac_address=<MAC>` for a virtual machine <!-- What did you expect to happen? --> ### Expected Behavior - Virtual machine : `https://XXXXXXX/virtualization/virtual-machines/335/` ![Screenshot from 2020-06-08 17-53-19](https://user-images.githubusercontent.com/32940684/84053459-382d7f00-a9b2-11ea-91b9-295747c93cb2.png) - API output (`GET /api/dcim/interfaces/?mac_address=52:54:00:09:02:88`) : ``` HTTP 200 OK Allow: GET, POST, HEAD, OPTIONS, TRACE Content-Type: application/json Vary: Accept ``` ``` { "count": 1, "next": null, "previous": null, "results": [ { "id": 9194, "virtual-machines": { "id": 335, "url": "https://XXXXXXX/api/virtualization/virtual-machines/335/", "name": "XXXXXXX", "display_name": "XXXXXXX" }, "name": "XXXXXXX", "type": { "value": "XXXXXXX", "label": "XXXXXXX", "id": 0 }, "enabled": true, "lag": null, "mtu": null, "mac_address": "52:54:00:09:02:88", "mgmt_only": false, "description": "XXXXXXX", "connected_endpoint_type": null, "connected_endpoint": null, "connection_status": null, "cable": null, "mode": null, "untagged_vlan": null, "tagged_vlans": [], "tags": [], "count_ipaddresses": 0 } ] } ``` > Data anonymized with `XXXXXXX` for API output <!-- What happened instead? --> ### Observed Behavior The MAC is present on the interface of the virtual machine, but because it is an `Virtual interface` I see no result. - API output (`GET /api/dcim/interfaces/?mac_address=52:54:00:09:02:88`) : ``` HTTP 200 OK Allow: GET, POST, HEAD, OPTIONS, TRACE Content-Type: application/json Vary: Accept ``` ``` { "count": 0, "next": null, "previous": null, "results": [] } ```
adam closed this issue 2025-12-29 18:31:05 +01:00
Author
Owner

@tyler-8 commented on GitHub (Jun 8, 2020):

If it's a virtual machine interface, try using /api/virtualization/interfaces/?mac_address=

@tyler-8 commented on GitHub (Jun 8, 2020): If it's a virtual machine interface, try using `/api/virtualization/interfaces/?mac_address=`
Author
Owner

@etigui commented on GitHub (Jun 8, 2020):

If it's a virtual machine interface, try using /api/virtualization/interfaces/?mac_address=

Ahh right, thanks ! :)

@etigui commented on GitHub (Jun 8, 2020): > If it's a virtual machine interface, try using `/api/virtualization/interfaces/?mac_address=` Ahh right, thanks ! :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3758