Package ganeti :: Module hooksmaster :: Class HooksMaster
[hide private]
[frames] | no frames]

Class HooksMaster

source code


Instance Methods [hide private]
 
__init__(self, opcode, hooks_path, nodes, hooks_execution_fn, hooks_results_adapt_fn, build_env_fn, log_fn, htype=None, cluster_name=None, master_name=None)
Base class for hooks masters.
source code
 
_BuildEnv(self, phase)
Compute the environment and the target nodes.
source code
 
_RunWrapper(self, node_list, hpath, phase, phase_env)
Simple wrapper over self.callfn.
source code
 
RunPhase(self, phase, node_names=None)
Run all the scripts for a phase.
source code
 
RunConfigUpdate(self)
Run the special configuration update hook
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods [hide private]
 
BuildFromLu(hooks_execution_fn, lu) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, opcode, hooks_path, nodes, hooks_execution_fn, hooks_results_adapt_fn, build_env_fn, log_fn, htype=None, cluster_name=None, master_name=None)
(Constructor)

source code 

Base class for hooks masters.

This class invokes the execution of hooks according to the behaviour specified by its parameters.

Parameters:
  • opcode (string) - opcode of the operation to which the hooks are tied
  • hooks_path (string) - prefix of the hooks directories
  • nodes (2-tuple of lists) - 2-tuple of lists containing nodes on which pre-hooks must be run and nodes on which post-hooks must be run
  • hooks_execution_fn (function that accepts the following parameters: (node_list, hooks_path, phase, environment)) - function that will execute the hooks; can be None, indicating that no conversion is necessary.
  • hooks_results_adapt_fn (function) - function that will adapt the return value of hooks_execution_fn to the format expected by RunPhase
  • build_env_fn (function that returns a dictionary having strings as keys) - function that builds the environment for the hooks
  • log_fn (function that accepts a string) - logging function
  • htype (string or None) - None or one of constants.HTYPE_CLUSTER, constants.HTYPE_NODE, constants.HTYPE_INSTANCE
  • cluster_name (string) - name of the cluster
  • master_name (string) - name of the master
Overrides: object.__init__

_BuildEnv(self, phase)

source code 

Compute the environment and the target nodes.

Based on the opcode and the current node list, this builds the environment for the hooks and the target node list for the run.

_RunWrapper(self, node_list, hpath, phase, phase_env)

source code 

Simple wrapper over self.callfn.

This method fixes the environment before executing the hooks.

RunPhase(self, phase, node_names=None)

source code 

Run all the scripts for a phase.

This is the main function of the HookMaster. It executes self.hooks_execution_fn, and after running self.hooks_results_adapt_fn on its results it expects them to be in the form {node_name: (fail_msg, [(script, result, output), ...]}).

Parameters:
Returns:
the processed results of the hooks multi-node rpc call
Raises:

RunConfigUpdate(self)

source code 

Run the special configuration update hook

This is a special hook that runs only on the master after each top-level LI if the configuration has been updated.