Class: VagrantPlugins::VMM::Action::WaitForIPAddress
- Inherits:
-
Object
- Object
- VagrantPlugins::VMM::Action::WaitForIPAddress
- Defined in:
- lib/vagrant-vmm/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.
8 9 10 11 |
# File 'lib/vagrant-vmm/action/wait_for_ip_address.rb', line 8 def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant::VMM::wait_for_ip_addr") end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vagrant-vmm/action/wait_for_ip_address.rb', line 13 def call(env) timeout = env[:machine].provider_config.ip_address_timeout env[:ui].output("Waiting for the machine to report its IP address(might take some time, have a patience)...") env[:ui].detail("Timeout: #{timeout} seconds") vmm_server_address = env[:machine].provider_config.vmm_server_address # generate options = { vmm_server_address: vmm_server_address, proxy_server_address: env[:machine].provider_config.proxy_server_address, timeout: timeout } guest_adr = nil Timeout.timeout(timeout) do while true # If a ctrl-c came through, break out return if env[:interrupted] # Try to get the IP network_info = env[:machine].provider.driver.read_guest_ip() guest_adr = network_info["address"] if guest_adr begin IPAddr.new(guest_adr) break rescue IPAddr::InvalidAddressError # Ignore, continue looking. @logger.warn("Invalid IP address returned: #{guest_adr}") end end sleep 1 end end # If we were interrupted then return now return if env[:interrupted] env[:ui].detail("VM Address: #{guest_adr}") env[:machine].provider_config.vm_address = guest_adr env[:machine].config.winrm.host = guest_adr @app.call(env) rescue Timeout::Error raise Errors::IPAddrTimeout end |