From ed976d285caab1858f0b6e74e14a723113d27052 Mon Sep 17 00:00:00 2001
From: Bob Fournier <bfournie@redhat.com>
Date: Wed, 23 Aug 2017 17:15:34 -0400
Subject: [PATCH] Handle failure of carrier check in configure_safe_defaults()

Configure_safe_defaults() should handle carrier check failures
in the same way as the change that was made to
dhcp-all-interfaces.sh in https://review.openstack.org/#/c/419527/.
That is, it should ignore failures when cat'ing the carrier file.

Change-Id: I100a40835d0ccecee9b4851aae6366c6ab4813a5
Closes-Bug: 1712687
---
 network/scripts/run-os-net-config.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/network/scripts/run-os-net-config.sh b/network/scripts/run-os-net-config.sh
index 864da24b71..d121fcf138 100755
--- a/network/scripts/run-os-net-config.sh
+++ b/network/scripts/run-os-net-config.sh
@@ -75,12 +75,13 @@ EOF_CAT
         if [ "$mac_addr_type" != "0" ]; then
             echo "Device has generated MAC, skipping."
         else
-            ip link set dev $iface up &>/dev/null
-            HAS_LINK="$(cat /sys/class/net/${iface}/carrier)"
+            HAS_LINK="$(cat /sys/class/net/${iface}/carrier || echo 0)"
 
             TRIES=10
             while [ "$HAS_LINK" == "0" -a $TRIES -gt 0 ]; do
-                HAS_LINK="$(cat /sys/class/net/${iface}/carrier)"
+                # Need to set the link up on each iteration
+                ip link set dev $iface up &>/dev/null
+                HAS_LINK="$(cat /sys/class/net/${iface}/carrier || echo 0)"
                 if [ "$HAS_LINK" == "1" ]; then
                     break
                 else