mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Fixes #6350: Include first & last IP addresses when allocating available IPv6 addresses via the REST API
This commit is contained in:
parent
a4955b420a
commit
7f2f98885b
@ -18,6 +18,7 @@
|
|||||||
* [#6321](https://github.com/netbox-community/netbox/issues/6321) - Restore "add an IP" button under prefix IPs view
|
* [#6321](https://github.com/netbox-community/netbox/issues/6321) - Restore "add an IP" button under prefix IPs view
|
||||||
* [#6333](https://github.com/netbox-community/netbox/issues/6333) - Fix filtering of circuit terminations by primary key
|
* [#6333](https://github.com/netbox-community/netbox/issues/6333) - Fix filtering of circuit terminations by primary key
|
||||||
* [#6339](https://github.com/netbox-community/netbox/issues/6339) - Improve ordering of interfaces when viewing virtual chassis master
|
* [#6339](https://github.com/netbox-community/netbox/issues/6339) - Improve ordering of interfaces when viewing virtual chassis master
|
||||||
|
* [#6350](https://github.com/netbox-community/netbox/issues/6350) - Include first & last IP addresses when allocating available IPv6 addresses via the REST API
|
||||||
* [#6355](https://github.com/netbox-community/netbox/issues/6355) - Fix caching error when swapping A/Z circuit terminations
|
* [#6355](https://github.com/netbox-community/netbox/issues/6355) - Fix caching error when swapping A/Z circuit terminations
|
||||||
* [#6357](https://github.com/netbox-community/netbox/issues/6357) - Fix ProviderNetwork nested API serializer
|
* [#6357](https://github.com/netbox-community/netbox/issues/6357) - Fix ProviderNetwork nested API serializer
|
||||||
* [#6363](https://github.com/netbox-community/netbox/issues/6363) - Correct pre-population of cluster group when creating a cluster
|
* [#6363](https://github.com/netbox-community/netbox/issues/6363) - Correct pre-population of cluster group when creating a cluster
|
||||||
|
@ -426,19 +426,11 @@ class Prefix(PrimaryModel):
|
|||||||
child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
|
child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
|
||||||
available_ips = prefix - child_ips
|
available_ips = prefix - child_ips
|
||||||
|
|
||||||
# All IP addresses within a pool are considered usable
|
# IPv6, pool, or IPv4 /31 sets are fully usable
|
||||||
if self.is_pool:
|
if self.family == 6 or self.is_pool or self.prefix.prefixlen == 31:
|
||||||
return available_ips
|
return available_ips
|
||||||
|
|
||||||
# All IP addresses within a point-to-point prefix (IPv4 /31 or IPv6 /127) are considered usable
|
# For "normal" IPv4 prefixes, omit first and last addresses
|
||||||
if (
|
|
||||||
self.prefix.version == 4 and self.prefix.prefixlen == 31 # RFC 3021
|
|
||||||
) or (
|
|
||||||
self.prefix.version == 6 and self.prefix.prefixlen == 127 # RFC 6164
|
|
||||||
):
|
|
||||||
return available_ips
|
|
||||||
|
|
||||||
# Omit first and last IP address from the available set
|
|
||||||
available_ips -= netaddr.IPSet([
|
available_ips -= netaddr.IPSet([
|
||||||
netaddr.IPAddress(self.prefix.first),
|
netaddr.IPAddress(self.prefix.first),
|
||||||
netaddr.IPAddress(self.prefix.last),
|
netaddr.IPAddress(self.prefix.last),
|
||||||
|
Loading…
Reference in New Issue
Block a user