Comment 1 for bug 1815784

Revision history for this message
Mike Pontillo (mpontillo) wrote : Re: Show usage on 'Reserved ranges' table on VLAN summary page

I spent some time today looking at this.

The relevant code that will need to be changed is likely to be maasserver/models/subnet.py:Subnet.get_ipranges_in_use(), and provisioningserver/utils/network.py:MAASIPSet.get_unused_ranges().

This code is relatively complex, especially since the definition of a reserved range (whether or not the IPs are "in-use" or not) can change depending on if the subnet is managed or unmanaged.

I think the most efficient way to make this calculation would be to allow the MAASIPSet to be divided into smaller sets of addresses, based on the start and end address of the range. Then we could re-use all the code that calculates range usage by calculating it once for the subnet, and then iterating over each range and including that separately for each IP range returned by the websocket/CLI.

Note that there has also been some concern about the performance impacts of doing this on a per-range basis, which will need to be investigated as well. I don't expect the performance of the calculation itself to be particularly impactful. But the websocket may trigger recalculations based on distantly-related objects or updates to irrelevant relationships with other model objects in MAAS, so it may be a problem in aggregate.

I'll continue to investigate this tomorrow.