Permalink
Browse files

Merge branch 'master' of https://github.com/wbailey/claws

Conflicts:
	lib/claws/command/ec2.rb
  • Loading branch information...
2 parents cf31fa8 + a49e1a7 commit 3941a841aba4e2965a6ff02c4773e400e766b8e9 @aaronfeng aaronfeng committed Jun 1, 2012
Showing with 18 additions and 7 deletions.
  1. +10 −2 lib/claws/command/ec2.rb
  2. +1 −0 lib/claws/command/initialize.rb
  3. +7 −5 spec/command/ec2_spec.rb
View
@@ -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
@@ -10,6 +10,7 @@ def self.exec
},
'ssh' => {
'user' => nil,
+ 'identity' => nil,
},
'aws' => {
'access_key_id' => nil,
View
@@ -102,7 +102,9 @@
OpenStruct.new(
{
:ssh => OpenStruct.new(
- { :user => 'test' }
+ { :user => 'test',
+ :identity => 'my_id'
+ }
),
:ec2 => OpenStruct.new(
:fields => {
@@ -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
@@ -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
@@ -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} )
@@ -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

0 comments on commit 3941a84

Please sign in to comment.