From e4aa424642fdf97ae2153ee5c9db65d612236f57 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Tue, 24 Sep 2019 16:59:18 +0100 Subject: [PATCH] Use compression by default for 'SshDriver' Given we use these to copy images about the place, this should be some bit faster for uncompressed images. Change-Id: I2860db55ff580282cd6905f5310f01fca17e132d Signed-off-by: Stephen Finucane --- nova/tests/unit/virt/libvirt/volume/test_remotefs.py | 10 ++++++++++ nova/virt/libvirt/volume/remotefs.py | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/volume/test_remotefs.py b/nova/tests/unit/virt/libvirt/volume/test_remotefs.py index 45dfa60cb7d6..62060bcf1ef1 100644 --- a/nova/tests/unit/virt/libvirt/volume/test_remotefs.py +++ b/nova/tests/unit/virt/libvirt/volume/test_remotefs.py @@ -171,6 +171,16 @@ class RemoteFSTestCase(test.NoDBTestCase): def test_remote_copy_file_ssh(self, mock_execute): remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey', '/home/favourite', None, None, True) + mock_execute.assert_called_once_with('scp', '-C', '-r', + '1.2.3.4:/home/SpaceOdyssey', + '/home/favourite', + on_completion=None, + on_execute=None) + + @mock.patch('oslo_concurrency.processutils.execute') + def test_remote_copy_file_ssh__without_compression(self, mock_execute): + remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey', + '/home/favourite', None, None, False) mock_execute.assert_called_once_with('scp', '-r', '1.2.3.4:/home/SpaceOdyssey', '/home/favourite', diff --git a/nova/virt/libvirt/volume/remotefs.py b/nova/virt/libvirt/volume/remotefs.py index 19cb1b43fe18..8eb53e870b9f 100644 --- a/nova/virt/libvirt/volume/remotefs.py +++ b/nova/virt/libvirt/volume/remotefs.py @@ -190,10 +190,13 @@ class SshDriver(RemoteFilesystemDriver): on_execute=on_execute, on_completion=on_completion) def copy_file(self, src, dst, on_execute, on_completion, compression): + args = ['scp'] + if compression: + args.append('-C') # As far as ploop disks are in fact directories we add '-r' argument - processutils.execute('scp', '-r', src, dst, - on_execute=on_execute, - on_completion=on_completion) + args.extend(['-r', src, dst]) + processutils.execute( + *args, on_execute=on_execute, on_completion=on_completion) class RsyncDriver(RemoteFilesystemDriver):