Files
EdgeAdmin/internal/web/actions/default/clusters/cluster/installManual.go

69 lines
1.7 KiB
Go
Raw Normal View History

2020-10-28 12:47:24 +08:00
package cluster
import (
"encoding/json"
2024-07-27 15:42:58 +08:00
2020-10-28 12:47:24 +08:00
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
type InstallManualAction struct {
actionutils.ParentAction
}
func (this *InstallManualAction) Init() {
this.Nav("", "node", "install")
this.SecondMenu("nodes")
}
func (this *InstallManualAction) RunGet(params struct {
ClusterId int64
}) {
2023-06-28 16:18:52 +08:00
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "manual", this.LangCode())
2020-10-28 12:47:24 +08:00
2021-05-25 17:48:51 +08:00
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithNodeClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
2020-10-28 12:47:24 +08:00
if err != nil {
this.ErrorPage(err)
return
}
nodeMaps := []maps.Map{}
for _, node := range nodesResp.Nodes {
loginParams := maps.Map{}
2021-08-11 20:59:58 +08:00
if node.NodeLogin != nil && len(node.NodeLogin.Params) > 0 {
err := json.Unmarshal(node.NodeLogin.Params, &loginParams)
2020-10-28 12:47:24 +08:00
if err != nil {
this.ErrorPage(err)
return
}
}
installStatus := maps.Map{
"isRunning": false,
"isFinished": false,
}
if node.InstallStatus != nil {
installStatus = maps.Map{
"isRunning": node.InstallStatus.IsRunning,
"isFinished": node.InstallStatus.IsFinished,
"isOk": node.InstallStatus.IsOk,
"error": node.InstallStatus.Error,
}
}
nodeMaps = append(nodeMaps, maps.Map{
"id": node.Id,
"isOn": node.IsOn,
"name": node.Name,
"addresses": node.IpAddresses,
2021-08-11 20:59:58 +08:00
"login": node.NodeLogin,
2020-10-28 12:47:24 +08:00
"loginParams": loginParams,
"installStatus": installStatus,
})
}
this.Data["nodes"] = nodeMaps
this.Show()
}