def create_tenant_plugin(self, tenant, user_id, region, desc, plugin_alias, category, build_source, image, code_repo): plugin_id = make_uuid() if build_source == "dockerfile": if not code_repo: return 400, "代码仓库不能为空", None if build_source == "image": if not image: return 400, "镜像地址不能为空", None if category not in (PluginCategoryConstants.OUTPUT_INPUT_NET, PluginCategoryConstants.OUTPUT_NET, PluginCategoryConstants.INPUT_NET, PluginCategoryConstants.PERFORMANCE_ANALYSIS, PluginCategoryConstants.INIT_TYPE, PluginCategoryConstants.COMMON_TYPE): return 400, "插件类别参数不支持", None plugin_params = { "plugin_id": plugin_id, "tenant_id": tenant.tenant_id, "region": region, "create_user": user_id, "desc": desc, "plugin_name": "gr" + plugin_id[:6], "plugin_alias": plugin_alias, "category": category, "build_source": build_source, "image": image, "code_repo": code_repo } tenant_plugin = plugin_repo.create_plugin(**plugin_params) return 200, "success", tenant_plugin
def create_tenant_plugin(self, plugin_params): plugin_id = make_uuid() plugin_params["plugin_id"] = plugin_id plugin_params["plugin_name"] = "gr" + plugin_id[:6] if plugin_params["build_source"] == "dockerfile" and not plugin_params["code_repo"]: return 400, "代码仓库不能为空", None if plugin_params["build_source"] == "image" and not plugin_params["image"]: return 400, "镜像地址不能为空", None if plugin_params["category"] not in allow_plugins: return 400, "插件类别参数不支持", None tenant_plugin = plugin_repo.create_plugin(**plugin_params) return 200, "success", tenant_plugin