From e790aba3e4b8e682f923f2f209966dcd4db5d4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sat, 10 Oct 2020 12:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0CPU=E7=BA=BF=E7=A8=8B?= =?UTF-8?q?=E6=95=B0=E5=92=8C=E4=BF=AE=E6=94=B9=E8=8A=82=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_dao.go | 5 ++++- internal/rpc/services/service_node.go | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index f890da05..7c44b131 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -103,7 +103,7 @@ func (this *NodeDAO) CreateNode(name string, clusterId int64) (nodeId int64, err } // 修改节点 -func (this *NodeDAO) UpdateNode(nodeId int64, name string, clusterId int64) error { +func (this *NodeDAO) UpdateNode(nodeId int64, name string, clusterId int64, maxCPU int32, isOn bool) error { if nodeId <= 0 { return errors.New("invalid nodeId") } @@ -112,6 +112,8 @@ func (this *NodeDAO) UpdateNode(nodeId int64, name string, clusterId int64) erro op.Name = name op.ClusterId = clusterId op.LatestVersion = dbs.SQL("latestVersion+1") + op.MaxCPU = maxCPU + op.IsOn = isOn _, err := this.Save(op) return err } @@ -395,6 +397,7 @@ func (this *NodeDAO) ComposeNodeConfig(nodeId int64) (*nodeconfigs.NodeConfig, e Servers: nil, Version: int64(node.Version), Name: node.Name, + MaxCPU: types.Int32(node.MaxCPU), } // 获取所有的服务 diff --git a/internal/rpc/services/service_node.go b/internal/rpc/services/service_node.go index 9a0c9959..9ac500d4 100644 --- a/internal/rpc/services/service_node.go +++ b/internal/rpc/services/service_node.go @@ -10,6 +10,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/configutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/logs" + "github.com/iwind/TeaGo/types" ) // 边缘节点相关服务 @@ -114,6 +115,8 @@ func (this *NodeService) ListEnabledNodesMatch(ctx context.Context, req *pb.List Name: clusterName, }, InstallStatus: installStatusResult, + MaxCPU: types.Int32(node.MaxCPU), + IsOn: node.IsOn == 1, }) } @@ -149,6 +152,8 @@ func (this *NodeService) FindAllEnabledNodesWithClusterId(ctx context.Context, r UniqueId: node.UniqueId, Secret: node.Secret, ConnectedAPINodeIds: apiNodeIds, + MaxCPU: types.Int32(node.MaxCPU), + IsOn: node.IsOn == 1, }) } return &pb.FindAllEnabledNodesWithClusterIdResponse{Nodes: result}, nil @@ -176,7 +181,7 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque return nil, err } - err = models.SharedNodeDAO.UpdateNode(req.NodeId, req.Name, req.ClusterId) + err = models.SharedNodeDAO.UpdateNode(req.NodeId, req.Name, req.ClusterId, req.MaxCPU, req.IsOn) if err != nil { return nil, err } @@ -271,6 +276,8 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable }, Login: respLogin, InstallStatus: installStatusResult, + MaxCPU: types.Int32(node.MaxCPU), + IsOn: node.IsOn == 1, }}, nil }