Revision ff8067cf

b/lib/ht.py
360 360
  return desc(TAnd(TList, lambda lst: compat.all(my_type(v) for v in lst)))
361 361

  
362 362

  
363
TMaybeListOf = lambda item_type: TOr(TNone, TListOf(item_type))
364

  
365

  
363 366
def TDictOf(key_type, val_type):
364 367
  """Checks a dict type for the type of its key/values.
365 368

  
b/lib/opcodes.py
170 170
    ht.TNonEmptyString,
171 171
    ]))
172 172

  
173
_TestClusterOsList = ht.TOr(ht.TNone, ht.TListOf(_TestClusterOsListItem))
173
_TestClusterOsList = ht.TMaybeListOf(_TestClusterOsListItem)
174 174

  
175 175
# TODO: Generate check from constants.INIC_PARAMS_TYPES
176 176
#: Utility function for testing NIC definitions
......
473 473
            ht.TItems([job_id,
474 474
                       ht.TListOf(ht.TElemOf(constants.JOBS_FINALIZED))]))
475 475

  
476
  return ht.TOr(ht.TNone, ht.TListOf(job_dep))
476
  return ht.TMaybeListOf(job_dep)
477 477

  
478 478

  
479 479
TNoRelativeJobDependencies = _BuildJobDepCheck(False)
......
818 818
     "Master network device"),
819 819
    ("master_netmask", None, ht.TOr(ht.TInt, ht.TNone),
820 820
     "Netmask of the master IP"),
821
    ("reserved_lvs", None, ht.TOr(ht.TListOf(ht.TNonEmptyString), ht.TNone),
821
    ("reserved_lvs", None, ht.TMaybeListOf(ht.TNonEmptyString),
822 822
     "List of reserved LVs"),
823 823
    ("hidden_os", None, _TestClusterOsList,
824 824
     "Modify list of hidden operating systems. Each modification must have"
......
880 880
  OP_DSC_FIELD = "what"
881 881
  OP_PARAMS = [
882 882
    _PQueryWhat,
883
    ("fields", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
883
    ("fields", None, ht.TMaybeListOf(ht.TNonEmptyString),
884 884
     "Requested fields; if not given, all are returned"),
885 885
    ]
886 886

  
......
1426 1426
    _PInstanceName,
1427 1427
    _PEarlyRelease,
1428 1428
    ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"),
1429
    ("target_groups", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
1429
    ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString),
1430 1430
     "Destination group names or UUIDs (defaults to \"all but current group\""),
1431 1431
    ]
1432 1432
  OP_RESULT = TJobIdListOnly
......
1508 1508
    _PGroupName,
1509 1509
    _PEarlyRelease,
1510 1510
    ("iallocator", None, ht.TMaybeString, "Iallocator for computing solution"),
1511
    ("target_groups", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
1511
    ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString),
1512 1512
     "Destination group names or UUIDs"),
1513 1513
    ]
1514 1514
  OP_RESULT = TJobIdListOnly
......
1682 1682
     ht.TElemOf(constants.VALID_IALLOCATOR_DIRECTIONS), None),
1683 1683
    ("mode", ht.NoDefault, ht.TElemOf(constants.VALID_IALLOCATOR_MODES), None),
1684 1684
    ("name", ht.NoDefault, ht.TNonEmptyString, None),
1685
    ("nics", ht.NoDefault, ht.TOr(ht.TNone, ht.TListOf(
1686
     ht.TDictOf(ht.TElemOf([constants.INIC_MAC, constants.INIC_IP, "bridge"]),
1687
                ht.TOr(ht.TNone, ht.TNonEmptyString)))), None),
1685
    ("nics", ht.NoDefault,
1686
     ht.TMaybeListOf(ht.TDictOf(ht.TElemOf([constants.INIC_MAC,
1687
                                            constants.INIC_IP,
1688
                                            "bridge"]),
1689
                                ht.TOr(ht.TNone, ht.TNonEmptyString))),
1690
     None),
1688 1691
    ("disks", ht.NoDefault, ht.TOr(ht.TNone, ht.TList), None),
1689 1692
    ("hypervisor", None, ht.TMaybeString, None),
1690 1693
    ("allocator", None, ht.TMaybeString, None),
......
1693 1696
    ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
1694 1697
    ("os", None, ht.TMaybeString, None),
1695 1698
    ("disk_template", None, ht.TMaybeString, None),
1696
    ("instances", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
1697
     None),
1699
    ("instances", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
1698 1700
    ("evac_mode", None,
1699 1701
     ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None),
1700
    ("target_groups", None, ht.TOr(ht.TNone, ht.TListOf(ht.TNonEmptyString)),
1701
     None),
1702
    ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
1702 1703
    ]
1703 1704

  
1704 1705

  

Also available in: Unified diff