diff options
author | 2019-04-19 00:09:44 +0000 | |
---|---|---|
committer | 2019-04-19 00:09:44 +0000 | |
commit | cdaa0d3851ad758f02163af1a4fc2cfbb19eb9e2 (patch) | |
tree | 8677ba1410a54be9680fa61ffe5b0fc1f8769c29 /ms/command-executor/src/main/python/command_executor_server.py | |
parent | 3a00a565dc29f402d24bb67c63fc7c62e337a27d (diff) | |
parent | 5a47fe8d6a7c665db048e1959f484af297a74315 (diff) |
Merge "Add CommandExecutor handler"
Diffstat (limited to 'ms/command-executor/src/main/python/command_executor_server.py')
-rw-r--r-- | ms/command-executor/src/main/python/command_executor_server.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/ms/command-executor/src/main/python/command_executor_server.py b/ms/command-executor/src/main/python/command_executor_server.py index 35eed8e57..b62f15011 100644 --- a/ms/command-executor/src/main/python/command_executor_server.py +++ b/ms/command-executor/src/main/python/command_executor_server.py @@ -25,6 +25,8 @@ import grpc import proto.CommandExecutor_pb2_grpc as CommandExecutor_pb2_grpc from request_header_validator_interceptor import RequestHeaderValidatorInterceptor +from command_executor_handler import CommandExecutorHandler +import utils _ONE_DAY_IN_SECONDS = 60 * 60 * 24 @@ -32,10 +34,30 @@ _ONE_DAY_IN_SECONDS = 60 * 60 * 24 class CommandExecutorServer(CommandExecutor_pb2_grpc.CommandExecutorServiceServicer): def prepareEnv(self, request, context): - return + blueprint_id = utils.get_blueprint_id(request) + print("{} - Received prepareEnv request".format(blueprint_id)) + print (request) + + results = [] + handler = CommandExecutorHandler(request) + if not handler.prepare_env(request, results): + print("{} - Failed to prepare python environment. {}".format(blueprint_id, results)) + return utils.build_response(request, results, False) + print("{} - Package installation logs {}".format(blueprint_id, results)) + return utils.build_response(request, results) def executeCommand(self, request, context): - return + blueprint_id = utils.get_blueprint_id(request) + print("{} - Received executeCommand request".format(blueprint_id)) + print(request) + + results = [] + handler = CommandExecutorHandler(request) + if not handler.execute_command(request, results): + print("{} - Failed to executeCommand. {}".format(blueprint_id, results)) + return utils.build_response(request, results, False) + print("{} - Execute command logs: {}".format(blueprint_id, results)) + return utils.build_response(request, results) def serve(): |