def post(self, request, *args, **kwargs): serializer = AppServiceTelescopicHorizontalSerializer(data=request.data) serializer.is_valid(raise_exception=True) new_node = serializer.data.get("new_node") app_manage_service.horizontal_upgrade( self.team, self.service, self.user, int(new_node), oauth_instance=self.oauth_instance) return Response(None, status=200)
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: new_node description: 节点个数 required: true type: int paramType: form """ try: new_node = request.data.get("new_node", None) if not new_node: return Response(general_message(400, "node is null", "请选择节点个数"), status=400) app_manage_service.horizontal_upgrade( self.tenant, self.service, self.user, int(new_node), oauth_instance=self.oauth_instance) result = general_message(200, "success", "操作成功", bean={}) except ServiceHandleException as e: return Response( general_message(e.status_code, e.msg, e.msg_show), status=(400 if e.status_code > 599 else e.status_code)) 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) 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: new_node description: 节点个数 required: true type: int paramType: form """ try: new_node = request.data.get("new_node", None) if not new_node: return Response(general_message(400, "node is null", "请选择节点个数"), status=400) new_add_memory = (int(new_node) - self.service.min_node) * self.service.min_memory if new_add_memory < 0: new_add_memory = 0 allow_create, tips = app_service.verify_source(self.tenant, self.service.service_region, new_add_memory, "start_app") if not allow_create: return Response(general_message(412, "resource is not enough", "资源不足,无法升级")) code, msg, event = app_manage_service.horizontal_upgrade(self.tenant, self.service, self.user, int(new_node)) 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, "horizontal upgrade 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: new_node description: 节点个数 required: true type: int paramType: form """ try: new_node = request.data.get("new_node", None) if not new_node: return Response(general_message(400, "node is null", "请选择节点个数"), status=400) code, msg = app_manage_service.horizontal_upgrade( self.tenant, self.service, self.user, int(new_node)) bean = {} if code != 200: return Response(general_message(code, "horizontal upgrade 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) 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: new_node description: 节点个数 required: true type: int paramType: form """ try: new_node = request.data.get("new_node", None) if not new_node: return Response(general_message(400, "node is null", "请选择节点个数"), status=400) code, msg, event = app_manage_service.horizontal_upgrade( self.tenant, self.service, self.user, int(new_node)) 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, "horizontal upgrade error", msg, bean=bean), status=code) result = general_message(code, "success", "操作成功", bean=bean) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])