Merge pull request #75 from cloudbees/master

Reverting wait_for_ssh command
This commit is contained in:
R. Tyler Croy 2013-03-29 17:35:05 -07:00
commit bf307f6df8
5 changed files with 25 additions and 37 deletions

View File

@ -13,8 +13,7 @@ Feature: SCP a file into a named VM
end
"""
And I have a file named "hello.txt"
When I run `blimpy wait_for_ssh`
And I run `blimpy scp Gherkins hello.txt`
When I run `blimpy scp Gherkins hello.txt`
Then the exit status should be 1
And the output should contain:
"""
@ -35,6 +34,5 @@ Feature: SCP a file into a named VM
"""
And I have a file named "hello.txt"
And I run `blimpy start`
When I run `blimpy wait_for_ssh`
And I run `blimpy scp "Cucumber Host" hello.txt`
When I run `blimpy scp "Cucumber Host" hello.txt`
Then the exit status should be 0

View File

@ -12,8 +12,7 @@ Feature: SSH into a named VM
end
end
"""
When I run `blimpy wait_for_ssh`
And I run `blimpy ssh Gherkins`
When I run `blimpy ssh Gherkins`
Then the exit status should be 1
And the output should contain:
"""

View File

@ -34,7 +34,6 @@ end
When /^I ssh into the machine$/ do
step %{I run `blimpy start`}
step %{I run `blimpy wait_for_ssh`}
step %{I run `blimpy ssh "Cucumber Host" -o StrictHostKeyChecking=no` interactively}
end

View File

@ -197,11 +197,15 @@ module Blimpy
end
end
def ssh_commands(*args)
['ssh', '-o', 'PasswordAuthentication=no',
'-o', 'StrictHostKeyChecking=no',
'-p', (ssh_port||22).to_s,
'-l', username, dns, *args]
end
def ssh_into(*args)
run_command('ssh', '-o', 'PasswordAuthentication=no',
'-o', 'StrictHostKeyChecking=no',
'-p', ssh_port||22.to_s,
'-l', username, dns, *args)
run_command(*ssh_commands(*args))
end
def scp_file(filename, directory='', *args)
@ -240,10 +244,20 @@ module Blimpy
until @ssh_connected
# Run the `true` command and exit
@ssh_connected = ssh_into('-q', 'true')
# if SSH is killed (such as Ctrl+C), abort right away
raise Exception, "ssh was killed: #{$?.exitstatus}" if $?.exitstatus>128 && $?.exitstatus<200
# if SSH is killed, don't repeat
if $?.signaled?
if $?.termsig==2
# if Ctrl+C, report what we were doing
puts "Failed to connect. To try it yourself:\n#{ssh_commands('-v','true').join(' ')}"
end
raise Exception, "ssh was killed: #{$?}"
end
unless @ssh_connected
if !need_nl
p = ssh_port.nil? ? "" : ":#{ssh_port}"
print ">> Connecting #{username}@#{name}#{p}"
end
if (Time.now.to_i - start) < 60
print '.'
need_nl = true

View File

@ -143,31 +143,8 @@ end
end
end
box.ssh_into *args
end
desc 'wait_for_ssh', 'Wait for SSHD to come online'
def wait_for_ssh(name=nil, *args)
unless name.nil?
box = box_by_name(name)
if box.nil?
puts "Could not find a blimp named \"#{name}\""
exit 1
end
else
blimps = current_blimps
unless blimps
puts "No Blimps running!"
exit 1
end
blimps.each do |blimp, data|
next unless data[:name]
box = box_by_name(data[:name])
end
end
box.wait_for_sshd
box.ssh_into *args
end
desc 'scp BLIMP_NAME FILE_NAME', 'Securely copy FILE_NAME into the blimp'
@ -178,6 +155,7 @@ end
puts "Could not find a blimp named \"#{name}\""
exit 1
end
box.wait_for_sshd
# Pass any extra commands along to the `scp` invocation
box.scp_file(filename, '', *ARGV[3..-1])
end