mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
narrowed down exception we ignore and fail if any other unexpected one
crops up. Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
This commit is contained in:
parent
efaaaa6c79
commit
b7b1c714f9
1 changed files with 18 additions and 19 deletions
|
@ -626,28 +626,27 @@ class LinuxHardware(Hardware):
|
|||
if line.startswith('/'):
|
||||
fields = line.rstrip('\n').split()
|
||||
if(fields[2] != 'none'):
|
||||
size_total = None
|
||||
size_available = None
|
||||
try:
|
||||
statvfs_result = os.statvfs(fields[1])
|
||||
self.facts['mounts'].append(
|
||||
{'mount': fields[1],
|
||||
'device':fields[0],
|
||||
'fstype': fields[2],
|
||||
'options': fields[3],
|
||||
# statvfs data
|
||||
'size_total': statvfs_result.f_bsize * statvfs_result.f_blocks,
|
||||
'size_available': statvfs_result.f_bsize * (statvfs_result.f_bavail),
|
||||
})
|
||||
size_total = statvfs_result.f_bsize * statvfs_result.f_blocks
|
||||
size_available = statvfs_result.f_bsize * (statvfs_result.f_bavail)
|
||||
except OSError, e:
|
||||
# don't have access to stat so we'll set to None
|
||||
self.facts['mounts'].append(
|
||||
{'mount': fields[1],
|
||||
'device':fields[0],
|
||||
'fstype': fields[2],
|
||||
'options': fields[3],
|
||||
# statvfs data
|
||||
'size_total': None,
|
||||
'size_available': None,
|
||||
})
|
||||
if e.errno == errno.ENOENT:
|
||||
pass
|
||||
else:
|
||||
self.fail_json(msg=e.strerror)
|
||||
|
||||
self.facts['mounts'].append(
|
||||
{'mount': fields[1],
|
||||
'device':fields[0],
|
||||
'fstype': fields[2],
|
||||
'options': fields[3],
|
||||
# statvfs data
|
||||
'size_total': size_total,
|
||||
'size_available': size_available,
|
||||
})
|
||||
|
||||
def get_device_facts(self):
|
||||
self.facts['devices'] = {}
|
||||
|
|
Loading…
Reference in a new issue