From 2f2739d2a7d5ca8edddb62101368c7605c8460d1 Mon Sep 17 00:00:00 2001 From: Julien Fontaine Date: Mon, 27 Jul 2020 11:26:27 -0400 Subject: Fix empty dict in the script arguments when running a script in the cmd-exec Add a test to check if dynamic properties are empty. If empty we don't pass them to the script. Issue-ID: CCSDK-2614 Signed-off-by: Julien Fontaine Change-Id: Iaa5a2b49e38d9a120fb193966af13f0843773e5f --- ms/command-executor/src/main/python/command_executor_handler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ms/command-executor/src') diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py index eec385783..06004b551 100644 --- a/ms/command-executor/src/main/python/command_executor_handler.py +++ b/ms/command-executor/src/main/python/command_executor_handler.py @@ -104,11 +104,16 @@ class CommandExecutorHandler(): cmd = "cd " + self.venv_home + ### if properties are defined we add them to the command + properties = "" + if request.properties is not None and len(request.properties) > 0: + properties = " " + re.escape(MessageToJson(request.properties)) + ### TODO: replace with os.environ['VIRTUAL_ENV']? if "ansible-playbook" in request.command: cmd = cmd + "; " + request.command + " -e 'ansible_python_interpreter=" + self.venv_home + "/bin/python'" else: - cmd = cmd + "; " + request.command + " " + re.escape(MessageToJson(request.properties)) + cmd = cmd + "; " + request.command + properties ### extract the original header request into sys-env variables ### RequestID -- cgit 1.2.3-korg