Merge pull request #39238 from dmurphy18/fix_aix_disk_mount

Update disk fstype, inodeusage, percent and mount.active functions for AIX support
This commit is contained in:
Mike Place 2017-02-08 14:53:31 -07:00 committed by GitHub
commit 7611698474
2 changed files with 52 additions and 11 deletions

View file

@ -75,9 +75,7 @@ def usage(args=None):
return {}
if __grains__['kernel'] == 'Linux':
cmd = 'df -P'
elif __grains__['kernel'] == 'OpenBSD':
cmd = 'df -kP'
elif __grains__['kernel'] == 'AIX':
elif __grains__['kernel'] == 'OpenBSD' or __grains__['kernel'] == 'AIX':
cmd = 'df -kP'
else:
cmd = 'df'
@ -141,7 +139,10 @@ def inodeusage(args=None):
salt '*' disk.inodeusage
'''
flags = _clean_flags(args, 'disk.inodeusage')
cmd = 'df -iP'
if __grains__['kernel'] == 'AIX':
cmd = 'df -i'
else:
cmd = 'df -iP'
if flags:
cmd += ' -{0}'.format(flags)
ret = {}
@ -163,6 +164,14 @@ def inodeusage(args=None):
'use': comps[7],
'filesystem': comps[0],
}
elif __grains__['kernel'] == 'AIX':
ret[comps[6]] = {
'inodes': comps[4],
'used': comps[5],
'free': comps[2],
'use': comps[5],
'filesystem': comps[0],
}
else:
ret[comps[5]] = {
'inodes': comps[1],
@ -189,7 +198,7 @@ def percent(args=None):
'''
if __grains__['kernel'] == 'Linux':
cmd = 'df -P'
elif __grains__['kernel'] == 'OpenBSD':
elif __grains__['kernel'] == 'OpenBSD' or __grains__['kernel'] == 'AIX':
cmd = 'df -kP'
else:
cmd = 'df'
@ -201,9 +210,11 @@ def percent(args=None):
if line.startswith('Filesystem'):
continue
comps = line.split()
while not comps[1].isdigit():
while len(comps) >= 2 and not comps[1].isdigit():
comps[0] = '{0} {1}'.format(comps[0], comps[1])
comps.pop(1)
if len(comps) < 2:
continue
try:
if __grains__['kernel'] == 'Darwin':
ret[comps[8]] = comps[4]
@ -464,11 +475,18 @@ def fstype(device):
if salt.utils.which('df'):
# the fstype was not set on the block device, so inspect the filesystem
# itself for its type
df_out = __salt__['cmd.run']('df -T {0}'.format(device)).splitlines()
if len(df_out) > 1:
fs_type = df_out[1]
if fs_type:
return fs_type
if __grains__['kernel'] == 'AIX' and os.path.isfile('/usr/sysv/bin/df'):
df_out = __salt__['cmd.run']('/usr/sysv/bin/df -n {0}'.format(device)).split()
if len(df_out) > 2:
fs_type = df_out[2]
if fs_type:
return fs_type
else:
df_out = __salt__['cmd.run']('df -T {0}'.format(device)).splitlines()
if len(df_out) > 1:
fs_type = df_out[1]
if fs_type:
return fs_type
return ''

View file

@ -110,6 +110,27 @@ def _active_mounts(ret):
return ret
def _active_mounts_aix(ret):
'''
List active mounts on AIX systems
'''
for line in __salt__['cmd.run_stdout']('mount -p').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
if comps and comps[0] == 'node' or comps[0] == '--------':
continue
if len(comps) < 8:
ret[comps[1]] = {'device': comps[0],
'fstype': comps[2],
'opts': _resolve_user_group_names(comps[6].split(','))}
else:
ret[comps[2]] = {'node': comps[0],
'device': comps[1],
'fstype': comps[3],
'opts': _resolve_user_group_names(comps[7].split(','))}
return ret
def _active_mounts_freebsd(ret):
'''
List active mounts on FreeBSD systems
@ -202,6 +223,8 @@ def active(extended=False):
ret = {}
if __grains__['os'] == 'FreeBSD':
_active_mounts_freebsd(ret)
elif __grains__['kernel'] == 'AIX':
_active_mounts_aix(ret)
elif __grains__['kernel'] == 'SunOS':
_active_mounts_solaris(ret)
elif __grains__['os'] == 'OpenBSD':