def TSetParamsMods(fn):
  # Old format
  # TODO: Remove in version 2.11 including support in LUInstanceSetParams
  old_mod_item_fn = \
    TAnd(TIsLength(2),
         TItems([TOr(TElemOf(constants.DDMS_VALUES), TNonNegativeInt), fn]))

  # New format, supporting adding/removing disks/NICs at arbitrary indices
  mod_item_fn = \
      TAnd(TIsLength(3), TItems([
        TElemOf(constants.DDMS_VALUES_WITH_MODIFY),
        Comment("Device index, can be negative, e.g. -1 for last disk")
                 (TOr(TInt, TString)),
        fn,
        ]))

  return TOr(Comment("Recommended")(TListOf(mod_item_fn)),
             Comment("Deprecated")(TListOf(old_mod_item_fn)))
Generates a check for modification lists.
dataset/ETHPy150Open ganeti/ganeti/lib/ht.py/TSetParamsMods