Commit c755a3d6 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

opticalcontroller: honour persisted slot occupancy in P2MP spectrum assignment

consecutives_pmp built its candidate list from the slot map's keys alone,
so every slot looked free regardless of its recorded value. That was
harmless while link slots were re-initialised as a fully free band on
every topology load, but develop persists spectrum state: a slot already
carrying a service is stored with value 0, and the P2MP engine both
re-offered those slots and failed to find a usable run, leaving
assigned_slots and subcarriers empty and so configuring nothing.

It now selects only slots recorded as free, which is what the
point-to-point path already does in consecutives().

This keeps develop's spectrum persistence intact -- RSA.py is unchanged
-- rather than restoring the old behaviour of resetting every band to
free, which would have discarded it.

Relates to #316
parent 1d1a3455
Loading
Loading
Loading
Loading
+6 −2
Changes for src/opticalcontroller/tools.py: 6 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -530,9 +530,13 @@ def consecutives_pmp(x, val):
    res = []
    temp = []

    # Ensure x is a list of integers
    # Ensure x is a list of integers. When a slot map is given, honour each
    # slot's occupancy: a value of 1 means free, anything else means the slot
    # is already carrying a service and must not be handed out again. Taking
    # the keys alone would ignore the persisted spectrum state and re-allocate
    # slots that are in use.
    if isinstance(x, dict):
        x = sorted(map(int, x.keys()))  # Convert dict keys to sorted integers
        x = sorted(int(slot) for slot, free in x.items() if int(free) == 1)
    else:
        x = sorted(map(int, x))  # Convert list elements to sorted integers