From c48a31d6bdd204c09d3a1997a3a22be97712f5e0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 31 Dec 2011 19:08:56 -0800 Subject: [PATCH] Fix template paths for other guests --- lib/vagrant/guest/arch.rb | 5 +++-- lib/vagrant/guest/freebsd.rb | 4 ++-- lib/vagrant/guest/gentoo.rb | 6 +++--- lib/vagrant/guest/redhat.rb | 6 +++--- templates/guests/arch/network_hostonly.erb | 7 +++++++ templates/guests/gentoo/network_hostonly.erb | 4 ++++ .../redhat/network_hostonly.erb} | 7 +++---- templates/network_entry_arch.erb | 9 --------- templates/network_entry_gentoo.erb | 5 ----- 9 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 templates/guests/arch/network_hostonly.erb create mode 100644 templates/guests/gentoo/network_hostonly.erb rename templates/{network_entry_redhat.erb => guests/redhat/network_hostonly.erb} (50%) delete mode 100644 templates/network_entry_arch.erb delete mode 100644 templates/network_entry_gentoo.erb diff --git a/lib/vagrant/guest/arch.rb b/lib/vagrant/guest/arch.rb index 962521e06..38ff8d25a 100644 --- a/lib/vagrant/guest/arch.rb +++ b/lib/vagrant/guest/arch.rb @@ -14,13 +14,14 @@ module Vagrant def prepare_host_only_network(net_options=nil) vm.ssh.execute do |ssh| - ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces") + ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces") ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/rc.conf'") end end def enable_host_only_network(net_options) - entry = TemplateRenderer.render('network_entry_arch', :net_options => net_options) + entry = TemplateRenderer.render('guests/arch/network_hostonly', + :net_options => net_options) vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| diff --git a/lib/vagrant/guest/freebsd.rb b/lib/vagrant/guest/freebsd.rb index 8f9c2d0ee..fa9104ba3 100644 --- a/lib/vagrant/guest/freebsd.rb +++ b/lib/vagrant/guest/freebsd.rb @@ -63,13 +63,13 @@ module Vagrant # interface file. vm.ssh.execute do |ssh| # Clear out any previous entries - ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/rc.conf") + ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/rc.conf") ssh.exec!("sudo mv /tmp/rc.conf /etc/rc.conf") end end def enable_host_only_network(net_options) - entry = "#VAGRANT-BEGIN\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END\n" + entry = "#VAGRANT-BEGIN-HOSTONLY\nifconfig_em#{net_options[:adapter]}=\"inet #{net_options[:ip]} netmask #{net_options[:netmask]}\"\n#VAGRANT-END-HOSTONLY\n" vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| diff --git a/lib/vagrant/guest/gentoo.rb b/lib/vagrant/guest/gentoo.rb index cf5590cc6..69d11bf89 100644 --- a/lib/vagrant/guest/gentoo.rb +++ b/lib/vagrant/guest/gentoo.rb @@ -5,14 +5,14 @@ module Vagrant # Remove any previous host only network additions to the # interface file. vm.ssh.execute do |ssh| - # Clear out any previous entries - ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces") + ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces") ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/conf.d/net'") end end def enable_host_only_network(net_options) - entry = TemplateRenderer.render('network_entry_gentoo', :net_options => net_options) + entry = TemplateRenderer.render('guests/gentoo/network_hostonly', + :net_options => net_options) vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| diff --git a/lib/vagrant/guest/redhat.rb b/lib/vagrant/guest/redhat.rb index 14a4557cb..49cfac2d0 100644 --- a/lib/vagrant/guest/redhat.rb +++ b/lib/vagrant/guest/redhat.rb @@ -7,14 +7,14 @@ module Vagrant vm.ssh.execute do |ssh| # Clear out any previous entries ssh.exec!("sudo touch #{network_scripts_dir}/ifcfg-eth#{net_options[:adapter]}") - ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}") + ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' #{network_scripts_dir}/ifcfg-eth#{net_options[:adapter]} > /tmp/vagrant-ifcfg-eth#{net_options[:adapter]}") ssh.exec!("sudo su -c 'cat /tmp/vagrant-ifcfg-eth#{net_options[:adapter]} > #{network_scripts_dir}/ifcfg-eth#{net_options[:adapter]}'") end end def enable_host_only_network(net_options) - entry = TemplateRenderer.render('network_entry_redhat', :net_options => net_options) - + entry = TemplateRenderer.render('guests/redhat/network_hostonly', + :net_options => net_options) vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry") vm.ssh.execute do |ssh| diff --git a/templates/guests/arch/network_hostonly.erb b/templates/guests/arch/network_hostonly.erb new file mode 100644 index 000000000..6208344fb --- /dev/null +++ b/templates/guests/arch/network_hostonly.erb @@ -0,0 +1,7 @@ +#VAGRANT-BEGIN-HOSTONLY +# The contents below are automatically generated by Vagrant. Do not modify. +interface=eth<%= net_options[:adapter] %> +address=<%= net_options[:ip]%> +netmask=<%= net_options[:netmask] %> +gateway= +#VAGRANT-END-HOSTONLY diff --git a/templates/guests/gentoo/network_hostonly.erb b/templates/guests/gentoo/network_hostonly.erb new file mode 100644 index 000000000..19ebaaf2e --- /dev/null +++ b/templates/guests/gentoo/network_hostonly.erb @@ -0,0 +1,4 @@ +#VAGRANT-BEGIN-HOSTONLY +# The contents below are automatically generated by Vagrant. Do not modify. +config_eth<%= net_options[:adapter] %>=("<%= net_options[:ip] %> netmask <%= net_options[:netmask] %>") +#VAGRANT-END-HOSTONLY diff --git a/templates/network_entry_redhat.erb b/templates/guests/redhat/network_hostonly.erb similarity index 50% rename from templates/network_entry_redhat.erb rename to templates/guests/redhat/network_hostonly.erb index 497d9519a..1ca1a8c98 100644 --- a/templates/network_entry_redhat.erb +++ b/templates/guests/redhat/network_hostonly.erb @@ -1,9 +1,8 @@ -#VAGRANT-BEGIN -# The contents below are automatically generated by Vagrant. -# Please do not modify any of these contents. +#VAGRANT-BEGIN-HOSTONLY +# The contents below are automatically generated by Vagrant. Do not modify. BOOTPROTO=static DHCPCLASS= IPADDR=<%= net_options[:ip] %> NETMASK=<%= net_options[:netmask] %> DEVICE=eth<%= net_options[:adapter] %> -#VAGRANT-END \ No newline at end of file +#VAGRANT-END-HOSTONLY diff --git a/templates/network_entry_arch.erb b/templates/network_entry_arch.erb deleted file mode 100644 index b40211749..000000000 --- a/templates/network_entry_arch.erb +++ /dev/null @@ -1,9 +0,0 @@ - -#VAGRANT-BEGIN -# The contents below are automatically generated by Vagrant. -# Please do not modify any of these contents. -interface=eth<%= net_options[:adapter] %> -address=<%= net_options[:ip]%> -netmask=<%= net_options[:netmask] %> -gateway= -#VAGRANT-END diff --git a/templates/network_entry_gentoo.erb b/templates/network_entry_gentoo.erb deleted file mode 100644 index d5bbdfcd1..000000000 --- a/templates/network_entry_gentoo.erb +++ /dev/null @@ -1,5 +0,0 @@ -#VAGRANT-BEGIN -# The contents below are automatically generated by Vagrant. -# Please do not modify any of these contents. -config_eth<%= net_options[:adapter] %>=("<%= net_options[:ip] %> netmask <%= net_options[:netmask] %>") -#VAGRANT-END