diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-02-26 13:14:55 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-02-26 13:14:55 -0500 |
commit | 5acc36948efd4d1dc3d6d33bf2fb67ac4ac80ef6 (patch) | |
tree | eb36b0e4b8e2943fc6374b98d09fe95190b8b54f | |
parent | 6c5a804e0c0dd815edd8d1422612e5fad9a5180e (diff) | |
download | vyos-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
-rw-r--r-- | cloudinit/netinfo.py | 17 |
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) |