Merge "Use compression by default for 'SshDriver'"

This commit is contained in:
Zuul 2020-07-29 14:52:13 +00:00 committed by Gerrit Code Review
commit 49c3ac7dfa
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): def test_remote_copy_file_ssh(self, mock_execute):
remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey', remotefs.SshDriver().copy_file('1.2.3.4:/home/SpaceOdyssey',
'/home/favourite', None, None, True) '/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', mock_execute.assert_called_once_with('scp', '-r',
'1.2.3.4:/home/SpaceOdyssey', '1.2.3.4:/home/SpaceOdyssey',
'/home/favourite', '/home/favourite',

View File

@ -190,10 +190,13 @@ class SshDriver(RemoteFilesystemDriver):
on_execute=on_execute, on_completion=on_completion) on_execute=on_execute, on_completion=on_completion)
def copy_file(self, src, dst, on_execute, on_completion, compression): 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 # As far as ploop disks are in fact directories we add '-r' argument
processutils.execute('scp', '-r', src, dst, args.extend(['-r', src, dst])
on_execute=on_execute, processutils.execute(
on_completion=on_completion) *args, on_execute=on_execute, on_completion=on_completion)
class RsyncDriver(RemoteFilesystemDriver): class RsyncDriver(RemoteFilesystemDriver):