Merge pull request #8572 from chrisroberts/fix/nmcli-disconnect

Always disconnect interface when controlled by NetworkManager
This commit is contained in:
Chris Roberts 2017-05-08 19:40:04 -07:00 committed by GitHub
commit bf04b97ff3
1 changed files with 2 additions and 4 deletions

View File

@ -64,9 +64,7 @@ module VagrantPlugins
final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}" final_path = "#{network_scripts_dir}/ifcfg-#{network[:device]}"
if nm_controlled if nm_controlled
if extra_opts[:nm_controlled] == "no" commands[:start] << "nmcli d disconnect iface '#{network[:device]}'"
commands[:start] << "nmcli d disconnect iface '#{network[:device]}'"
end
else else
commands[:start] << "/sbin/ifdown '#{network[:device]}'" commands[:start] << "/sbin/ifdown '#{network[:device]}'"
end end
@ -78,7 +76,7 @@ module VagrantPlugins
if nmcli_installed if nmcli_installed
commands[:middle] << "((nmcli c help 2>&1 | grep reload) && nmcli c reload) || " \ commands[:middle] << "((nmcli c help 2>&1 | grep reload) && nmcli c reload) || " \
"(test -f /etc/init.d/NetworkManager && /etc/init.d/NetworkManager restart) || " \ "(test -f /etc/init.d/NetworkManager && /etc/init.d/NetworkManager restart) || " \
"((systemctl | grep NetworkManager.service) && systemctl NetworkManager restart)" "((systemctl | grep NetworkManager.service) && systemctl restart NetworkManager)"
end end
commands = commands[:start] + commands[:middle] + commands[:end] commands = commands[:start] + commands[:middle] + commands[:end]
comm.sudo(commands.join("\n")) comm.sudo(commands.join("\n"))