mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 05:00:25 +08:00
DNS节点可以修改SSH登录相关信息
This commit is contained in:
@@ -1,5 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
ROOT=$(dirname $0)
|
||||||
|
|
||||||
|
# build all nodes
|
||||||
|
if [ -f $ROOT"/../../EdgeNode/build/build-all-plus.sh" ]; then
|
||||||
|
echo "=============================="
|
||||||
|
echo "build all edge-node"
|
||||||
|
echo "=============================="
|
||||||
|
cd $ROOT"/../../EdgeNode/build"
|
||||||
|
./build-all-plus.sh
|
||||||
|
cd -
|
||||||
|
fi
|
||||||
|
|
||||||
./build.sh linux amd64
|
./build.sh linux amd64
|
||||||
./build.sh linux 386
|
./build.sh linux 386
|
||||||
./build.sh linux arm64
|
./build.sh linux arm64
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
|||||||
module github.com/TeaOSLab/EdgeAdmin
|
module github.com/TeaOSLab/EdgeAdmin
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon
|
replace github.com/TeaOSLab/EdgeCommon => ../EdgeCommon
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/grants/grantutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
@@ -63,12 +64,52 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 登录信息
|
||||||
|
var loginMap maps.Map = nil
|
||||||
|
if node.NodeLogin != nil {
|
||||||
|
loginParams := maps.Map{}
|
||||||
|
if len(node.NodeLogin.Params) > 0 {
|
||||||
|
err = json.Unmarshal(node.NodeLogin.Params, &loginParams)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
grantMap := maps.Map{}
|
||||||
|
grantId := loginParams.GetInt64("grantId")
|
||||||
|
if grantId > 0 {
|
||||||
|
grantResp, err := this.RPC().NodeGrantRPC().FindEnabledNodeGrant(this.AdminContext(), &pb.FindEnabledNodeGrantRequest{NodeGrantId: grantId})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if grantResp.NodeGrant != nil {
|
||||||
|
grantMap = maps.Map{
|
||||||
|
"id": grantResp.NodeGrant.Id,
|
||||||
|
"name": grantResp.NodeGrant.Name,
|
||||||
|
"method": grantResp.NodeGrant.Method,
|
||||||
|
"methodName": grantutils.FindGrantMethodName(grantResp.NodeGrant.Method),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loginMap = maps.Map{
|
||||||
|
"id": node.NodeLogin.Id,
|
||||||
|
"name": node.NodeLogin.Name,
|
||||||
|
"type": node.NodeLogin.Type,
|
||||||
|
"params": loginParams,
|
||||||
|
"grant": grantMap,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.Data["node"] = maps.Map{
|
this.Data["node"] = maps.Map{
|
||||||
"id": node.Id,
|
"id": node.Id,
|
||||||
"name": node.Name,
|
"name": node.Name,
|
||||||
"ipAddresses": ipAddressMaps,
|
"ipAddresses": ipAddressMaps,
|
||||||
"cluster": clusterMap,
|
"cluster": clusterMap,
|
||||||
"isOn": node.IsOn,
|
"isOn": node.IsOn,
|
||||||
|
"login": loginMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 所有集群
|
// 所有集群
|
||||||
@@ -94,6 +135,10 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
|
|
||||||
func (this *UpdateAction) RunPost(params struct {
|
func (this *UpdateAction) RunPost(params struct {
|
||||||
LoginId int64
|
LoginId int64
|
||||||
|
GrantId int64
|
||||||
|
SshHost string
|
||||||
|
SshPort int
|
||||||
|
|
||||||
NodeId int64
|
NodeId int64
|
||||||
Name string
|
Name string
|
||||||
IPAddressesJSON []byte `alias:"ipAddressesJSON"`
|
IPAddressesJSON []byte `alias:"ipAddressesJSON"`
|
||||||
@@ -139,12 +184,25 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
this.Fail("请至少输入一个IP地址")
|
this.Fail("请至少输入一个IP地址")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 检查登录授权
|
||||||
|
loginInfo := &pb.NodeLogin{
|
||||||
|
Id: params.LoginId,
|
||||||
|
Name: "SSH",
|
||||||
|
Type: "ssh",
|
||||||
|
Params: maps.Map{
|
||||||
|
"grantId": params.GrantId,
|
||||||
|
"host": params.SshHost,
|
||||||
|
"port": params.SshPort,
|
||||||
|
}.AsJSON(),
|
||||||
|
}
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
_, err = this.RPC().NSNodeRPC().UpdateNSNode(this.AdminContext(), &pb.UpdateNSNodeRequest{
|
_, err = this.RPC().NSNodeRPC().UpdateNSNode(this.AdminContext(), &pb.UpdateNSNodeRequest{
|
||||||
NsNodeId: params.NodeId,
|
NsNodeId: params.NodeId,
|
||||||
Name: params.Name,
|
Name: params.Name,
|
||||||
NsClusterId: params.ClusterId,
|
NsClusterId: params.ClusterId,
|
||||||
IsOn: params.IsOn,
|
IsOn: params.IsOn,
|
||||||
|
NodeLogin: loginInfo,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<h3>修改节点</h3>
|
<h3>修改节点</h3>
|
||||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||||
<input type="hidden" name="nodeId" :value="node.id"/>
|
<input type="hidden" name="nodeId" :value="node.id"/>
|
||||||
|
<input type="hidden" name="loginId" :value="loginId"/>
|
||||||
<table class="ui table definition selectable">
|
<table class="ui table definition selectable">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="title">节点名称 *</td>
|
<td class="title">节点名称 *</td>
|
||||||
@@ -31,6 +32,26 @@
|
|||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tbody v-show="moreOptionsVisible">
|
<tbody v-show="moreOptionsVisible">
|
||||||
|
<tr>
|
||||||
|
<td>SSH主机地址</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="sshHost" maxlength="64" v-model="sshHost"/>
|
||||||
|
<p class="comment">比如192.168.1.100</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>SSH主机端口</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="sshPort" maxlength="5" v-model="sshPort"/>
|
||||||
|
<p class="comment">比如22。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>SSH登录认证</td>
|
||||||
|
<td>
|
||||||
|
<grant-selector :v-grant="grant"></grant-selector>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否启用</td>
|
<td>是否启用</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -5,4 +5,30 @@ Tea.context(function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.success = NotifySuccess("保存成功", "/ns/clusters/cluster/node?clusterId=" + this.clusterId + "&nodeId=" + this.node.id);
|
this.success = NotifySuccess("保存成功", "/ns/clusters/cluster/node?clusterId=" + this.clusterId + "&nodeId=" + this.node.id);
|
||||||
});
|
|
||||||
|
// 认证相关
|
||||||
|
this.grant = null
|
||||||
|
|
||||||
|
this.sshHost = ""
|
||||||
|
this.sshPort = ""
|
||||||
|
this.loginId = 0
|
||||||
|
if (this.node.login != null) {
|
||||||
|
this.loginId = this.node.login.id
|
||||||
|
|
||||||
|
if (this.node.login.params != null) {
|
||||||
|
this.sshHost = this.node.login.params.host
|
||||||
|
if (this.node.login.params.port > 0) {
|
||||||
|
this.sshPort = this.node.login.params.port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.node.login.grant != null && typeof this.node.login.grant.id != "undefined") {
|
||||||
|
this.grant = {
|
||||||
|
id: this.node.login.grant.id,
|
||||||
|
name: this.node.login.grant.name,
|
||||||
|
method: this.node.login.grant.method,
|
||||||
|
methodName: this.node.login.grant.methodName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user