Class: VagrantAWS::Action::PopulateSSH
- Inherits:
-
Object
- Object
- VagrantAWS::Action::PopulateSSH
- Defined in:
- lib/vagrant-aws/action/populate_ssh.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ PopulateSSH
constructor
A new instance of PopulateSSH.
- #local_key_path(name) ⇒ Object
Constructor Details
#initialize(app, env) ⇒ PopulateSSH
Returns a new instance of PopulateSSH.
4 5 6 |
# File 'lib/vagrant-aws/action/populate_ssh.rb', line 4 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vagrant-aws/action/populate_ssh.rb', line 8 def call(env) @env = env if @env["config"].aws.private_key_path.nil? # See if we are using a key vagrant aws generated @env["config"].aws.private_key_path = local_key_path(env["vm"].vm.key_name) if env["vm"].vm.key_name =~ /^vagrantaws_[0-9a-f]{12}/ end raise VagrantAWS::Errors::PrivateKeyFileNotSpecified if env["config"].aws.private_key_path.nil? || !File.exists?(env["config"].aws.private_key_path) env["config"].ssh.host = env["vm"].vm.dns_name env["config"].ssh.username = env["config"].aws.username env["config"].ssh.private_key_path = env["config"].aws.private_key_path env["config"].ssh.port = 22 # Make sure we can connect begin env["vm"].vm.wait_for { env["vm"].ssh.up? } rescue Fog::Errors::Error raise Vagrant::Errors::SSHConnectionRefused end @app.call(env) end |
#local_key_path(name) ⇒ Object
33 34 35 |
# File 'lib/vagrant-aws/action/populate_ssh.rb', line 33 def local_key_path(name) @env.env.ssh_keys_path.join(name) end |