Get child Prefixes from a prefix ID via API REST CALL #3732

Closed
opened 2025-12-29 18:30:49 +01:00 by adam · 1 comment
Owner

Originally created by @jorgeNeutrona on GitHub (May 28, 2020).

Environment

  • Python version: 3.6
  • NetBox version: 2.8.4

Proposed Functionality

Add API rest call GET just to get child prefixes from a prefix ID, I need to list child prefix for sanity check

Use Case

Useful API call to get child prefix and execute a PUT of IPs when prefixes are migrated but inside the prefix IP are not allocated.

Example from a migrations procedure:

/29 - With out prefix --> run PUT IP address to complete /29 IPs allocation.

/29 with one prefix --> do not run PUT IP.

When migrating from other IPAMs, IP address are no always been allocated. I need an option to fullfill subnets with IPs when a subnet has not prefixes (child) allocated.

Currently netbox has /ipam/prefixes/{id}/available-prefixes/ but there is a false positive when:

/29 no prefix assignated, fill the prefix with IPs

/29 with one child prefix, do not run the fill script

/29 with 2x30 child prefixes, no prefix is available, the script should run, but the problem is that the child prefixes are already allotacted. the script should not run.

In order to decide to run or not the script, the subnet should no have child prefixes.

a combination of

/ipam/prefixes/{id}/available-prefixes/

and

/ipam/prefixes/{id}/available-ips/

could solve the problem, but get childs prefix for a subnet is a nice to have.

Originally created by @jorgeNeutrona on GitHub (May 28, 2020). ### Environment * Python version: 3.6 * NetBox version: 2.8.4 ### Proposed Functionality Add API rest call GET just to get child prefixes from a prefix ID, I need to list child prefix for sanity check ### Use Case Useful API call to get child prefix and execute a PUT of IPs when prefixes are migrated but inside the prefix IP are not allocated. Example from a migrations procedure: /29 - With out prefix --> run PUT IP address to complete /29 IPs allocation. /29 with one prefix --> do not run PUT IP. When migrating from other IPAMs, IP address are no always been allocated. I need an option to fullfill subnets with IPs when a subnet has not prefixes (child) allocated. Currently netbox has /ipam/prefixes/{id}/available-prefixes/ but there is a false positive when: /29 no prefix assignated, fill the prefix with IPs /29 with one child prefix, do not run the fill script /29 with 2x30 child prefixes, no prefix is available, the script should run, but the problem is that the child prefixes are already allotacted. the script should not run. In order to decide to run or not the script, the subnet should no have child prefixes. a combination of /ipam/prefixes/{id}/available-prefixes/ and /ipam/prefixes/{id}/available-ips/ could solve the problem, but get childs prefix for a subnet is a nice to have.
adam closed this issue 2025-12-29 18:30:49 +01:00
Author
Owner

@jeremystretch commented on GitHub (May 28, 2020):

There is no direct database relationship from a child prefix to it parent(s), which is why there is not ID-based filter. You can use a combination of the vrf and within or within_include filters to find child prefixes, which is how the UI filter form works.

@jeremystretch commented on GitHub (May 28, 2020): There is no direct database relationship from a child prefix to it parent(s), which is why there is not ID-based filter. You can use a combination of the `vrf` and `within` or `within_include` filters to find child prefixes, which is how the UI filter form works.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3732