guests/darwin: Allow ipv6 static networks

This commit is contained in:
Seth Vargo 2016-06-19 11:48:11 -04:00
parent 22c24d619c
commit 177b7784dd
No known key found for this signature in database
GPG Key ID: 905A90C2949E8787
3 changed files with 18 additions and 5 deletions

View File

@ -448,6 +448,10 @@ module Vagrant
error_key(:not_found, "vagrant.actions.vm.host_only_network") error_key(:not_found, "vagrant.actions.vm.host_only_network")
end end
class NetworkTypeNotSupported < VagrantError
error_key(:network_type_not_supported)
end
class NFSBadExports < VagrantError class NFSBadExports < VagrantError
error_key(:nfs_bad_exports) error_key(:nfs_bad_exports)
end end

View File

@ -35,12 +35,19 @@ module VagrantPlugins
end end
network_type = network[:type].to_sym network_type = network[:type].to_sym
if network_type == :static case network_type.to_sym
command = "networksetup -setmanual \"#{service_name}\" #{network[:ip]} #{network[:netmask]}" when :static
elsif network_type == :dhcp command = "networksetup -setmanual \"#{service_name}\" #{network[:ip]} #{network[:netmask]} #{network[:router]}"
when :static6
command = "networksetup -setv6manual \"#{service_name}\" #{network[:ip]} #{network[:netmask]} #{network[:router]}"
when :dhcp
command = "networksetup -setdhcp \"#{service_name}\"" command = "networksetup -setdhcp \"#{service_name}\""
when :dhcp6
# This is not actually possible yet in Vagrant, but when we do
# enable IPv6 across the board, Darwin will already have support.
command = "networksetup -setv6automatic \"#{service_name}\""
else else
raise "#{network_type} network type is not supported, try static or dhcp" raise Vagrant::Errors::NetworkTypeNotSupported, type: network_type
end end
machine.communicate.sudo(command) machine.communicate.sudo(command)
@ -65,7 +72,7 @@ module VagrantPlugins
ints = ::IO.read(tmp_ints) ints = ::IO.read(tmp_ints)
ints.split(/\n\n/m).each do |i| ints.split(/\n\n/m).each do |i|
if i.match(/Hardware/) && i.match(/Ethernet/) if i.match(/Hardware/) && i.match(/Ethernet/)
# Ethernet, should be 2 lines, # Ethernet, should be 2 lines,
# (3) Thunderbolt Ethernet # (3) Thunderbolt Ethernet
# (Hardware Port: Thunderbolt Ethernet, Device: en1) # (Hardware Port: Thunderbolt Ethernet, Device: en1)

View File

@ -869,6 +869,8 @@ en:
If the problem persists, please report a bug to the net-ssh project. If the problem persists, please report a bug to the net-ssh project.
%{message} %{message}
network_type_not_supported: |-
The %{type} network type is not supported for this box or guest.
nfs_bad_exports: |- nfs_bad_exports: |-
NFS is reporting that your exports file is invalid. Vagrant does NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct this check before making any changes to the file. Please correct