Merge pull request #51905 from aplanas/fix_mount

mount: fix extra -t parameter
This commit is contained in:
Daniel Wozniak 2019-03-05 12:55:59 -07:00 committed by GitHub
commit 2c4dff609c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 6 deletions

View File

@ -1208,13 +1208,15 @@ 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 differs from typical Linux use of -t functionality
# AIX uses -v vfsname, -t fstype mounts all with fstype in /etc/filesystems
if 'AIX' in __grains__['os']:
if fstype:
if fstype:
# 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 'AIX' in __grains__['os']:
args += ' -v {0}'.format(fstype)
else:
args += ' -t {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)
if out['retcode']:

View File

@ -297,6 +297,13 @@ class MountTestCase(TestCase, LoaderModuleMockMixin):
'stderr': True})
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device'))
mock.assert_called_with('mount device name ',
python_shell=False, runas=None)
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device', fstype='fstype'))
mock.assert_called_with('mount -t fstype device name ',
python_shell=False, runas=None)
mock = MagicMock(return_value={'retcode': False,
'stderr': False})
@ -312,6 +319,35 @@ class MountTestCase(TestCase, LoaderModuleMockMixin):
'stderr': True})
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device'))
mock.assert_called_with('mount device name ',
python_shell=False, runas=None)
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device', fstype='fstype'))
mock.assert_called_with('mount -v fstype device name ',
python_shell=False, runas=None)
mock = MagicMock(return_value={'retcode': False,
'stderr': False})
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device'))
with patch.dict(mount.__grains__, {'os': 'Linux'}):
mock = MagicMock(return_value=True)
with patch.object(os.path, 'exists', mock):
mock = MagicMock(return_value=None)
with patch.dict(mount.__salt__, {'file.mkdir': None}):
mock = MagicMock(return_value={'retcode': True,
'stderr': True})
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device'))
mock.assert_called_with('mount -o defaults device name ',
python_shell=False, runas=None)
with patch.dict(mount.__salt__, {'cmd.run_all': mock}):
self.assertTrue(mount.mount('name', 'device', fstype='fstype'))
mock.assert_called_with('mount -o defaults -t fstype device name ',
python_shell=False, runas=None)
mock = MagicMock(return_value={'retcode': False,
'stderr': False})