From 67f3c8b48cc51c2489d0d9258b778be7355804c2 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 25 Oct 2016 07:45:38 -0700 Subject: [PATCH] guests/redhat: Force NetworkManager to reload device configurations When configuring network devices force NetworkManager to reload new configuration files as they appear. This prevents NetworkManager from attempting to continue managing devices on initial start up. --- plugins/guests/redhat/cap/configure_networks.rb | 8 +++----- .../plugins/guests/redhat/cap/configure_networks_test.rb | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/guests/redhat/cap/configure_networks.rb b/plugins/guests/redhat/cap/configure_networks.rb index 04b49ab92..6749f1bdc 100644 --- a/plugins/guests/redhat/cap/configure_networks.rb +++ b/plugins/guests/redhat/cap/configure_networks.rb @@ -40,13 +40,11 @@ module VagrantPlugins # Down the interface before munging the config file. This might # fail if the interface is not actually set up yet so ignore # errors. - /sbin/ifdown '#{network[:device]}' || true - + /sbin/ifdown '#{network[:device]}' # Move new config into place mv -f '#{remote_path}' '#{final_path}' - - # Bring the interface up - ARPCHECK=no /sbin/ifup '#{network[:device]}' + # attempt to force network manager to reload configurations + nmcli c reload || true EOH end diff --git a/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb b/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb index 1da032e88..926713298 100644 --- a/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +++ b/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb @@ -56,9 +56,10 @@ describe "VagrantPlugins::GuestRedHat::Cap::ConfigureNetworks" do cap.configure_networks(machine, [network_1, network_2]) expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth1'/) - expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth1'/) + expect(comm.received_commands[0]).to match(/ifcfg-eth1/) expect(comm.received_commands[0]).to match(/\/sbin\/ifdown 'eth2'/) - expect(comm.received_commands[0]).to match(/\/sbin\/ifup 'eth2'/) + expect(comm.received_commands[0]).to match(/ifcfg-eth2/) + expect(comm.received_commands[0]).to match(/nmcli c reload/) end end end