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