mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #51905 from aplanas/fix_mount
mount: fix extra -t parameter
This commit is contained in:
commit
2c4dff609c
@ -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']:
|
||||
|
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user