diff --git a/lib/cli.py b/lib/cli.py index 34657a0e0033475149876f16b5b2a81be486bc2e..03ea3b48ed7d2f9dddd20edff3e144395336b0fd 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -81,6 +81,7 @@ __all__ = [ "DST_NODE_OPT", "EARLY_RELEASE_OPT", "ENABLED_HV_OPT", + "ENABLED_STORAGE_TYPES_OPT", "ERROR_CODES_OPT", "FAILURE_ONLY_OPT", "FIELDS_OPT", @@ -1156,6 +1157,12 @@ ENABLED_HV_OPT = cli_option("--enabled-hypervisors", help="Comma-separated list of hypervisors", type="string", default=None) +ENABLED_STORAGE_TYPES_OPT = cli_option("--enabled-storage-types", + dest="enabled_storage_types", + help="Comma-separated list of " + "storage methods", + type="string", default=None) + NIC_PARAMS_OPT = cli_option("-N", "--nic-parameters", dest="nicparams", type="keyval", default={}, help="NIC parameters") diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index f87a2748f7a3a7705340cbe47ac6882731cf42a9..61b3f604eaa5a599bb654db611957358f6839290 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -962,6 +962,7 @@ 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 + opts.enabled_storage_types or opts.disk_state or opts.ispecs_mem_size or opts.ispecs_cpu_count or @@ -994,6 +995,10 @@ def SetClusterParams(opts, args): if hvlist is not None: hvlist = hvlist.split(",") + enabled_storage_types = opts.enabled_storage_types + if enabled_storage_types is not None: + enabled_storage_types = enabled_storage_types.split(",") + # a list of (name, dict) we can pass directly to dict() (or []) hvparams = dict(opts.hvparams) for hv_params in hvparams.values(): @@ -1061,30 +1066,32 @@ def SetClusterParams(opts, args): hv_state = dict(opts.hv_state) - op = opcodes.OpClusterSetParams(vg_name=vg_name, - drbd_helper=drbd_helper, - enabled_hypervisors=hvlist, - hvparams=hvparams, - os_hvp=None, - beparams=beparams, - nicparams=nicparams, - ndparams=ndparams, - diskparams=diskparams, - ipolicy=ipolicy, - candidate_pool_size=opts.candidate_pool_size, - maintain_node_health=mnh, - uid_pool=uid_pool, - add_uids=add_uids, - remove_uids=remove_uids, - default_iallocator=opts.default_iallocator, - prealloc_wipe_disks=opts.prealloc_wipe_disks, - master_netdev=opts.master_netdev, - 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, - ) + op = opcodes.OpClusterSetParams( + vg_name=vg_name, + drbd_helper=drbd_helper, + enabled_hypervisors=hvlist, + hvparams=hvparams, + os_hvp=None, + beparams=beparams, + nicparams=nicparams, + ndparams=ndparams, + diskparams=diskparams, + ipolicy=ipolicy, + candidate_pool_size=opts.candidate_pool_size, + maintain_node_health=mnh, + uid_pool=uid_pool, + add_uids=add_uids, + remove_uids=remove_uids, + default_iallocator=opts.default_iallocator, + prealloc_wipe_disks=opts.prealloc_wipe_disks, + master_netdev=opts.master_netdev, + 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, + enabled_storage_types=enabled_storage_types, + ) SubmitOrSend(op, opts) return 0 @@ -1566,7 +1573,7 @@ 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] + + DISK_STATE_OPT, SUBMIT_OPT, ENABLED_STORAGE_TYPES_OPT] + INSTANCE_POLICY_OPTS, "[opts...]", "Alters the parameters of the cluster"), diff --git a/lib/cmdlib.py b/lib/cmdlib.py index c56d7ba6a1ecfb5dd4be214f32ed6099cf95666b..0bc1ace62ff605aaf816310fbcda85cec0a7b049 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -4408,6 +4408,10 @@ class LUClusterSetParams(LogicalUnit): hv_class.CheckParameterSyntax(hv_params) _CheckHVParams(self, node_list, hv_name, hv_params) + # FIXME: Regarding enabled_storage_types: If a method is removed + # which is actually currently used by an instance, should removing + # it be prevented? + if self.op.os_hvp: # no need to check any newly-enabled hypervisors, since the # defaults have already been checked in the above code-block @@ -4459,6 +4463,9 @@ 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 + if self.op.enabled_storage_types is not None: + self.cluster.enabled_storage_types = \ + list(set(self.op.enabled_storage_types)) if self.op.beparams: self.cluster.beparams[constants.PP_DEFAULT] = self.new_beparams if self.op.nicparams: diff --git a/lib/opcodes.py b/lib/opcodes.py index e6db3c37aaea06a80415356fbe327eeed2ea9b68..969fe714efd9884aeff55ee7bd6a21acdf84c289 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -954,6 +954,10 @@ 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"), + ("enabled_storage_types", None, + ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.VALID_STORAGE_TYPES)), + ht.TTrue)), + "List of enabled storage types"), ] OP_RESULT = ht.TNone diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs index f720577633dfe238aed6404731184228c36143e5..7eba05015f691e85a4b2e9d34b56799a8395c5a3 100644 --- a/src/Ganeti/OpCodes.hs +++ b/src/Ganeti/OpCodes.hs @@ -175,6 +175,7 @@ $(genOpCode "OpCode" , pHiddenOs , pBlacklistedOs , pUseExternalMipScript + , pEnabledStorageTypes ]) , ("OpClusterRedistConf", []) , ("OpClusterActivateMasterIp", []) diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs index cccdb7c5fa3b0e7b2efd65dc6f9a9c1e5334dbbb..7e91ae4f7a993883465ae0417a0c16434f5cd576 100644 --- a/src/Ganeti/OpParams.hs +++ b/src/Ganeti/OpParams.hs @@ -237,6 +237,7 @@ module Ganeti.OpParams , pDependencies , pComment , pReason + , pEnabledStorageTypes , dOldQuery , dOldQueryNoLocking ) where @@ -758,6 +759,12 @@ pEnabledHypervisors = optionalField $ simpleField "enabled_hypervisors" [t| NonEmpty Hypervisor |] +-- | List of enabled storage methods. +pEnabledStorageTypes :: Field +pEnabledStorageTypes = + optionalField $ + simpleField "enabled_storage_types" [t| NonEmpty StorageType |] + -- | Selected hypervisor for an instance. pHypervisor :: Field pHypervisor = diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs index 4c06ee2dfb128283bb1d8f63714eaf011b72a1c4..c303fd8d59a372ad90553d2fc07232d3d11ae9ec 100644 --- a/test/hs/Test/Ganeti/OpCodes.hs +++ b/test/hs/Test/Ganeti/OpCodes.hs @@ -163,7 +163,7 @@ instance Arbitrary OpCodes.OpCode where arbitrary <*> arbitrary <*> arbitrary <*> emptyMUD <*> emptyMUD <*> 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