Revision 4da7909a lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
10341 | 10341 |
return output |
10342 | 10342 |
|
10343 | 10343 |
|
10344 |
class LUSetGroupParams(LogicalUnit): |
|
10345 |
"""Modifies the parameters of a node group. |
|
10346 |
|
|
10347 |
""" |
|
10348 |
HPATH = None |
|
10349 |
HTYPE = None |
|
10350 |
|
|
10351 |
_OP_PARAMS = [ |
|
10352 |
_PGroupName, |
|
10353 |
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)), |
|
10354 |
] |
|
10355 |
|
|
10356 |
REQ_BGL = False |
|
10357 |
|
|
10358 |
def CheckArguments(self): |
|
10359 |
all_changes = [ |
|
10360 |
self.op.ndparams, |
|
10361 |
] |
|
10362 |
|
|
10363 |
if all_changes.count(None) == len(all_changes): |
|
10364 |
raise errors.OpPrereqError("Please pass at least one modification", |
|
10365 |
errors.ECODE_INVAL) |
|
10366 |
|
|
10367 |
def ExpandNames(self): |
|
10368 |
# This raises errors.OpPrereqError on its own: |
|
10369 |
self.group_uuid = self.cfg.LookupNodeGroup(self.op.group_name) |
|
10370 |
|
|
10371 |
self.needed_locks = { |
|
10372 |
locking.LEVEL_NODEGROUP: [self.group_uuid], |
|
10373 |
} |
|
10374 |
|
|
10375 |
def CheckPrereq(self): |
|
10376 |
"""Check prerequisites. |
|
10377 |
|
|
10378 |
""" |
|
10379 |
self.group = self.cfg.GetNodeGroup(self.group_uuid) |
|
10380 |
|
|
10381 |
if self.group is None: |
|
10382 |
raise errors.OpExecError("Could not retrieve group '%s' (UUID: %s)" % |
|
10383 |
(self.op.group_name, self.group_uuid)) |
|
10384 |
|
|
10385 |
if self.op.ndparams: |
|
10386 |
utils.ForceDictType(self.op.ndparams, constants.NDS_PARAMETER_TYPES) |
|
10387 |
self.new_ndparams = self.group.SimpleFillND(self.op.ndparams) |
|
10388 |
|
|
10389 |
def Exec(self, feedback_fn): |
|
10390 |
"""Modifies the node group. |
|
10391 |
|
|
10392 |
""" |
|
10393 |
result = [] |
|
10394 |
|
|
10395 |
if self.op.ndparams: |
|
10396 |
self.group.ndparams = self.new_ndparams |
|
10397 |
result.append(("ndparams", str(self.group.ndparams))) |
|
10398 |
|
|
10399 |
self.cfg.Update(self.group, feedback_fn) |
|
10400 |
return result |
|
10401 |
|
|
10402 |
|
|
10403 |
|
|
10344 | 10404 |
class LURemoveGroup(LogicalUnit): |
10345 | 10405 |
HPATH = "group-remove" |
10346 | 10406 |
HTYPE = constants.HTYPE_GROUP |
Also available in: Unified diff