Package ClusterShell :: Package Worker :: Module Exec :: Class ExecWorker
[hide private]
[frames] | no frames]

Class ExecWorker

source code


ClusterShell simple execution worker Class.

It runs commands locally. If a node list is provided, one command will be launched for each node and specific keywords will be replaced based on node name and rank.

Local shell usage example:

>>> worker = ExecWorker(nodeset, handler=MyEventHandler(),
...                     timeout=30, command="/bin/uptime")
>>> task.schedule(worker)   # schedule worker for execution
>>> task.run()              # run

Local copy usage example:

>>> worker = ExecWorker(nodeset, handler=MyEventHandler(),
...                     source="/etc/my.cnf",
...                     dest="/etc/my.cnf.bak")
>>> task.schedule(worker)      # schedule worker for execution
>>> task.run()                 # run

connect_timeout option is ignored by this worker.

Nested Classes [hide private]
  SHELL_CLASS
Run a simple local command.
  COPY_CLASS
Run a local `cp' between a source and destination.
Instance Methods [hide private]
 
__init__(self, nodes, handler, timeout=None, **kwargs)
Create an ExecWorker and its engine client instances.
source code
 
_create_clients(self, **kwargs)
Create several shell and copy engine client instances based on worker properties.
source code
 
_add_client(self, nodes, **kwargs)
Create one shell or copy client.
source code
 
_engine_clients(self)
Used by upper layer to get the list of underlying created engine clients.
source code
 
write(self, buf, sname=None)
Write to worker clients.
source code
 
set_write_eof(self, sname=None)
Tell worker to close its writer file descriptors once flushed.
source code
 
abort(self)
Abort processing any action by this worker.
source code
 
_on_node_timeout(self, node)
Update on node timeout.
source code
 
_check_fini(self)
Must be called by each client when closing.
source code

Inherited from Worker.DistantWorker: iter_buffers, iter_errors, iter_keys_timeout, iter_node_buffers, iter_node_errors, iter_node_retcodes, iter_retcodes, last_error, last_node, last_read, last_retcode, node_buffer, node_error, node_error_buffer, node_rc, node_retcode, num_timeout

Inherited from Worker.Worker: did_timeout, flush_buffers, flush_errors, read

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

Class Variables [hide private]

Inherited from Worker.Worker: SNAME_STDERR, SNAME_STDIN, SNAME_STDOUT

Instance Variables [hide private]

Inherited from Worker.Worker: current_errmsg, current_msg, current_node, current_rc, current_sname, eh, started, task

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, nodes, handler, timeout=None, **kwargs)
(Constructor)

source code 

Create an ExecWorker and its engine client instances.

Overrides: object.__init__

_create_clients(self, **kwargs)

source code 

Create several shell and copy engine client instances based on worker properties.

Additional arguments in `kwargs' will be used for client creation. There will be one client per node in self.nodes

_engine_clients(self)

source code 

Used by upper layer to get the list of underlying created engine clients.

Overrides: Worker.Worker._engine_clients

set_write_eof(self, sname=None)

source code 

Tell worker to close its writer file descriptors once flushed. Do not perform writes after this call.

abort(self)

source code 

Abort processing any action by this worker.

Overrides: Worker.Worker.abort

_on_node_timeout(self, node)

source code 

Update on node timeout.

Overrides: Worker.DistantWorker._on_node_timeout
(inherited documentation)

_check_fini(self)

source code 

Must be called by each client when closing.

If they are all closed, trigger the required events.