mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Further updates to support for mount on AIX
This commit is contained in:
parent
210076276f
commit
b701e16ad0
3 changed files with 92 additions and 25 deletions
|
@ -457,8 +457,10 @@ class _filesystems_entry(object):
|
|||
def dict_from_lines(cls, lines, keys=filesystems_keys):
|
||||
if len(lines) < 2:
|
||||
raise ValueError('Invalid number of lines: {0}'.format(lines))
|
||||
|
||||
if len(keys) < 6:
|
||||
if not keys:
|
||||
# if empty force default filesystems_keys
|
||||
keys = _filesystems_entry.filesystems_keys
|
||||
elif len(keys) < 6:
|
||||
raise ValueError('Invalid key array: {0}'.format(keys))
|
||||
|
||||
blk_lines = lines
|
||||
|
@ -479,7 +481,10 @@ class _filesystems_entry(object):
|
|||
|
||||
@classmethod
|
||||
def dict_from_cmd_line(cls, ipargs, keys=filesystems_keys):
|
||||
if len(keys) < 1:
|
||||
if not keys:
|
||||
# if empty force default filesystems_keys
|
||||
keys = _filesystems_entry.filesystems_keys
|
||||
elif len(keys) < 1:
|
||||
raise ValueError('Invalid key array: {0}'.format(keys))
|
||||
|
||||
cmdln_dict = ipargs
|
||||
|
@ -1204,8 +1209,11 @@ def mount(name, device, mkmnt=False, fstype='', opts='defaults', user=None, util
|
|||
lopts = ','.join(opts)
|
||||
args = '-o {0}'.format(lopts)
|
||||
|
||||
# use of fstype on AIX is with /etc/filesystems
|
||||
if fstype and 'AIX' not in __grains__['os']:
|
||||
# use of fstype on AIX differs from typical Linux use of -t functionality
|
||||
# AIX uses -v vfsname, -t fstype mounts all with fstype in /etc/filesystems
|
||||
if fstype and 'AIX' in __grains__['os']:
|
||||
args += ' -v {0}'.format(fstype)
|
||||
else:
|
||||
args += ' -t {0}'.format(fstype)
|
||||
cmd = 'mount {0} {1} {2} '.format(args, device, name)
|
||||
out = __salt__['cmd.run_all'](cmd, runas=user, python_shell=False)
|
||||
|
@ -1249,9 +1257,13 @@ def remount(name, device, mkmnt=False, fstype='', opts='defaults', user=None):
|
|||
lopts = ','.join(opts)
|
||||
args = '-o {0}'.format(lopts)
|
||||
|
||||
# use of fstype on AIX is with /etc/filesystems
|
||||
if fstype and 'AIX' not in __grains__['os']:
|
||||
# use of fstype on AIX differs from typical Linux use of -t functionality
|
||||
# AIX uses -v vfsname, -t fstype mounts all with fstype in /etc/filesystems
|
||||
if fstype and 'AIX' in __grains__['os']:
|
||||
args += ' -v {0}'.format(fstype)
|
||||
else:
|
||||
args += ' -t {0}'.format(fstype)
|
||||
|
||||
if __grains__['os'] not in ['OpenBSD', 'MacOS', 'Darwin'] or force_mount:
|
||||
cmd = 'mount {0} {1} {2} '.format(args, device, name)
|
||||
else:
|
||||
|
@ -1639,7 +1651,6 @@ def filesystems(config='/etc/filesystems'):
|
|||
def set_filesystems(
|
||||
name,
|
||||
device,
|
||||
fstype,
|
||||
vfstype,
|
||||
opts='-',
|
||||
mount='true',
|
||||
|
@ -1651,7 +1662,17 @@ def set_filesystems(
|
|||
.. versionadded:: 2018.3.3
|
||||
|
||||
Verify that this mount is represented in the filesystems, change the mount
|
||||
to match the data passed, or add the mount if it is not present.
|
||||
to match the data passed, or add the mount if it is not present on AIX
|
||||
|
||||
Provide information if the path is mounted
|
||||
|
||||
:param name: The name of the mount point where the device is mounted.
|
||||
:param device: The device that is being mounted.
|
||||
:param vfstype: The file system that is used (AIX has two fstypes, fstype and vfstype - similar to Linux fstype)
|
||||
:param opts: Additional options used when mounting the device.
|
||||
:param mount: Mount if not mounted, default True.
|
||||
:param config: Configuration file, default /etc/filesystems.
|
||||
:param match: File systems type to match on, default auto
|
||||
|
||||
CLI Example:
|
||||
|
||||
|
@ -1667,7 +1688,6 @@ def set_filesystems(
|
|||
entry_args = {
|
||||
'name': name,
|
||||
'dev': device.replace('\\ ', '\\040'),
|
||||
'fstype': fstype,
|
||||
'vfstype': vfstype,
|
||||
'opts': opts,
|
||||
'mount': mount,
|
||||
|
@ -1717,7 +1737,7 @@ def set_filesystems(
|
|||
'autofs',
|
||||
'stnfs'])
|
||||
|
||||
if fstype in specialFSes:
|
||||
if vfstype in specialFSes:
|
||||
match_on = ['name']
|
||||
else:
|
||||
match_on = ['dev']
|
||||
|
|
|
@ -206,6 +206,10 @@ def mounted(name,
|
|||
if __grains__['os'] in ['MacOS', 'Darwin'] and opts == 'defaults':
|
||||
opts = 'noowners'
|
||||
|
||||
# Defaults is not a valid option on AIX
|
||||
if __grains__['os'] in ['AIX'] and opts == 'defaults':
|
||||
opts = ''
|
||||
|
||||
# Make sure that opts is correct, it can be a list or a comma delimited
|
||||
# string
|
||||
if isinstance(opts, string_types):
|
||||
|
@ -571,9 +575,14 @@ def mounted(name,
|
|||
ret['comment'] = '{0} not mounted'.format(name)
|
||||
|
||||
if persist:
|
||||
# Override default for Mac OS
|
||||
if __grains__['os'] in ['MacOS', 'Darwin'] and config == '/etc/fstab':
|
||||
config = "/etc/auto_salt"
|
||||
if '/etc/fstab' == config:
|
||||
# Override default for Mac OS
|
||||
if __grains__['os'] in ['MacOS', 'Darwin']:
|
||||
config = "/etc/auto_salt"
|
||||
|
||||
# Override default for AIX
|
||||
elif 'AIX' in __grains__['os']:
|
||||
config = "/etc/filesystems"
|
||||
|
||||
if __opts__['test']:
|
||||
if __grains__['os'] in ['MacOS', 'Darwin']:
|
||||
|
@ -583,6 +592,15 @@ def mounted(name,
|
|||
opts,
|
||||
config,
|
||||
test=True)
|
||||
elif __grains__['os'] in ['AIX']:
|
||||
out = __salt__['mount.set_filesystems'](name,
|
||||
device,
|
||||
fstype,
|
||||
opts,
|
||||
mount,
|
||||
config,
|
||||
test=True,
|
||||
match_on=match_on)
|
||||
else:
|
||||
out = __salt__['mount.set_fstab'](name,
|
||||
device,
|
||||
|
@ -631,6 +649,14 @@ def mounted(name,
|
|||
fstype,
|
||||
opts,
|
||||
config)
|
||||
elif __grains__['os'] in ['AIX']:
|
||||
out = __salt__['mount.set_filesystems'](name,
|
||||
device,
|
||||
fstype,
|
||||
opts,
|
||||
mount,
|
||||
config,
|
||||
match_on=match_on)
|
||||
else:
|
||||
out = __salt__['mount.set_fstab'](name,
|
||||
device,
|
||||
|
@ -712,7 +738,13 @@ def swap(name, persist=True, config='/etc/fstab'):
|
|||
ret['result'] = False
|
||||
|
||||
if persist:
|
||||
fstab_data = __salt__['mount.fstab'](config)
|
||||
if 'AIX' in __grains__['os']:
|
||||
if '/etc/fstab' == config:
|
||||
# Override default for AIX
|
||||
config = "/etc/filesystems"
|
||||
fstab_data = __salt__['mount.filesystems'](config)
|
||||
else:
|
||||
fstab_data = __salt__['mount.fstab'](config)
|
||||
if __opts__['test']:
|
||||
if name not in fstab_data:
|
||||
ret['result'] = None
|
||||
|
@ -726,15 +758,21 @@ def swap(name, persist=True, config='/etc/fstab'):
|
|||
fstab_data['none']['fstype'] != 'swap':
|
||||
return ret
|
||||
|
||||
# present, new, change, bad config
|
||||
# Make sure the entry is in the fstab
|
||||
out = __salt__['mount.set_fstab']('none',
|
||||
name,
|
||||
'swap',
|
||||
['defaults'],
|
||||
0,
|
||||
0,
|
||||
config)
|
||||
if 'AIX' in __grains__['os']:
|
||||
out = None
|
||||
ret['result'] = False
|
||||
ret['comment'] += '. swap not present in /etc/filesystems on AIX.'
|
||||
return ret
|
||||
else:
|
||||
# present, new, change, bad config
|
||||
# Make sure the entry is in the fstab
|
||||
out = __salt__['mount.set_fstab']('none',
|
||||
name,
|
||||
'swap',
|
||||
['defaults'],
|
||||
0,
|
||||
0,
|
||||
config)
|
||||
if out == 'present':
|
||||
return ret
|
||||
if out == 'new':
|
||||
|
@ -827,6 +865,10 @@ def unmounted(name,
|
|||
if __grains__['os'] in ['MacOS', 'Darwin'] and config == '/etc/fstab':
|
||||
config = "/etc/auto_salt"
|
||||
fstab_data = __salt__['mount.automaster'](config)
|
||||
elif 'AIX' in __grains__['os']:
|
||||
if config == '/etc/fstab':
|
||||
config = "/etc/filesystems"
|
||||
fstab_data = __salt__['mount.filesystems'](config)
|
||||
else:
|
||||
fstab_data = __salt__['mount.fstab'](config)
|
||||
|
||||
|
@ -846,6 +888,8 @@ def unmounted(name,
|
|||
else:
|
||||
if __grains__['os'] in ['MacOS', 'Darwin']:
|
||||
out = __salt__['mount.rm_automaster'](name, device, config)
|
||||
elif 'AIX' in __grains__['os']:
|
||||
out = __salt__['mount.rm_filesystems'](name, device, config)
|
||||
else:
|
||||
out = __salt__['mount.rm_fstab'](name, device, config)
|
||||
if out is not True:
|
||||
|
|
|
@ -407,7 +407,10 @@ def flopen(*args, **kwargs):
|
|||
with fopen(*args, **kwargs) as f_handle:
|
||||
try:
|
||||
if is_fcntl_available(check_sunos=True):
|
||||
fcntl.flock(f_handle.fileno(), fcntl.LOCK_SH)
|
||||
lock_type = fcntl.LOCK_SH
|
||||
if salt.utils.platform.is_aix() and ('a' in args[1] or 'w' in args[1]):
|
||||
lock_type = fcntl.LOCK_EX
|
||||
fcntl.flock(f_handle.fileno(), lock_type)
|
||||
yield f_handle
|
||||
finally:
|
||||
if is_fcntl_available(check_sunos=True):
|
||||
|
|
Loading…
Add table
Reference in a new issue