class documentation

class HooksMaster(object):

View In Hierarchy

Undocumented

Static Method BuildFromLu Undocumented
Method __init__ Base class for hooks masters.
Method RunConfigUpdate Run the special configuration update hook
Method RunPhase Run all the scripts for a phase.
Instance Variable build_env_fn Undocumented
Instance Variable cluster_name Undocumented
Instance Variable hooks_execution_fn Undocumented
Instance Variable hooks_path Undocumented
Instance Variable hooks_results_adapt_fn Undocumented
Instance Variable htype Undocumented
Instance Variable log_fn Undocumented
Instance Variable master_name Undocumented
Instance Variable opcode Undocumented
Instance Variable post_nodes Undocumented
Instance Variable pre_env Undocumented
Instance Variable pre_nodes Undocumented
Instance Variable prepare_post_nodes_fn Undocumented
Method _BuildEnv Compute the environment and the target nodes.
Method _RunWrapper Simple wrapper over self.callfn.
@staticmethod
def BuildFromLu(hooks_execution_fn, lu):

Undocumented

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

Base class for hooks masters.

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

Parameters
opcode:stringopcode of the operation to which the hooks are tied
hooks_path:stringprefix of the hooks directories
nodes:2-tuple of lists2-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:functionfunction 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 keysfunction that builds the environment for the hooks
prepare_post_nodes_fn:function that take a list of node UUIDs and returns a list of node UUIDsfunction that is invoked right before executing post hooks and can change the list of node UUIDs to run the post hooks on
log_fn:function that accepts a stringlogging function
htype:string or NoneNone or one of constants.HTYPE_CLUSTER, constants.HTYPE_NODE, constants.HTYPE_INSTANCE
cluster_name:stringname of the cluster
master_name:stringname of the master
def RunConfigUpdate(self):

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.

def RunPhase(self, phase, node_names=None):

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
phaseone of constants.HOOKS_PHASE_POST or constants.HOOKS_PHASE_PRE; it denotes the hooks phase
node_namesoverrides the predefined list of nodes for the given phase
Returns
the processed results of the hooks multi-node rpc call
Raises
errors.HooksFailureon communication failure to the nodes
errors.HooksAborton failure of one of the hooks
build_env_fn =

Undocumented

cluster_name =

Undocumented

hooks_execution_fn =

Undocumented

hooks_path =

Undocumented

hooks_results_adapt_fn =

Undocumented

htype =

Undocumented

log_fn =

Undocumented

master_name =

Undocumented

opcode =

Undocumented

post_nodes =

Undocumented

pre_env =

Undocumented

pre_nodes =

Undocumented

prepare_post_nodes_fn =

Undocumented

def _BuildEnv(self, phase):

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.

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

Simple wrapper over self.callfn.

This method fixes the environment before executing the hooks.