Am 7. Januar 2011 15:49 schrieb Adeodato Simo <[email protected]>:
> --- a/lib/cmdlib.py
> +++ b/lib/cmdlib.py
> +class LUAssignNodes(NoHooksLU):
> + def CheckPrereq(self):
> + self.warn = []
> + self.group = self.cfg.GetNodeGroup(self.group_uuid)
> + instance_data = self.cfg.GetAllInstancesInfo()
> +
> + if self.group is None:
> + raise errors.OpExecError("Could not retrieve group '%s' (UUID: %s)" %
> + (self.op.group_name, self.group_uuid))
> +
> + new_splits, previous_splits = self.CheckAssignmentForSplitInstances(
> + [(node, self.group_uuid) for node in self.op.nodes],
> + self.node_data, instance_data)
Wrapping:
(new_splits, previous_splits) = \
self.CheckAssignmentForSplitInstances([(node, self.group_uuid)
for node in self.op.nodes],
self.node_data, instance_data)
Maybe you could also shorten the function name to, e.g., “CheckSplitInstances”.
> + if new_splits:
> + fmt_new_splits = utils.CommaJoin(utils.NiceSort(new_splits))
> +
> + if not self.op.force:
> + raise errors.OpExecError("The following instances get split by this"
> + " change and --force was not given: %s" %
> + fmt_new_splits)
> + else:
> + self.warn.append("WARNING: this operation will split the following"
> + " instances: %s." % fmt_new_splits)
> +
> + if previous_splits:
> + self.warn.append("WARNING: in addition, the already-split
> instances"
> + " continue to be spit across groups: %s." %
> + utils.CommaJoin(utils.NiceSort(previous_splits)))
> +
> + def Exec(self, feedback_fn):
> + """Assign nodes to a new group.
> +
> + """
> + for warning in self.warn:
> + feedback_fn(warning)
Please use self.LogWarning in CheckPrereq.
> + for node in self.op.nodes:
> + self.node_data[node].group = self.group_uuid
Michael