errno.ENOENT, 'No such file or directory.')
with self.assertRaisesRegex(exception.NfsException,
- '/sbin/mount.nfs is not installed'):
+ 'mount.nfs is not installed'):
drv.do_setup(self.context)
mock_os_path_exists.assert_has_calls(
[mock.call(self.configuration.nfs_shares_config)])
mock_execute.assert_has_calls(
- [mock.call('/sbin/mount.nfs',
+ [mock.call('mount.nfs',
check_exit_code=False,
- run_as_root=False)])
+ run_as_root=True)])
def test_setup_should_throw_exception_if_mount_nfs_command_fails(self):
"""do_setup should throw error if mount.nfs fails with OSError
mock_os_path_exists.assert_has_calls(
[mock.call(self.configuration.nfs_shares_config)])
mock_execute.assert_has_calls(
- [mock.call('/sbin/mount.nfs',
+ [mock.call('mount.nfs',
check_exit_code=False,
- run_as_root=False)])
+ run_as_root=True)])
@mock.patch.object(os, 'rename')
def test_update_migrated_available_volume(self, rename_volume):
self.shares = {} # address : options
- # Check if /sbin/mount.nfs is installed on this system;
- # note that we don't need to be root, to see if the package
- # is installed.
- # We rely on the absolute path /sbin/mount.nfs; this seems to be
- # common on most distributions (SUSE, RedHat, CentOS, Ubuntu, Debian)
- # and it does not depend on correct PATH of the executing user,
- # when trying to find the relative binary.
- package = '/sbin/mount.nfs'
+ # Check if mount.nfs is installed on this system; note that we
+ # need to be root, to also find mount.nfs on distributions, where
+ # it is not located in an unprivileged users PATH (e.g. /sbin).
+ package = 'mount.nfs'
try:
self._execute(package, check_exit_code=False,
- run_as_root=False)
+ run_as_root=True)
except OSError as exc:
if exc.errno == errno.ENOENT:
msg = _('%s is not installed') % package