add static route configuration for redhat guests

This commit is contained in:
thomasDOTwtf 2020-04-05 15:26:11 +02:00
parent d0d6d01e24
commit da010cddcf
2 changed files with 24 additions and 0 deletions

View file

@ -48,6 +48,23 @@ module VagrantPlugins
raise Vagrant::Errors::NetworkManagerNotInstalled, device: network[:device]
end
# Render static route file if present
if network.key?(:route) && network[:route] != nil
routeentry = TemplateRenderer.render("guests/redhat/network_route",
routes: network[:route],
)
route_remote_path = "/tmp/vagrant-network-route-entry-#{network[:device]}-#{Time.now.to_i}-#{i}"
Tempfile.open("vagrant-redhat-configure-networks-routes") do |f|
f.binmode
f.write(routeentry)
f.fsync
f.close
machine.communicate.upload(f.path, route_remote_path)
end
route_final_path = "#{network_scripts_dir}/route-#{network[:device]}"
commands[:middle] << "mv -f '#{route_remote_path}' '#{route_final_path}'"
end
# Render a new configuration
entry = TemplateRenderer.render("guests/redhat/network_#{network[:type]}",
options: extra_opts.merge(network),

View file

@ -0,0 +1,7 @@
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
# <%= routes.inspect %>
<% routes.split(';').each do |route| %>
<%= route %>
<% end %>
#VAGRANT-END