summaryrefslogtreecommitdiffstats
path: root/ms/command-executor/src/main/python/utils.py
diff options
context:
space:
mode:
authorOleg Mitsura <oleg.mitsura@amdocs.com>2020-01-29 23:39:49 -0500
committerDan Timoney <dtimoney@att.com>2020-04-09 12:46:12 +0000
commit189661821e0782434dc473788492c884a5086936 (patch)
tree4f7803ecff1d671a6745472df37ac4ca30a5bc80 /ms/command-executor/src/main/python/utils.py
parent0466d6807e71c7c443f60e340445927194c0ee39 (diff)
Improving CMD-exec err msgs/handling.
Issue-ID: CCSDK-2049 rev1. initial commit rev2. added better logging/passing errors. rev3. bugfixes rev4. bugfix for CommandExecutorServer.prepareEnv return status was still returning bool. (was caught only during a defective mariadb pip package install!) Signed-off-by: Oleg Mitsura <oleg.mitsura@amdocs.com> Change-Id: Ifbddaeb0e15857f42b121af10e30e29dec5c20b2 (cherry picked from commit 6f18499858e224a53086a049917037029e6267ee)
Diffstat (limited to 'ms/command-executor/src/main/python/utils.py')
-rw-r--r--ms/command-executor/src/main/python/utils.py41
1 files changed, 26 insertions, 15 deletions
diff --git a/ms/command-executor/src/main/python/utils.py b/ms/command-executor/src/main/python/utils.py
index a3748eb17..574be51db 100644
--- a/ms/command-executor/src/main/python/utils.py
+++ b/ms/command-executor/src/main/python/utils.py
@@ -18,23 +18,34 @@ 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
- blueprint_version = request.identifiers.blueprintVersion
- return blueprint_name + '/' + blueprint_version
+ blueprint_name = request.identifiers.blueprintName
+ blueprint_version = request.identifiers.blueprintVersion
+ return blueprint_name + '/' + blueprint_version
+# Create a response for grpc. Fills in the timestamp as well as removes cds_is_successful element
+def build_grpc_response(request, log_results, payload_return, is_success=False):
+ if is_success:
+ status = CommandExecutor_pb2.SUCCESS
+ else:
+ status = CommandExecutor_pb2.FAILURE
-def build_response(request, log_results, payload_return, is_success=False):
- if is_success:
- status = CommandExecutor_pb2.SUCCESS
- else:
- status = CommandExecutor_pb2.FAILURE
+ timestamp = Timestamp()
+ timestamp.GetCurrentTime()
- timestamp = Timestamp()
- timestamp.GetCurrentTime()
+ if "cds_is_successful" in payload_return:
+ payload_return.pop('cds_is_successful')
+ payload_str = json.dumps(payload_return)
+ return CommandExecutor_pb2.ExecutionOutput(requestId=request.requestId,
+ response=log_results,
+ status=status,
+ payload=payload_str,
+ 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)
+# build a return data structure which may contain an error message
+def build_ret_data(cds_is_successful, err_msg):
+ ret_data = {"cds_is_successful": cds_is_successful }
+ if err_msg != "":
+ ret_data["err_msg"] = err_msg
+ return ret_data