[DRE-commits] [vagrant-libvirt] 37/77: Add support for bridge interface type

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:36 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.17
in repository vagrant-libvirt.

commit 8eece013eb2e663907c8aff73cc7e7b016ce672a
Author: Maximilian Fischer <mafi at inagile.org>
Date:   Wed Mar 12 12:48:56 2014 +0000

    Add support for bridge interface type
    
    - Example for configuration inside Vagrantfile:
      test_vm1.vm.network :public_network, :dev => "br0", :mode => 'bridge',
        :type => "bridge", :model_type => "e1000"
---
 lib/vagrant-libvirt/action/create_network_interfaces.rb | 10 ++++++++--
 lib/vagrant-libvirt/templates/public_interface.xml.erb  |  8 +++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb
index 86adc19..bedafb1 100644
--- a/lib/vagrant-libvirt/action/create_network_interfaces.rb
+++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -70,9 +70,11 @@ module VagrantPlugins
 
             # Configuration for public interfaces which use the macvtap driver
             if iface_configuration[:iface_type] == :public_network
-              template_name = 'public_interface'
               @device = iface_configuration.fetch(:dev, 'eth0')
+              @type = iface_configuration.fetch(:type, 'direct')
               @mode = iface_configuration.fetch(:mode, 'bridge')
+              @model_type = iface_configuration.fetch(:model_type, 'e1000')
+              template_name = 'public_interface'
               @logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
             end
 
@@ -147,6 +149,10 @@ 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
+
           if options[:ip]
             address = network_address(options[:ip], options[:netmask])
             available_networks.each do |network|
@@ -157,7 +163,7 @@ module VagrantPlugins
             end
           end
 
-          raise NetworkNotAvailableError, network_name: options[:ip]
+          raise Errors::NetworkNotAvailableError, network_name: options[:ip]
         end
       end
     end
diff --git a/lib/vagrant-libvirt/templates/public_interface.xml.erb b/lib/vagrant-libvirt/templates/public_interface.xml.erb
index d4a7fbf..30232f6 100644
--- a/lib/vagrant-libvirt/templates/public_interface.xml.erb
+++ b/lib/vagrant-libvirt/templates/public_interface.xml.erb
@@ -1,7 +1,13 @@
-<interface type='direct'>
+<interface type='<%= @type %>'>
 	<% if @mac %>
   	<mac address='<%= @mac %>'/>
   <% end %>
+  <%if @type == 'direct'%>
   <source dev='<%= @device %>' mode='<%= @mode %>'/>
+  <% else %>
+  <source bridge='<%=@device%>'/>
+  <model type='<%=@model_type%>'/>
+  <% end %>
 </interface>
 
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list