Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wbailey/claws
Browse files Browse the repository at this point in the history
Conflicts:
	lib/claws/command/ec2.rb
  • Loading branch information
aaronfeng committed Jun 1, 2012
2 parents cf31fa8 + a49e1a7 commit 3941a84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 10 additions & 2 deletions lib/claws/command/ec2.rb
Expand Up @@ -33,13 +33,21 @@ def self.exec(options)

puts 'connecting to server...'

identity = config.ssh.identity.nil? ? '' : "-i #{config.ssh.identity}"
current_instance = instances[selection.to_i]
ssh_opts = {:identity => identity, :ssh_user => config.ssh.user}

if instances[selection.to_i].vpc?
system "ssh #{config.ssh.user}@#{instances[selection.to_i].private_ip_address}"
ssh(ssh_opts.merge(:host => current_instance.private_ip_address))
else
system "ssh #{config.ssh.user}@#{instances[selection.to_i].dns_name}"
ssh(ssh_opts.merge(:host => current_instance.dns_name))
end
end
end

def self.ssh(opts={})
system "ssh #{opts[:identity]} #{opts[:ssh_user]}@#{opts[:host]}"
end
end
end
end
1 change: 1 addition & 0 deletions lib/claws/command/initialize.rb
Expand Up @@ -10,6 +10,7 @@ def self.exec
},
'ssh' => {
'user' => nil,
'identity' => nil,
},
'aws' => {
'access_key_id' => nil,
Expand Down
12 changes: 7 additions & 5 deletions spec/command/ec2_spec.rb
Expand Up @@ -102,7 +102,9 @@
OpenStruct.new(
{
:ssh => OpenStruct.new(
{ :user => 'test' }
{ :user => 'test',
:identity => 'my_id'
}
),
:ec2 => OpenStruct.new(
:fields => {
Expand Down Expand Up @@ -130,7 +132,7 @@
)

subject.should_receive(:puts).twice
subject.should_receive(:system).with('ssh test@secret.com').and_return(0)
subject.should_receive(:system).with('ssh -i my_id test@secret.com').and_return(0)

capture_stdout {
subject.exec options
Expand All @@ -152,7 +154,7 @@
)

subject.should_receive(:puts).twice
subject.should_receive(:system).with('ssh test@test.com').and_return(0)
subject.should_receive(:system).with('ssh -i my_id test@test.com').and_return(0)

capture_stdout {
subject.exec options
Expand All @@ -175,7 +177,7 @@
)

subject.should_receive(:puts).twice
subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)

capture_stdout {
subject.exec OpenStruct.new( {:selection => 1, :config_file => nil, :connect => true} )
Expand All @@ -190,7 +192,7 @@

subject.should_receive(:gets).and_return('1\n')
subject.should_receive(:puts).once
subject.should_receive(:system).with('ssh test@test2.com').and_return(0)
subject.should_receive(:system).with('ssh -i my_id test@test2.com').and_return(0)

capture_stdout {
subject.exec options
Expand Down

0 comments on commit 3941a84

Please sign in to comment.