Merge pull request #6659 from swiftstack/change_ipv6_adapter_address

Use <prefix>::1 as the IPv6 adapter IP.
This commit is contained in:
Mitchell Hashimoto 2015-12-14 15:37:28 -08:00
commit d47c7c74d7
2 changed files with 30 additions and 2 deletions

View File

@ -290,8 +290,8 @@ module VagrantPlugins
# Default subnet prefix length
options[:netmask] ||= 64
# IPv6 we just mask the address and use that as the adapter
options[:adapter_ip] ||= ip.mask(options[:netmask].to_i).to_s
# Set adapter IP to <prefix>::1
options[:adapter_ip] ||= (ip.mask(options[:netmask].to_i) | 1).to_s
# Append a 6 to the end of the type
options[:type] = "#{options[:type]}6".to_sym

View File

@ -42,6 +42,34 @@ describe VagrantPlugins::ProviderVirtualBox::Action::Network do
expect(called).to eq(true)
end
it "creates a host-only interface with an IPv6 address <prefix>:1" do
guest = double("guest")
machine.config.vm.network 'private_network', { type: :static, ip: 'dead:beef::100' }
#allow(driver).to receive(:read_bridged_interfaces) { [] }
allow(driver).to receive(:read_host_only_interfaces) { [] }
#allow(driver).to receive(:read_dhcp_servers) { [] }
allow(machine).to receive(:guest) { guest }
allow(driver).to receive(:create_host_only_network) {{ name: 'vboxnet0' }}
allow(guest).to receive(:capability)
interface_ip = 'dead:beef::1'
subject.call(env)
expect(driver).to have_received(:create_host_only_network).with({
adapter_ip: interface_ip,
netmask: 64,
})
expect(guest).to have_received(:capability).with(:configure_networks, [{
type: :static6,
adapter_ip: 'dead:beef::1',
ip: 'dead:beef::100',
netmask: 64,
auto_config: true,
interface: nil
}])
end
context "with a dhcp private network" do
let(:bridgedifs) { [] }
let(:hostonlyifs) { [] }