Commit c4929a8b authored by René Nussbaumer's avatar René Nussbaumer
Browse files

gnt-cluster: Add hv/disk state to init


Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 6396dc04
......@@ -290,7 +290,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
modify_etc_hosts=True, modify_ssh_setup=True,
maintain_node_health=False, drbd_helper=None, uid_pool=None,
default_iallocator=None, primary_ip_version=None, ipolicy=None,
prealloc_wipe_disks=False, use_external_mip_script=False):
prealloc_wipe_disks=False, use_external_mip_script=False,
hv_state=None, disk_state=None):
"""Initialise the cluster.
@type candidate_pool_size: int
......@@ -429,6 +430,26 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
else:
ndparams = dict(constants.NDC_DEFAULTS)
# This is ugly, as we modify the dict itself
# FIXME: Make utils.ForceDictType pure functional or write a wrapper around it
if hv_state:
for hvname, hvs_data in hv_state.items():
utils.ForceDictType(hvs_data, constants.HVSTS_PARAMETER_TYPES)
hv_state[hvname] = objects.Cluster.SimpleFillHvState(hvs_data)
else:
hv_state = dict((hvname, constants.HVST_DEFAULTS)
for hvname in enabled_hypervisors)
# FIXME: disk_state has no default values yet
if disk_state:
for storage, ds_data in disk_state.items():
if storage not in constants.DS_VALID_TYPES:
raise errors.OpPrereqError("Invalid storage type in disk state: %s" %
storage, errors.ECODE_INVAL)
for ds_name, state in ds_data.items():
utils.ForceDictType(state, constants.DSS_PARAMETER_TYPES)
ds_data[ds_name] = objects.Cluster.SimpleFillDiskState(state)
# hvparams is a mapping of hypervisor->hvparams dict
for hv_name, hv_params in hvparams.iteritems():
utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES)
......@@ -506,7 +527,9 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
primary_ip_family=ipcls.family,
prealloc_wipe_disks=prealloc_wipe_disks,
use_external_mip_script=use_external_mip_script,
ipolicy=ipolicy
ipolicy=ipolicy,
hv_state_static=hv_state,
disk_state_static=disk_state,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
......
......@@ -180,6 +180,13 @@ def InitCluster(opts, args):
ToStderr("Invalid master netmask value: %s" % str(err))
return 1
if opts.disk_state:
disk_state = utils.FlatToDict(opts.disk_state)
else:
disk_state = {}
hv_state = dict(opts.hv_state)
bootstrap.InitCluster(cluster_name=args[0],
secondary_ip=opts.secondary_ip,
vg_name=vg_name,
......@@ -205,6 +212,8 @@ def InitCluster(opts, args):
primary_ip_version=primary_ip_version,
prealloc_wipe_disks=opts.prealloc_wipe_disks,
use_external_mip_script=external_ip_setup_script,
hv_state=hv_state,
disk_state=disk_state,
)
op = opcodes.OpClusterPostInit()
SubmitOpCode(op, opts=opts)
......@@ -1453,7 +1462,7 @@ commands = {
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT, USE_EXTERNAL_MIP_SCRIPT,
DISK_PARAMS_OPT] + INSTANCE_POLICY_OPTS,
DISK_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT] + INSTANCE_POLICY_OPTS,
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
......
......@@ -190,6 +190,8 @@ INIT
| [--specs-disk-size *spec-param*=*value* [,*spec-param*=*value*...]]
| [--specs-mem-size *spec-param*=*value* [,*spec-param*=*value*...]]
| [--specs-nic-count *spec-param*=*value* [,*spec-param*=*value*...]]
| [--disk-state *diskstate*]
| [--hypervisor-state *hvstate*]
| {*clustername*}
This commands is only run once initially on the first node of the
......@@ -493,6 +495,9 @@ instance.
``--specs-mem-size`` limits the amount of memory available
``--specs-nic-count`` sets limits on the amount of nics used
For details about how to use ``--hypervisor-state`` and ``--disk-state``
have a look at **ganeti**(7).
LIST-TAGS
~~~~~~~~~
......
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