Commit c074a9e8 authored by Helga Velroyen's avatar Helga Velroyen

gnt-cluster init: add enabled_storage_types parameter

This patch extends the 'gnt-cluster init' command to set the list
of enabled storage types on cluster creation.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent c270ee07
......@@ -372,11 +372,14 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
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,
hv_state=None, disk_state=None):
hv_state=None, disk_state=None, enabled_storage_types=None):
"""Initialise the cluster.
@type candidate_pool_size: int
@param candidate_pool_size: master candidate pool size
@type enabled_storage_types: list of string
@param enabled_storage_types: list of storage types to be used in this
cluster
"""
# TODO: complete the docstring
......@@ -393,6 +396,16 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
" entries: %s" % invalid_hvs,
errors.ECODE_INVAL)
if not enabled_storage_types:
raise errors.OpPrereqError("Enabled storage types list must contain at"
" least one member", errors.ECODE_INVAL)
invalid_storage_types = \
set(enabled_storage_types) - constants.VALID_STORAGE_TYPES
if invalid_storage_types:
raise errors.OpPrereqError("Enabled storage_types contains invalid"
" entries: %s" % invalid_storage_types,
errors.ECODE_INVAL)
try:
ipcls = netutils.IPAddress.GetClassFromIpVersion(primary_ip_version)
except errors.ProgrammerError:
......@@ -621,6 +634,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
ipolicy=full_ipolicy,
hv_state_static=hv_state,
disk_state_static=disk_state,
enabled_storage_types=enabled_storage_types,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
......
......@@ -194,6 +194,12 @@ def InitCluster(opts, args):
hv_state = dict(opts.hv_state)
enabled_storage_types = opts.enabled_storage_types
if enabled_storage_types is not None:
enabled_storage_types = enabled_storage_types.split(",")
else:
enabled_storage_types = list(constants.DEFAULT_ENABLED_STORAGE_TYPES)
bootstrap.InitCluster(cluster_name=args[0],
secondary_ip=opts.secondary_ip,
vg_name=vg_name,
......@@ -221,6 +227,7 @@ def InitCluster(opts, args):
use_external_mip_script=external_ip_setup_script,
hv_state=hv_state,
disk_state=disk_state,
enabled_storage_types=enabled_storage_types,
)
op = opcodes.OpClusterPostInit()
SubmitOpCode(op, opts=opts)
......@@ -1495,7 +1502,8 @@ 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, HV_STATE_OPT, DISK_STATE_OPT] + INSTANCE_POLICY_OPTS,
DISK_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT, ENABLED_STORAGE_TYPES_OPT]
+ INSTANCE_POLICY_OPTS,
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
......
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