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