ipaddons¶
- ipaddons.ip_allocation(supernet: UnSpecNet, used_networks: UnspecNetSeq | None = None, ignore_invalid_subnets: bool = True) IPv4Allocation | IPv6Allocation¶
Create an IP allocation.
Creates and returns an IP allocation object.
- Parameters:
supernet – An IPv4 or IPv6 network, either as a string or as an ipaddress network object.
used_networks – A list of subnets of the
supernetthat are already in use in this allocation, either as a string or an ipaddress network object.ignore_invalid_subnets – If set to False, used subnets that do not overlap with the supernet will raise a ValueError.
- Returns:
An
IPv4AllocationorIPv6Allocationinstance, depending on the passedsupernetargument. Same principle asipaddress.ip_network().
- class ipaddons.IPv4Allocation(supernet: UnSpecNet, used_subnets: UnspecNetSeq | None = None, ignore_invalid_subnets: bool = True)¶
An IP allocation.
The object represents a supernet (the allocation) with an optional list of used (assigned) subnets. You can also request an iterator for free subnets of a specific size.
- Parameters:
supernet – An IPv4 or IPv6 network, either as a string or as an ipaddress network object.
used_subnets – A list of subnets of the
supernetthat are already in use in this allocation, either as string or an ipaddress network object.ignore_invalid_subnets – If set to False, used subnets that do not overlap with the supernet will raise a ValueError.
- add_used_subnets(subnets: UnspecNetSeq) None¶
Add additional subnets to the list of used networks in this allocation.
- Parameters:
subnets – A list of networks that are added to the in-use networks of this allocation, either as a string or ipaddress network objects.
- get_free_subnets(prefixlen: int) Generator[_N, None, None]¶
List free subnets of a specific size.
- Parameters:
prefixlen – Size of the free subnets returned in CIDR notation.
- Returns:
An iterator for free subnets of
prefixlensize.
- class ipaddons.IPv6Allocation(supernet: UnSpecNet, used_subnets: UnspecNetSeq | None = None, ignore_invalid_subnets: bool = True)¶
An IP allocation.
The object represents a supernet (the allocation) with an optional list of used (assigned) subnets. You can also request an iterator for free subnets of a specific size.
- Parameters:
supernet – An IPv4 or IPv6 network, either as a string or as an ipaddress network object.
used_subnets – A list of subnets of the
supernetthat are already in use in this allocation, either as string or an ipaddress network object.ignore_invalid_subnets – If set to False, used subnets that do not overlap with the supernet will raise a ValueError.
- add_used_subnets(subnets: UnspecNetSeq) None¶
Add additional subnets to the list of used networks in this allocation.
- Parameters:
subnets – A list of networks that are added to the in-use networks of this allocation, either as a string or ipaddress network objects.
- get_free_subnets(prefixlen: int) Generator[_N, None, None]¶
List free subnets of a specific size.
- Parameters:
prefixlen – Size of the free subnets returned in CIDR notation.
- Returns:
An iterator for free subnets of
prefixlensize.