Skip to content

Callback support for run_command in parallel and single clients #275

Open
@pkittenis

Description

@pkittenis

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions