aboutsummaryrefslogtreecommitdiffstats
path: root/ms/command-executor/src/main/python/utils.py
diff options
context:
space:
mode:
authorSerge Simard <serge@agilitae.com>2019-10-24 01:42:27 -0400
committerSerge Simard <serge@agilitae.com>2019-10-24 01:45:31 -0400
commit35ab81bb9ff203e14116de10bc2735ffb2883f67 (patch)
tree574ff6ea87e099971bc41184cafbc72638b0bf4a /ms/command-executor/src/main/python/utils.py
parent4433fa9514ed0a031b797367a0daa9aea611d138 (diff)
Improve Remote Python Executor error handling and allow for structured response
Issue-ID: CCSDK-1855 Signed-off-by: Serge Simard <serge@agilitae.com> Change-Id: I924918fb06a5a0f118772dedaa41c536c7eca9e7 Signed-off-by: Serge Simard <serge@agilitae.com>
Diffstat (limited to 'ms/command-executor/src/main/python/utils.py')
-rw-r--r--ms/command-executor/src/main/python/utils.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ms/command-executor/src/main/python/utils.py b/ms/command-executor/src/main/python/utils.py
index 4314b287d..a3748eb17 100644
--- a/ms/command-executor/src/main/python/utils.py
+++ b/ms/command-executor/src/main/python/utils.py
@@ -16,7 +16,7 @@
from google.protobuf.timestamp_pb2 import Timestamp
import proto.CommandExecutor_pb2 as CommandExecutor_pb2
-
+import json
def get_blueprint_id(request):
blueprint_name = request.identifiers.blueprintName
@@ -24,7 +24,7 @@ def get_blueprint_id(request):
return blueprint_name + '/' + blueprint_version
-def build_response(request, results, is_success=True):
+def build_response(request, log_results, payload_return, is_success=False):
if is_success:
status = CommandExecutor_pb2.SUCCESS
else:
@@ -32,5 +32,9 @@ def build_response(request, results, is_success=True):
timestamp = Timestamp()
timestamp.GetCurrentTime()
- return CommandExecutor_pb2.ExecutionOutput(requestId=request.requestId, response=results, status=status,
- timestamp=timestamp)
+
+ if 'cds_return_code' in payload_return:
+ payload_return.pop('cds_return_code')
+ payload_str = json.dumps(payload_return)
+ return CommandExecutor_pb2.ExecutionOutput(requestId=request.requestId, response=log_results, status=status,
+ payload=payload_str, timestamp=timestamp)