diff --git a/Makefile.am b/Makefile.am index 78b5c4d15ad218d6fdbca208cab36aec2ddb7750..d50b7c2b4be0a2956f33e6bef8fabb2485f6149a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -116,6 +116,7 @@ pkgpython_PYTHON = \ lib/ssh.py \ lib/storage.py \ lib/utils.py \ + lib/uidpool.py \ lib/workerpool.py hypervisor_PYTHON = \ diff --git a/lib/cli.py b/lib/cli.py index 796cd0c46933a6a8fdc454a2dbd8c79c793038b8..7044fc1c0c53c31de74255fa870bf922d5573454 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -124,6 +124,7 @@ __all__ = [ "SYNC_OPT", "TAG_SRC_OPT", "TIMEOUT_OPT", + "UIDPOOL_OPT", "USEUNITS_OPT", "USE_REPL_NET_OPT", "VERBOSE_OPT", @@ -929,6 +930,11 @@ IDENTIFY_DEFAULTS_OPT = \ " the current cluster defaults and set them as such, instead" " of marking them as overridden") +UIDPOOL_OPT = cli_option("--uid-pool", default=None, + action="store", dest="uid_pool", + help=("A list of user-ids or user-id" + " ranges separated by commas")) + def _ParseArgs(argv, commands, aliases): """Parser for the command line arguments. diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 783fedfb49437524bca49a7be1c089983aa006fb..cc0c2625d988d6bb3a6a90beb078717226fbcc6f 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -44,6 +44,7 @@ from ganeti import constants from ganeti import objects from ganeti import serializer from ganeti import ssconf +from ganeti import uidpool class LogicalUnit(object): @@ -2265,8 +2266,12 @@ class LUSetClusterParams(LogicalUnit): if self.op.candidate_pool_size < 1: raise errors.OpPrereqError("At least one master candidate needed", errors.ECODE_INVAL) + _CheckBooleanOpField(self.op, "maintain_node_health") + if self.op.uid_pool: + uidpool.CheckUidPool(self.op.uid_pool) + def ExpandNames(self): # FIXME: in the future maybe other cluster params won't require checking on # all nodes to be modified. @@ -2461,6 +2466,9 @@ class LUSetClusterParams(LogicalUnit): if self.op.maintain_node_health is not None: self.cluster.maintain_node_health = self.op.maintain_node_health + if self.op.uid_pool is not None: + self.cluster.uid_pool = self.op.uid_pool + self.cfg.Update(self.cluster, feedback_fn) @@ -3719,6 +3727,7 @@ class LUQueryClusterInfo(NoHooksLU): "mtime": cluster.mtime, "uuid": cluster.uuid, "tags": list(cluster.GetTags()), + "uid_pool": cluster.uid_pool, } return result diff --git a/lib/opcodes.py b/lib/opcodes.py index b093af0a92b7ea178bb8f40b5a61ac90235176e5..f6c7845cd741047c4a6fe620057586011db74a8c 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -306,6 +306,7 @@ class OpSetClusterParams(OpCode): "nicparams", "candidate_pool_size", "maintain_node_health", + "uid_pool", ] diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index e284e5620c7f4d76d843dbe283e18b7e75737849..37502cf124ed32fdfc243e897e2d29a25f9c43a2 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -39,6 +39,7 @@ from ganeti import utils from ganeti import bootstrap from ganeti import ssh from ganeti import objects +from ganeti import uidpool @UsesRPC @@ -601,6 +602,7 @@ def SetClusterParams(opts, args): opts.enabled_hypervisors or opts.hvparams or opts.beparams or opts.nicparams or opts.candidate_pool_size is not None or + opts.uid_pool is not None or opts.maintain_node_health is not None): ToStderr("Please give at least one of the parameters.") return 1 @@ -628,8 +630,13 @@ def SetClusterParams(opts, args): nicparams = opts.nicparams utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES) + mnh = opts.maintain_node_health + uid_pool = opts.uid_pool + if uid_pool is not None: + uid_pool = uidpool.ParseUidPool(uid_pool) + op = opcodes.OpSetClusterParams(vg_name=vg_name, enabled_hypervisors=hvlist, hvparams=hvparams, @@ -637,7 +644,8 @@ def SetClusterParams(opts, args): beparams=beparams, nicparams=nicparams, candidate_pool_size=opts.candidate_pool_size, - maintain_node_health=mnh) + maintain_node_health=mnh, + uid_pool=uid_pool) SubmitOpCode(op, opts=opts) return 0 @@ -788,7 +796,8 @@ commands = { 'modify': ( SetClusterParams, ARGS_NONE, [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, - NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT], + NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, + UIDPOOL_OPT], "[opts...]", "Alters the parameters of the cluster"), "renew-crypto": (