Revision 2c9fa1ff lib/opcodes.py

b/lib/opcodes.py
51 51

  
52 52
#: the shutdown timeout
53 53
_PShutdownTimeout = \
54
  ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
54
  ("shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TNonNegativeInt,
55 55
   "How long to wait for instance to shut down")
56 56

  
57 57
#: the force parameter
......
541 541
  WITH_LU = True
542 542
  OP_PARAMS = [
543 543
    ("dry_run", None, ht.TMaybeBool, "Run checks only, don't execute"),
544
    ("debug_level", None, ht.TOr(ht.TNone, ht.TPositiveInt), "Debug level"),
544
    ("debug_level", None, ht.TOr(ht.TNone, ht.TNonNegativeInt), "Debug level"),
545 545
    ("priority", constants.OP_PRIO_DEFAULT,
546 546
     ht.TElemOf(constants.OP_PRIO_SUBMIT_VALID), "Opcode priority"),
547 547
    (DEPEND_ATTR, None, _BuildJobDepCheck(True),
......
768 768
    ]
769 769
  OP_RESULT = ht.TListOf(ht.TAnd(ht.TIsLength(3),
770 770
                                 ht.TItems([ht.TNonEmptyString,
771
                                            ht.TPositiveInt,
772
                                            ht.TPositiveInt])))
771
                                            ht.TNonNegativeInt,
772
                                            ht.TNonNegativeInt])))
773 773

  
774 774

  
775 775
class OpClusterConfigQuery(OpCode):
......
823 823
                              ht.TNone),
824 824
     "Cluster-wide OS parameter defaults"),
825 825
    _PDiskParams,
826
    ("candidate_pool_size", None, ht.TOr(ht.TStrictPositiveInt, ht.TNone),
826
    ("candidate_pool_size", None, ht.TOr(ht.TPositiveInt, ht.TNone),
827 827
     "Master candidate pool size"),
828 828
    ("uid_pool", None, ht.NoType,
829 829
     "Set UID pool, must be list of lists describing UID ranges (two items,"
......
940 940
     "Timeout before the OOB helper will be terminated"),
941 941
    ("ignore_status", False, ht.TBool,
942 942
     "Ignores the node offline status for power off"),
943
    ("power_delay", constants.OOB_POWER_DELAY, ht.TPositiveFloat,
943
    ("power_delay", constants.OOB_POWER_DELAY, ht.TNonNegativeFloat,
944 944
     "Time in seconds to wait between powering on nodes"),
945 945
    ]
946 946
  # Fixme: Make it more specific with all the special cases in LUOobCommand
......
1220 1220
    ("source_instance_name", None, ht.TMaybeString,
1221 1221
     "Source instance name (remote import only)"),
1222 1222
    ("source_shutdown_timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT,
1223
     ht.TPositiveInt,
1223
     ht.TNonNegativeInt,
1224 1224
     "How long source instance was given to shut down (remote import only)"),
1225 1225
    ("source_x509_ca", None, ht.TMaybeString,
1226 1226
     "Source X509 CA in PEM format (remote import only)"),
......
1349 1349
  OP_PARAMS = [
1350 1350
    _PInstanceName,
1351 1351
    _PIgnoreOfflineNodes,
1352
    ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TPositiveInt,
1352
    ("timeout", constants.DEFAULT_SHUTDOWN_TIMEOUT, ht.TNonNegativeInt,
1353 1353
     "How long to wait for instance to shut down"),
1354 1354
    _PNoRemember,
1355 1355
    ]
......
1379 1379
    _PIgnoreIpolicy,
1380 1380
    ("mode", ht.NoDefault, ht.TElemOf(constants.REPLACE_MODES),
1381 1381
     "Replacement mode"),
1382
    ("disks", ht.EmptyList, ht.TListOf(ht.TPositiveInt),
1382
    ("disks", ht.EmptyList, ht.TListOf(ht.TNonNegativeInt),
1383 1383
     "Disk indexes"),
1384 1384
    ("remote_node", None, ht.TMaybeString, "New secondary node"),
1385 1385
    ("iallocator", None, ht.TMaybeString,
......
1489 1489
  """Recreate an instance's disks."""
1490 1490
  _TDiskChanges = \
1491 1491
    ht.TAnd(ht.TIsLength(2),
1492
            ht.TItems([ht.Comment("Disk index")(ht.TPositiveInt),
1492
            ht.TItems([ht.Comment("Disk index")(ht.TNonNegativeInt),
1493 1493
                       ht.Comment("Parameters")(_TDiskParams)]))
1494 1494

  
1495 1495
  OP_DSC_FIELD = "instance_name"
1496 1496
  OP_PARAMS = [
1497 1497
    _PInstanceName,
1498 1498
    ("disks", ht.EmptyList,
1499
     ht.TOr(ht.TListOf(ht.TPositiveInt), ht.TListOf(_TDiskChanges)),
1499
     ht.TOr(ht.TListOf(ht.TNonNegativeInt), ht.TListOf(_TDiskChanges)),
1500 1500
     "List of disk indexes (deprecated) or a list of tuples containing a disk"
1501 1501
     " index and a possibly empty dictionary with disk parameter changes"),
1502 1502
    ("nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString),
......
1539 1539
  # TODO: Remove in version 2.8 including support in LUInstanceSetParams
1540 1540
  old_mod_item_fn = \
1541 1541
    ht.TAnd(ht.TIsLength(2), ht.TItems([
1542
      ht.TOr(ht.TElemOf(constants.DDMS_VALUES), ht.TPositiveInt),
1542
      ht.TOr(ht.TElemOf(constants.DDMS_VALUES), ht.TNonNegativeInt),
1543 1543
      fn,
1544 1544
      ]))
1545 1545

  
......
1581 1581
    ("disks", ht.EmptyList, TestDiskModifications,
1582 1582
     "List of disk changes; see ``nics``"),
1583 1583
    ("beparams", ht.EmptyDict, ht.TDict, "Per-instance backend parameters"),
1584
    ("runtime_mem", None, ht.TMaybeStrictPositiveInt, "New runtime memory"),
1584
    ("runtime_mem", None, ht.TMaybePositiveInt, "New runtime memory"),
1585 1585
    ("hvparams", ht.EmptyDict, ht.TDict,
1586 1586
     "Per-instance hypervisor parameters, hypervisor-dependent"),
1587 1587
    ("disk_template", None, ht.TOr(ht.TNone, _BuildDiskTemplateCheck(False)),
......
1605 1605
    _PInstanceName,
1606 1606
    _PWaitForSync,
1607 1607
    ("disk", ht.NoDefault, ht.TInt, "Disk index"),
1608
    ("amount", ht.NoDefault, ht.TPositiveInt,
1608
    ("amount", ht.NoDefault, ht.TNonNegativeInt,
1609 1609
     "Amount of disk space to add (megabytes)"),
1610 1610
    ("absolute", False, ht.TBool,
1611 1611
     "Whether the amount parameter is an absolute target or a relative one"),
......
1883 1883
    ("duration", ht.NoDefault, ht.TNumber, None),
1884 1884
    ("on_master", True, ht.TBool, None),
1885 1885
    ("on_nodes", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
1886
    ("repeat", 0, ht.TPositiveInt, None),
1886
    ("repeat", 0, ht.TNonNegativeInt, None),
1887 1887
    ]
1888 1888

  
1889 1889

  
......
1914 1914
    ("hypervisor", None, ht.TMaybeString, None),
1915 1915
    ("allocator", None, ht.TMaybeString, None),
1916 1916
    ("tags", ht.EmptyList, ht.TListOf(ht.TNonEmptyString), None),
1917
    ("memory", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
1918
    ("vcpus", None, ht.TOr(ht.TNone, ht.TPositiveInt), None),
1917
    ("memory", None, ht.TOr(ht.TNone, ht.TNonNegativeInt), None),
1918
    ("vcpus", None, ht.TOr(ht.TNone, ht.TNonNegativeInt), None),
1919 1919
    ("os", None, ht.TMaybeString, None),
1920 1920
    ("disk_template", None, ht.TMaybeString, None),
1921 1921
    ("instances", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
1922 1922
    ("evac_mode", None,
1923 1923
     ht.TOr(ht.TNone, ht.TElemOf(constants.IALLOCATOR_NEVAC_MODES)), None),
1924 1924
    ("target_groups", None, ht.TMaybeListOf(ht.TNonEmptyString), None),
1925
    ("spindle_use", 1, ht.TPositiveInt, None),
1926
    ("count", 1, ht.TPositiveInt, None),
1925
    ("spindle_use", 1, ht.TNonNegativeInt, None),
1926
    ("count", 1, ht.TNonNegativeInt, None),
1927 1927
    ]
1928 1928

  
1929 1929

  

Also available in: Unified diff