mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
2708ef99b8
commit
f4593ecac7
1 changed files with 19 additions and 1 deletions
|
@ -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…
Reference in a new issue