--- /usr/lib/python3/dist-packages/cloudinit/netinfo.py 2021-01-15 12:33:05.000000000 -0500 +++ netinfo.py 2022-08-23 14:58:06.000000000 -0400 @@ -195,6 +195,38 @@ return devs +def _netdev_info_inetutils_ifconfig(ifconfig_data): + # fields that need to be returned in devs for each dev + devs = {} + for line in ifconfig_data.splitlines(): + if len(line) == 0: + continue + if line[0] not in ("\t", " "): + curdev = line.split()[0] + # current ifconfig pops a ':' on the end of the device + if curdev.endswith(":"): + curdev = curdev[:-1] + if curdev not in devs: + devs[curdev] = deepcopy(DEFAULT_NETDEV_INFO) + toks = line.lower().strip().split() + + for i in range(len(toks)): + if i == 0 and toks[i] == "inet" and toks[i+1] == "address": # Create new ipv4 addr entry + devs[curdev]["ipv4"].append( + {"ip": toks[i + 2]} + ) + elif i == 0 and toks[i] == "broadcast": + devs[curdev]["ipv4"][-1]["bcast"] = toks[i + 1] + elif i == 0 and toks[i] == "netmask": + devs[curdev]["ipv4"][-1]["mask"] = toks[i + 1] + elif i == 0 and toks[i] == "hardware" and toks[i+1] == "addr": + devs[curdev]["hwaddr"] = toks[i + 2] + elif i == 0 and toks[i] == "flags" and toks[i+1] == "up": + devs[curdev]["up"] = True + + return devs + + def netdev_info(empty=""): devs = {} if util.is_NetBSD(): @@ -208,6 +240,10 @@ # Fall back to net-tools if iproute2 is not present (ifcfg_out, _err) = subp.subp(["ifconfig", "-a"], rcs=[0, 1]) devs = _netdev_info_ifconfig(ifcfg_out) + elif subp.which('inetutils-ifconfig'): + # Fall back to net-tools if iproute2 is not present + (ifcfg_out, _err) = subp.subp(["inetutils-ifconfig", "-a"], rcs=[0, 1]) + devs = _netdev_info_inetutils_ifconfig(ifcfg_out) else: LOG.warning( "Could not print networks: missing 'ip' and 'ifconfig' commands")