diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-04-12 18:52:29 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-04-16 10:38:51 -0400 |
commit | 5a47fe8d6a7c665db048e1959f484af297a74315 (patch) | |
tree | fa629210d02e2b37168d3846d210fc6e9f3443de /ms/command-executor/src/main/python/command_executor_server.py | |
parent | ee120a54f32d3643eefbef03ca0f4ca9c423e58b (diff) |
Add CommandExecutor handler
Change-Id: I7a4fbd13d11618ed6b2c85827ec2ced1cb65b31f
Issue-ID: CCCSDK-1215
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
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(): |