libvirt: Fix ssh driver to to prevent prompting

This patch fix the bug which was resolved in
this patch Ib1e38f397afaac96a2e1a8717c87a4b6756419db
but got lost after the merge of this
I586a9faa2a7afa3f195239df305898b6da4fb583 patch

Change-Id: I75d09832980a88752b061309e80c3fcfce1f2fcc
This commit is contained in:
Moshe Levi
2016-03-16 10:43:32 +02:00
parent 859ff4893f
commit b274a85e96
2 changed files with 28 additions and 28 deletions

View File

@@ -74,11 +74,11 @@ class RemoteFSTestCase(test.NoDBTestCase):
self.assertEqual(2, mock_execute.call_count)
self.assertEqual(1, mock_mkdtemp.call_count)
@mock.patch('nova.utils.execute')
def test_remove_remote_file_ssh(self, mock_execute):
@mock.patch('nova.utils.ssh_execute')
def test_remove_remote_file_ssh(self, mock_ssh_execute):
remotefs.SshDriver().remove_file('host', 'dest', None, None)
mock_execute.assert_called_once_with(
'ssh', 'host', 'rm', 'dest',
mock_ssh_execute.assert_called_once_with(
'host', 'rm', 'dest',
on_completion=None, on_execute=None)
@mock.patch('tempfile.mkdtemp', return_value='/tmp/Venus')
@@ -101,11 +101,11 @@ class RemoteFSTestCase(test.NoDBTestCase):
self.assertEqual(3, mock_execute.call_count)
self.assertEqual(1, mock_mkdtemp.call_count)
@mock.patch('nova.utils.execute')
def test_remove_remote_dir_ssh(self, mock_execute):
@mock.patch('nova.utils.ssh_execute')
def test_remove_remote_dir_ssh(self, mock_ssh_execute):
remotefs.SshDriver().remove_dir('host', 'dest', None, None)
mock_execute.assert_called_once_with(
'ssh', 'host', 'rm', '-rf', 'dest', on_completion=None,
mock_ssh_execute.assert_called_once_with(
'host', 'rm', '-rf', 'dest', on_completion=None,
on_execute=None)
@mock.patch('tempfile.mkdtemp', return_value='/tmp/Mars')
@@ -128,11 +128,11 @@ class RemoteFSTestCase(test.NoDBTestCase):
self.assertEqual(4, mock_execute.call_count)
self.assertEqual(1, mock_mkdtemp.call_count)
@mock.patch('nova.utils.execute')
def test_create_remote_file_ssh(self, mock_execute):
@mock.patch('nova.utils.ssh_execute')
def test_create_remote_file_ssh(self, mock_ssh_execute):
remotefs.SshDriver().create_file('host', 'dest_dir', None, None)
mock_execute.assert_called_once_with('ssh', 'host',
'touch', 'dest_dir',
mock_ssh_execute.assert_called_once_with('host', 'touch',
'dest_dir',
on_completion=None,
on_execute=None)
@@ -153,10 +153,10 @@ class RemoteFSTestCase(test.NoDBTestCase):
self.assertEqual(3, mock_execute.call_count)
self.assertEqual(1, mock_mkdtemp.call_count)
@mock.patch('nova.utils.execute')
def test_create_remote_dir_ssh(self, mock_execute):
@mock.patch('nova.utils.ssh_execute')
def test_create_remote_dir_ssh(self, mock_ssh_execute):
remotefs.SshDriver().create_dir('host', 'dest_dir', None, None)
mock_execute.assert_called_once_with('ssh', 'host', 'mkdir',
mock_ssh_execute.assert_called_once_with('host', 'mkdir',
'-p', 'dest_dir',
on_completion=None,
on_execute=None)

View File

@@ -189,19 +189,19 @@ class RemoteFilesystemDriver(object):
class SshDriver(RemoteFilesystemDriver):
def create_file(self, host, dst_path, on_execute, on_completion):
utils.execute('ssh', host, 'touch', dst_path,
utils.ssh_execute(host, 'touch', dst_path,
on_execute=on_execute, on_completion=on_completion)
def remove_file(self, host, dst, on_execute, on_completion):
utils.execute('ssh', host, 'rm', dst,
utils.ssh_execute(host, 'rm', dst,
on_execute=on_execute, on_completion=on_completion)
def create_dir(self, host, dst_path, on_execute, on_completion):
utils.execute('ssh', host, 'mkdir', '-p', dst_path,
utils.ssh_execute(host, 'mkdir', '-p', dst_path,
on_execute=on_execute, on_completion=on_completion)
def remove_dir(self, host, dst, on_execute, on_completion):
utils.execute('ssh', host, 'rm', '-rf', dst,
utils.ssh_execute(host, 'rm', '-rf', dst,
on_execute=on_execute, on_completion=on_completion)
def copy_file(self, src, dst, on_execute, on_completion, compression):