From 78d4d0a7902b6eb20b4353bb2b158f00e6d36a8a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 8 Apr 2013 11:02:03 -0700 Subject: [PATCH] Networks come back up properly after reboot on RedHat [GH-921] --- CHANGELOG.md | 1 + plugins/guests/redhat/cap/configure_networks.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe040f5a9..d5763c201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,7 @@ BUG FIXES: since they can be quite large and were messing with tmpfs. [GH-1442] - Fix issue parsing extra SSH args in `vagrant ssh` in multi-machine environments. [GH-1545] + - Networks come back up properly on RedHat systems after reboot. [GH-921] ## 1.1.6 (April 3, 2013) diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb index 8a4ed4abc..227fecfa6 100644 --- a/plugins/guests/redhat/cap/configure_networks.rb +++ b/plugins/guests/redhat/cap/configure_networks.rb @@ -1,12 +1,14 @@ require "set" require "tempfile" +require "vagrant/util/retryable" require "vagrant/util/template_renderer" module VagrantPlugins module GuestRedHat module Cap class ConfigureNetworks + extend Vagrant::Util::Retryable include Vagrant::Util def self.configure_networks(machine, networks) @@ -43,10 +45,13 @@ module VagrantPlugins # each specifically, we avoid reconfiguring eth0 (the NAT interface) so # SSH never dies. interfaces.each do |interface| - machine.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false) - machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}") + retryable(:on => Vagrant::Errors::VagrantError, :tries => 3, :sleep => 2) do + machine.communicate.sudo("/sbin/ifdown eth#{interface} 2> /dev/null", :error_check => false) + machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-eth#{interface}") + machine.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null") + end + machine.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}") - machine.communicate.sudo("/sbin/ifup eth#{interface} 2> /dev/null") end end end