mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-01-02 09:06:37 +08:00
可以批量远程安装和升级节点
This commit is contained in:
@@ -19,7 +19,7 @@ func (this *InstallManualAction) Init() {
|
||||
func (this *InstallManualAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "manual")
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "manual")
|
||||
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
|
||||
@@ -19,7 +19,7 @@ func (this *InstallNodesAction) Init() {
|
||||
func (this *InstallNodesAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "register")
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "register")
|
||||
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *InstallRemoteAction) Init() {
|
||||
func (this *InstallRemoteAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "install")
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "install")
|
||||
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
@@ -34,6 +34,7 @@ func (this *StatusAction) RunPost(params struct {
|
||||
"isOk": node.InstallStatus.IsOk,
|
||||
"updatedAt": node.InstallStatus.UpdatedAt,
|
||||
"error": node.InstallStatus.Error,
|
||||
"errorCode": node.InstallStatus.ErrorCode,
|
||||
}
|
||||
} else {
|
||||
this.Data["installStatus"] = nil
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *UpgradeRemoteAction) Init() {
|
||||
func (this *UpgradeRemoteAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "upgrade")
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(this.AdminContext(), params.ClusterId, "upgrade")
|
||||
|
||||
nodes := []maps.Map{}
|
||||
resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
|
||||
@@ -1,12 +1,34 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// 安装升级相关的左侧菜单
|
||||
func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
|
||||
func LeftMenuItemsForInstall(ctx context.Context, clusterId int64, selectedItem string) []maps.Map {
|
||||
rpcClient, _ := rpc.SharedRPC()
|
||||
countNotInstalled := int64(0)
|
||||
countUpgrade := int64(0)
|
||||
if rpcClient != nil {
|
||||
{
|
||||
resp, err := rpcClient.NodeRPC().CountAllNotInstalledNodesWithClusterId(ctx, &pb.CountAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: clusterId})
|
||||
if err == nil {
|
||||
countNotInstalled = resp.Count
|
||||
}
|
||||
}
|
||||
{
|
||||
resp, err := rpcClient.NodeRPC().CountAllUpgradeNodesWithClusterId(ctx, &pb.CountAllUpgradeNodesWithClusterIdRequest{NodeClusterId: clusterId})
|
||||
if err == nil {
|
||||
countUpgrade = resp.Count
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return []maps.Map{
|
||||
{
|
||||
"name": "手动安装",
|
||||
@@ -19,12 +41,12 @@ func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
|
||||
"isActive": selectedItem == "register",
|
||||
},
|
||||
{
|
||||
"name": "远程安装",
|
||||
"name": "远程安装(" + strconv.FormatInt(countNotInstalled, 10) + ")",
|
||||
"url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(clusterId),
|
||||
"isActive": selectedItem == "install",
|
||||
},
|
||||
{
|
||||
"name": "远程升级",
|
||||
"name": "远程升级(" + strconv.FormatInt(countUpgrade, 10) + ")",
|
||||
"url": "/clusters/cluster/upgradeRemote?clusterId=" + numberutils.FormatInt64(clusterId),
|
||||
"isActive": selectedItem == "upgrade",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user