On Tue, Aug 25, 2009 at 12:34:29PM +0100, Luca Bigliardi wrote: > > Run post phase of node-remove on the removed node as well. > > Signed-off-by: Luca Bigliardi <[email protected]> > --- > doc/hooks.rst | 5 +++-- > lib/cmdlib.py | 23 ++++++++++++++++++++++- > lib/mcpu.py | 1 + > 3 files changed, 26 insertions(+), 3 deletions(-) > > diff --git a/doc/hooks.rst b/doc/hooks.rst > index ecd6c9e..829ee33 100644 > --- a/doc/hooks.rst > +++ b/doc/hooks.rst > @@ -128,12 +128,13 @@ Adds a node to the cluster. > OP_REMOVE_NODE > ++++++++++++++ > > -Removes a node from the cluster. > +Removes a node from the cluster. On the removed node the hooks are called > +during the execution of the operation and not after its completion. > > :directory: node-remove > :env. vars: NODE_NAME > :pre-execution: all existing nodes except the removed node > -:post-execution: all existing nodes except the removed node > +:post-execution: all existing nodes > > OP_NODE_SET_PARAMS > ++++++++++++++++++ > diff --git a/lib/cmdlib.py b/lib/cmdlib.py > index 02a5128..a866ba9 100644 > --- a/lib/cmdlib.py > +++ b/lib/cmdlib.py > @@ -2155,7 +2155,8 @@ class LURemoveNode(LogicalUnit): > "NODE_NAME": self.op.node_name, > } > all_nodes = self.cfg.GetNodeList() > - all_nodes.remove(self.op.node_name) > + if self.op.node_name in all_nodes: > + all_nodes.remove(self.op.node_name) > return env, all_nodes, all_nodes > > def CheckPrereq(self): > @@ -2198,6 +2199,26 @@ class LURemoveNode(LogicalUnit): > > self.context.RemoveNode(node.name) > > + # Run post hooks on the node before it's removed > + try: > + hm = self.proc.hmclass(self.rpc.call_hooks_runner, self) > + h_results = hm.RunPhase(constants.HOOKS_PHASE_POST, [node.name]) > + finally:
LGTM, except the "hm = self.proc ..." must come before the 'try' (not in the try block). iustin
