mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-07 02:20:24 +08:00
实现CPU线程数和修改节点的启用状态
This commit is contained in:
@@ -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 {
|
if nodeId <= 0 {
|
||||||
return errors.New("invalid nodeId")
|
return errors.New("invalid nodeId")
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,8 @@ func (this *NodeDAO) UpdateNode(nodeId int64, name string, clusterId int64) erro
|
|||||||
op.Name = name
|
op.Name = name
|
||||||
op.ClusterId = clusterId
|
op.ClusterId = clusterId
|
||||||
op.LatestVersion = dbs.SQL("latestVersion+1")
|
op.LatestVersion = dbs.SQL("latestVersion+1")
|
||||||
|
op.MaxCPU = maxCPU
|
||||||
|
op.IsOn = isOn
|
||||||
_, err := this.Save(op)
|
_, err := this.Save(op)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -395,6 +397,7 @@ func (this *NodeDAO) ComposeNodeConfig(nodeId int64) (*nodeconfigs.NodeConfig, e
|
|||||||
Servers: nil,
|
Servers: nil,
|
||||||
Version: int64(node.Version),
|
Version: int64(node.Version),
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
|
MaxCPU: types.Int32(node.MaxCPU),
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有的服务
|
// 获取所有的服务
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"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,
|
Name: clusterName,
|
||||||
},
|
},
|
||||||
InstallStatus: installStatusResult,
|
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,
|
UniqueId: node.UniqueId,
|
||||||
Secret: node.Secret,
|
Secret: node.Secret,
|
||||||
ConnectedAPINodeIds: apiNodeIds,
|
ConnectedAPINodeIds: apiNodeIds,
|
||||||
|
MaxCPU: types.Int32(node.MaxCPU),
|
||||||
|
IsOn: node.IsOn == 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return &pb.FindAllEnabledNodesWithClusterIdResponse{Nodes: result}, nil
|
return &pb.FindAllEnabledNodesWithClusterIdResponse{Nodes: result}, nil
|
||||||
@@ -176,7 +181,7 @@ func (this *NodeService) UpdateNode(ctx context.Context, req *pb.UpdateNodeReque
|
|||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -271,6 +276,8 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
|||||||
},
|
},
|
||||||
Login: respLogin,
|
Login: respLogin,
|
||||||
InstallStatus: installStatusResult,
|
InstallStatus: installStatusResult,
|
||||||
|
MaxCPU: types.Int32(node.MaxCPU),
|
||||||
|
IsOn: node.IsOn == 1,
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user