From 06a8791b9beec5a95a5072e9a02a4379ac46770d Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: May 16 2024 12:46:32 +0000 Subject: tests: helper to copy files from one host to another Simple function that takes a list of file names and copies them from one host to another. It isn't the most efficient but for a small number of files it should be sufficient. Signed-off-by: Rob Crittenden Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 39b9589..78a86cc 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2920,3 +2920,15 @@ def move_date(host, chrony_cmd, date_str): """ host.run_command(['systemctl', chrony_cmd, 'chronyd']) host.run_command(['date', '-s', date_str]) + + +def copy_files(source_host, dest_host, filelist): + """Helper to copy a file from one host to another + :param source_host: source host of the file to copy + :param dest_host: destination host + :param filelist: list of full path of files to copy + """ + for file in filelist: + dest_host.transport.mkdir_recursive(os.path.dirname(file)) + data = source_host.get_file_contents(file) + dest_host.transport.put_file_contents(file, data)