Class: VagrantPlugins::Haipa::Action::WaitForIpAddress
- Inherits:
-
Object
- Object
- VagrantPlugins::Haipa::Action::WaitForIpAddress
- Includes:
- Vagrant::Util::Retryable
- Defined in:
- lib/vagrant-haipa/action/wait_for_ip_address.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ WaitForIpAddress
constructor
A new instance of WaitForIpAddress.
Constructor Details
#initialize(app, env) ⇒ WaitForIpAddress
Returns a new instance of WaitForIpAddress.
7 8 9 10 11 |
# File 'lib/vagrant-haipa/action/wait_for_ip_address.rb', line 7 def initialize(app, env) @app = app @machine = env[:machine] @logger = Log4r::Logger.new('vagrant::haipa::wait_for_ip_address') end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vagrant-haipa/action/wait_for_ip_address.rb', line 13 def call(env) # get machine state from driver and output ip address retryable(:tries => 20, :sleep => 10) do next if env[:interrupted] haipa_machine = @machine.provider.driver.machine('Networks') addresses = haipa_machine.networks.map{|x| x.ip_v4addresses}.flatten addresses.reject! { |s| s.nil? || s.strip.empty? } address = addresses.first raise 'not ready' unless address env[:machine_ip] ||= address end @app.call(env) end |