diff --git a/pycroft/lib/net.py b/pycroft/lib/net.py index a7f9bebba..6e2a6e963 100644 --- a/pycroft/lib/net.py +++ b/pycroft/lib/net.py @@ -28,19 +28,6 @@ def __init__(self) -> None: super().__init__("MAC address already exists") -def get_unused_ips( - subnets: t.Iterable[Subnet], -) -> dict[Subnet, t.Iterator[netaddr.IPAddress]]: - import warnings - - warnings.warn( - "Use `subnet.iter_unused_ips()` instead of `net.get_unused_ips`", - DeprecationWarning, - stacklevel=2, - ) - return {subnet: subnet.unused_ips_iter() for subnet in subnets} - - def get_free_ip(subnets: t.Iterable[Subnet]) -> tuple[netaddr.IPAddress, Subnet]: try: return next((ip, subnet) for subnet in subnets for ip in subnet.unused_ips_iter()) diff --git a/web/blueprints/host/__init__.py b/web/blueprints/host/__init__.py index b20f8bc55..7924a59ba 100644 --- a/web/blueprints/host/__init__.py +++ b/web/blueprints/host/__init__.py @@ -9,7 +9,7 @@ from pycroft.exc import PycroftException from pycroft.helpers.net import mac_regex, get_interface_manufacturer from pycroft.lib import host as lib_host -from pycroft.lib.net import get_subnets_for_room, get_unused_ips +from pycroft.lib.net import get_subnets_for_room from pycroft.lib.facilities import get_room from pycroft.model import session from pycroft.model.host import Host, Interface @@ -247,10 +247,10 @@ def interface_edit(interface_id: int) -> ResponseReturnValue: subnets = get_subnets_for_room(interface.host.room) current_ips = [ip.address for ip in interface.ips] + unused_ips = [ip for subnet in subnets for ip in subnet.unused_ips_iter()] form = InterfaceForm(obj=interface) form.meta.current_mac = interface.mac - unused_ips = [ip for ips in get_unused_ips(subnets).values() for ip in ips] form.ips.choices = [(str(ip), str(ip)) for ip in current_ips + unused_ips] def default_response() -> ResponseReturnValue: @@ -287,7 +287,7 @@ def interface_create(host_id: int) -> ResponseReturnValue: host = get_host_or_404(host_id) subnets = get_subnets_for_room(host.room) form = InterfaceForm() - unused_ips = [ip for ips in get_unused_ips(subnets).values() for ip in ips] + unused_ips = [ip for subnet in subnets for ip in subnet.unused_ips_iter()] form.ips.choices = [(str(ip), str(ip)) for ip in unused_ips] def default_response() -> ResponseReturnValue: