mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-08 19:40:24 +08:00
实现删除集群
This commit is contained in:
@@ -729,6 +729,14 @@ func (this *ServerDAO) FindAllEnabledServersWithWebIds(webIds []int64) (result [
|
||||
return
|
||||
}
|
||||
|
||||
// 计算使用某个集群的所有服务数量
|
||||
func (this *ServerDAO) CountAllEnabledServersWithNodeClusterId(clusterId int64) (int64, error) {
|
||||
return this.Query().
|
||||
State(ServerStateEnabled).
|
||||
Attr("clusterId", clusterId).
|
||||
Count()
|
||||
}
|
||||
|
||||
// 创建事件
|
||||
func (this *ServerDAO) createEvent() error {
|
||||
return SharedSysEventDAO.CreateEvent(NewServerChangeEvent())
|
||||
|
||||
@@ -46,7 +46,7 @@ func (this *NodeClusterService) UpdateNodeCluster(ctx context.Context, req *pb.U
|
||||
}
|
||||
|
||||
// 禁用集群
|
||||
func (this *NodeClusterService) DisableNodeCluster(ctx context.Context, req *pb.DisableNodeClusterRequest) (*pb.DisableNodeClusterResponse, error) {
|
||||
func (this *NodeClusterService) DeleteNodeCluster(ctx context.Context, req *pb.DeleteNodeClusterRequest) (*pb.RPCDeleteSuccess, error) {
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -57,7 +57,7 @@ func (this *NodeClusterService) DisableNodeCluster(ctx context.Context, req *pb.
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.DisableNodeClusterResponse{}, nil
|
||||
return rpcutils.RPCDeleteSuccess()
|
||||
}
|
||||
|
||||
// 查找单个集群
|
||||
|
||||
@@ -718,3 +718,18 @@ func (this *ServerService) CountAllEnabledServersWithHTTPFirewallPolicyId(ctx co
|
||||
}
|
||||
return &pb.CountAllEnabledServersWithHTTPFirewallPolicyIdResponse{Count: countServers}, nil
|
||||
}
|
||||
|
||||
// 计算运行在某个集群上的所有服务数量
|
||||
func (this *ServerService) CountAllEnabledServersWithNodeClusterId(ctx context.Context, req *pb.CountAllEnabledServersWithNodeClusterIdRequest) (*pb.CountAllEnabledServersWithNodeClusterIdResponse, error) {
|
||||
// 校验请求
|
||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
count, err := models.SharedServerDAO.CountAllEnabledServersWithNodeClusterId(req.NodeClusterId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.CountAllEnabledServersWithNodeClusterIdResponse{Count: count}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user