summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarm Weites <harm@weites.com>2013-12-14 12:50:01 +0000
committerHarm Weites <harm@weites.com>2013-12-14 12:50:01 +0000
commitab2bf49eecede2fe0ce4f7685f751c64b20dd390 (patch)
treeae1c2eb9d550c9f9305a0a373d608b592841e7a8
parent53f1938a1c33b4d9e333101d1d614803373a6bc5 (diff)
downloadvyos-cloud-init-ab2bf49eecede2fe0ce4f7685f751c64b20dd390.tar.gz
vyos-cloud-init-ab2bf49eecede2fe0ce4f7685f751c64b20dd390.zip
fix: Fallback to check the interface state, specifically freebsd benefits
of this.
-rw-r--r--cloudinit/netinfo.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/cloudinit/netinfo.py b/cloudinit/netinfo.py
index f5949122..a9c3090e 100644
--- a/cloudinit/netinfo.py
+++ b/cloudinit/netinfo.py
@@ -21,6 +21,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import cloudinit.util as util
+import re
from prettytable import PrettyTable
@@ -34,13 +35,17 @@ def netdev_info(empty=""):
continue
if line[0] not in ("\t", " "):
curdev = line.split()[0]
- # TODO: up/down detection fails on FreeBSD
devs[curdev] = {"up": False}
for field in fields:
devs[curdev][field] = ""
toks = line.lower().strip().split()
if toks[0] == "up":
devs[curdev]['up'] = True
+ # If the output of ifconfig doesn't contain the required info in the
+ # obvious place, use a regex filter to be sure.
+ elif len(toks) > 1:
+ if re.search("flags=\d+<up,", toks[1]):
+ devs[curdev]['up'] = True
fieldpost = ""
if toks[0] == "inet6":