def mode_to_int(mode):
    """Returns the integer representation in VPP of a given bondethernet mode,
    or -1 if 'mode' is not a valid string.

    See src/vnet/bonding/bond.api and schema.yaml for valid pairs."""

    ret = {"round-robin": 1, "active-backup": 2, "xor": 3, "broadcast": 4, "lacp": 5}
    try:
        return ret[mode]
    except KeyError:
        pass
    return -1