Merge pull request #14552 from kilburn/lsblk-dedup

Avoid duplicate /bin/lsblk calls in the setup module.
This commit is contained in:
Brian Coca 2016-02-20 12:24:22 -05:00
commit 81368d8119

View file

@ -1037,6 +1037,7 @@ class LinuxHardware(Hardware):
@timeout(10) @timeout(10)
def get_mount_facts(self): def get_mount_facts(self):
uuids = dict()
self.facts['mounts'] = [] self.facts['mounts'] = []
mtab = get_file_content('/etc/mtab', '') mtab = get_file_content('/etc/mtab', '')
for line in mtab.split('\n'): for line in mtab.split('\n'):
@ -1052,13 +1053,17 @@ class LinuxHardware(Hardware):
except OSError: except OSError:
continue continue
uuid = 'NA' if fields[0] in uuids:
lsblkPath = module.get_bin_path("lsblk") uuid = uuids[fields[0]]
if lsblkPath: else:
rc, out, err = module.run_command("%s -ln --output UUID %s" % (lsblkPath, fields[0]), use_unsafe_shell=True) uuid = 'NA'
lsblkPath = module.get_bin_path("lsblk")
if lsblkPath:
rc, out, err = module.run_command("%s -ln --output UUID %s" % (lsblkPath, fields[0]), use_unsafe_shell=True)
if rc == 0: if rc == 0:
uuid = out.strip() uuid = out.strip()
uuids[fields[0]] = uuid
self.facts['mounts'].append( self.facts['mounts'].append(
{'mount': fields[1], {'mount': fields[1],