Commit 1338f2b4 authored by Balazs Lecz's avatar Balazs Lecz
Browse files

Add --uid-pool option to gnt-cluster modify


Signed-off-by: default avatarBalazs Lecz <leczb@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 6d127406
...@@ -116,6 +116,7 @@ pkgpython_PYTHON = \ ...@@ -116,6 +116,7 @@ pkgpython_PYTHON = \
lib/ssh.py \ lib/ssh.py \
lib/storage.py \ lib/storage.py \
lib/utils.py \ lib/utils.py \
lib/uidpool.py \
lib/workerpool.py lib/workerpool.py
hypervisor_PYTHON = \ hypervisor_PYTHON = \
......
...@@ -124,6 +124,7 @@ __all__ = [ ...@@ -124,6 +124,7 @@ __all__ = [
"SYNC_OPT", "SYNC_OPT",
"TAG_SRC_OPT", "TAG_SRC_OPT",
"TIMEOUT_OPT", "TIMEOUT_OPT",
"UIDPOOL_OPT",
"USEUNITS_OPT", "USEUNITS_OPT",
"USE_REPL_NET_OPT", "USE_REPL_NET_OPT",
"VERBOSE_OPT", "VERBOSE_OPT",
...@@ -929,6 +930,11 @@ IDENTIFY_DEFAULTS_OPT = \ ...@@ -929,6 +930,11 @@ IDENTIFY_DEFAULTS_OPT = \
" the current cluster defaults and set them as such, instead" " the current cluster defaults and set them as such, instead"
" of marking them as overridden") " 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): def _ParseArgs(argv, commands, aliases):
"""Parser for the command line arguments. """Parser for the command line arguments.
......
...@@ -44,6 +44,7 @@ from ganeti import constants ...@@ -44,6 +44,7 @@ from ganeti import constants
from ganeti import objects from ganeti import objects
from ganeti import serializer from ganeti import serializer
from ganeti import ssconf from ganeti import ssconf
from ganeti import uidpool
class LogicalUnit(object): class LogicalUnit(object):
...@@ -2265,8 +2266,12 @@ class LUSetClusterParams(LogicalUnit): ...@@ -2265,8 +2266,12 @@ class LUSetClusterParams(LogicalUnit):
if self.op.candidate_pool_size < 1: if self.op.candidate_pool_size < 1:
raise errors.OpPrereqError("At least one master candidate needed", raise errors.OpPrereqError("At least one master candidate needed",
errors.ECODE_INVAL) errors.ECODE_INVAL)
_CheckBooleanOpField(self.op, "maintain_node_health") _CheckBooleanOpField(self.op, "maintain_node_health")
if self.op.uid_pool:
uidpool.CheckUidPool(self.op.uid_pool)
def ExpandNames(self): def ExpandNames(self):
# FIXME: in the future maybe other cluster params won't require checking on # FIXME: in the future maybe other cluster params won't require checking on
# all nodes to be modified. # all nodes to be modified.
...@@ -2461,6 +2466,9 @@ class LUSetClusterParams(LogicalUnit): ...@@ -2461,6 +2466,9 @@ class LUSetClusterParams(LogicalUnit):
if self.op.maintain_node_health is not None: if self.op.maintain_node_health is not None:
self.cluster.maintain_node_health = self.op.maintain_node_health 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) self.cfg.Update(self.cluster, feedback_fn)
...@@ -3719,6 +3727,7 @@ class LUQueryClusterInfo(NoHooksLU): ...@@ -3719,6 +3727,7 @@ class LUQueryClusterInfo(NoHooksLU):
"mtime": cluster.mtime, "mtime": cluster.mtime,
"uuid": cluster.uuid, "uuid": cluster.uuid,
"tags": list(cluster.GetTags()), "tags": list(cluster.GetTags()),
"uid_pool": cluster.uid_pool,
} }
return result return result
......
...@@ -306,6 +306,7 @@ class OpSetClusterParams(OpCode): ...@@ -306,6 +306,7 @@ class OpSetClusterParams(OpCode):
"nicparams", "nicparams",
"candidate_pool_size", "candidate_pool_size",
"maintain_node_health", "maintain_node_health",
"uid_pool",
] ]
......
...@@ -39,6 +39,7 @@ from ganeti import utils ...@@ -39,6 +39,7 @@ from ganeti import utils
from ganeti import bootstrap from ganeti import bootstrap
from ganeti import ssh from ganeti import ssh
from ganeti import objects from ganeti import objects
from ganeti import uidpool
@UsesRPC @UsesRPC
...@@ -601,6 +602,7 @@ def SetClusterParams(opts, args): ...@@ -601,6 +602,7 @@ def SetClusterParams(opts, args):
opts.enabled_hypervisors or opts.hvparams or opts.enabled_hypervisors or opts.hvparams or
opts.beparams or opts.nicparams or opts.beparams or opts.nicparams or
opts.candidate_pool_size is not None or opts.candidate_pool_size is not None or
opts.uid_pool is not None or
opts.maintain_node_health is not None): opts.maintain_node_health is not None):
ToStderr("Please give at least one of the parameters.") ToStderr("Please give at least one of the parameters.")
return 1 return 1
...@@ -628,8 +630,13 @@ def SetClusterParams(opts, args): ...@@ -628,8 +630,13 @@ def SetClusterParams(opts, args):
nicparams = opts.nicparams nicparams = opts.nicparams
utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES) utils.ForceDictType(nicparams, constants.NICS_PARAMETER_TYPES)
mnh = opts.maintain_node_health 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, op = opcodes.OpSetClusterParams(vg_name=vg_name,
enabled_hypervisors=hvlist, enabled_hypervisors=hvlist,
hvparams=hvparams, hvparams=hvparams,
...@@ -637,7 +644,8 @@ def SetClusterParams(opts, args): ...@@ -637,7 +644,8 @@ def SetClusterParams(opts, args):
beparams=beparams, beparams=beparams,
nicparams=nicparams, nicparams=nicparams,
candidate_pool_size=opts.candidate_pool_size, candidate_pool_size=opts.candidate_pool_size,
maintain_node_health=mnh) maintain_node_health=mnh,
uid_pool=uid_pool)
SubmitOpCode(op, opts=opts) SubmitOpCode(op, opts=opts)
return 0 return 0
...@@ -788,7 +796,8 @@ commands = { ...@@ -788,7 +796,8 @@ commands = {
'modify': ( 'modify': (
SetClusterParams, ARGS_NONE, SetClusterParams, ARGS_NONE,
[BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, [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...]", "[opts...]",
"Alters the parameters of the cluster"), "Alters the parameters of the cluster"),
"renew-crypto": ( "renew-crypto": (
......
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