From 5937314a8a30bf2eeb43cdafa709a02c16f21199 Mon Sep 17 00:00:00 2001 From: peter_yu Date: Fri, 14 Apr 2023 08:23:35 +0000 Subject: [PATCH 1/2] [ZTP] 'config reload' use -f to avoid system checks sometimes config_db.json didn't take effect, and it displayed: -- Aug 13 08:51:12.048103 sonic INFO sonic-ztp[30764]: configdb-json: Reloading config_db.json to Config DB. Aug 13 08:51:12.586370 sonic INFO sonic-ztp[35241]: SwSS container is not ready. Retry later or use -f to avoid system checks --- src/usr/lib/ztp/plugins/configdb-json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/lib/ztp/plugins/configdb-json b/src/usr/lib/ztp/plugins/configdb-json index b465833..a527fbb 100755 --- a/src/usr/lib/ztp/plugins/configdb-json +++ b/src/usr/lib/ztp/plugins/configdb-json @@ -205,7 +205,7 @@ class ConfigDBJson: self.__stop_dhcp() logger.info('configdb-json: Reloading config_db.json to Config DB.') updateActivity('configdb-json: Reloading config_db.json to Config DB') - cmd += 'reload' + cmd += 'reload -f' else: logger.info('configdb-json: Applying config_db.json to Config DB.') updateActivity('configdb-json: Applying config_db.json to Config DB') From 0fdcee053cb1a246188fdbb940a0d4bc7c60d0d0 Mon Sep 17 00:00:00 2001 From: peter_yu Date: Fri, 6 May 2022 10:20:08 +0000 Subject: [PATCH 2/2] [ZTP] bufsize=1 not supported in binary mode In Python 3.8, line buffering (buffering=1) isn't supported in binary mode --- src/usr/lib/python3/dist-packages/ztp/ZTPLib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/usr/lib/python3/dist-packages/ztp/ZTPLib.py b/src/usr/lib/python3/dist-packages/ztp/ZTPLib.py index 5882ee2..f2354ce 100644 --- a/src/usr/lib/python3/dist-packages/ztp/ZTPLib.py +++ b/src/usr/lib/python3/dist-packages/ztp/ZTPLib.py @@ -95,7 +95,7 @@ def runCommand(cmd, capture_stdout=True, use_shell=False): else: shcmd = cmd if capture_stdout is True: - proc = subprocess.Popen(shcmd, shell=use_shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1, close_fds=True) + proc = subprocess.Popen(shcmd, shell=use_shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) pid = proc.pid runcmd_pids.append(pid) output_stdout, output_stderr = proc.communicate()