aboutsummaryrefslogtreecommitdiffstats
path: root/ms/command-executor/src
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2020-03-31 04:19:55 -0400
committerOleg Mitsura <oleg.mitsura@amdocs.com>2020-03-31 04:25:31 -0400
commit383f847e97275e59542b0ed54b40cb18cc034d88 (patch)
tree329b96c80ef252e843fd6c39aca157242faa1cb9 /ms/command-executor/src
parent461c7cff722824e2133456ea3e83bb70a228aedf (diff)
cherrypicking to elalto
Issue-ID: CCSDK-1860 CDS_REQUEST_ID in cmd-exec env + logging Upstream code: a)revision 4 of patch https://gerrit.onap.org/r/c/ccsdk/cds/+/100922 fixed a bug where boolean was expected instead of return_struct with err msg. b)CDS_REQUEST_ID from this patch https://gerrit.onap.org/r/c/ccsdk/cds/+/97582 Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: I7a332f245da9db40745e74356c2267f8566bafec
Diffstat (limited to 'ms/command-executor/src')
-rw-r--r--ms/command-executor/src/main/python/command_executor_handler.py13
1 files changed, 12 insertions, 1 deletions
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 a32be6257..c5469a192 100644
--- a/ms/command-executor/src/main/python/command_executor_handler.py
+++ b/ms/command-executor/src/main/python/command_executor_handler.py
@@ -108,8 +108,16 @@ class CommandExecutorHandler():
payload_section = []
is_payload_section = False
+ ### extract the original header request into sys-env variables
+ ### RequestID
+ request_id = request.requestId
+ ### Sub-requestID
+ subrequest_id = request.correlationId
+ request_id_map = {'CDS_REQUEST_ID':request_id, 'CDS_CORRELATION_ID':subrequest_id}
+ updated_env = { **os.environ, **request_id_map }
+
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- shell=True, bufsize=1, universal_newlines=True) as newProcess:
+ shell=True, bufsize=1, universal_newlines=True, env=updated_env) as newProcess:
while True:
output = newProcess.stdout.readline()
if output == '' and newProcess.poll() is not None:
@@ -181,9 +189,11 @@ class CommandExecutorHandler():
try:
results.append(subprocess.run(command, check=True, stdout=PIPE, stderr=PIPE, env=env).stdout.decode())
results.append("\n")
+ self.logger.info("install_python_packages {} succeeded".format(package))
return True
except CalledProcessError as e:
results.append(e.stderr.decode())
+ self.logger.error("install_python_packages {} failed".format(package))
return False
def install_ansible_packages(self, package, results):
@@ -215,6 +225,7 @@ class CommandExecutorHandler():
# venv doesn't populate the activate_this.py script, hence we use from virtualenv
venv.create(self.venv_home, with_pip=True, system_site_packages=True)
virtualenv.writefile(os.path.join(bin_dir, "activate_this.py"), virtualenv.ACTIVATE_THIS)
+ self.logger.info("{} - Creation of Python Virtual Environment finished.".format(self.blueprint_id))
return utils.build_ret_data(True, "")
except Exception as err:
err_msg = "{} - Failed to provision Python Virtual Environment. Error: {}".format(self.blueprint_id, err)