def post(self, request, *args, **kwargs): """ 回滚服务 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path - name: deploy_version description: 回滚的版本 required: true type: string paramType: form """ try: deploy_version = request.data.get("deploy_version", None) if not deploy_version: return Response(general_message(400, "deploy version is not found", "请指明回滚的版本"), status=400) allow_create, tips = app_service.verify_source( self.tenant, self.service.service_region, 0, "start_app") if not allow_create: return Response( general_message(412, "resource is not enough", "资源不足,无法回滚")) code, msg, event = app_manage_service.roll_back( self.tenant, self.service, self.user, deploy_version) bean = {} if event: bean = event.to_dict() bean["type_cn"] = event_service.translate_event_type( event.type) if code != 200: return Response(general_message(code, "roll back app error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except ResourceNotEnoughException as re: logger.exception(re) return Response(general_message(10406, "resource is not enough", re.message), status=412) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])
def post(self, request, *args, **kwargs): """ 回滚服务 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: serviceAlias description: 服务别名 required: true type: string paramType: path - name: deploy_version description: 回滚的版本 required: true type: string paramType: form """ try: deploy_version = request.data.get("deploy_version", None) upgrade_or_rollback = request.data.get("upgrade_or_rollback", None) if not deploy_version or not upgrade_or_rollback: return Response(general_message(400, "deploy version is not found", "请指明版本及操作类型"), status=400) allow_create, tips = app_service.verify_source( self.tenant, self.service.service_region, 0, "start_app") if not allow_create: return Response( general_message(412, "resource is not enough", "资源不足,无法操作")) code, msg = app_manage_service.roll_back(self.tenant, self.service, self.user, deploy_version, upgrade_or_rollback) bean = {} if code != 200: return Response(general_message(code, "roll back app error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except ResourceNotEnoughException as re: raise re except AccountOverdueException as re: logger.exception(re) return Response(general_message(10410, "resource is not enough", re.message), status=412) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])