mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 16:50:26 +08:00
实现远程升级节点
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type UpgradeRemoteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *UpgradeRemoteAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *UpgradeRemoteAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "upgrade")
|
||||
|
||||
nodes := []maps.Map{}
|
||||
resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithClusterIdRequest{ClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
for _, node := range resp.Nodes {
|
||||
loginParams := maps.Map{}
|
||||
if node.Node.Login != nil && len(node.Node.Login.Params) > 0 {
|
||||
err := json.Unmarshal(node.Node.Login.Params, &loginParams)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
nodes = append(nodes, maps.Map{
|
||||
"id": node.Node.Id,
|
||||
"name": node.Node.Name,
|
||||
"os": node.Os,
|
||||
"arch": node.Arch,
|
||||
"oldVersion": node.OldVersion,
|
||||
"newVersion": node.NewVersion,
|
||||
"login": node.Node.Login,
|
||||
"loginParams": loginParams,
|
||||
"addresses": node.Node.IpAddresses,
|
||||
"installStatus": node.Node.InstallStatus,
|
||||
})
|
||||
}
|
||||
this.Data["nodes"] = nodes
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *UpgradeRemoteAction) RunPost(params struct {
|
||||
NodeId int64
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
_, err := this.RPC().NodeRPC().UpgradeNode(this.AdminContext(), &pb.UpgradeNodeRequest{NodeId: params.NodeId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
Reference in New Issue
Block a user