aboutsummaryrefslogtreecommitdiff
path: root/netinfo.py.patch
diff options
context:
space:
mode:
authorPasha <pasha@member.fsf.org>2022-08-24 21:00:50 +0000
committerPasha <pasha@member.fsf.org>2022-08-24 21:00:50 +0000
commit62b5f3aad043d50f29db7a7dc53b1d9eb7393c8e (patch)
tree059786de090373bc4044553486fae77fcd227103 /netinfo.py.patch
downloadhurd_openstack-62b5f3aad043d50f29db7a7dc53b1d9eb7393c8e.tar.gz
hurd_openstack-62b5f3aad043d50f29db7a7dc53b1d9eb7393c8e.tar.bz2
initial commit
Diffstat (limited to 'netinfo.py.patch')
-rw-r--r--netinfo.py.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/netinfo.py.patch b/netinfo.py.patch
new file mode 100644
index 0000000..37dc90d
--- /dev/null
+++ b/netinfo.py.patch
@@ -0,0 +1,52 @@
+--- /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")