管理端全部功能跑通
This commit is contained in:
47
EdgeAPI/internal/db/models/node_task_dao_httpdns.go
Normal file
47
EdgeAPI/internal/db/models/node_task_dao_httpdns.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/iwind/TeaGo/dbs"
|
||||
)
|
||||
|
||||
// ExtractHTTPDNSClusterTask 分解HTTPDNS节点集群任务
|
||||
func (this *NodeTaskDAO) ExtractHTTPDNSClusterTask(tx *dbs.Tx, clusterId int64, taskType NodeTaskType) error {
|
||||
nodes, err := SharedHTTPDNSNodeDAO.ListEnabledNodes(tx, clusterId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = this.Query(tx).
|
||||
Attr("role", nodeconfigs.NodeRoleHTTPDNS).
|
||||
Attr("clusterId", clusterId).
|
||||
Gt("nodeId", 0).
|
||||
Attr("type", taskType).
|
||||
Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, node := range nodes {
|
||||
if !node.IsOn {
|
||||
continue
|
||||
}
|
||||
|
||||
err = this.CreateNodeTask(tx, nodeconfigs.NodeRoleHTTPDNS, clusterId, int64(node.Id), 0, 0, taskType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, err = this.Query(tx).
|
||||
Attr("role", nodeconfigs.NodeRoleHTTPDNS).
|
||||
Attr("clusterId", clusterId).
|
||||
Attr("nodeId", 0).
|
||||
Attr("type", taskType).
|
||||
Delete()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user