mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-07 07:55:48 +08:00
节点SSH登录自动使用集群设置
This commit is contained in:
@@ -198,7 +198,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
}
|
||||
|
||||
// UpdateCluster 修改集群
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool) error {
|
||||
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig, autoRemoteStart bool, autoInstallTables bool, sshParams *nodeconfigs.SSHParams) error {
|
||||
if clusterId <= 0 {
|
||||
return errors.New("invalid clusterId")
|
||||
}
|
||||
@@ -226,6 +226,14 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
|
||||
op.AutoRemoteStart = autoRemoteStart
|
||||
op.AutoInstallNftables = autoInstallTables
|
||||
|
||||
if sshParams != nil {
|
||||
sshParamsJSON, err := json.Marshal(sshParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
op.SshParams = sshParamsJSON
|
||||
}
|
||||
|
||||
err := this.Save(tx, op)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -454,6 +462,27 @@ func (this *NodeClusterDAO) FindClusterGrantId(tx *dbs.Tx, clusterId int64) (int
|
||||
FindInt64Col(0)
|
||||
}
|
||||
|
||||
// FindClusterSSHParams 查找集群的SSH默认参数
|
||||
func (this *NodeClusterDAO) FindClusterSSHParams(tx *dbs.Tx, clusterId int64) (*nodeconfigs.SSHParams, error) {
|
||||
sshParamsJSON, err := this.Query(tx).
|
||||
Pk(clusterId).
|
||||
Result("sshParams").
|
||||
FindJSONCol()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var params = nodeconfigs.DefaultSSHParams()
|
||||
if len(sshParamsJSON) == 0 {
|
||||
return params, nil
|
||||
}
|
||||
err = json.Unmarshal(sshParamsJSON, params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// FindClusterDNSInfo 查找DNS信息
|
||||
func (this *NodeClusterDAO) FindClusterDNSInfo(tx *dbs.Tx, clusterId int64, cacheMap *utils.CacheMap) (*NodeCluster, error) {
|
||||
var cacheKey = this.Table + ":FindClusterDNSInfo:" + types.String(clusterId)
|
||||
|
||||
@@ -15,6 +15,7 @@ type NodeCluster struct {
|
||||
Order uint32 `field:"order"` // 排序
|
||||
CreatedAt uint64 `field:"createdAt"` // 创建时间
|
||||
GrantId uint32 `field:"grantId"` // 默认认证方式
|
||||
SshParams dbs.JSON `field:"sshParams"` // SSH默认参数
|
||||
State uint8 `field:"state"` // 状态
|
||||
AutoRegister uint8 `field:"autoRegister"` // 是否开启自动注册
|
||||
UniqueId string `field:"uniqueId"` // 唯一ID
|
||||
@@ -53,6 +54,7 @@ type NodeClusterOperator struct {
|
||||
Order any // 排序
|
||||
CreatedAt any // 创建时间
|
||||
GrantId any // 默认认证方式
|
||||
SshParams any // SSH默认参数
|
||||
State any // 状态
|
||||
AutoRegister any // 是否开启自动注册
|
||||
UniqueId any // 唯一ID
|
||||
|
||||
Reference in New Issue
Block a user