From b7b1c714f90b61d6d3519c34f00970d9358890aa Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Sat, 20 Jul 2013 11:51:52 -0400 Subject: [PATCH] narrowed down exception we ignore and fail if any other unexpected one crops up. Signed-off-by: Brian Coca --- library/system/setup | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/library/system/setup b/library/system/setup index 4fae1485f08..5b78aae02e8 100644 --- a/library/system/setup +++ b/library/system/setup @@ -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'] = {}