From 17e8292301c0f498cba93833d0528433bb9adf45 Mon Sep 17 00:00:00 2001
From: Luca Bigliardi <shammash@google.com>
Date: Mon, 24 Aug 2009 18:32:28 +0100
Subject: [PATCH] HooksMaster: list of nodes override

Allow the caller of HooksMaster.RunPhase() to specify an alternative list of
nodes.

Signed-off-by: Luca Bigliardi <shammash@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/mcpu.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/mcpu.py b/lib/mcpu.py
index 94cde5677..72e9b03e4 100644
--- a/lib/mcpu.py
+++ b/lib/mcpu.py
@@ -333,24 +333,28 @@ class HooksMaster(object):
 
     return self.callfn(node_list, hpath, phase, env)
 
-  def RunPhase(self, phase):
+  def RunPhase(self, phase, nodes=None):
     """Run all the scripts for a phase.
 
     This is the main function of the HookMaster.
 
     @param phase: one of L{constants.HOOKS_PHASE_POST} or
         L{constants.HOOKS_PHASE_PRE}; it denotes the hooks phase
+    @param nodes: overrides the predefined list of nodes for the given phase
     @return: the processed results of the hooks multi-node rpc call
     @raise errors.HooksFailure: on communication failure to the nodes
 
     """
-    if not self.node_list[phase]:
+    if not self.node_list[phase] and not nodes:
       # empty node list, we should not attempt to run this as either
       # we're in the cluster init phase and the rpc client part can't
       # even attempt to run, or this LU doesn't do hooks at all
       return
     hpath = self.lu.HPATH
-    results = self._RunWrapper(self.node_list[phase], hpath, phase)
+    if nodes is not None:
+      results = self._RunWrapper(nodes, hpath, phase)
+    else:
+      results = self._RunWrapper(self.node_list[phase], hpath, phase)
     if phase == constants.HOOKS_PHASE_PRE:
       errs = []
       if not results:
-- 
GitLab