def create_build_version(self, region, plugin_id, tenant_id, user_id, update_info, build_status, min_memory, build_cmd="", image_tag="latest", code_version="master", build_version=None): """创建插件版本信息""" min_cpu = self.calculate_cpu(region, int(min_memory)) if not build_version: build_version = datetime.datetime.now().strftime('%Y%m%d%H%M%S') build_version_params = { "plugin_id": plugin_id, "tenant_id": tenant_id, "region": region, "user_id": user_id, "update_info": update_info, "build_version": build_version, "build_status": build_status, "min_memory": min_memory, "min_cpu": min_cpu, "build_cmd": build_cmd, "image_tag": image_tag, "code_version": code_version, } return plugin_version_repo.create_plugin_build_version( **build_version_params)
def copy_build_version_info(self, plugin_id, old_version, new_version): old_build_version = plugin_version_repo.get_by_id_and_version(plugin_id, old_version) old_dict = model_to_dict(old_build_version) old_dict["build_status"] = "unbuild" old_dict["event_id"] = "" # 剔除主键 old_dict.pop("ID") old_dict["build_version"] = new_version return plugin_version_repo.create_plugin_build_version(**old_dict)