Merge "Execute mount.nfs check as root" into stable/liberty

This commit is contained in:
Jenkins
2016-02-17 00:23:27 +00:00
committed by Gerrit Code Review
2 changed files with 6 additions and 5 deletions

View File

@@ -1291,7 +1291,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_execute.assert_has_calls(
[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
@@ -1315,7 +1315,7 @@ class NfsDriverDoSetupTestCase(test.TestCase):
mock_execute.assert_has_calls(
[mock.call('mount.nfs',
check_exit_code=False,
run_as_root=False)])
run_as_root=True)])
def test_update_migrated_volume_is_there(self):
"""Ensure that driver.update_migrated_volume() is there."""

View File

@@ -143,12 +143,13 @@ class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
self.shares = {} # address : options
# Check if mount.nfs is installed on this system; note that we don't
# need to be root to see if the package is installed.
# 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