Commit 2da9f556 authored by René Nussbaumer's avatar René Nussbaumer

gnt-cluster: Allow modify disk/hv state

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent a8282327
......@@ -907,7 +907,9 @@ def SetClusterParams(opts, args):
opts.master_netdev is not None or
opts.master_netmask is not None or
opts.use_external_mip_script is not None or
opts.prealloc_wipe_disks is not None):
opts.prealloc_wipe_disks is not None or
opts.hv_state or
opts.disk_state):
ToStderr("Please give at least one of the parameters.")
return 1
......@@ -980,6 +982,13 @@ def SetClusterParams(opts, args):
ext_ip_script = opts.use_external_mip_script
if opts.disk_state:
disk_state = utils.FlatToDict(opts.disk_state)
else:
disk_state = {}
hv_state = dict(opts.hv_state)
op = opcodes.OpClusterSetParams(vg_name=vg_name,
drbd_helper=drbd_helper,
enabled_hypervisors=hvlist,
......@@ -1000,6 +1009,8 @@ def SetClusterParams(opts, args):
master_netmask=opts.master_netmask,
reserved_lvs=opts.reserved_lvs,
use_external_mip_script=ext_ip_script,
hv_state=hv_state,
disk_state=disk_state,
)
SubmitOpCode(op, opts=opts)
return 0
......@@ -1480,7 +1491,8 @@ commands = {
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT,
DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT,
RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT],
NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT,
DISK_STATE_OPT],
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
......
......@@ -3660,6 +3660,20 @@ class LUClusterSetParams(LogicalUnit):
self.new_ndparams["oob_program"] = \
constants.NDC_DEFAULTS[constants.ND_OOB_PROGRAM]
if self.op.hv_state:
new_hv_state = _MergeAndVerifyHvState(self.op.hv_state,
self.cluster.hv_state_static)
self.new_hv_state = dict((hv, cluster.SimpleFillHvState(values))
for hv, values in new_hv_state.items())
if self.op.disk_state:
new_disk_state = _MergeAndVerifyDiskState(self.op.disk_state,
self.cluster.disk_state_static)
self.new_disk_state = \
dict((storage, dict((name, cluster.SimpleFillDiskState(values))
for name, values in svalues.items()))
for storage, svalues in new_disk_state.items())
if self.op.nicparams:
utils.ForceDictType(self.op.nicparams, constants.NICS_PARAMETER_TYPES)
self.new_nicparams = cluster.SimpleFillNIC(self.op.nicparams)
......@@ -3826,6 +3840,10 @@ class LUClusterSetParams(LogicalUnit):
self.cluster.ndparams = self.new_ndparams
if self.op.diskparams:
self.cluster.diskparams = self.new_diskparams
if self.op.hv_state:
self.cluster.hv_state_static = self.new_hv_state
if self.op.disk_state:
self.cluster.disk_state_static = self.new_disk_state
if self.op.candidate_pool_size is not None:
self.cluster.candidate_pool_size = self.op.candidate_pool_size
......
......@@ -860,6 +860,14 @@ HVST_MEMORY_HV = "mem_hv"
HVST_CPU_TOTAL = "cpu_total"
HVST_CPU_NODE = "cpu_node"
HVST_DEFAULTS = {
HVST_MEMORY_TOTAL: 0,
HVST_MEMORY_NODE: 0,
HVST_MEMORY_HV: 0,
HVST_CPU_TOTAL: 1,
HVST_CPU_NODE: 1,
}
HVSTS_PARAMETER_TYPES = {
HVST_MEMORY_TOTAL: VTYPE_INT,
HVST_MEMORY_NODE: VTYPE_INT,
......@@ -875,6 +883,12 @@ DS_DISK_TOTAL = "disk_total"
DS_DISK_RESERVED = "disk_reserved"
DS_DISK_OVERHEAD = "disk_overhead"
DS_DEFAULTS = {
DS_DISK_TOTAL: 0,
DS_DISK_RESERVED: 0,
DS_DISK_OVERHEAD: 0,
}
DSS_PARAMETER_TYPES = {
DS_DISK_TOTAL: VTYPE_INT,
DS_DISK_RESERVED: VTYPE_INT,
......
......@@ -1254,6 +1254,8 @@ class Cluster(TaggableObject):
"blacklisted_os",
"primary_ip_family",
"prealloc_wipe_disks",
"hv_state_static",
"disk_state_static",
] + _TIMESTAMPS + _UUID
def UpgradeConfig(self):
......@@ -1497,6 +1499,20 @@ class Cluster(TaggableObject):
# specified params
return FillDict(result, os_params)
@staticmethod
def SimpleFillHvState(hv_state):
"""Fill an hv_state sub dict with cluster defaults.
"""
return FillDict(constants.HVST_DEFAULTS, hv_state)
@staticmethod
def SimpleFillDiskState(disk_state):
"""Fill an disk_state sub dict with cluster defaults.
"""
return FillDict(constants.DS_DEFAULTS, disk_state)
def FillND(self, node, nodegroup):
"""Return filled out ndparams for L{objects.NodeGroup} and L{objects.Node}
......
......@@ -757,6 +757,8 @@ class OpClusterSetParams(OpCode):
"""
OP_PARAMS = [
_PHvState,
_PDiskState,
("vg_name", None, ht.TMaybeString, "Volume group name"),
("enabled_hypervisors", None,
ht.TOr(ht.TAnd(ht.TListOf(ht.TElemOf(constants.HYPER_TYPES)), ht.TTrue),
......
......@@ -453,6 +453,8 @@ MODIFY
| [--master-netdev *interface-name*]
| [--master-netmask *netmask*]
| [--use-external-mip-script {yes \| no}]
| [--hypervisor-state *hvstate*]
| [--disk-state *diskstate*]
Modify the options for the cluster.
......@@ -464,6 +466,9 @@ The ``--vg-name``, ``--no-lvm-storarge``, ``--enabled-hypervisors``,
``--use-external-mip-script`` options are described in the
**init** command.
The ``--hypervisor-state`` and ``--disk-state`` options are described in
detail in **ganeti**(7).
The ``--add-uids`` and ``--remove-uids`` options can be used to
modify the user-id pool by adding/removing a list of user-ids or
user-id ranges.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment