From 96611341a96d7d19fdade5556a110b22c6add22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Faille?= Date: Wed, 21 Dec 2016 20:31:53 -0500 Subject: [PATCH] Revert "Fix `service network restart` on RHEL-7 / Fedora" `/etc/init.d/network restart` already restart NM and shutdown interfaces. In start() : ``` if [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]; then nmcli connection reload fi ``` In stop() : ``` for i in $vpninterfaces $xdslinterfaces $bridgeinterfaces $vlaninterfaces $remaining; do unset DEVICE TYPE (. ./ifcfg-$i if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi if ! check_device_down $DEVICE; then action $"Shutting down interface $i: " ./ifdown $i boot [ $? -ne 0 ] && rc=1 fi ) done ``` Where $remaining include all "others" interfaces including eth* This reverts commit 166d10d4e16836e908be0bd94c2f671cac2b38b4. --- plugins/guests/redhat/cap/change_host_name.rb | 8 ++------ plugins/guests/redhat/cap/configure_networks.rb | 12 ++++-------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/plugins/guests/redhat/cap/change_host_name.rb b/plugins/guests/redhat/cap/change_host_name.rb index e950c987b90..afe461d4f91 100644 --- a/plugins/guests/redhat/cap/change_host_name.rb +++ b/plugins/guests/redhat/cap/change_host_name.rb @@ -31,12 +31,8 @@ def self.change_host_name(machine, name) sed -i'' '1i 127.0.0.1\\t#{name}\\t#{basename}' /etc/hosts } - # Restart network (through NetworkManager if running) - if service NetworkManager status 2>&1 | grep -q running; then - service NetworkManager restart - else - service network restart - fi + # Restart network + service network restart EOH end end diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb index 39645796883..6749f1bdcdc 100644 --- a/plugins/guests/redhat/cap/configure_networks.rb +++ b/plugins/guests/redhat/cap/configure_networks.rb @@ -36,7 +36,7 @@ def self.configure_networks(machine, networks) # Add the new interface and bring it back up final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}" - commands << <<-EOH.gsub(/^ {14}/, '') + commands << <<-EOH.gsub(/^ */, '') # Down the interface before munging the config file. This might # fail if the interface is not actually set up yet so ignore # errors. @@ -48,13 +48,9 @@ def self.configure_networks(machine, networks) EOH end - commands << <<-EOH.gsub(/^ {12}/, '') - # Restart network (through NetworkManager if running) - if service NetworkManager status 2>&1 | grep -q running; then - service NetworkManager restart - else - service network restart - fi + commands << <<-EOH.gsub(/^ */, '') + # Restart network + service network restart EOH comm.sudo(commands.join("\n"))