Commit 66af5ec5 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

gnt-cluster modify: modify enabled disk templates



Adds setting of the list of enabled disk templates to 'gnt-cluster modify'.
Note that this does not yet include any verification regarding disk templates
currently used by instances.
Signed-off-by: default avatarHelga Velroyen <helgav@google.com>
Reviewed-by: default avatarMichele Tartara <mtarara@google.com>
parent 966e1580
......@@ -81,7 +81,9 @@ __all__ = [
"DST_NODE_OPT",
"EARLY_RELEASE_OPT",
"ENABLED_HV_OPT",
# FIXME: disable storage types once disk templates are fully implemented.
"ENABLED_STORAGE_TYPES_OPT",
"ENABLED_DISK_TEMPLATES_OPT",
"ERROR_CODES_OPT",
"FAILURE_ONLY_OPT",
"FIELDS_OPT",
......@@ -1165,12 +1167,19 @@ ENABLED_HV_OPT = cli_option("--enabled-hypervisors",
help="Comma-separated list of hypervisors",
type="string", default=None)
# FIXME: Remove once enabled disk templates are fully implemented.
ENABLED_STORAGE_TYPES_OPT = cli_option("--enabled-storage-types",
dest="enabled_storage_types",
help="Comma-separated list of "
"storage methods",
type="string", default=None)
ENABLED_DISK_TEMPLATES_OPT = cli_option("--enabled-disk-templates",
dest="enabled_disk_templates",
help="Comma-separated list of "
"disk templates",
type="string", default=None)
NIC_PARAMS_OPT = cli_option("-N", "--nic-parameters", dest="nicparams",
type="keyval", default={},
help="NIC parameters")
......
......@@ -193,14 +193,6 @@ def InitCluster(opts, args):
hv_state = dict(opts.hv_state)
# FIXME: remove enabled_storage_types when enabled_disk_templates are
# fully implemented.
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)
enabled_disk_templates = opts.enabled_disk_templates
if enabled_disk_templates:
enabled_disk_templates = enabled_disk_templates.split(",")
......@@ -972,7 +964,10 @@ def SetClusterParams(opts, args):
opts.use_external_mip_script is not None or
opts.prealloc_wipe_disks is not None or
opts.hv_state or
# FIXME: Remove 'enabled_storage_types' once 'enabled_disk_templates'
# are fully implemented.
opts.enabled_storage_types or
opts.enabled_disk_templates or
opts.disk_state or
opts.ispecs_mem_size or
opts.ispecs_cpu_count or
......@@ -1005,10 +1000,15 @@ def SetClusterParams(opts, args):
if hvlist is not None:
hvlist = hvlist.split(",")
# FIXME: Remove once 'enabled_disk_templates' are fully implemented.
enabled_storage_types = opts.enabled_storage_types
if enabled_storage_types is not None:
enabled_storage_types = enabled_storage_types.split(",")
enabled_disk_templates = opts.enabled_disk_templates
if enabled_disk_templates:
enabled_disk_templates = enabled_disk_templates.split(",")
# a list of (name, dict) we can pass directly to dict() (or [])
hvparams = dict(opts.hvparams)
for hv_params in hvparams.values():
......@@ -1100,7 +1100,9 @@ def SetClusterParams(opts, args):
use_external_mip_script=ext_ip_script,
hv_state=hv_state,
disk_state=disk_state,
# FIXME: remove once 'enabled_disk_templates' are fully implemented.
enabled_storage_types=enabled_storage_types,
enabled_disk_templates=enabled_disk_templates,
)
SubmitOrSend(op, opts)
return 0
......@@ -1584,7 +1586,8 @@ commands = {
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, HV_STATE_OPT,
DISK_STATE_OPT, SUBMIT_OPT, ENABLED_STORAGE_TYPES_OPT] +
DISK_STATE_OPT, SUBMIT_OPT, ENABLED_STORAGE_TYPES_OPT,
ENABLED_DISK_TEMPLATES_OPT] +
INSTANCE_POLICY_OPTS,
"[opts...]",
"Alters the parameters of the cluster"),
......
......@@ -4498,9 +4498,13 @@ class LUClusterSetParams(LogicalUnit):
if self.op.enabled_hypervisors is not None:
self.cluster.hvparams = self.new_hvparams
self.cluster.enabled_hypervisors = self.op.enabled_hypervisors
# FIXME: remove once 'enabled_disk_templates' is fully implemented.
if self.op.enabled_storage_types is not None:
self.cluster.enabled_storage_types = \
list(set(self.op.enabled_storage_types))
if self.op.enabled_disk_templates:
self.cluster.enabled_disk_templates = \
list(set(self.op.enabled_disk_templates))
if self.op.beparams:
self.cluster.beparams[constants.PP_DEFAULT] = self.new_beparams
if self.op.nicparams:
......
......@@ -954,10 +954,15 @@ class OpClusterSetParams(OpCode):
" ``%s`` or ``%s``" % (constants.DDM_ADD, constants.DDM_REMOVE)),
("use_external_mip_script", None, ht.TMaybeBool,
"Whether to use an external master IP address setup script"),
# FIXME: remove once enabled disk templates are fully implemented.
("enabled_storage_types", None,
ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.VALID_STORAGE_TYPES)),
ht.TTrue)),
"List of enabled storage types"),
("enabled_disk_templates", None,
ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.DISK_TEMPLATES)),
ht.TTrue)),
"List of enabled disk templates"),
]
OP_RESULT = ht.TNone
......
......@@ -175,7 +175,9 @@ $(genOpCode "OpCode"
, pHiddenOs
, pBlacklistedOs
, pUseExternalMipScript
-- FIXME: Remove once enabled disk templates are fully implemented.
, pEnabledStorageTypes
, pEnabledDiskTemplates
])
, ("OpClusterRedistConf", [])
, ("OpClusterActivateMasterIp", [])
......
......@@ -237,7 +237,9 @@ module Ganeti.OpParams
, pDependencies
, pComment
, pReason
-- FIXME: Remove once enabled disk templates are fully implemented
, pEnabledStorageTypes
, pEnabledDiskTemplates
, dOldQuery
, dOldQueryNoLocking
) where
......@@ -760,11 +762,18 @@ pEnabledHypervisors =
simpleField "enabled_hypervisors" [t| NonEmpty Hypervisor |]
-- | List of enabled storage methods.
-- FIXME: Remove once enabled disk templates are fully implemented.
pEnabledStorageTypes :: Field
pEnabledStorageTypes =
optionalField $
simpleField "enabled_storage_types" [t| NonEmpty StorageType |]
-- | List of enabled disk templates.
pEnabledDiskTemplates :: Field
pEnabledDiskTemplates =
optionalField $
simpleField "enabled_disk_templates" [t| NonEmpty DiskTemplate |]
-- | Selected hypervisor for an instance.
pHypervisor :: Field
pHypervisor =
......
......@@ -163,7 +163,8 @@ instance Arbitrary OpCodes.OpCode where
arbitrary <*> arbitrary <*> arbitrary <*>
emptyMUD <*> emptyMUD <*> arbitrary <*>
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
arbitrary
"OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf
"OP_CLUSTER_ACTIVATE_MASTER_IP" ->
pure OpCodes.OpClusterActivateMasterIp
......
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