Respect Vagrantfile options to disable forwarded port

Closes GH-149
This commit is contained in:
Fabio Rehm 2013-11-06 21:01:19 -02:00
parent 6b5db24a6b
commit bf6e4b5c89
3 changed files with 11 additions and 0 deletions

View file

@ -3,6 +3,7 @@
IMPROVEMENTS: IMPROVEMENTS:
- Warn users about unsupported private / public networking configs [#154](https://github.com/fgrehm/vagrant-lxc/issues/154) - Warn users about unsupported private / public networking configs [#154](https://github.com/fgrehm/vagrant-lxc/issues/154)
- Respect Vagrantfile options to disable forwarded port [#149](https://github.com/fgrehm/vagrant-lxc/issues/149)
BUG FIXES: BUG FIXES:

View file

@ -63,6 +63,9 @@ module Vagrant
mappings = {} mappings = {}
config.vm.networks.each do |type, options| config.vm.networks.each do |type, options|
next if options[:disabled]
# TODO: Deprecate this behavior of "automagically" skipping ssh forwarded ports
if type == :forwarded_port && options[:id] != 'ssh' if type == :forwarded_port && options[:id] != 'ssh'
options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty? options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty?
mappings[options[:host]] = options mappings[options[:host]] = options

View file

@ -63,6 +63,13 @@ describe Vagrant::LXC::Action::ForwardPorts do
pid_file.should == pid pid_file.should == pid
end end
it 'allows disabling a previously forwarded port' do
forward_conf[:disabled] = true
subject.stub(system: true)
subject.call(env)
subject.should_not have_received(:spawn)
end
it 'raises RedirNotInstalled error if `redir` is not installed' do it 'raises RedirNotInstalled error if `redir` is not installed' do
subject.stub(system: false) subject.stub(system: false)
lambda { subject.call(env) }.should raise_error(Vagrant::LXC::Errors::RedirNotInstalled) lambda { subject.call(env) }.should raise_error(Vagrant::LXC::Errors::RedirNotInstalled)