mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-10 20:40:56 +08:00
提供查询某集群未安装的节点数量的API
This commit is contained in:
@@ -656,6 +656,15 @@ func (this *NodeDAO) FindAllEnabledNodesWithGrantId(tx *dbs.Tx, grantId int64) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算未安装的节点数量
|
||||||
|
func (this *NodeDAO) CountAllNotInstalledNodesWithClusterId(tx *dbs.Tx, clusterId int64) (int64, error) {
|
||||||
|
return this.Query(tx).
|
||||||
|
State(NodeStateEnabled).
|
||||||
|
Attr("clusterId", clusterId).
|
||||||
|
Attr("isInstalled", false).
|
||||||
|
Count()
|
||||||
|
}
|
||||||
|
|
||||||
// 查找所有未安装的节点
|
// 查找所有未安装的节点
|
||||||
func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(tx *dbs.Tx, clusterId int64) (result []*Node, err error) {
|
func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(tx *dbs.Tx, clusterId int64) (result []*Node, err error) {
|
||||||
_, err = this.Query(tx).
|
_, err = this.Query(tx).
|
||||||
|
|||||||
@@ -733,10 +733,23 @@ func (this *NodeService) FindAllEnabledNodesWithGrantId(ctx context.Context, req
|
|||||||
return &pb.FindAllEnabledNodesWithGrantIdResponse{Nodes: result}, nil
|
return &pb.FindAllEnabledNodesWithGrantIdResponse{Nodes: result}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 计算没有安装的节点数量
|
||||||
|
func (this *NodeService) CountAllNotInstalledNodesWithClusterId(ctx context.Context, req *pb.CountAllNotInstalledNodesWithClusterIdRequest) (*pb.RPCCountResponse, error) {
|
||||||
|
_, err := this.ValidateAdmin(ctx, 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tx := this.NullTx()
|
||||||
|
count, err := models.SharedNodeDAO.CountAllNotInstalledNodesWithClusterId(tx, req.NodeClusterId)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return this.SuccessCount(count)
|
||||||
|
}
|
||||||
|
|
||||||
// 列出所有未安装的节点
|
// 列出所有未安装的节点
|
||||||
func (this *NodeService) FindAllNotInstalledNodesWithClusterId(ctx context.Context, req *pb.FindAllNotInstalledNodesWithClusterIdRequest) (*pb.FindAllNotInstalledNodesWithClusterIdResponse, error) {
|
func (this *NodeService) FindAllNotInstalledNodesWithClusterId(ctx context.Context, req *pb.FindAllNotInstalledNodesWithClusterIdRequest) (*pb.FindAllNotInstalledNodesWithClusterIdResponse, error) {
|
||||||
// 校验请求
|
_, err := this.ValidateAdmin(ctx, 0)
|
||||||
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user