diff options
author | Oleg Mitsura <oleg.mitsura@amdocs.com> | 2019-10-24 19:22:46 -0400 |
---|---|---|
committer | Oleg Mitsura <omitsura@gmail.com> | 2019-11-28 20:12:10 +0000 |
commit | 4947afebcfbee275e2f3a804d0a5648428f69908 (patch) | |
tree | 0b3a92ccbd9ac47b2952d301989f8c3aa4b2f60a | |
parent | ddc61816d0a201d550e439e49b2814a785541e01 (diff) |
Pass requestID/subreqID to python script.
Issue-ID: CCSDK-1860
1. initial commit
2. rebased with return value
3. CDS_CORRELATION_ID
Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com>
Change-Id: Ia64a0ee9c8eb60e3f39ec00ee17e7ab1b4aa3638
-rw-r--r-- | ms/command-executor/src/main/python/command_executor_handler.py | 12 |
1 files changed, 10 insertions, 2 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 c920dda89..3219a974b 100644 --- a/ms/command-executor/src/main/python/command_executor_handler.py +++ b/ms/command-executor/src/main/python/command_executor_handler.py @@ -31,7 +31,7 @@ import json REQUIREMENTS_TXT = "requirements.txt" -class CommandExecutorHandler(): +class CommandExecutorHandler: def __init__(self, request): self.request = request @@ -81,9 +81,17 @@ 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 } + try: 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: |