mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-29 01:06:36 +08:00
可以在集群中查看待安装节点、并直接安装节点
This commit is contained in:
@@ -171,6 +171,19 @@ func (this *APINodeDAO) FindAllEnabledAPINodes() (result []*APINode, err error)
|
||||
return
|
||||
}
|
||||
|
||||
// 列出所有可用而且启用的API节点
|
||||
func (this *APINodeDAO) FindAllEnabledAndOnAPINodes() (result []*APINode, err error) {
|
||||
_, err = this.Query().
|
||||
Attr("clusterId", 0). // 非集群专用
|
||||
Attr("isOn", true).
|
||||
State(APINodeStateEnabled).
|
||||
Desc("order").
|
||||
AscPk().
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
}
|
||||
|
||||
// 计算API节点数量
|
||||
func (this *APINodeDAO) CountAllEnabledAPINodes() (int64, error) {
|
||||
return this.Query().
|
||||
|
||||
@@ -268,6 +268,14 @@ func (this *NodeClusterDAO) FindAllEnabledClustersWithGrantId(grantId int64) (re
|
||||
return
|
||||
}
|
||||
|
||||
// 查找集群的认证ID
|
||||
func (this *NodeClusterDAO) FindClusterGrantId(clusterId int64) (int64, error) {
|
||||
return this.Query().
|
||||
Pk(clusterId).
|
||||
Result("grantId").
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// 生成唯一ID
|
||||
func (this *NodeClusterDAO) genUniqueId() (string, error) {
|
||||
for {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -6,6 +6,7 @@ type NodeInstallStatus struct {
|
||||
IsFinished bool `json:"isFinished"` // 是否已结束
|
||||
IsOk bool `json:"isOk"` // 是否正确安装
|
||||
Error string `json:"error"` // 错误信息
|
||||
ErrorCode string `json:"errorCode"` // 错误代号
|
||||
UpdatedAt int64 `json:"updatedAt"` // 更新时间,安装过程中需要每隔N秒钟更新这个状态,以便于让系统知道安装仍在进行中
|
||||
Steps []*NodeInstallStatusStep `json:"steps"` // 步骤
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user