neutron_lib.utils.file module¶
-
neutron_lib.utils.file.
replace_file
(file_name, data, file_mode=420)¶ Replaces the contents of file_name with data in a safe manner.
First write to a temp file and then rename. Since POSIX renames are atomic, the file is unlikely to be corrupted by competing writes.
We create the tempfile on the same device to ensure that it can be renamed.
- Parameters
file_name – Path to the file to replace.
data – The data to write to the file.
file_mode – The mode to use for the replaced file.
- Returns
None.