Merge pull request #833 from hugoboos/domain-name

Add network domain name feature
This commit is contained in:
Gerben Meijer 2017-11-28 10:51:38 +01:00 committed by GitHub
commit 57db358a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View File

@ -490,6 +490,13 @@ An examples of network interface definitions:
:libvirt__network_address => '10.20.30.0'
end
# Private network (as above) using a domain name
config.vm.define :test_vm1 do |test_vm1|
test_vm1.vm.network :private_network,
:ip => "10.20.30.40",
:libvirt__domain_name => "test.local"
end
# Private network. Point to Point between 2 Guest OS using a TCP tunnel
# Guest 1
config.vm.define :test_vm1 do |test_vm1|
@ -561,6 +568,8 @@ starts with `libvirt__` string. Here is a list of those options:
* `:libvirt__network_address` - Used only when `:type` is set to `dhcp`. Only `/24` subnet is supported. Default is `172.28.128.0`.
* `:libvirt__host_ip` - Address to use for the host (not guest). Default is
first possible address (after network address).
* `:libvirt__domain_name` - DNS domain of the DHCP server. Used only
when creating new network.
* `:libvirt__dhcp_enabled` - If DHCP will offer addresses, or not. Used only
when creating new network. Default is true.
* `:libvirt__dhcp_start` - First address given out via DHCP. Default is third

View File

@ -56,6 +56,7 @@ module VagrantPlugins
netmask: @options[:netmask],
network_address: nil,
bridge_name: nil,
domain_name: nil,
ipv6_address: options[:ipv6_address] || nil,
ipv6_prefix: options[:ipv6_prefix] || nil,
created: false,
@ -121,6 +122,7 @@ module VagrantPlugins
def handle_ip_option(env)
return unless @options[:ip]
net_address = nil
unless @options[:forward_mode] == 'veryisolated'
net_address = network_address(@options[:ip], @options[:netmask])
@ -317,6 +319,8 @@ module VagrantPlugins
@network_dhcp_enabled = false
end
@network_domain_name = @options[:domain_name]
begin
@interface_network[:libvirt_network] = \
@libvirt_client.define_network_xml(to_xml('private_network'))

View File

@ -2,6 +2,10 @@
<name><%= @network_name %></name>
<bridge name="<%= @network_bridge_name %>" />
<% if @network_domain_name %>
<domain name="<%= @network_domain_name %>" localOnly="yes" />
<% end %>
<% if (@network_forward_mode != 'none' && @network_forward_mode != 'veryisolated') %>
<% if @network_forward_device %>
<forward mode="<%= @network_forward_mode %>" dev="<%= @network_forward_device %>" />

View File

@ -112,6 +112,9 @@ module VagrantPlugins
false
end
domain_name = xml.at_xpath('/network/domain/@name')
domain_name = domain_name.value if domain_name
# Calculate network address of network from ip address and
# netmask.
network_address = (network_address(ip, netmask) if ip && netmask)
@ -123,6 +126,7 @@ module VagrantPlugins
network_address: network_address,
dhcp_enabled: dhcp_enabled,
bridge_name: libvirt_network.bridge_name,
domain_name: domain_name,
created: true,
active: libvirt_network.active?,
autostart: libvirt_network.autostart?,