On Mon, Jan 10, 2011 at 13:59 +0000, Michael Hanselmann <[email protected]> 
wrote:
> 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)

Oh, right; failed to recall this when fixing the same issue in the unit tests.

> Maybe you could also shorten the function name to, e.g., 
> “CheckSplitInstances”.

If you deem it necessary, I will, but my preference would be not to,
to indicate explicitly that this method acts on an assignment, and not
on the current state of the cluster.

> > +    for warning in self.warn:
> > +      feedback_fn(warning)

> Please use self.LogWarning in CheckPrereq.

Done.

diff --git lib/cmdlib.py lib/cmdlib.py
index b147f0a..451ab7e 100644
--- lib/cmdlib.py
+++ lib/cmdlib.py
@@ -9983,7 +9983,6 @@ class LUAssignGroupNodes(NoHooksLU):
     """Check prerequisites.
 
     """
-    self.warn = []
     self.group = self.cfg.GetNodeGroup(self.group_uuid)
     instance_data = self.cfg.GetAllInstancesInfo()
 
@@ -9991,9 +9990,10 @@ class LUAssignGroupNodes(NoHooksLU):
       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)
+    (new_splits, previous_splits) = \
+      self.CheckAssignmentForSplitInstances([(node, self.group_uuid)
+                                             for node in self.op.nodes],
+                                            self.node_data, instance_data)
 
     if new_splits:
       fmt_new_splits = utils.CommaJoin(utils.NiceSort(new_splits))
@@ -10003,21 +10003,18 @@ class LUAssignGroupNodes(NoHooksLU):
                                  " 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)
+        self.LogWarning("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)))
+          self.LogWarning("In addition, these 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)
-
     for node in self.op.nodes:
       self.node_data[node].group = self.group_uuid
 

--
Adeodato Simo | [email protected]
Corp Computing Services SRE (Dublin)

Reply via email to