mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 23:30:26 +08:00
创建集群的时候可以填写DNS信息/集群设置页增加DNS设置功能
This commit is contained in:
@@ -3,6 +3,7 @@ package clusters
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/dns/domains/domainutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
@@ -16,24 +17,61 @@ func (this *CreateAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunGet(params struct{}) {
|
||||
hasDomainsResp, err := this.RPC().DNSDomainRPC().ExistAvailableDomains(this.AdminContext(), &pb.ExistAvailableDomainsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["hasDomains"] = hasDomainsResp.Exist
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
Name string
|
||||
Name string
|
||||
|
||||
// SSH相关
|
||||
GrantId int64
|
||||
InstallDir string
|
||||
|
||||
// DNS相关
|
||||
DnsDomainId int64
|
||||
DnsName string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("name", params.Name).
|
||||
Require("请输入集群名称")
|
||||
|
||||
// 检查DNS名称
|
||||
if len(params.DnsName) > 0 {
|
||||
if !domainutils.ValidateDomainFormat(params.DnsName) {
|
||||
this.FailField("dnsName", "请输入正确的DNS子域名")
|
||||
}
|
||||
|
||||
// 检查是否已经被使用
|
||||
resp, err := this.RPC().NodeClusterRPC().CheckNodeClusterDNSName(this.AdminContext(), &pb.CheckNodeClusterDNSNameRequest{
|
||||
NodeClusterId: 0,
|
||||
DnsName: params.DnsName,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if resp.IsUsed {
|
||||
this.FailField("dnsName", "此DNS子域名已经被使用,请换一个再试")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 检查DnsDomainId的有效性
|
||||
|
||||
createResp, err := this.RPC().NodeClusterRPC().CreateNodeCluster(this.AdminContext(), &pb.CreateNodeClusterRequest{
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsName: params.DnsName,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -41,7 +79,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
this.CreateLog(oplogs.LevelInfo, "创建集群:%d", createResp.ClusterId)
|
||||
this.CreateLog(oplogs.LevelInfo, "创建节点集群:%d", createResp.ClusterId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user