aix_facts: statvfs works on AIX too so make use of it (#46759)

This commit is contained in:
Daniel Balko 2018-11-08 00:21:26 +01:00 committed by ansibot
parent 1e3b704ff1
commit 58ae93d273

View file

@ -19,6 +19,7 @@ __metaclass__ = type
import re
from ansible.module_utils.facts.hardware.base import Hardware, HardwareCollector
from ansible.module_utils.facts.utils import get_mount_size
class AIXHardware(Hardware):
@ -175,6 +176,9 @@ class AIXHardware(Hardware):
mount_facts = {}
mount_facts['mounts'] = []
mounts = []
# AIX does not have mtab but mount command is only source of info (or to use
# api calls to get same info)
mount_path = self.module.get_bin_path('mount')
@ -185,11 +189,13 @@ class AIXHardware(Hardware):
if len(fields) != 0 and fields[0] != 'node' and fields[0][0] != '-' and re.match('^/.*|^[a-zA-Z].*|^[0-9].*', fields[0]):
if re.match('^/', fields[0]):
# normal mount
mount_facts['mounts'].append({'mount': fields[1],
'device': fields[0],
'fstype': fields[2],
'options': fields[6],
'time': '%s %s %s' % (fields[3], fields[4], fields[5])})
mount = fields[1]
mount_info = {'mount': mount,
'device': fields[0],
'fstype': fields[2],
'options': fields[6],
'time': '%s %s %s' % (fields[3], fields[4], fields[5])}
mount_info.update(get_mount_size(mount))
else:
# nfs or cifs based mount
# in case of nfs if no mount options are provided on command line
@ -197,11 +203,16 @@ class AIXHardware(Hardware):
if len(fields) < 8:
fields.append("")
mount_facts['mounts'].append({'mount': fields[2],
'device': '%s:%s' % (fields[0], fields[1]),
'fstype': fields[3],
'options': fields[7],
'time': '%s %s %s' % (fields[4], fields[5], fields[6])})
mount_info = {'mount': fields[2],
'device': '%s:%s' % (fields[0], fields[1]),
'fstype': fields[3],
'options': fields[7],
'time': '%s %s %s' % (fields[4], fields[5], fields[6])}
mounts.append(mount_info)
mount_facts['mounts'] = mounts
return mount_facts
def get_device_facts(self):