Module: VagrantPlugins::GuestMSYS2::Cap::ChooseAddressableIPAddr

Defined in:
lib/vagrant-guest-msys2/cap/choose_addressable_ip_addr.rb

Class Method Summary collapse

Class Method Details

.choose_addressable_ip_addr(machine, possible) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/vagrant-guest-msys2/cap/choose_addressable_ip_addr.rb', line 5

def self.choose_addressable_ip_addr(machine, possible)
  machine.communicate.tap do |comm|
    possible.each do |ip|
      command = "ping -n 1 -w 1 #{ip}"
      if comm.test(command)
        return ip
      end
    end
  end

  nil
end