Make sure the machine is accessible when checking for the dhcp ip

This commit is contained in:
Fabio Rehm 2013-03-02 23:20:52 -03:00
parent 8507d07862
commit 7b68802dd2
2 changed files with 11 additions and 0 deletions

View file

@ -121,6 +121,14 @@ module Vagrant
if ip.empty?
raise LXC::Errors::ExecuteError, 'Unable to identify container ip'
end
# Sometimes lxc reports the container as running before DNS is returning
# the right IP, so have to try a couple of times sometimes.
# Tks to https://github.com/neerolyte/vagueant/blob/master/bin/vagueant#L318-L330
r = raw "ping -c 1 #{ip} > /dev/null 2>&1"
if r.exit_code != 0
raise LXC::Errors::ExecuteError, 'Unable to reach container'
end
end
ip
end

View file

@ -5,6 +5,9 @@ module UnitExampleGroup
Object.any_instance.stub(:system) { |*args, &block|
UnitExampleGroup.prevent_system_calls(*args, &block)
}
Object.any_instance.stub(:`) { |*args, &block|
UnitExampleGroup.prevent_system_calls(*args, &block)
}
require 'vagrant/util/subprocess'
Vagrant::Util::Subprocess.stub(:execute) { |*args, &block|
UnitExampleGroup.prevent_system_calls(*args, &block)