ganesha: fix execute call using invalid argument

An execute call in the ganesha manager module that writes ganesha
export config files is made with 'process_input' argument. This
argument is invalid for processutils's ssh_execute() method which is
used by the execute call to write config files to a remote ganesha
server node. Fix this by not using the 'process_input' argument instead
use other arguments that would still enable the execute call to write
ganesha config files.

Change-Id: I58369468ac7be1de38364a1c1bf6cbf8695b9a1d
Closes-Bug: #1422235
This commit is contained in:
Ramana Raja 2015-02-15 14:48:55 +00:00
parent 00184fbf54
commit a0097bfe15
3 changed files with 11 additions and 7 deletions

View File

@ -81,7 +81,7 @@ service: CommandFilter, service, root
mktemp: CommandFilter, mktemp, root
# manila/share/drivers/ganesha/manager.py:
shcat: RegExpFilter, sh, root, sh, -c, cat > /.*
shcat: RegExpFilter, sh, root, sh, -c, echo '((.|\n)*)' > /.*
# manila/share/drivers/ganesha/manager.py:
dbus-addexport: RegExpFilter, dbus-send, root, dbus-send, --print-reply, --system, --dest=org\.ganesha\.nfsd, /org/ganesha/nfsd/ExportMgr, org\.ganesha\.nfsd\.exportmgr\.(Add|Remove)Export, .*, .*

View File

@ -226,8 +226,10 @@ class GaneshaManager(object):
("dir", "base"))
tmpf = self.execute('mktemp', '-p', dirpath, "-t",
fname + ".XXXXXX")[0][:-1]
self.execute('sh', '-c', 'cat > ' + pipes.quote(tmpf),
process_input=data, message='writing ' + tmpf)
self.execute(
'sh', '-c',
'echo %s > %s' % (pipes.quote(data), pipes.quote(tmpf)),
message='writing ' + tmpf)
self.execute('mv', tmpf, path)
def _write_conf_file(self, name, data):

View File

@ -227,14 +227,14 @@ class GaneshaManagerTestCase(test.TestCase):
def test_write_file(self):
test_data = 'fakedata'
self.mock_object(manager.pipes, 'quote',
mock.Mock(return_value='fakefile.conf.RANDOM'))
mock.Mock(side_effect=['fakedata',
'fakefile.conf.RANDOM']))
test_args = [
('mktemp', '-p', '/fakedir0/export.d', '-t',
'fakefile.conf.XXXXXX'),
('sh', '-c', 'cat > fakefile.conf.RANDOM'),
('sh', '-c', 'echo fakedata > fakefile.conf.RANDOM'),
('mv', 'fakefile.conf.RANDOM', test_path)]
test_kwargs = {
'process_input': test_data,
'message': 'writing fakefile.conf.RANDOM'
}
@ -249,7 +249,9 @@ class GaneshaManagerTestCase(test.TestCase):
mock.call(*test_args[0]),
mock.call(*test_args[1], **test_kwargs),
mock.call(*test_args[2])])
manager.pipes.quote.assert_called_once_with('fakefile.conf.RANDOM')
manager.pipes.quote.assert_has_calls([
mock.call('fakedata'),
mock.call('fakefile.conf.RANDOM')])
def test_write_conf_file(self):
test_data = 'fakedata'