Fix bug to run command as root in HDFS driver

A complete proposal is like below steps:
1. Assume the HDFS user in manila.conf has the authority to launch hdfs command.
2. Set run_as_root to False if there is no argument by default, all the cases in
Manila HDFS Driver don't need be a root to run hdfs command.
3. If root is required, please deliver run_as_root parameter and set it as True

Change-Id: I310713c3c1b74ff9990832f61e777cf4c12696fe
Closes-Bug: #1481567
This commit is contained in:
weiting-chen 2015-08-10 20:55:54 +08:00
parent f96ebefc22
commit bed9b9f3f2
2 changed files with 2 additions and 2 deletions

View File

@ -107,7 +107,7 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
def _hdfs_local_execute(self, *cmd, **kwargs):
if 'run_as_root' not in kwargs:
kwargs.update({'run_as_root': True})
kwargs.update({'run_as_root': False})
return utils.execute(*cmd, **kwargs)

View File

@ -358,7 +358,7 @@ class HDFSNativeShareDriverTestCase(test.TestCase):
cmd = 'testcmd'
self.mock_object(utils, 'execute', mock.Mock(return_value=True))
self._driver._hdfs_local_execute(cmd)
utils.execute.assert_called_once_with(cmd, run_as_root=True)
utils.execute.assert_called_once_with(cmd, run_as_root=False)
def test__hdfs_remote_execute(self):
self._driver._run_ssh = mock.Mock(return_value=True)