saberx.executers package

Submodules

saberx.executers.actionexecuter module

class saberx.executers.actionexecuter.ActionExecuter[source]

Bases: object

class for handling execution of a given action. This class mostly comrises of status function.

static execute_action(**kwargs)[source]

Method to execute a given action

This method executes a given action. It fires the associated trigger using the required trigger handler if trigger is successfull, executes the desired commands.

The layout of a action will be as follows:

action_name: string trigger:

type: TCP_TRIGGER check: tcp_connect | tcp_fail host: host_name port: port negate: true | false attemp: number threshold: number ssl: true | false

execute: - command1 - command2

Parameters:kwargs – Object containing action, thread lock and logger
Returns:Success or failure for this action
Return type:bool
static sanitize(action)[source]

saberx.executers.groupexecuter module

class saberx.executers.groupexecuter.GroupExecuter[source]

Bases: object

Class for handling executing of a group of actions

static execute_group(**kwargs)[source]

Method for executing a group of actions

This method takes a group of actions. It then ieterates over thoses group actions and executes them one by one using the required actionexecuter module.

It is important to be noted here that actions in a group are executed synchronously, and if one action in the pipeline fails, ie, triggered but command executions fails due to some excpetion or error, the entire pipeline after the failed action is ignored.

If you dont wont the above dependency between your actions, it is advised to place the actions in different groups. Groups have no such dependencies are executed concurrently.

static sanitize(group)[source]

saberx.executers.threaddriver module

class saberx.executers.threaddriver.ThreadExecuter(**kwargs)[source]

Bases: object

Class for spawning and managing threads for executing groups

spawn_workers(lock_file)[source]

** Method to spawn threads**

This method is used to spawn new threads to execute groups. Each thread calls the __worker fuction as target with a given group.

Parameters:lock_file (string) – Path to lock file
Returns;
bool: Threads spawned and executed successfully or not.

Module contents