节点SSH登录自动使用集群设置

This commit is contained in:
GoEdgeLab
2022-10-26 19:23:50 +08:00
parent 9474d6d45e
commit 655a09ace0
3 changed files with 34 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err)
return
}
grant := grantResp.NodeGrant
var grant = grantResp.NodeGrant
if grant != nil {
grantMap = maps.Map{
"id": grant.Id,
@@ -79,6 +79,16 @@ func (this *IndexAction) RunGet(params struct {
}
}
// SSH参数
var sshParams = nodeconfigs.DefaultSSHParams()
if len(cluster.SshParamsJSON) > 0 {
err = json.Unmarshal(cluster.SshParamsJSON, sshParams)
if err != nil {
this.ErrorPage(err)
return
}
}
this.Data["cluster"] = maps.Map{
"id": cluster.Id,
"name": cluster.Name,
@@ -89,6 +99,7 @@ func (this *IndexAction) RunGet(params struct {
"clock": clockConfig,
"autoRemoteStart": cluster.AutoRemoteStart,
"autoInstallNftables": cluster.AutoInstallNftables,
"sshParams": sshParams,
}
// 默认值
@@ -104,6 +115,7 @@ func (this *IndexAction) RunPost(params struct {
ClusterId int64
Name string
GrantId int64
SshParamsPort int
InstallDir string
TimeZone string
NodeMaxThreads int32
@@ -129,6 +141,16 @@ func (this *IndexAction) RunPost(params struct {
Lte(int64(nodeconfigs.DefaultMaxThreadsMax), "单节点最大线程数最大值不能大于"+types.String(nodeconfigs.DefaultMaxThreadsMax))
}
// ssh
var sshParams = nodeconfigs.DefaultSSHParams()
sshParams.Port = params.SshParamsPort
sshParamsJSON, err := json.Marshal(sshParams)
if err != nil {
this.ErrorPage(err)
return
}
// clock
var clockConfig = nodeconfigs.DefaultClockConfig()
clockConfig.AutoSync = params.ClockAutoSync
clockConfig.Server = params.ClockServer
@@ -155,6 +177,7 @@ func (this *IndexAction) RunPost(params struct {
ClockJSON: clockConfigJSON,
AutoRemoteStart: params.AutoRemoteStart,
AutoInstallNftables: params.AutoInstallNftables,
SshParamsJSON: sshParamsJSON,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -175,7 +175,7 @@
<h3>运行状态</h3>
<table class="ui table definition selectable">
<tr>
<td class="title">是否在运行</td>
<td class="title">运行状态</td>
<td>
<div v-if="node.status.isActive">
<span class="green">运行中</span> &nbsp;

View File

@@ -11,10 +11,17 @@
<td><input type="text" name="name" maxlength="50" ref="focus" v-model="cluster.name"/></td>
</tr>
<tr>
<td>默认SSH登录方式</td>
<td>默认SSH认证</td>
<td>
<grant-selector :v-grant="grant"></grant-selector>
<p class="comment">当节点没有单独设置SSH登录方式时,默认使用此设置。</p>
<p class="comment">当节点没有单独设置SSH认证时,默认使用此设置。</p>
</td>
</tr>
<tr>
<td>默认SSH端口</td>
<td>
<input type="text" name="sshParamsPort" v-model="cluster.sshParams.port" maxlength="5" style="width: 5em"/>
<p class="comment">节点默认SSH登录端口。</p>
</td>
</tr>
<tr>