Josef Stribny c2d9327
From 29e60882ca87a006c29d0e3bb4f37746f75f8477 Mon Sep 17 00:00:00 2001
Josef Stribny c2d9327
From: =?UTF-8?q?Tadej=20Jane=C5=BE?= <tadej.j@nez.si>
Josef Stribny c2d9327
Date: Sun, 11 Oct 2015 23:09:10 +0200
Josef Stribny c2d9327
Subject: [PATCH] Fixes Fedora network issues when biosdevname command is not
Josef Stribny c2d9327
 present.
Josef Stribny c2d9327
Josef Stribny c2d9327
Previously, configuring and enabling network interfaces failed with:
Josef Stribny c2d9327
Josef Stribny c2d9327
"The following SSH command responded with a non-zero exit status.
Josef Stribny c2d9327
Vagrant assumes that this means the command failed!
Josef Stribny c2d9327
Josef Stribny c2d9327
/usr/sbin/biosdevname --policy=all_ethN -i bash: /usr/sbin/biosdevname:
Josef Stribny c2d9327
No such file or directory
Josef Stribny c2d9327
Josef Stribny c2d9327
Stdout from the command:
Josef Stribny c2d9327
Josef Stribny c2d9327
bash: /usr/sbin/biosdevname: No such file or directory"
Josef Stribny c2d9327
Josef Stribny c2d9327
The previous attempt to fix this (ccc4162) doesn't work since it doesn't
Josef Stribny c2d9327
properly parse the 'bash: /usr/sbin/biosdevname: No such file or
Josef Stribny c2d9327
directory' error message.
Josef Stribny c2d9327
Josef Stribny c2d9327
This patch works around that problem and adds a comment explaining the
Josef Stribny c2d9327
meaning of the return codes.
Josef Stribny c2d9327
---
Josef Stribny c2d9327
 plugins/guests/fedora/cap/configure_networks.rb | 5 ++++-
Josef Stribny c2d9327
 1 file changed, 4 insertions(+), 1 deletion(-)
Josef Stribny c2d9327
Josef Stribny c2d9327
diff --git a/plugins/guests/fedora/cap/configure_networks.rb b/plugins/guests/fedora/cap/configure_networks.rb
Josef Stribny c2d9327
index 963996e..364b744 100644
Josef Stribny c2d9327
--- a/plugins/guests/fedora/cap/configure_networks.rb
Josef Stribny c2d9327
+++ b/plugins/guests/fedora/cap/configure_networks.rb
Josef Stribny c2d9327
@@ -17,7 +17,10 @@ def self.configure_networks(machine, networks)
Josef Stribny c2d9327
           virtual = false
Josef Stribny c2d9327
           interface_names = Array.new
Josef Stribny c2d9327
           interface_names_by_slot = Array.new
Josef Stribny c2d9327
-          machine.communicate.sudo("/usr/sbin/biosdevname; echo $?") do |_, result|
Josef Stribny c2d9327
+          machine.communicate.sudo("/usr/sbin/biosdevname &>/dev/null; echo $?") do |_, result|
Josef Stribny c2d9327
+            # The above command returns:
Josef Stribny c2d9327
+            #   - '4' if /usr/sbin/biosdevname detects it is running in a virtual machine
Josef Stribny c2d9327
+            #   - '127' if /usr/sbin/biosdevname doesn't exist
Josef Stribny c2d9327
             virtual = true if ['4', '127'].include? result.chomp
Josef Stribny c2d9327
           end
Josef Stribny c2d9327
 
Josef Stribny c2d9327