Skip to content

Commit

Permalink
ifdown ethN before munging ifcfg-ethN (i.e. removing previous vagrant…
Browse files Browse the repository at this point in the history
… config for network interface)
  • Loading branch information
onejli committed Nov 2, 2013
1 parent a92e03c commit 1ad756d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/guests/redhat/cap/configure_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def self.configure_networks(machine, networks)
networks.each do |network|
interfaces.add(network[:interface])

# Down the interface before munging the config file
retryable(:on => Vagrant::Errors::VagrantError, :tries => 3, :sleep => 2) do
machine.communicate.sudo("/sbin/ifdown eth#{network[:interface]} 2> /dev/null")
end

# Remove any previous vagrant configuration in this network interface's
# configuration files.
machine.communicate.sudo("touch #{network_scripts_dir}/ifcfg-eth#{network[:interface]}")
Expand All @@ -46,7 +51,8 @@ def self.configure_networks(machine, networks)
# SSH never dies.
interfaces.each do |interface|
retryable(:on => Vagrant::Errors::VagrantError, :tries => 3, :sleep => 2) do
machine.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false)
# The interface should already be down
machine.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}")
machine.communicate.sudo("ARPCHECK=no /sbin/ifup eth#{interface} 2> /dev/null")
end
Expand Down

0 comments on commit 1ad756d

Please sign in to comment.