def delete(self, req, app_id, *args, **kwargs): msg_list = [] try: force = int(req.GET.get("force", 0)) except ValueError: raise ServiceHandleException(msg='force value error', msg_show=u"参数错误") service_ids = app_service.get_group_services_by_id(self.app.ID) services = service_repo.get_services_by_service_ids(service_ids) if services: status_list = base_service.status_multi_service( region=self.app.region_name, tenant_name=self.team.tenant_name, service_ids=service_ids, enterprise_id=self.team.enterprise_id) status_list = filter(lambda x: x not in ["closed", "undeploy"], map(lambda x: x["status"], status_list)) if len(status_list) > 0: raise ServiceHandleException( msg= "There are running components under the current application", msg_show=u"当前应用下有运行态的组件,不可删除") else: code_status = 200 for service in services: code, msg = app_manage_service.batch_delete(self.user, self.team, service, is_force=True) msg_dict = dict() msg_dict['status'] = code msg_dict['msg'] = msg msg_dict['service_id'] = service.service_id msg_dict['service_cname'] = service.service_cname msg_list.append(msg_dict) if code != 200: code_status = code if force: code_status = 200 app_manage_service.delete_again(self.user, self.team, service, is_force=True) if code_status != 200: raise ServiceHandleException(msg=msg_list, msg_show=u"请求错误") else: code, msg, data = group_service.delete_group_no_service( self.app.ID) if code != 200: raise ServiceHandleException(msg=msg, msg_show=u"请求错误") return Response(None, status=code) code, msg, data = group_service.delete_group_no_service(self.app.ID) if code != 200: raise ServiceHandleException(msg=msg, msg_show=u"请求错误") return Response(None, status=code)
def delete(self, request, app_id, *args, **kwargs): """ 删除应用 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: group_id description: 组id required: true type: string paramType: path """ service = group_service_relation_repo.get_service_by_group(app_id) if not service: code, msg, data = group_service.delete_group_no_service(app_id) else: code = 400 msg = '当前应用内存在组件,无法删除' result = general_message(code, msg, None) return Response(result, status=result["code"]) if code != 200: result = general_message(code, "delete group error", msg) else: result = general_message(code, "success", msg) return Response(result, status=result["code"])
def delete(self, request, *args, **kwargs): """ 删除组信息 --- parameters: - name: tenantName description: 租户名 required: true type: string paramType: path - name: group_id description: 组id required: true type: string paramType: path """ try: group_id = int(kwargs.get("group_id", None)) service = group_service_relation_repo.get_service_by_group( group_id) group_object = group_repo.get_group_by_id(group_id) if group_object.is_default: result = general_message(400, "默认应用不允许删除", None) return Response(result, status=result["code"]) if not service: code, msg, data = group_service.delete_group_no_service( group_id) else: code = 400 msg = '当前组内有应用,无法删除' result = general_message(code, msg, None) return Response(result, status=result["code"]) if code != 200: result = general_message(code, "delete group error", msg) else: result = general_message(code, "success", msg) except Exception as e: logger.exception(e) result = error_message(e.message) return Response(result, status=result["code"])