summaryrefslogtreecommitdiff
path: root/cloudinit/netinfo.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2014-02-26 13:14:55 -0500
committerScott Moser <smoser@ubuntu.com>2014-02-26 13:14:55 -0500
commit5acc36948efd4d1dc3d6d33bf2fb67ac4ac80ef6 (patch)
treeeb36b0e4b8e2943fc6374b98d09fe95190b8b54f /cloudinit/netinfo.py
parent6c5a804e0c0dd815edd8d1422612e5fad9a5180e (diff)
downloadvyos-cloud-init-5acc36948efd4d1dc3d6d33bf2fb67ac4ac80ef6.tar.gz
vyos-cloud-init-5acc36948efd4d1dc3d6d33bf2fb67ac4ac80ef6.zip
netinfo.py: fix regression causing ubuntu to show 'addr:v.x.y.z'
after freebsd merge, ubuntu shows addr:v.x.y.z instead of v.x.y.z for the ipv4 address. This should fix that by just skipping the 'inet' (or inet6) token if the next token starts with 'addr:'. LP: #1285185
Diffstat (limited to 'cloudinit/netinfo.py')
-rw-r--r--cloudinit/netinfo.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/cloudinit/netinfo.py b/cloudinit/netinfo.py
index ac3c011f..30b6f3b3 100644
--- a/cloudinit/netinfo.py
+++ b/cloudinit/netinfo.py
@@ -52,18 +52,23 @@ def netdev_info(empty=""):
fieldpost = "6"
for i in range(len(toks)):
- if toks[i] == "hwaddr" or toks[i] == "ether":
- try:
- devs[curdev]["hwaddr"] = toks[i + 1]
- except IndexError:
- pass
+ # older net-tools (ubuntu) show 'inet addr:xx.yy',
+ # newer (freebsd and fedora) show 'inet xx.yy'
+ # just skip this 'inet' entry. (LP: #1285185)
+ try:
+ if (toks[i] in ("inet", "inet6") and
+ toks[i + 1].startswith("addr:")):
+ continue
+ except IndexError:
+ pass
# Couple the different items we're interested in with the correct
# field since FreeBSD/CentOS/Fedora differ in the output.
ifconfigfields = {
"addr:": "addr", "inet": "addr",
"bcast:": "bcast", "broadcast": "bcast",
- "mask:": "mask", "netmask": "mask"
+ "mask:": "mask", "netmask": "mask",
+ "hwaddr": "hwaddr", "ether": "hwaddr",
}
for origfield, field in ifconfigfields.items():
target = "%s%s" % (field, fieldpost)