Revision 2da9f556

b/lib/client/gnt_cluster.py
907 907
          opts.master_netdev is not None or
908 908
          opts.master_netmask is not None or
909 909
          opts.use_external_mip_script is not None or
910
          opts.prealloc_wipe_disks is not None):
910
          opts.prealloc_wipe_disks is not None or
911
          opts.hv_state or
912
          opts.disk_state):
911 913
    ToStderr("Please give at least one of the parameters.")
912 914
    return 1
913 915

  
......
980 982

  
981 983
  ext_ip_script = opts.use_external_mip_script
982 984

  
985
  if opts.disk_state:
986
    disk_state = utils.FlatToDict(opts.disk_state)
987
  else:
988
    disk_state = {}
989

  
990
  hv_state = dict(opts.hv_state)
991

  
983 992
  op = opcodes.OpClusterSetParams(vg_name=vg_name,
984 993
                                  drbd_helper=drbd_helper,
985 994
                                  enabled_hypervisors=hvlist,
......
1000 1009
                                  master_netmask=opts.master_netmask,
1001 1010
                                  reserved_lvs=opts.reserved_lvs,
1002 1011
                                  use_external_mip_script=ext_ip_script,
1012
                                  hv_state=hv_state,
1013
                                  disk_state=disk_state,
1003 1014
                                  )
1004 1015
  SubmitOpCode(op, opts=opts)
1005 1016
  return 0
......
1480 1491
     MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT,
1481 1492
     DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT,
1482 1493
     RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT,
1483
     NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT],
1494
     NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT,
1495
     DISK_STATE_OPT],
1484 1496
    "[opts...]",
1485 1497
    "Alters the parameters of the cluster"),
1486 1498
  "renew-crypto": (
b/lib/cmdlib.py
3660 3660
        self.new_ndparams["oob_program"] = \
3661 3661
            constants.NDC_DEFAULTS[constants.ND_OOB_PROGRAM]
3662 3662

  
3663
    if self.op.hv_state:
3664
      new_hv_state = _MergeAndVerifyHvState(self.op.hv_state,
3665
                                            self.cluster.hv_state_static)
3666
      self.new_hv_state = dict((hv, cluster.SimpleFillHvState(values))
3667
                               for hv, values in new_hv_state.items())
3668

  
3669
    if self.op.disk_state:
3670
      new_disk_state = _MergeAndVerifyDiskState(self.op.disk_state,
3671
                                                self.cluster.disk_state_static)
3672
      self.new_disk_state = \
3673
        dict((storage, dict((name, cluster.SimpleFillDiskState(values))
3674
                            for name, values in svalues.items()))
3675
             for storage, svalues in new_disk_state.items())
3676

  
3663 3677
    if self.op.nicparams:
3664 3678
      utils.ForceDictType(self.op.nicparams, constants.NICS_PARAMETER_TYPES)
3665 3679
      self.new_nicparams = cluster.SimpleFillNIC(self.op.nicparams)
......
3826 3840
      self.cluster.ndparams = self.new_ndparams
3827 3841
    if self.op.diskparams:
3828 3842
      self.cluster.diskparams = self.new_diskparams
3843
    if self.op.hv_state:
3844
      self.cluster.hv_state_static = self.new_hv_state
3845
    if self.op.disk_state:
3846
      self.cluster.disk_state_static = self.new_disk_state
3829 3847

  
3830 3848
    if self.op.candidate_pool_size is not None:
3831 3849
      self.cluster.candidate_pool_size = self.op.candidate_pool_size
b/lib/constants.py
860 860
HVST_CPU_TOTAL = "cpu_total"
861 861
HVST_CPU_NODE = "cpu_node"
862 862

  
863
HVST_DEFAULTS = {
864
  HVST_MEMORY_TOTAL: 0,
865
  HVST_MEMORY_NODE: 0,
866
  HVST_MEMORY_HV: 0,
867
  HVST_CPU_TOTAL: 1,
868
  HVST_CPU_NODE: 1,
869
  }
870

  
863 871
HVSTS_PARAMETER_TYPES = {
864 872
  HVST_MEMORY_TOTAL: VTYPE_INT,
865 873
  HVST_MEMORY_NODE: VTYPE_INT,
......
875 883
DS_DISK_RESERVED = "disk_reserved"
876 884
DS_DISK_OVERHEAD = "disk_overhead"
877 885

  
886
DS_DEFAULTS = {
887
  DS_DISK_TOTAL: 0,
888
  DS_DISK_RESERVED: 0,
889
  DS_DISK_OVERHEAD: 0,
890
  }
891

  
878 892
DSS_PARAMETER_TYPES = {
879 893
  DS_DISK_TOTAL: VTYPE_INT,
880 894
  DS_DISK_RESERVED: VTYPE_INT,
b/lib/objects.py
1254 1254
    "blacklisted_os",
1255 1255
    "primary_ip_family",
1256 1256
    "prealloc_wipe_disks",
1257
    "hv_state_static",
1258
    "disk_state_static",
1257 1259
    ] + _TIMESTAMPS + _UUID
1258 1260

  
1259 1261
  def UpgradeConfig(self):
......
1497 1499
    # specified params
1498 1500
    return FillDict(result, os_params)
1499 1501

  
1502
  @staticmethod
1503
  def SimpleFillHvState(hv_state):
1504
    """Fill an hv_state sub dict with cluster defaults.
1505

  
1506
    """
1507
    return FillDict(constants.HVST_DEFAULTS, hv_state)
1508

  
1509
  @staticmethod
1510
  def SimpleFillDiskState(disk_state):
1511
    """Fill an disk_state sub dict with cluster defaults.
1512

  
1513
    """
1514
    return FillDict(constants.DS_DEFAULTS, disk_state)
1515

  
1500 1516
  def FillND(self, node, nodegroup):
1501 1517
    """Return filled out ndparams for L{objects.NodeGroup} and L{objects.Node}
1502 1518

  
b/lib/opcodes.py
757 757

  
758 758
  """
759 759
  OP_PARAMS = [
760
    _PHvState,
761
    _PDiskState,
760 762
    ("vg_name", None, ht.TMaybeString, "Volume group name"),
761 763
    ("enabled_hypervisors", None,
762 764
     ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue),
b/man/gnt-cluster.rst
453 453
| [--master-netdev *interface-name*]
454 454
| [--master-netmask *netmask*]
455 455
| [--use-external-mip-script {yes \| no}]
456
| [--hypervisor-state *hvstate*]
457
| [--disk-state *diskstate*]
456 458

  
457 459
Modify the options for the cluster.
458 460

  
......
464 466
``--use-external-mip-script`` options are described in the
465 467
**init** command.
466 468

  
469
The ``--hypervisor-state`` and ``--disk-state`` options are described in
470
detail in **ganeti**(7).
471

  
467 472
The ``--add-uids`` and ``--remove-uids`` options can be used to
468 473
modify the user-id pool by adding/removing a list of user-ids or
469 474
user-id ranges.

Also available in: Unified diff