From c1c39beaabf29c32cd8ecaede6c9fd10cd9b1188 Mon Sep 17 00:00:00 2001 From: linyows Date: Wed, 13 May 2015 18:07:32 +0900 Subject: [PATCH 1/2] restart NetworkManager and network for CentOS 7.1 --- plugins/guests/redhat/cap/configure_networks.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb index f176cca3d..81575b6ad 100644 --- a/plugins/guests/redhat/cap/configure_networks.rb +++ b/plugins/guests/redhat/cap/configure_networks.rb @@ -26,6 +26,9 @@ module VagrantPlugins require File.expand_path("../../../fedora/cap/configure_networks", __FILE__) ::VagrantPlugins::GuestFedora::Cap::ConfigureNetworks. configure_networks(machine, networks) + + machine.communicate.sudo("systemctl restart NetworkManager") + machine.communicate.sudo("systemctl restart network") end def self.configure_networks_default(machine, networks) From 421fab17a2d7e7f9ef2f2bb1813ed46453b0ae13 Mon Sep 17 00:00:00 2001 From: linyows Date: Thu, 14 May 2015 12:53:23 +0900 Subject: [PATCH 2/2] reload connection instead of restart --- plugins/guests/fedora/cap/configure_networks.rb | 1 + plugins/guests/redhat/cap/configure_networks.rb | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/guests/fedora/cap/configure_networks.rb b/plugins/guests/fedora/cap/configure_networks.rb index 2f67099cd..67669c58b 100644 --- a/plugins/guests/fedora/cap/configure_networks.rb +++ b/plugins/guests/fedora/cap/configure_networks.rb @@ -85,6 +85,7 @@ module VagrantPlugins interfaces.each do |interface| retryable(on: Vagrant::Errors::VagrantError, tries: 3, sleep: 2) do machine.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-#{interface}") + machine.communicate.sudo("which nmcli >/dev/null 2>&1 && nmcli c reload #{interface}") machine.communicate.sudo("/sbin/ifdown #{interface}", error_check: true) machine.communicate.sudo("/sbin/ifup #{interface}") end diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb index 81575b6ad..f176cca3d 100644 --- a/plugins/guests/redhat/cap/configure_networks.rb +++ b/plugins/guests/redhat/cap/configure_networks.rb @@ -26,9 +26,6 @@ module VagrantPlugins require File.expand_path("../../../fedora/cap/configure_networks", __FILE__) ::VagrantPlugins::GuestFedora::Cap::ConfigureNetworks. configure_networks(machine, networks) - - machine.communicate.sudo("systemctl restart NetworkManager") - machine.communicate.sudo("systemctl restart network") end def self.configure_networks_default(machine, networks)