From ce75b9a02e99e15c0c59903caca94d4aa03523f4 Mon Sep 17 00:00:00 2001 From: Erik van Pienbroek Date: Wed, 1 Apr 2015 14:49:35 +0200 Subject: [PATCH] Allow the situation where DHCP is not requested but where it is enabled on the virtual network --- README.md | 6 ++++++ lib/vagrant-libvirt/action/create_networks.rb | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a26b4c8..cbe643b 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,12 @@ starts with 'libvirt__' string. Here is a list of those options: * `:mac` - MAC address for the interface. * `model_type` - parameter specifies the model of the network adapter when you create a domain value by default virtio KVM believe possible values, see the documentation for libvirt +When the option `:libvirt__dhcp_enabled` is to to 'false' it shouldn't matter +whether the virtual network contains a DHCP server or not and vagrant-libvirt +should not fail on it. The only situation where vagrant-libvirt should fail +is when DHCP is requested but isn't configured on a matching already existing +virtual network. + ### Public Network Options * `:dev` - Physical device that the public interface should use. Default is 'eth0'. * `:mode` - The mode in which the public interface should operate in. Supported diff --git a/lib/vagrant-libvirt/action/create_networks.rb b/lib/vagrant-libvirt/action/create_networks.rb index 298b5c4..7ef4643 100644 --- a/lib/vagrant-libvirt/action/create_networks.rb +++ b/lib/vagrant-libvirt/action/create_networks.rb @@ -100,8 +100,10 @@ module VagrantPlugins # match what was configured in the vagrantfile # since we always enable dhcp for the management network # this ensures we wont start a vm vagrant cant reach + # Allow the situation where DHCP is not requested (:libvirt__dhcp_enabled == false) + # but where it is enabled on the virtual network def verify_dhcp - unless @options[:dhcp_enabled] == @interface_network[:dhcp_enabled] + if @interface_network[:dhcp_enabled] == true && @options[:dhcp_enabled] == false raise Errors::DHCPMismatch, network_name: @interface_network[:name], requested: @options[:dhcp_enabled] ? 'enabled' : 'disabled'