mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 15:00:27 +08:00
可以在集群中查看待安装节点、并直接安装节点
This commit is contained in:
@@ -376,21 +376,33 @@ func (this *NodeDAO) UpdateNodeIsInstalled(nodeId int64, isInstalled bool) error
|
||||
|
||||
// 查询节点的安装状态
|
||||
func (this *NodeDAO) FindNodeInstallStatus(nodeId int64) (*NodeInstallStatus, error) {
|
||||
installStatus, err := this.Query().
|
||||
node, err := this.Query().
|
||||
Pk(nodeId).
|
||||
Result("installStatus").
|
||||
FindStringCol("")
|
||||
Result("installStatus", "isInstalled").
|
||||
Find()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if node == nil {
|
||||
return nil, errors.New("not found")
|
||||
}
|
||||
|
||||
installStatus := node.(*Node).InstallStatus
|
||||
isInstalled := node.(*Node).IsInstalled == 1
|
||||
if len(installStatus) == 0 {
|
||||
return NewNodeInstallStatus(), nil
|
||||
}
|
||||
|
||||
status := &NodeInstallStatus{}
|
||||
err = json.Unmarshal([]byte(installStatus), status)
|
||||
return status, err
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if isInstalled {
|
||||
status.IsFinished = true
|
||||
status.IsOk = true
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
|
||||
// 修改节点的安装状态
|
||||
@@ -524,6 +536,18 @@ func (this *NodeDAO) FindAllEnabledNodesWithGrantId(grantId int64) (result []*No
|
||||
return
|
||||
}
|
||||
|
||||
// 查找所有未安装的节点
|
||||
func (this *NodeDAO) FindAllNotInstalledNodesWithClusterId(clusterId int64) (result []*Node, err error) {
|
||||
_, err = this.Query().
|
||||
State(NodeStateEnabled).
|
||||
Attr("clusterId", clusterId).
|
||||
Attr("isInstalled", false).
|
||||
DescPk().
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
}
|
||||
|
||||
// 生成唯一ID
|
||||
func (this *NodeDAO) genUniqueId() (string, error) {
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user