예제 #1
0
 def get(self, request, *args, **kwargs):
     """获取插件信息"""
     plugin_id = request.GET.get("plugin_id")
     build_version = request.GET.get("build_version")
     if not plugin_id or not build_version:
         logger.error("plugin.relation", u'参数错误,plugin_id and version_id')
         data = {"success": False, "code": 405, 'msg': u'参数错误'}
         data = oldResultSuitGeneralMessage(data, "params error", "")
         return JsonResponse(data, status=200)
     result = {}
     result["config_group"] = self.useDefaultAttr(plugin_id, build_version,
                                                  "get")
     build_relations = plugin_svc.get_tenant_service_plugin_relation_by_plugin(
         self.service.service_id, plugin_id)
     version_info = plugin_svc.getPluginMetaType(plugin_id, build_version)
     bl = {}
     bl["create_time"] = build_relations[0].create_time
     bl["build_info"] = version_info.update_info
     bl["memory"] = version_info.min_memory
     result["build_version"] = bl
     result["success"] = True
     result["code"] = 200
     result["msg"] = u"操作成功"
     result = general_message(200, "success", u"操作成功",
                              result["build_version"],
                              result["config_group"])
     return JsonResponse(result, status=200)
예제 #2
0
 def get(self, request, plugin_id, *args, **kwargs):
     """
     应用插件查看配置
     ---
     parameters:
         - name: tenantName
           description: 租户名
           required: true
           type: string
           paramType: path
         - name: serviceAlias
           description: 服务别名
           required: true
           type: string
           paramType: path
         - name: plugin_id
           description: 插件ID
           required: true
           type: string
           paramType: path
         - name: build_version
           description: 插件版本
           required: true
           type: string
           paramType: path
     """
     build_version = request.GET.get("build_version", None)
     if not plugin_id or not build_version:
         logger.error("plugin.relation", u'参数错误,plugin_id and version_id')
         return Response(general_message(400, "params error", "参数错误"), status=400)
     result = {}
     try:
         result["config_group"] = self.useDefaultAttr(plugin_id, build_version, "get")
         build_relations = plugin_svc.get_tenant_service_plugin_relation_by_plugin(self.service.service_id,
                                                                                   plugin_id)
         version_info = plugin_svc.getPluginMetaType(plugin_id, build_version)
         bl = {}
         bl["create_time"] = build_relations[0].create_time
         bl["build_info"] = version_info.update_info
         bl["memory"] = version_info.min_memory
         result["build_version"] = bl
         result["success"] = True
         result["code"] = 200
         result["msg"] = u"操作成功"
         result = general_message(200, "success", u"操作成功", result["build_version"], result["config_group"])
         return Response(result, status=200)
     except HasNoDownStreamService as e:
         logger.error("service has no dependence services operation suspend")
         return Response(general_message(409, "service has no dependence", "应用没有依赖其他应用,配置无效"),status=409)
     except Exception as e:
         logger.exception(e)
         result = error_message(e.message)
         return Response(result, result["code"])