Add 'utilization' field to IPRangeSerializer #9358

Open
opened 2025-12-29 20:48:58 +01:00 by adam · 2 comments
Owner

Originally created by @icovada on GitHub (Mar 15, 2024).

NetBox version

v3.7.4

Feature type

Change to existing functionality

Proposed functionality

Show the "utilization" field in the API response for IPRange

Use case

Allowing users to keep track of IP Range utilization via API

Database changes

None

External dependencies

None

Originally created by @icovada on GitHub (Mar 15, 2024). ### NetBox version v3.7.4 ### Feature type Change to existing functionality ### Proposed functionality Show the "utilization" field in the API response for IPRange ### Use case Allowing users to keep track of IP Range utilization via API ### Database changes None ### External dependencies None
adam added the type: featurecomplexity: mediumnetboxstatus: backlog labels 2025-12-29 20:48:58 +01:00
Author
Owner

@icovada commented on GitHub (Mar 15, 2024):

Code already existing at 6f4e16d25a

Waiting to be assigned this issue to create a PR

@icovada commented on GitHub (Mar 15, 2024): Code already existing at https://github.com/netbox-community/netbox/commit/6f4e16d25a401a7ec1ee0f6c302f7c518a24365a Waiting to be assigned this issue to create a PR
Author
Owner

@jeremystretch commented on GitHub (Apr 3, 2024):

It is not sufficient to merely add the utilization field to the serializer, or this would have already been done. As it stands, your change would effect a new database query to fetch all the IP addresses for each individual IP range returned in an API response. (Take a look at the utilization property defined on the IPRange mode.) This would substantially degrade performance.

This is somewhat similar to #7845, but might be doable by annotating the count of IP addresses for each range on the queryset. @icovada would you like to own that work?

@jeremystretch commented on GitHub (Apr 3, 2024): It is not sufficient to merely add the `utilization` field to the serializer, or this would have already been done. As it stands, your change would effect a new database query to fetch all the IP addresses for each individual IP range returned in an API response. (Take a look at the `utilization` property defined on the IPRange mode.) This would substantially degrade performance. This is somewhat similar to #7845, but might be doable by annotating the count of IP addresses for each range on the queryset. @icovada would you like to own that work?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9358