[PR #19064] [MERGED] Closed #9763: Treat IP ranges as fully populated #15515

Closed
opened 2025-12-30 00:22:24 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19064
Author: @jeremystretch
Created: 4/2/2025
Status: Merged
Merged: 4/9/2025
Merged by: @arthanson

Base: featureHead: 9763-reserved-ip-ranges


📝 Commits (10+)

  • 6761536 Add mark_reserved boolean field to IPRange
  • 5f54872 Update utilized/reserved logic for Prefix and IPRange
  • d82040b Rename mark_reserved to mark_populated
  • ecb56dd Replace add_available_ipaddresses() with annotate_ip_space()
  • 55d02b3 List child IP addresses even when consumed by a range
  • e94d00c Fix tests
  • 5fd229b Introduce AnnotatedIPAddressTable for PrefixIPAddressesView
  • 70f5914 Prohibit creating an IP address within a populated range
  • 3c2c793 Fix model documentation
  • def267a Flesh out model documentation

📊 Changes

16 files changed (+257 additions, -78 deletions)

View changed files

📝 docs/models/ipam/iprange.md (+12 -0)
📝 netbox/ipam/api/serializers_/ip.py (+2 -1)
📝 netbox/ipam/filtersets.py (+1 -1)
📝 netbox/ipam/forms/bulk_edit.py (+5 -0)
📝 netbox/ipam/forms/bulk_import.py (+2 -2)
📝 netbox/ipam/forms/filtersets.py (+8 -1)
📝 netbox/ipam/forms/model_forms.py (+4 -4)
netbox/ipam/migrations/0078_iprange_mark_utilized.py (+16 -0)
📝 netbox/ipam/models/ip.py (+40 -15)
📝 netbox/ipam/tables/ip.py (+19 -3)
📝 netbox/ipam/tables/template_code.py (+4 -4)
📝 netbox/ipam/tests/test_filtersets.py (+18 -2)
📝 netbox/ipam/tests/test_models.py (+38 -4)
📝 netbox/ipam/utils.py (+77 -37)
📝 netbox/ipam/views.py (+3 -3)
📝 netbox/templates/ipam/iprange.html (+8 -1)

📄 Description

Fixes: #9763

  • Add a mark_populated boolean field to the IPRange model
  • Replace the add_available_ipaddresses() utility function with annotate_ip_space()
  • Introduce the AvailableIPSpace data class to represent unallocated space between two real IP objects
  • Extend the get_child_ranges() method the Prefix model to allow passing filters

Note: Calling get_available_ips() on a prefix with mark_utilized=True no longer automatically returns an empty IPSet. This is a deviation from the current behavior that, while not explicitly addressed in the FR, is necessary to ensure the consistent treatment of both prefixes and IP ranges.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19064 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 4/2/2025 **Status:** ✅ Merged **Merged:** 4/9/2025 **Merged by:** [@arthanson](https://github.com/arthanson) **Base:** `feature` ← **Head:** `9763-reserved-ip-ranges` --- ### 📝 Commits (10+) - [`6761536`](https://github.com/netbox-community/netbox/commit/67615368b2405f976fb9335928464b0ed8fe6813) Add mark_reserved boolean field to IPRange - [`5f54872`](https://github.com/netbox-community/netbox/commit/5f548725ee6ded9cb1c2a67fa1efc5e4e945c17e) Update utilized/reserved logic for Prefix and IPRange - [`d82040b`](https://github.com/netbox-community/netbox/commit/d82040bdc42d321bc4b52ec8a292e261091c5717) Rename mark_reserved to mark_populated - [`ecb56dd`](https://github.com/netbox-community/netbox/commit/ecb56dda14c07fbdaaa61e7c2569094d379adbc5) Replace add_available_ipaddresses() with annotate_ip_space() - [`55d02b3`](https://github.com/netbox-community/netbox/commit/55d02b3c2c0370273b4404b2dd4cb290bf356f88) List child IP addresses even when consumed by a range - [`e94d00c`](https://github.com/netbox-community/netbox/commit/e94d00c2c1cfba7d83a790891ca72d761c059dbb) Fix tests - [`5fd229b`](https://github.com/netbox-community/netbox/commit/5fd229bd1d499e664098beb11a1588543da59d57) Introduce AnnotatedIPAddressTable for PrefixIPAddressesView - [`70f5914`](https://github.com/netbox-community/netbox/commit/70f5914469bc482212c029c7cfefd6f171a1f432) Prohibit creating an IP address within a populated range - [`3c2c793`](https://github.com/netbox-community/netbox/commit/3c2c7933e7f63f44b67d17b4efc2059ad5510d40) Fix model documentation - [`def267a`](https://github.com/netbox-community/netbox/commit/def267a9dacd9640a263e406e4310ebda3d282b4) Flesh out model documentation ### 📊 Changes **16 files changed** (+257 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `docs/models/ipam/iprange.md` (+12 -0) 📝 `netbox/ipam/api/serializers_/ip.py` (+2 -1) 📝 `netbox/ipam/filtersets.py` (+1 -1) 📝 `netbox/ipam/forms/bulk_edit.py` (+5 -0) 📝 `netbox/ipam/forms/bulk_import.py` (+2 -2) 📝 `netbox/ipam/forms/filtersets.py` (+8 -1) 📝 `netbox/ipam/forms/model_forms.py` (+4 -4) ➕ `netbox/ipam/migrations/0078_iprange_mark_utilized.py` (+16 -0) 📝 `netbox/ipam/models/ip.py` (+40 -15) 📝 `netbox/ipam/tables/ip.py` (+19 -3) 📝 `netbox/ipam/tables/template_code.py` (+4 -4) 📝 `netbox/ipam/tests/test_filtersets.py` (+18 -2) 📝 `netbox/ipam/tests/test_models.py` (+38 -4) 📝 `netbox/ipam/utils.py` (+77 -37) 📝 `netbox/ipam/views.py` (+3 -3) 📝 `netbox/templates/ipam/iprange.html` (+8 -1) </details> ### 📄 Description ### Fixes: #9763 - Add a `mark_populated` boolean field to the IPRange model - Replace the `add_available_ipaddresses()` utility function with `annotate_ip_space()` - Introduce the AvailableIPSpace data class to represent unallocated space between two real IP objects - Extend the `get_child_ranges()` method the Prefix model to allow passing filters Note: Calling `get_available_ips()` on a prefix with `mark_utilized=True` no longer automatically returns an empty IPSet. This is a deviation from the current behavior that, while not explicitly addressed in the FR, is necessary to ensure the consistent treatment of both prefixes and IP ranges. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:22:24 +01:00
adam closed this issue 2025-12-30 00:22:25 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15515