parallel-ssh icon indicating copy to clipboard operation
parallel-ssh copied to clipboard

Callback support for run_command in parallel and single clients

Open pkittenis opened this issue 4 years ago • 0 comments

Is your feature request related to a problem? Please describe. Would like to be able to use callback function for run_command to call when a command has finished executing.

Describe the solution you'd like

def my_cb(host_out, my_arg):
    for line in host_out.stdout:
        print(line)

client.run_command('echo me', callback=my_cb, callback_extra_args=('my_arg',))

my_cb gets executed as my_cb(host_out, 'my_arg') when command completes on each host. This allows for output handling code to be executed automatically on command completion without client code having to store or handle output objects explicitly.

Describe alternatives you've considered Can be done by sub-classing, though non-trivial.

Additional context N/A.

pkittenis avatar Jan 19 '21 12:01 pkittenis