def executeCommand(self, request, context): blueprint_id = utils.get_blueprint_id(request) self.logger.info("{} - Received executeCommand request".format(blueprint_id)) self.logger.info(request) results = [] handler = CommandExecutorHandler(request) if not handler.execute_command(request, results): self.logger.info("{} - Failed to executeCommand. {}".format(blueprint_id, results)) return utils.build_response(request, results, False) self.logger.info("{} - Execution finished successfully.".format(blueprint_id)) return utils.build_response(request, results)
def prepareEnv(self, request, context): blueprint_id = utils.get_blueprint_id(request) self.logger.info("{} - Received prepareEnv request".format(blueprint_id)) self.logger.info(request) results = [] handler = CommandExecutorHandler(request) if not handler.prepare_env(request, results): self.logger.info("{} - Failed to prepare python environment. {}".format(blueprint_id, results)) return utils.build_response(request, results, False) self.logger.info("{} - Package installation logs {}".format(blueprint_id, results)) return utils.build_response(request, results)
def prepareEnv(self, request, context): blueprint_id = utils.get_blueprint_id(request) extra = utils.getExtraLogData(request) self.logger.info("{} - Received prepareEnv request".format(blueprint_id), extra=extra) self.logger.info(request, extra=extra) handler = CommandExecutorHandler(request) prepare_env_response = handler.prepare_env(request) if prepare_env_response[utils.CDS_IS_SUCCESSFUL_KEY]: self.logger.info("{} - Package installation logs {}".format(blueprint_id, prepare_env_response[utils.RESULTS_LOG_KEY]), extra=extra) else: self.logger.info("{} - Failed to prepare python environment. {}".format(blueprint_id, prepare_env_response[utils.ERR_MSG_KEY]), extra=extra) self.logger.info("Prepare Env Response returned : %s" % prepare_env_response, extra=extra) return utils.build_grpc_response(request.requestId, prepare_env_response)
def executeCommand(self, request, context): blueprint_id = utils.get_blueprint_id(request) extra = utils.getExtraLogData(request) self.logger.info("{} - Received executeCommand request".format(blueprint_id), extra=extra) if os.environ.get('CE_DEBUG','false') == "true": self.logger.info(request, extra=extra) handler = CommandExecutorHandler(request) exec_cmd_response = handler.execute_command(request) if exec_cmd_response[utils.CDS_IS_SUCCESSFUL_KEY]: self.logger.info("{} - Execution finished successfully.".format(blueprint_id), extra=extra) else: self.logger.info("{} - Failed to executeCommand. {}".format(blueprint_id, exec_cmd_response[utils.RESULTS_LOG_KEY]), extra=extra) ret = utils.build_grpc_response(request.requestId, exec_cmd_response) self.logger.info("Payload returned : {}".format(exec_cmd_response), extra=extra) return ret
def executeCommand(self, request, context): blueprint_id = utils.get_blueprint_id(request) self.logger.info( "{} - Received executeCommand request".format(blueprint_id)) if os.environ.get('CE_DEBUG', 'false') == "true": self.logger.info(request) log_results = [] payload_result = {} handler = CommandExecutorHandler(request) payload_result = handler.execute_command(request, log_results) if payload_result["cds_return_code"] != 0: self.logger.info("{} - Failed to executeCommand. {}".format( blueprint_id, log_results)) else: self.logger.info( "{} - Execution finished successfully.".format(blueprint_id)) ret = utils.build_response(request, log_results, payload_result, payload_result["cds_return_code"] == 0) self.logger.info("Payload returned %s" % payload_result) return ret
def __init__(self, request): self.request = request self.logger = logging.getLogger(self.__class__.__name__) self.blueprint_id = utils.get_blueprint_id(request) self.venv_home = '/opt/app/onap/blueprints/deploy/' + self.blueprint_id self.installed = self.venv_home + '/.installed'