From 1d150173814235285d94820d9f18a79907f9da43 Mon Sep 17 00:00:00 2001 From: dima Date: Thu, 9 Apr 2015 07:50:28 +0200 Subject: [PATCH] add information and correct example for bridge. close #330 --- README.md | 6 +++++- .../action/create_network_interfaces.rb | 10 ++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ece0283..1a4f807 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,10 @@ An examples of network interface definitions: # Public Network config.vm.define :test_vm1 do |test_vm1| - test_vm1.vm.network :public_network, :dev => "eth0", :mode => 'bridge' + test_vm1.vm.network :public_network, + :dev => "virbr0", + :mode => "bridge", + :type => "bridge" end ``` @@ -264,6 +267,7 @@ virtual network. * `:mode` - The mode in which the public interface should operate in. Supported modes are available from the [libvirt documentation](http://www.libvirt.org/formatdomain.html#elementsNICSDirect). Default mode is 'bridge'. +* `:type` - is type of interface.(``) * `:mac` - MAC address for the interface. * `:ovs` - Support to connect to an open vSwitch bridge device. Default is 'false'. diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb index 8c05cc1..35886ad 100644 --- a/lib/vagrant-libvirt/action/create_network_interfaces.rb +++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb @@ -17,8 +17,8 @@ module VagrantPlugins def initialize(app, env) @logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces') @management_network_name = env[:machine].provider_config.management_network_name - config = env[:machine].provider_config - @nic_model_type = config.nic_model_type + config = env[:machine].provider_config + @nic_model_type = config.nic_model_type @app = app end @@ -74,8 +74,8 @@ module VagrantPlugins # Configuration for public interfaces which use the macvtap driver if iface_configuration[:iface_type] == :public_network @device = iface_configuration.fetch(:dev, 'eth0') - @type = iface_configuration.fetch(:type, 'direct') @mode = iface_configuration.fetch(:mode, 'bridge') + @type = iface_configuration.fetch(:type, 'direct') @model_type = iface_configuration.fetch(:model_type, @nic_model_type) template_name = 'public_interface' @logger.info("Setting up public interface using device #{@device} in mode #{@mode}") @@ -156,9 +156,7 @@ module VagrantPlugins # Get list of all (active and inactive) libvirt networks. available_networks = libvirt_networks(libvirt_client) - if options[:iface_type] == :public_network - return 'public' - end + return 'public' if options[:iface_type] == :public_network if options[:ip] address = network_address(options[:ip], options[:netmask])