Ensure default public_network :dev shown on error (#1670)

During validation ensure that the default value for public network
devices is selected and shown on error if it's not one of the host
devices that are currently discovered.
This commit is contained in:
Darragh Bailey
2022-11-10 18:49:46 +00:00
committed by GitHub
parent 980db1049a
commit df41f6f037

View File

@@ -1214,8 +1214,9 @@ module VagrantPlugins
# only interested in public networks where portgroup is nil, as then source will be a host device # only interested in public networks where portgroup is nil, as then source will be a host device
if type == :public_network && opts[:portgroup] == nil if type == :public_network && opts[:portgroup] == nil
devices = host_devices(machine) devices = host_devices(machine)
if !devices.include?(opts[:dev]) hostdev = opts.fetch(:dev, 'eth0')
errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{opts[:dev]}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}" if !devices.include?(hostdev)
errors << "network configuration #{index} for machine #{machine.name} is a public_network referencing host device '#{hostdev}' which does not exist, consider adding ':dev => ....' referencing one of #{devices.join(", ")}"
end end
end end
end end