Skip to content

Commit

Permalink
Adding -w flag to ssh
Browse files Browse the repository at this point in the history
Using helper method for waiting for active state before SSH-ing.
  • Loading branch information
petems committed Nov 22, 2015
1 parent 5a237b1 commit a1dd98c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/tugboat/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def images
:type => :string,
:aliases => [ "-c", "-y" ,],
:desc => "Command to run on the droplet"
method_option "wait",
:type => :boolean,
:aliases => '-w',
:desc => 'Wait for droplet to become active before trying to SSH'
def ssh(name=nil)
Middleware.sequence_ssh_droplet.call({
"tugboat_action" => __method__,
Expand All @@ -138,7 +142,8 @@ def ssh(name=nil)
"user_droplet_use_private_ip" => options[:use_private_ip],
"user_droplet_ssh_opts" => options[:ssh_opts],
"user_droplet_ssh_command" => options[:ssh_command],
"user_quiet" => options[:quiet]
"user_droplet_ssh_wait" => options[:wait],
"user_quiet" => options[:quiet],
})
end

Expand Down
5 changes: 5 additions & 0 deletions lib/tugboat/middleware/ssh_droplet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def call(env)

host_string = "#{ssh_user}@#{host_ip}"

if env['user_droplet_ssh_wait']
"Wait flag given, waiting for droplet to become active"
wait_for_state(env["droplet_id"],'active',env['barge'])
end

say "Attempting SSH: #{host_string}"

options << host_string
Expand Down

0 comments on commit a1dd98c

Please sign in to comment.