summaryrefslogtreecommitdiff
path: root/cloudinit/netinfo.py
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2019-02-08 22:08:47 +0000
committerServer Team CI Bot <josh.powers+server-team-bot@canonical.com>2019-02-08 22:08:47 +0000
commitfff37e7dc6849fd16db504b0d338fae20a7beb39 (patch)
tree5407e3901f3206071a101defce2d8d24e85cc7c0 /cloudinit/netinfo.py
parentcf30836645473c62599e838ab48b2d31677fa584 (diff)
downloadcloud-init-git-fff37e7dc6849fd16db504b0d338fae20a7beb39.tar.gz
netinfo: Adjust ifconfig output parsing for FreeBSD ipv6 entries
FreeBSD ifconfig output for ipv6 addrs doesn't find scopeid values when present in the output and the pformat rendering assumes that an ipv6 address will have a 'scope6' entry in the netdev info dictionary. This patch finds the scopeid value, which is not always inside <>, and in some cases v6 addrs don't have a scopeid value in the output, so when rendering the table, allow scope6 value to be replaced with the empty value. LP: #1779672
Diffstat (limited to 'cloudinit/netinfo.py')
-rw-r--r--cloudinit/netinfo.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/cloudinit/netinfo.py b/cloudinit/netinfo.py
index 9ff929c2..e91cd263 100644
--- a/cloudinit/netinfo.py
+++ b/cloudinit/netinfo.py
@@ -141,6 +141,9 @@ def _netdev_info_ifconfig(ifconfig_data):
res = re.match(r'.*<(\S+)>', toks[i + 1])
if res:
devs[curdev]['ipv6'][-1]['scope6'] = res.group(1)
+ else:
+ devs[curdev]['ipv6'][-1]['scope6'] = toks[i + 1]
+
return devs
@@ -389,8 +392,8 @@ def netdev_pformat():
addr.get('scope', empty), data["hwaddr"]))
for addr in data.get('ipv6'):
tbl.add_row(
- (dev, data["up"], addr["ip"], empty, addr["scope6"],
- data["hwaddr"]))
+ (dev, data["up"], addr["ip"], empty,
+ addr.get("scope6", empty), data["hwaddr"]))
if len(data.get('ipv6')) + len(data.get('ipv4')) == 0:
tbl.add_row((dev, data["up"], empty, empty, empty,
data["hwaddr"]))