Merge pull request #3529 from bcoca/setup_stat_exception

now won't throw exception if we don't have permission to stat a mtab
pull/3534/head
Michael DeHaan 11 years ago
commit b6c4ec0713

@ -626,16 +626,28 @@ class LinuxHardware(Hardware):
if line.startswith('/'): if line.startswith('/'):
fields = line.rstrip('\n').split() fields = line.rstrip('\n').split()
if(fields[2] != 'none'): if(fields[2] != 'none'):
statvfs_result = os.statvfs(fields[1]) try:
self.facts['mounts'].append( statvfs_result = os.statvfs(fields[1])
{'mount': fields[1], self.facts['mounts'].append(
'device':fields[0], {'mount': fields[1],
'fstype': fields[2], 'device':fields[0],
'options': fields[3], 'fstype': fields[2],
# statvfs data 'options': fields[3],
'size_total': statvfs_result.f_bsize * statvfs_result.f_blocks, # statvfs data
'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,
})
def get_device_facts(self): def get_device_facts(self):
self.facts['devices'] = {} self.facts['devices'] = {}

Loading…
Cancel
Save