mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-05-28 04:36:05 -04:00
Get stdout and stderr from privledged execute
This commit is contained in:
parent
88e1e5c1a7
commit
7a75ed6cbb
3 changed files with 13 additions and 6 deletions
|
|
@ -48,9 +48,12 @@ module Vagrant
|
|||
res.exit_code
|
||||
end
|
||||
|
||||
def sudo(cmd, opts=nil)
|
||||
def sudo(cmd, opts=nil, &block)
|
||||
@logger.debug("remote communicator, executing (privileged) command")
|
||||
@client.privileged_execute(@machine, cmd, opts)
|
||||
res = @client.privileged_execute(@machine, cmd, opts)
|
||||
yield :stdout, res.stdout if block_given?
|
||||
yield :stderr, res.stderr if block_given?
|
||||
res.exit_code
|
||||
end
|
||||
|
||||
def test(cmd, opts=nil)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ module VagrantPlugins
|
|||
@logger.debug("privleged excuting")
|
||||
res = client.privileged_execute(req)
|
||||
@logger.debug("privleged excution result: #{res}")
|
||||
res.exit_code
|
||||
res
|
||||
end
|
||||
|
||||
# @param [Vagrant::Machine]
|
||||
|
|
|
|||
|
|
@ -256,11 +256,15 @@ module VagrantPlugins
|
|||
plugin = Vagrant.plugin("2").manager.communicators[plugin_name.to_s.to_sym]
|
||||
communicator = plugin.new(machine)
|
||||
opts.transform_keys!(&:to_sym)
|
||||
exit_code = communicator.sudo(cmd.command, opts)
|
||||
logger.debug("command exit code: #{exit_code}")
|
||||
output = {stdout: '', stderr: ''}
|
||||
exit_code = communicator.sudo(cmd.command, opts) {
|
||||
|type, data| output[type] << data if output[type]
|
||||
}
|
||||
|
||||
SDK::Communicator::ExecuteResp.new(
|
||||
exit_code: exit_code
|
||||
exit_code: exit_code,
|
||||
stdout: output[:stdout],
|
||||
stderr: output[:stderr]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue