Merge pull request #642 from borisroman/add/portgroup_public

Add libvirt portgroup support.
This commit is contained in:
Dmitry Vasilets 2016-08-18 22:14:31 +02:00 committed by GitHub
commit 9e9811de8a
3 changed files with 8 additions and 0 deletions

View File

@ -431,6 +431,8 @@ virtual network.
Default mode is 'bridge'.
* `:type` - is type of interface.(`<interface type="#{@type}">`)
* `:mac` - MAC address for the interface.
* `:network_name` - Name of libvirt network to connect to.
* `:portgroup` - Name of libvirt portgroup to connect to.
* `:ovs` - Support to connect to an open vSwitch bridge device. Default is 'false'.
### Management Network

View File

@ -77,6 +77,8 @@ module VagrantPlugins
@mode = iface_configuration.fetch(:mode, 'bridge')
@type = iface_configuration.fetch(:type, 'direct')
@model_type = iface_configuration.fetch(:model_type, @nic_model_type)
@portgroup = iface_configuration.fetch(:portgroup, nil)
@network_name = iface_configuration.fetch(:network_name, @network_name)
template_name = 'public_interface'
@logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
@ovs = iface_configuration.fetch(:ovs, false)
@ -125,6 +127,8 @@ module VagrantPlugins
if iface_configuration[:iface_type] == :public_network
if @type == 'direct'
@mac = xml.xpath("/domain/devices/interface[source[@dev='#{@device}']]/mac/@address")
elsif !@portgroup.nil?
@mac = xml.xpath("/domain/devices/interface[source[@network='#{@network_name}']]/mac/@address")
else
@mac = xml.xpath("/domain/devices/interface[source[@bridge='#{@device}']]/mac/@address")
end

View File

@ -4,6 +4,8 @@
<% end %>
<%if @type == 'direct'%>
<source dev='<%= @device %>' mode='<%= @mode %>'/>
<% elsif !@portgroup.nil? %>
<source network='<%=@network_name%>' portgroup='<%=@portgroup%>'/>
<% else %>
<source bridge='<%=@device%>'/>
<% end %>