def lag_id(port):
    """
    Calculates the lag id to use for the given port. Max lag id is 32,
    using all 8 100G ports as separate lags leaves 1..24 for 25G ports
    """
    if port<=24:   # 25G ports on IXR-D2
        return port
    elif port>=49: # 8x 100G ports on IXR-D2
        return 25 + (port-49)
    else:
        raise Exception( f"Unable to allocate LAG ID for port {port}" )