From 243ff3bbf218102b24ed992e3931bf8c76cdaadd Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Thu, 16 Jul 2020 19:35:11 +0200 Subject: [PATCH] misc: optimize append_lines_to_file() to reuse remote.write_file The misc.append_lines_to_file method has been using get remote file to temporary file and then write back to remote host. The orchestra.remote.write_file method has 'append' parameter when using which there is no data downloaded from remote host. Signed-off-by: Kyr Shatskyy --- teuthology/misc.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index e6041d7025..b66e78c0ca 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -656,22 +656,8 @@ def remove_lines_from_file(remote, path, line_is_valid_test, def append_lines_to_file(remote, path, lines, sudo=False): """ Append lines to a file. - An intermediate file is used in the same manner as in - Remove_lines_from_list. """ - - temp_file_path = remote.mktemp() - - data = get_file(remote, path, sudo).decode() - - # add the additional data and write it back out, using a temp file - # in case of connectivity of loss, and then mv it to the - # actual desired location - data += lines - write_file(remote, temp_file_path, data) - - # then do a 'mv' to the actual file location - move_file(remote, temp_file_path, path, sudo) + remote.write_file(path, lines, append=True, sudo=sudo) def prepend_lines_to_file(remote, path, lines, sudo=False): """ -- 2.39.5