def get(self, request, *args, **kwargs): """ 获取组件检测信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path - name: check_uuid description: 检测id required: true type: string paramType: query """ check_uuid = request.GET.get("check_uuid", None) if not check_uuid: return Response(general_message(400, "params error", "参数错误,请求参数应该包含请求的ID"), status=400) code, msg, data = app_check_service.get_service_check_info( self.tenant, self.service.service_region, check_uuid) # 如果已创建完成 if self.service.create_status == "complete": app_check_service.update_service_check_info( self.tenant, self.service, data) check_brief_info = app_check_service.wrap_service_check_info( self.service, data) return Response( general_message(200, "success", "请求成功", bean=check_brief_info)) if data["service_info"] and len(data["service_info"]) < 2: # No need to save env, ports and other information for multiple services here. logger.debug("start save check info ! {0}".format( self.service.create_status)) save_code, save_msg = app_check_service.save_service_check_info( self.tenant, self.service, data) if save_code != 200: data["check_status"] = "failure" save_error = { "error_type": "check info save error", "solve_advice": "修改相关信息后重新尝试", "error_info": "{}".format(save_msg) } if data["error_infos"]: data["error_infos"].append(save_error) else: data["error_infos"] = [save_error] check_brief_info = app_check_service.wrap_service_check_info( self.service, data) result = general_message(200, "success", "请求成功", bean=check_brief_info) return Response(result, status=result["code"])
def get(self, request, *args, **kwargs): """ 获取组件检测信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 组件别名 required: true type: string paramType: path - name: check_uuid description: 检测id required: true type: string paramType: query """ check_uuid = request.GET.get("check_uuid", None) if not check_uuid: return Response(general_message(400, "params error", "参数错误,请求参数应该包含请求的ID"), status=400) code, msg, data = app_check_service.get_service_check_info( self.tenant, self.service.service_region, check_uuid) # 如果已创建完成 if self.service.create_status == "complete": service_info = data.get("service_info") if service_info is not None and len( service_info) > 1 and service_info[0].get( "language") == "Java-maven": pass else: app_check_service.update_service_check_info( self.tenant, self.service, data) check_brief_info = app_check_service.wrap_service_check_info( self.service, data) return Response( general_message(200, "success", "请求成功", bean=check_brief_info)) if data["service_info"] and len(data["service_info"]) < 2: # No need to save env, ports and other information for multiple services here. logger.debug("start save check info ! {0}".format( self.service.create_status)) save_code, save_msg = app_check_service.save_service_check_info( self.tenant, self.service, data) if save_code != 200: data["check_status"] = "failure" save_error = { "error_type": "check info save error", "solve_advice": "修改相关信息后重新尝试", "error_info": "{}".format(save_msg) } if data["error_infos"]: data["error_infos"].append(save_error) else: data["error_infos"] = [save_error] check_brief_info = app_check_service.wrap_service_check_info( self.service, data) code_from = self.service.code_from if code_from in support_oauth_type.keys(): for i in check_brief_info["service_info"]: if i["type"] == "source_from": result_url = re_spilt("[:,@]", i["value"]) if len(result_url) != 2: i["value"] = result_url[0] + '//' + result_url[ -2] + result_url[-1] result = general_message(200, "success", "请求成功", bean=check_brief_info) return Response(result, status=result["code"])
def get(self, request, *args, **kwargs): """ 获取服务检测信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path - name: check_uuid description: 检测id required: true type: string paramType: query """ sid = None try: check_uuid = request.GET.get("check_uuid", None) if not check_uuid: return Response(general_message(400, "params error", "参数错误,请求参数应该包含请求的ID"), status=400) code, msg, data = app_check_service.get_service_check_info( self.tenant, self.service.service_region, check_uuid) # 如果已创建完成 if self.service.create_status == "complete": check_brief_info = app_check_service.wrap_service_check_info( self.service, data) return Response( general_message(200, "success", "请求成功", bean=check_brief_info)) # 开启保存点 sid = transaction.savepoint() logger.debug("start save check info ! {0}".format( self.service.create_status)) save_code, save_msg = app_check_service.save_service_check_info( self.tenant, self.service, data) if save_code != 200: transaction.savepoint_rollback(sid) data["check_status"] = "failure" save_error = { "error_type": "check info save error", "solve_advice": "修改相关信息后重新尝试", "error_info": "{}".format(save_msg) } if data["error_infos"]: data["error_infos"].append(save_error) else: data["error_infos"] = [save_error] else: transaction.savepoint_commit(sid) logger.debug("check result = {0}".format(data)) check_brief_info = app_check_service.wrap_service_check_info( self.service, data) result = general_message(200, "success", "请求成功", bean=check_brief_info) except Exception as e: logger.exception(e) result = error_message(e.message) if sid: transaction.savepoint_rollback(sid) return Response(result, status=result["code"])