Revision 4fe5cf90
b/doc/hooks.rst | ||
---|---|---|
193 | 193 |
:pre-execution: master node |
194 | 194 |
:post-execution: master node |
195 | 195 |
|
196 |
OP_RENAME_GROUP |
|
197 |
+++++++++++++++ |
|
198 |
|
|
199 |
Renames a node group. |
|
200 |
|
|
201 |
:directory: group-rename |
|
202 |
:env. vars: OLD_NAME, NEW_NAME |
|
203 |
:pre-execution: master node and all nodes in the group |
|
204 |
:post-execution: master node and all nodes in the group |
|
205 |
|
|
196 | 206 |
|
197 | 207 |
Instance operations |
198 | 208 |
~~~~~~~~~~~~~~~~~~~ |
b/lib/cmdlib.py | ||
---|---|---|
10533 | 10533 |
self.remove_locks[locking.LEVEL_NODEGROUP] = self.group_uuid |
10534 | 10534 |
|
10535 | 10535 |
|
10536 |
class LURenameGroup(LogicalUnit): |
|
10537 |
HPATH = "group-rename" |
|
10538 |
HTYPE = constants.HTYPE_GROUP |
|
10539 |
|
|
10540 |
_OP_PARAMS = [ |
|
10541 |
("old_name", ht.NoDefault, ht.TNonEmptyString), |
|
10542 |
("new_name", ht.NoDefault, ht.TNonEmptyString), |
|
10543 |
] |
|
10544 |
|
|
10545 |
REQ_BGL = False |
|
10546 |
|
|
10547 |
def ExpandNames(self): |
|
10548 |
# This raises errors.OpPrereqError on its own: |
|
10549 |
self.group_uuid = self.cfg.LookupNodeGroup(self.op.old_name) |
|
10550 |
|
|
10551 |
self.needed_locks = { |
|
10552 |
locking.LEVEL_NODEGROUP: [self.group_uuid], |
|
10553 |
} |
|
10554 |
|
|
10555 |
def CheckPrereq(self): |
|
10556 |
"""Check prerequisites. |
|
10557 |
|
|
10558 |
This checks that the given old_name exists as a node group, and that |
|
10559 |
new_name doesn't. |
|
10560 |
|
|
10561 |
""" |
|
10562 |
try: |
|
10563 |
new_name_uuid = self.cfg.LookupNodeGroup(self.op.new_name) |
|
10564 |
except errors.OpPrereqError: |
|
10565 |
pass |
|
10566 |
else: |
|
10567 |
raise errors.OpPrereqError("Desired new name '%s' clashes with existing" |
|
10568 |
" node group (UUID: %s)" % |
|
10569 |
(self.op.new_name, new_name_uuid), |
|
10570 |
errors.ECODE_EXISTS) |
|
10571 |
|
|
10572 |
def BuildHooksEnv(self): |
|
10573 |
"""Build hooks env. |
|
10574 |
|
|
10575 |
""" |
|
10576 |
env = { |
|
10577 |
"OLD_NAME": self.op.old_name, |
|
10578 |
"NEW_NAME": self.op.new_name, |
|
10579 |
} |
|
10580 |
|
|
10581 |
mn = self.cfg.GetMasterNode() |
|
10582 |
all_nodes = self.cfg.GetAllNodesInfo() |
|
10583 |
run_nodes = [mn] |
|
10584 |
all_nodes.pop(mn, None) |
|
10585 |
|
|
10586 |
for node in all_nodes.values(): |
|
10587 |
if node.group == self.group_uuid: |
|
10588 |
run_nodes.append(node.name) |
|
10589 |
|
|
10590 |
return env, run_nodes, run_nodes |
|
10591 |
|
|
10592 |
def Exec(self, feedback_fn): |
|
10593 |
"""Rename the node group. |
|
10594 |
|
|
10595 |
""" |
|
10596 |
group = self.cfg.GetNodeGroup(self.group_uuid) |
|
10597 |
|
|
10598 |
if group is None: |
|
10599 |
raise errors.OpExecError("Could not retrieve group '%s' (UUID: %s)" % |
|
10600 |
(self.op.old_name, self.group_uuid)) |
|
10601 |
|
|
10602 |
group.name = self.op.new_name |
|
10603 |
self.cfg.Update(group, feedback_fn) |
|
10604 |
|
|
10605 |
return self.op.new_name |
|
10606 |
|
|
10607 |
|
|
10536 | 10608 |
class TagsLU(NoHooksLU): # pylint: disable-msg=W0223 |
10537 | 10609 |
"""Generic tags LU. |
10538 | 10610 |
|
b/lib/mcpu.py | ||
---|---|---|
192 | 192 |
opcodes.OpAddGroup: cmdlib.LUAddGroup, |
193 | 193 |
opcodes.OpQueryGroups: cmdlib.LUQueryGroups, |
194 | 194 |
opcodes.OpRemoveGroup: cmdlib.LURemoveGroup, |
195 |
opcodes.OpRenameGroup: cmdlib.LURenameGroup, |
|
195 | 196 |
# os lu |
196 | 197 |
opcodes.OpDiagnoseOS: cmdlib.LUDiagnoseOS, |
197 | 198 |
# exports lu |
b/lib/opcodes.py | ||
---|---|---|
740 | 740 |
__slots__ = ["group_name"] |
741 | 741 |
|
742 | 742 |
|
743 |
class OpRenameGroup(OpCode): |
|
744 |
"""Rename a node group in the cluster.""" |
|
745 |
OP_ID = "OP_GROUP_RENAME" |
|
746 |
OP_DSC_FIELD = "old_name" |
|
747 |
__slots__ = ["old_name", "new_name"] |
|
748 |
|
|
749 |
|
|
743 | 750 |
# OS opcodes |
744 | 751 |
class OpDiagnoseOS(OpCode): |
745 | 752 |
"""Compute the list of guest operating systems.""" |
Also available in: Unified diff