summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Hu <huh@vmware.com>2012-05-05 00:35:48 +0800
committerBryan McLellan <btm@opscode.com>2012-06-21 12:09:18 -0700
commit4dda538f1a9a1af5051535ff3d55ea2af78acaf8 (patch)
tree84fd4eb9b0d01b32095dcbb6157067e39967fffc
parente74c776443fd7043ec6972fe9cacd53b374077b6 (diff)
downloadchef-4dda538f1a9a1af5051535ff3d55ea2af78acaf8.tar.gz
CHEF-2627: run() and ssh_command() of Chef::Knife::Ssh should return the exit status of the SSH command executed
-rw-r--r--chef/lib/chef/knife/ssh.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/chef/lib/chef/knife/ssh.rb b/chef/lib/chef/knife/ssh.rb
index 3fe6d9376e..73508759b3 100644
--- a/chef/lib/chef/knife/ssh.rb
+++ b/chef/lib/chef/knife/ssh.rb
@@ -182,6 +182,7 @@ class Chef
end
def ssh_command(command, subsession=nil)
+ exit_status = 0
subsession ||= session
command = fixup_sudo(command)
subsession.open_channel do |ch|
@@ -194,9 +195,13 @@ class Chef
ichannel.send_data("#{get_password}\n")
end
end
+ ch.on_request "exit-status" do |ichannel, data|
+ exit_status = data.read_long
+ end
end
end
session.loop
+ exit_status
end
def get_password
@@ -378,6 +383,7 @@ class Chef
configure_identity_file
configure_session
+ exit_status =
case @name_args[1]
when "interactive"
interactive
@@ -398,6 +404,7 @@ class Chef
end
session.close
+ exit_status
end
end