procfs
procfs copied to clipboard
How to match /proc/net/bonding/bond* interfaces to bond class
Hey, I have added a bond class to proc/net/bonding/init.py but I would like to know how I can get /proc/net/bonding/bond0 to match. This is the code in proc/net/bonding/init.py
"""/proc/net/bonding handlers"""
from procfs.core import File, Dict
class bond(File):
"""/proc/net/bonding/bond*
"""
def __len__(self):
return len(self.read())
def _parse(self, content):
lines = content.splitlines()
count = 0
data = Dict()
for line in lines:
if line:
key, value = line.split(':', 1)
key = key.strip().replace(' ', '_').lower()
data[key] = value.strip()
return data
If I change the class name to bond0 everything works as expected for the bond0 interface, but we have up to 10 bonds per host. Once I understand how I can get /proc/net/bonding/bond* files to create the right class I can submit a pull request. Thanks.