Skip to content

Commit fb36d86

Browse files
authored
Merge pull request saltstack#55598 from garethgreenaway/master_mount_fixes
[master] regression fixes to mount module and state module
2 parents 4907e61 + 0e74d0a commit fb36d86

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

salt/modules/mount.py

+3
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,9 @@ def set_fstab(
763763
'securityfs',
764764
'devtmpfs',
765765
'cgroup',
766+
'nfs',
767+
'nfs4',
768+
'glusterfs',
766769
'btrfs'])
767770

768771
if fstype in specialFSes:

salt/states/mount.py

+2
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@ def mounted(name,
325325
if label_device and label_device not in device_list:
326326
device_list.append(label_device)
327327
if opts:
328+
opts.sort()
329+
328330
mount_invisible_options = [
329331
'_netdev',
330332
'actimeo',

tests/unit/states/test_mount.py

+50
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,56 @@ def test_mod_watch(self):
447447

448448
self.assertDictEqual(mount.mod_watch(name, sfun='unmount'), ret)
449449

450+
def test_mounted_multiple_mounts(self):
451+
'''
452+
Test to verify that a device is mounted.
453+
'''
454+
name = '/mnt/nfs1'
455+
device = 'localhost:/mnt/nfsshare'
456+
fstype = 'nfs4'
457+
458+
name2 = '/mnt/nfs2'
459+
device2 = 'localhost:/mnt/nfsshare'
460+
fstype2 = 'nfs4'
461+
462+
ret = {'name': name,
463+
'result': False,
464+
'comment': '',
465+
'changes': {}}
466+
467+
mock = MagicMock(side_effect=['new', 'present', 'new', 'change',
468+
'bad config', 'salt', 'present'])
469+
mock_t = MagicMock(return_value=True)
470+
mock_f = MagicMock(return_value=False)
471+
mock_ret = MagicMock(return_value={'retcode': 1})
472+
mock_mnt = MagicMock(return_value={name: {'device': device, 'opts': [],
473+
'superopts': []}})
474+
mock_read_cache = MagicMock(return_value={})
475+
mock_write_cache = MagicMock(return_value=True)
476+
mock_user = MagicMock(return_value={'uid': 510})
477+
mock_group = MagicMock(return_value={'gid': 100})
478+
mock_str = MagicMock(return_value='salt')
479+
mock_fstab_config = ['localhost:/mnt/nfsshare /mnt/nfs1 nfs defaults 0 0']
480+
481+
# Test no change for uid provided as a name #25293
482+
with patch.dict(mount.__grains__, {'os': 'CentOS'}):
483+
with patch.dict(mount.__opts__, {'test': True}):
484+
with patch.dict(mount.__salt__, {'mount.active': mock_mnt,
485+
'mount.mount': mock_str,
486+
'mount.umount': mock_f,
487+
'mount.read_mount_cache': mock_read_cache,
488+
'mount.write_mount_cache': mock_write_cache,
489+
'user.info': mock_user,
490+
'group.info': mock_group}):
491+
with patch.object(os.path, 'exists', mock_t):
492+
comt = '/mnt/nfs2 would be mounted'
493+
ret.update({'name': name2, 'result': None})
494+
ret.update({'comment': comt, 'changes': {}})
495+
self.assertDictEqual(mount.mounted(name2, device2,
496+
fstype2,
497+
opts=[]),
498+
ret)
499+
450500
def test__convert_to_fast_none(self):
451501
'''
452502
Test the device name conversor

0 commit comments

Comments
 (0)