Add support for getting hardware facts on GNU Hurd (#18152)

* Fallback to /proc/mounts if /etc/mtab do not exist

On modern system, the file is just a compatibility symlink, and
some system (like GNU Hurd) do not have it, but provides /proc/mounts

* Add support for uptime, memory and mount facts on GNU Hurd
pull/18172/head
Michael Scherer 8 years ago committed by Brian Coca
parent 2708ef99b8
commit f4593ecac7

@ -1281,7 +1281,11 @@ class LinuxHardware(Hardware):
return bind_mounts
def _mtab_entries(self):
mtab = get_file_content('/etc/mtab', '')
mtab_file = '/etc/mtab'
if not os.path.exists(mtab_file):
mtab_file = '/proc/mounts'
mtab = get_file_content(mtab_file, '')
mtab_entries = []
for line in mtab.splitlines():
fields = line.split()
@ -2159,6 +2163,20 @@ class Darwin(Hardware):
if rc == 0:
self.facts['memfree_mb'] = int(out.splitlines()[-1].split()[1]) // 1024 // 1024
class HurdHardware(LinuxHardware):
"""
GNU Hurd specific subclass of Hardware. Define memory and mount facts
based on procfs compatibility translator mimicking the interface of
the Linux kernel.
"""
platform = 'GNU'
def populate(self):
self.get_uptime_facts()
self.get_memory_facts()
self.get_mount_facts()
return self.facts
class Network(Facts):
"""

Loading…
Cancel
Save