Class: VagrantPlugins::Sakura::Action::ReadSSHInfo
- Inherits:
-
Object
- Object
- VagrantPlugins::Sakura::Action::ReadSSHInfo
- Defined in:
- lib/vagrant-sakura/action/read_ssh_info.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ ReadSSHInfo
constructor
A new instance of ReadSSHInfo.
Constructor Details
#initialize(app, env) ⇒ ReadSSHInfo
Returns a new instance of ReadSSHInfo.
7 8 9 10 |
# File 'lib/vagrant-sakura/action/read_ssh_info.rb', line 7 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_sakura::action::read_ssh_info") end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/vagrant-sakura/action/read_ssh_info.rb', line 12 def call(env) api = env[:sakura_api] serverid = env[:machine].id if serverid.nil? env[:machine_ssh_info] = nil else begin response = api.get("/server/#{serverid}") env[:machine_ssh_info] = { :host => response["Server"]["Interfaces"][0]["IPAddress"], :port => 22 } rescue Driver::NotFoundError @logger.info("Machine couldn't be found, assuming it has been destroyed.") env[:machine].id = nil env[:machine_ssh_info] = nil end end @app.call(env) end |