Add 'created' and 'last_updated' attributes to virtualization component models #4815

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

Originally created by @bb-Ricardo on GitHub (Apr 23, 2021).

NetBox version

v2.11.1

Feature type

Data model extension

Proposed functionality

Add created and last_updated attributes to virtualization models.

See: #5369 and #5901

Use case

I use Netbox as source for our monitoring system. There it is important to get interface data for all interfaces of Device/VM. In order to avoid requesting all interfaces of all devices/VMs a caching was implemented to get only interface objects which have changed since last request cycle. This works pretty well for devices, VMs and IP addresses but interfaces don't support these fields. Our NetBox instance contains thousends of interfaces and retreiving them all takes a long time.

This change would speed up the reading of interface data by A LOT.

Database changes

Yes. Adding 'created' and 'last_updated' to all virtualization models would be necessary.

External dependencies

None

Originally created by @bb-Ricardo on GitHub (Apr 23, 2021). ### NetBox version v2.11.1 ### Feature type Data model extension ### Proposed functionality Add `created` and `last_updated` attributes to `virtualization` models. See: #5369 and #5901 ### Use case I use Netbox as source for our monitoring system. There it is important to get interface data for all interfaces of Device/VM. In order to avoid requesting all interfaces of all devices/VMs a caching was implemented to get only interface objects which have changed since last request cycle. This works pretty well for devices, VMs and IP addresses but interfaces don't support these fields. Our NetBox instance contains thousends of interfaces and retreiving them all takes a long time. This change would speed up the reading of interface data by A LOT. ### Database changes Yes. Adding 'created' and 'last_updated' to all virtualization models would be necessary. ### External dependencies None
adam added the type: feature label 2025-12-29 19:20:53 +01:00
adam closed this issue 2025-12-29 19:20:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 23, 2021):

These fields already exist on these models. What specific change(s) are you proposing?

@jeremystretch commented on GitHub (Apr 23, 2021): These fields already exist on these models. What specific change(s) are you proposing?
Author
Owner

@bb-Ricardo commented on GitHub (Apr 23, 2021):

Hi, Jeremy.

Yes, you are correct. I found the Issue.

is the attribute filter "last_updated__gte" supported for data models with the "last_updated" attribute?

I used following query /api/dcim/interfaces/?last_updated__gte=2021-04-23T14:08:37.536301Z and it returned interfaces like this example:

{
    "id": 8801,
    "url": "https://example.com/api/dcim/interfaces/8801/",
    "display": "ge-0",
    "device": {
        "id": 480,
        "url": "https://example.com/api/dcim/devices/480/",
        "display": "1000",
        "name": "1000",
        "display_name": "1000"
    },
    "name": "ge-0",
    "label": "",
    "type": {
        "value": "1000base-t",
        "label": "1000BASE-T (1GE)"
    },
    "enabled": true,
    "parent": null,
    "lag": null,
    "mtu": null,
    "mac_address": "AA:BB:CC:DD:EE:FF",
    "mgmt_only": false,
    "description": "",
    "mode": null,
    "untagged_vlan": null,
    "tagged_vlans": [],
    "mark_connected": false,
    "cable": {
        "id": 1548,
        "url": "https://example.com/api/dcim/cables/1548/",
        "display": "#1548",
        "label": ""
    },
    "cable_peer": {
        "id": 8277,
        "url": "https://example.com/api/dcim/interfaces/8277/",
        "display": "ge-0/0/0",
        "device": {
            "id": 472,
            "url": "https://example.com/api/dcim/devices/472/",
            "display": "juEX34-04",
            "name": "juEX34-04",
            "display_name": "juEX34-04"
        },
        "name": "ge-0/0/0",
        "cable": 1548,
        "_occupied": true
    },
    "cable_peer_type": "dcim.interface",
    "connected_endpoint": {
        "id": 8277,
        "url": "https://example.com/api/dcim/interfaces/8277/",
        "display": "ge-0/0/0",
        "device": {
            "id": 472,
            "url": "https://example.com/api/dcim/devices/472/",
            "display": "juEX34-04",
            "name": "juEX34-04",
            "display_name": "juEX34-04"
        },
        "name": "ge-0/0/0",
        "cable": 1548,
        "_occupied": true
    },
    "connected_endpoint_type": "dcim.interface",
    "connected_endpoint_reachable": true,
    "tags": [],
    "custom_fields": {},
    "created": "2021-04-23",
    "last_updated": "2021-04-23T10:21:19.028563Z",
    "count_ipaddresses": 0,
    "_occupied": true
}

I tested it for virtualization.interfaces and there it works as expected.

Should I file a new bug for this?

@bb-Ricardo commented on GitHub (Apr 23, 2021): Hi, Jeremy. Yes, you are correct. I found the Issue. is the attribute filter "last_updated__gte" supported for data models with the "last_updated" attribute? I used following query `/api/dcim/interfaces/?last_updated__gte=2021-04-23T14:08:37.536301Z` and it returned interfaces like this example: ```json { "id": 8801, "url": "https://example.com/api/dcim/interfaces/8801/", "display": "ge-0", "device": { "id": 480, "url": "https://example.com/api/dcim/devices/480/", "display": "1000", "name": "1000", "display_name": "1000" }, "name": "ge-0", "label": "", "type": { "value": "1000base-t", "label": "1000BASE-T (1GE)" }, "enabled": true, "parent": null, "lag": null, "mtu": null, "mac_address": "AA:BB:CC:DD:EE:FF", "mgmt_only": false, "description": "", "mode": null, "untagged_vlan": null, "tagged_vlans": [], "mark_connected": false, "cable": { "id": 1548, "url": "https://example.com/api/dcim/cables/1548/", "display": "#1548", "label": "" }, "cable_peer": { "id": 8277, "url": "https://example.com/api/dcim/interfaces/8277/", "display": "ge-0/0/0", "device": { "id": 472, "url": "https://example.com/api/dcim/devices/472/", "display": "juEX34-04", "name": "juEX34-04", "display_name": "juEX34-04" }, "name": "ge-0/0/0", "cable": 1548, "_occupied": true }, "cable_peer_type": "dcim.interface", "connected_endpoint": { "id": 8277, "url": "https://example.com/api/dcim/interfaces/8277/", "display": "ge-0/0/0", "device": { "id": 472, "url": "https://example.com/api/dcim/devices/472/", "display": "juEX34-04", "name": "juEX34-04", "display_name": "juEX34-04" }, "name": "ge-0/0/0", "cable": 1548, "_occupied": true }, "connected_endpoint_type": "dcim.interface", "connected_endpoint_reachable": true, "tags": [], "custom_fields": {}, "created": "2021-04-23", "last_updated": "2021-04-23T10:21:19.028563Z", "count_ipaddresses": 0, "_occupied": true } ``` I tested it for `virtualization.interfaces` and there it works as expected. Should I file a new bug for this?
Author
Owner

@jeremystretch commented on GitHub (Apr 23, 2021):

Yes, please open a new bug if there's specific, reproducible behavior that you believe is incorrect. Be sure to include the set of steps that someone else can take to replicate the suspected bug.

@jeremystretch commented on GitHub (Apr 23, 2021): Yes, please open a new bug if there's specific, reproducible behavior that you believe is incorrect. Be sure to include the set of steps that someone else can take to replicate the suspected bug.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4815