Remove utils.read_file_as_root()
This is no longer used, and removes a rootwrap entry. Change-Id: Iad1f96de38cf23b85241bac4231c26e866ad4519
This commit is contained in:
parent
f3be714291
commit
12186f3b0e
@ -22,7 +22,6 @@ import time
|
|||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
from oslo_concurrency import processutils as putils
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
@ -151,25 +150,6 @@ class GenericUtilsTestCase(test.TestCase):
|
|||||||
self.assertEqual('/dev/xvdb1', utils.make_dev_path('xvdb', 1))
|
self.assertEqual('/dev/xvdb1', utils.make_dev_path('xvdb', 1))
|
||||||
self.assertEqual('/foo/xvdc1', utils.make_dev_path('xvdc', 1, '/foo'))
|
self.assertEqual('/foo/xvdc1', utils.make_dev_path('xvdc', 1, '/foo'))
|
||||||
|
|
||||||
@mock.patch('cinder.utils.execute')
|
|
||||||
def test_read_file_as_root(self, mock_exec):
|
|
||||||
out = mock.Mock()
|
|
||||||
err = mock.Mock()
|
|
||||||
mock_exec.return_value = (out, err)
|
|
||||||
test_filepath = '/some/random/path'
|
|
||||||
output = utils.read_file_as_root(test_filepath)
|
|
||||||
mock_exec.assert_called_once_with('cat', test_filepath,
|
|
||||||
run_as_root=True)
|
|
||||||
self.assertEqual(out, output)
|
|
||||||
|
|
||||||
@mock.patch('cinder.utils.execute',
|
|
||||||
side_effect=putils.ProcessExecutionError)
|
|
||||||
def test_read_file_as_root_fails(self, mock_exec):
|
|
||||||
test_filepath = '/some/random/path'
|
|
||||||
self.assertRaises(exception.FileNotFound,
|
|
||||||
utils.read_file_as_root,
|
|
||||||
test_filepath)
|
|
||||||
|
|
||||||
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
|
@test.testtools.skipIf(sys.platform == "darwin", "SKIP on OSX")
|
||||||
@mock.patch('tempfile.NamedTemporaryFile')
|
@mock.patch('tempfile.NamedTemporaryFile')
|
||||||
@mock.patch.object(os, 'open')
|
@mock.patch.object(os, 'open')
|
||||||
|
@ -379,15 +379,6 @@ def sanitize_hostname(hostname):
|
|||||||
return hostname
|
return hostname
|
||||||
|
|
||||||
|
|
||||||
def read_file_as_root(file_path):
|
|
||||||
"""Secure helper to read file as root."""
|
|
||||||
try:
|
|
||||||
out, _err = execute('cat', file_path, run_as_root=True)
|
|
||||||
return out
|
|
||||||
except processutils.ProcessExecutionError:
|
|
||||||
raise exception.FileNotFound(file_path=file_path)
|
|
||||||
|
|
||||||
|
|
||||||
def robust_file_write(directory, filename, data):
|
def robust_file_write(directory, filename, data):
|
||||||
"""Robust file write.
|
"""Robust file write.
|
||||||
|
|
||||||
|
@ -107,9 +107,6 @@ qemu-img_convert: CommandFilter, qemu-img, root
|
|||||||
|
|
||||||
udevadm: CommandFilter, udevadm, root
|
udevadm: CommandFilter, udevadm, root
|
||||||
|
|
||||||
# cinder/volume/driver.py: utils.read_file_as_root()
|
|
||||||
cat: CommandFilter, cat, root
|
|
||||||
|
|
||||||
# cinder/volume/nfs.py
|
# cinder/volume/nfs.py
|
||||||
stat: CommandFilter, stat, root
|
stat: CommandFilter, stat, root
|
||||||
mount: CommandFilter, mount, root
|
mount: CommandFilter, mount, root
|
||||||
|
Loading…
x
Reference in New Issue
Block a user