Class: VagrantPlugins::Filoo::Action::ReadSSHInfo
- Inherits:
-
Object
- Object
- VagrantPlugins::Filoo::Action::ReadSSHInfo
- Defined in:
- lib/vagrant_filoo/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.
9 10 11 12 13 |
# File 'lib/vagrant_filoo/action/read_ssh_info.rb', line 9 def initialize(app, env) @app = app @baseUrl =env[:machine].provider_config.filoo_api_entry_point() @apiKey = env[:machine].provider_config.filoo_api_key() end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/vagrant_filoo/action/read_ssh_info.rb', line 14 def call(env) vmid = vmid = env[:machine].id serverStatus = VagrantPlugins::Filoo::CloudCompute::getServerStatus(vmid, @baseUrl, @apiKey) if serverStatus["network_settings"].nil? raise VagrantPlugins::Filoo::Errors::UnexpectedStateError, resource: VagrantPlugins::Filoo::CloudCompute::SERVERSTATUS_RESOURCE, state: serverStatus, message: "Unexpected State of server status " + serverList.to_json, description: "Server with vmid #{vmid} should have server status with field network_settings present" end if serverStatus["network_settings"].length < 1 or serverStatus["network_settings"][0]["ipadress"].nil? raise VagrantPlugins::Filoo::Errors::UnexpectedStateError, resource: VagrantPlugins::Filoo::CloudCompute::SERVERSTATUS_RESOURCE, state: serverStatus, description: "Server with vmid #{vmid} should have server status with subfield field ipadress network_settings present" end env[:machine_ssh_info] = { :host => serverStatus["network_settings"][0]["ipadress"], :port => 22 , :username => "root" } @app.call(env) end |