diff --git a/octane/commands/update_bootstrap.py b/octane/commands/update_bootstrap.py index e799e373..d0c947dc 100644 --- a/octane/commands/update_bootstrap.py +++ b/octane/commands/update_bootstrap.py @@ -21,7 +21,7 @@ from octane.util import archivate def update_centos_bootstrap(): with archivate.update_cpio(magic_consts.BOOTSTRAP_INITRAMFS) as tmp_dir: - shutil.copy( + shutil.copy2( "/root/.ssh/authorized_keys", os.path.join(tmp_dir, "root/.ssh/authorized_keys")) diff --git a/octane/handlers/backup_restore/astute.py b/octane/handlers/backup_restore/astute.py index fd9b85a4..dbd138fc 100644 --- a/octane/handlers/backup_restore/astute.py +++ b/octane/handlers/backup_restore/astute.py @@ -109,7 +109,7 @@ class AstuteArchivator(base.PathArchivator): ",".join(not_found_keys))) old_path_name = "{0}.old".format(self.path) new_path_name = "{0}.new".format(self.path) - shutil.copy(self.path, old_path_name) + shutil.copy2(self.path, old_path_name) with open(new_path_name, "w") as new: yaml.safe_dump(current_yaml, new, default_flow_style=False) shutil.move(new_path_name, self.path) diff --git a/octane/tests/test_archivators_restore.py b/octane/tests/test_archivators_restore.py index d83bcf4a..7c7615eb 100644 --- a/octane/tests/test_archivators_restore.py +++ b/octane/tests/test_archivators_restore.py @@ -445,7 +445,7 @@ def test_astute_restore(mocker, mock_open, keys_in_dump_file, restored): mocker.patch("yaml.load", side_effect=[dump_dict, current_dict]) safe_dump = mocker.patch("yaml.safe_dump") - copy_mock = mocker.patch("shutil.copy") + copy_mock = mocker.patch("shutil.copy2") move_mock = mocker.patch("shutil.move") cls = astute.AstuteArchivator archive = TestArchive([member], cls) diff --git a/octane/tests/test_util_auth.py b/octane/tests/test_util_auth.py index 031cd53a..682e1cd9 100644 --- a/octane/tests/test_util_auth.py +++ b/octane/tests/test_util_auth.py @@ -26,7 +26,7 @@ def test_set_astute_password(mocker, mock_open, exc_on_apply): mkstemp_mock = mocker.patch( "tempfile.mkstemp", return_value=(1, "/etc/fuel/.astute.yaml.bac")) - mock_copy = mocker.patch("shutil.copy") + mock_copy = mocker.patch("shutil.copy2") mock_move = mocker.patch("shutil.move") yaml_load = mocker.patch( "yaml.load", return_value={"FUEL_ACCESS": {"password": "dump_pswd"}}) diff --git a/octane/util/auth.py b/octane/util/auth.py index e7ebd90e..e614991a 100644 --- a/octane/util/auth.py +++ b/octane/util/auth.py @@ -24,7 +24,7 @@ def set_astute_password(auth_context): _, tmp_file_name = tempfile.mkstemp( dir="/etc/fuel", prefix=".astute.yaml.octane") - shutil.copy("/etc/fuel/astute.yaml", tmp_file_name) + shutil.copy2("/etc/fuel/astute.yaml", tmp_file_name) try: data = helpers.get_astute_dict() data["FUEL_ACCESS"]["password"] = auth_context.password