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 <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2019-09-24 16:59:18 +01:00 committed by Stephen Finucane
parent 08b3b7e699
commit e4aa424642
2 changed files with 16 additions and 3 deletions

View File

@ -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',

View File

@ -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):