From fd57a8c6c0ff62a9142965abdf62ad7de5483e04 Mon Sep 17 00:00:00 2001 From: Vladimir Solomatin Date: Thu, 22 May 2025 23:34:28 +0300 Subject: [PATCH] Use `shutil.move` instead of `os.rename` to move `config_db.json` on place --- src/usr/lib/ztp/plugins/configdb-json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/usr/lib/ztp/plugins/configdb-json b/src/usr/lib/ztp/plugins/configdb-json index a527fbb..f01ecde 100755 --- a/src/usr/lib/ztp/plugins/configdb-json +++ b/src/usr/lib/ztp/plugins/configdb-json @@ -16,20 +16,21 @@ See the License for the specific language governing permissions and limitations under the License. ''' -import sys -import os import fcntl +import json +import os import select -import time +import shutil import stat +import sys +import time import traceback -import json from swsscommon.swsscommon import ConfigDBConnector +from ztp.Logger import logger +from ztp.ZTPLib import runCommand, getField, isString, updateActivity from ztp.ZTPObjects import URL, DynamicURL from ztp.ZTPSections import ConfigSection -from ztp.ZTPLib import runCommand, getField, isString, updateActivity -from ztp.Logger import logger class ConfigDBJson: @@ -226,7 +227,7 @@ class ConfigDBJson: # Move staged config file to requested destination file if final_dest_file is not None: - os.rename(dest_file, final_dest_file) + shutil.move(dest_file, final_dest_file) else: os.remove(dest_file)