Merge pull request #3602 from bcoca/fine_tune_stat_exception

narrowed down exception
reviewable/pr18780/r1
Michael DeHaan 11 years ago
commit 4281f773bb

@ -626,27 +626,26 @@ 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
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': None,
'size_available': None,
'size_total': size_total,
'size_available': size_available,
})
def get_device_facts(self):

Loading…
Cancel
Save