Revision 4da7909a

b/lib/client/gnt_group.py
105 105
  return 0
106 106

  
107 107

  
108
def SetGroupParams(opts, args):
109
  """Modifies a node group's parameters.
110

  
111
  @param opts: the command line options seletect by the user
112
  @type args: list
113
  @param args: should contain only one element, the node group name
114

  
115
  @rtype: int
116
  @return: the desired exit code
117

  
118
  """
119
  all_changes = {
120
    "ndparams": opts.ndparams,
121
  }
122

  
123
  if all_changes.values().count(None) == len(all_changes):
124
    ToStderr("Please give at least one of the parameters.")
125
    return 1
126

  
127
  op = opcodes.OpSetGroupParams(group_name=args[0], **all_changes)
128
  result = SubmitOrSend(op, opts)
129

  
130
  if result:
131
    ToStdout("Modified node group %s", args[0])
132
    for param, data in result:
133
      ToStdout(" - %-5s -> %s", param, data)
134

  
135
  return 0
136

  
137

  
108 138
def RemoveGroup(opts, args):
109 139
  """Remove a node group from the cluster.
110 140

  
......
146 176
    "Lists the node groups in the cluster. The available fields are (see"
147 177
    " the man page for details): %s. The default list is (in order): %s." %
148 178
    (utils.CommaJoin(_LIST_HEADERS), utils.CommaJoin(_LIST_DEF_FIELDS))),
179
  "modify": (
180
    SetGroupParams, ARGS_ONE_GROUP,
181
    [DRY_RUN_OPT, SUBMIT_OPT, NODE_PARAMS_OPT],
182
    "<group_name>", "Alters the parameters of a node group"),
149 183
  "remove": (
150 184
    RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT],
151 185
    "[--dry-run] <group_name>",
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
b/lib/mcpu.py
191 191
    # node group lu
192 192
    opcodes.OpAddGroup: cmdlib.LUAddGroup,
193 193
    opcodes.OpQueryGroups: cmdlib.LUQueryGroups,
194
    opcodes.OpSetGroupParams: cmdlib.LUSetGroupParams,
194 195
    opcodes.OpRemoveGroup: cmdlib.LURemoveGroup,
195 196
    opcodes.OpRenameGroup: cmdlib.LURenameGroup,
196 197
    # os lu
b/lib/opcodes.py
737 737
  __slots__ = ["output_fields", "names"]
738 738

  
739 739

  
740
class OpSetGroupParams(OpCode):
741
  """Change the parameters of a node group."""
742
  OP_ID = "OP_GROUP_SET_PARAMS"
743
  OP_DSC_FIELD = "group_name"
744
  __slots__ = [
745
    "group_name",
746
    "ndparams",
747
    ]
748

  
749

  
740 750
class OpRemoveGroup(OpCode):
741 751
  """Remove a node group from the cluster."""
742 752
  OP_ID = "OP_GROUP_REMOVE"
b/man/gnt-group.rst
34 34
parameters for nodes in the group. Please see **ganeti**(7) for more
35 35
information about supported key=value pairs.
36 36

  
37
MODIFY
38
~~~~~~
39

  
40
| **modify**
41
| [--node-parameters=*NDPARAMS*]
42
| {*group*}
43

  
44
Modifies some parameters from the node group.
45

  
46
The ``--node-parameters`` option is documented in the **add** command
47
above.
48

  
37 49
REMOVE
38 50
~~~~~~
39 51

  

Also available in: Unified diff