Add --uid-pool option to gnt-cluster modify
authorBalazs Lecz <leczb@google.com>
Wed, 24 Mar 2010 17:59:45 +0000 (17:59 +0000)
committerBalazs Lecz <leczb@google.com>
Fri, 16 Apr 2010 13:10:46 +0000 (14:10 +0100)
Signed-off-by: Balazs Lecz <leczb@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

Makefile.am
lib/cli.py
lib/cmdlib.py
lib/opcodes.py
scripts/gnt-cluster

index 78b5c4d..d50b7c2 100644 (file)
@@ -116,6 +116,7 @@ pkgpython_PYTHON = \
        lib/ssh.py \
        lib/storage.py \
        lib/utils.py \
+       lib/uidpool.py \
        lib/workerpool.py
 
 hypervisor_PYTHON = \
index 796cd0c..7044fc1 100644 (file)
@@ -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.
index 783fedf..cc0c262 100644 (file)
@@ -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
index b093af0..f6c7845 100644 (file)
@@ -306,6 +306,7 @@ class OpSetClusterParams(OpCode):
     "nicparams",
     "candidate_pool_size",
     "maintain_node_health",
+    "uid_pool",
     ]
 
 
index e284e56..37502cf 100755 (executable)
@@ -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": (