def create_service_plugin_relation(self, tenant_id, service_id, plugin_id, build_version, service_meta_type="", plugin_status=True): sprs = app_plugin_relation_repo.get_relation_by_service_and_plugin( service_id, plugin_id) if sprs: raise ServiceHandleException(msg="plugin has installed", status_code=409, msg_show="组件已安装该插件") plugin_version_info = plugin_version_repo.get_by_id_and_version( tenant_id, plugin_id, build_version) min_memory = plugin_version_info.min_memory min_cpu = plugin_version_info.min_cpu params = { "service_id": service_id, "build_version": build_version, "service_meta_type": service_meta_type, "plugin_id": plugin_id, "plugin_status": plugin_status, "min_memory": min_memory, "min_cpu": min_cpu, } return app_plugin_relation_repo.create_service_plugin_relation( **params)
def create_service_plugin_relation(self, service_id, plugin_id, build_version, service_meta_type, plugin_status): sprs = app_plugin_relation_repo.get_relation_by_service_and_plugin(service_id, plugin_id) if sprs: return 409, "应用已安装该插件", None params = { "service_id": service_id, "build_version": build_version, "service_meta_type": service_meta_type, "plugin_status": plugin_status } spr = app_plugin_relation_repo.create_service_plugin_relation(**params) return 200, "success", spr