Do not rely on IPAddr#prefix as it's not available on older rubies

This commit is contained in:
Chris Roberts 2019-03-22 16:42:30 -07:00
parent 8ba69e587c
commit 0575fdfd69
1 changed files with 2 additions and 2 deletions

View File

@ -43,8 +43,8 @@ module VagrantPlugins
if network[:type].to_s == "dhcp"
network_content = "DHCP=yes"
else
cidr = IPAddr.new("255.255.255.255").mask(network[:netmask])
address = "#{network[:ip]}/#{cidr.prefix}"
prefix = IPAddr.new("255.255.255.255/#{network[:netmask]}").to_i.to_s(2).count("1")
address = "#{network[:ip]}/#{prefix}"
network_content = "Address=#{address}"
end
{"name" => unit_name,