Skip to content

Commit

Permalink
Adjust vbox hostonly config for ipv6
Browse files Browse the repository at this point in the history
Check the type when an ipv6 address is being used. If the type does not
have a `6` suffix, append it.
  • Loading branch information
chrisroberts committed Sep 12, 2023
1 parent f414270 commit 6db640f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/providers/virtualbox/action/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def hostonly_config(options)
elsif ip.ipv6?
options[:netmask] ||= 64

# Append a 6 to the end of the type if it is not already set
options[:type] = "#{options[:type]}6".to_sym if
!options[:type].to_s.end_with?("6")
else
raise IPAddr::AddressFamilyError, 'unknown address family'
end
Expand Down
22 changes: 22 additions & 0 deletions test/unit/plugins/providers/virtualbox/action/network_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ def env=(e)
expect(subject).to receive(:validate_hostonly_ip!)
subject.hostonly_config(options)
end

context "when address is ipv6" do
let(:address) { "::1" }

context "when type is static6" do
let(:type) { :static6 }

it "should have a static6 type" do
result = subject.hostonly_config(options)
expect(result[:type]).to eq(:static6)
end
end

context "when type is static" do
let(:type) { :static }

it "should have static6 type" do
result = subject.hostonly_config(options)
expect(result[:type]).to eq(:static6)
end
end
end
end

describe "#validate_hostonly_ip!" do
Expand Down

0 comments on commit 6db640f

Please sign in to comment.