parent
3e7488f613
commit
9a168950fe
4 changed files with 17 additions and 9 deletions
|
@ -6,8 +6,15 @@ module Vagrant
|
|||
# @return [Array]
|
||||
attr_reader :start_opts
|
||||
|
||||
# The ip set for the built in LXC dhcp server (defaults to configured ip
|
||||
# at /etc/default/lxc or 10.0.3.1)
|
||||
#
|
||||
# @return [String]
|
||||
attr_accessor :lxc_dhcp_ip
|
||||
|
||||
def initialize
|
||||
@start_opts = []
|
||||
@start_opts = []
|
||||
@lxc_dhcp_ip = '10.0.3.1'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,7 +115,7 @@ module Vagrant
|
|||
end
|
||||
end
|
||||
|
||||
def dhcp_ip
|
||||
def dhcp_ip(server_ip)
|
||||
ip = ''
|
||||
# Right after creation lxc reports the container as running
|
||||
# before DNS is returning the right IP, so have to wait for a while
|
||||
|
@ -123,7 +123,7 @@ module Vagrant
|
|||
# By default LXC supplies a dns server on 10.0.3.1 so we request the IP
|
||||
# of our target from there.
|
||||
# Tks to: https://github.com/neerolyte/vagueant/blob/master/bin/vagueant#L340
|
||||
r = (raw 'dig', @name, '@10.0.3.1', '+short')
|
||||
r = (raw 'dig', @name, "@#{server_ip}", '+short')
|
||||
|
||||
# If the command was a failure then raise an exception that is nicely
|
||||
# handled by Vagrant.
|
||||
|
@ -131,7 +131,7 @@ module Vagrant
|
|||
if @interrupted
|
||||
@logger.info("Exit code != 0, but interrupted. Ignoring.")
|
||||
else
|
||||
raise LXC::Errors::ExecuteError, :command => command.inspect
|
||||
raise LXC::Errors::ExecuteError, :command => ['dig', @name, "@#{server_ip}", '+short'].inspect
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ module Vagrant
|
|||
return nil if state == :not_created
|
||||
|
||||
{
|
||||
:host => @container.dhcp_ip,
|
||||
:host => @container.dhcp_ip(@machine.provider_config.lxc_dhcp_ip),
|
||||
:port => 22 # @driver.ssh_port(@machine.config.ssh.guest_port)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -181,8 +181,9 @@ describe Vagrant::LXC::Container do
|
|||
end
|
||||
|
||||
describe 'dhcp ip' do
|
||||
let(:name) { 'random-container-name' }
|
||||
let(:ip) { "10.0.3.123" }
|
||||
let(:name) { 'random-container-name' }
|
||||
let(:ip) { "10.0.4.123" }
|
||||
let(:server_ip) { "10.0.4.1" }
|
||||
|
||||
before do
|
||||
subject.stub(:raw) {
|
||||
|
@ -191,8 +192,8 @@ describe Vagrant::LXC::Container do
|
|||
end
|
||||
|
||||
it 'digs the container ip from lxc dns server' do
|
||||
subject.dhcp_ip.should == ip
|
||||
subject.should have_received(:raw).with('dig', name, '@10.0.3.1', '+short')
|
||||
subject.dhcp_ip(server_ip).should == ip
|
||||
subject.should have_received(:raw).with('dig', name, "@#{server_ip}", '+short')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue