You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
get_stdout now returns buffers by default (the behaviour when return_buffers=True) for long running commands.
In this case the channel is also returned in the hash so that exit code can be got after command has finished executing.
Reading stdout can be used to block and get output of command while it's still running.
Will update documentation to reflect this usage and possibly re-do get_stdout as it is only returning input/output buffers and the channel in this case.
For example:
In [4]: cmds = client.exec_command('puppet agent -t', sudo=True)
In [5]: output = [client.get_stdout(cmd) for cmd in cmds]
In [7]: stdout = output[0]['XXXX']['stdout']
In [8]: for line in stdout: print line
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/ntp_is_configured.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/XXXXXXX.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/jenkins.rb
Info: Caching catalog for XXXXXXXXXX
Info: Applying configuration version '1412615199'
Notice: Finished catalog run in 25.42 seconds
In [9]:
In [10]: for line in stdout: print line
In [13]: chan.recv_exit_status()
Out[13]: 0
If a long running command, tail -f for exaple, is executed via exec_command the command is aborted after exec_command returns.
Fix by returning the pty to be used by get_stdout to get continuous output.
Also provide feedback in get_stdout that the command has not finished executing, how long it's been running and a way to kill it.
The text was updated successfully, but these errors were encountered: