mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
集群可以设置默认的WAF策略、缓存策略
This commit is contained in:
@@ -77,11 +77,11 @@ func (this *CreateBatchAction) RunPost(params struct {
|
||||
// 保存
|
||||
for _, ip := range realIPList {
|
||||
resp, err := this.RPC().NodeRPC().CreateNode(this.AdminContext(), &pb.CreateNodeRequest{
|
||||
Name: ip,
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Login: nil,
|
||||
Name: ip,
|
||||
NodeClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Login: nil,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -118,13 +118,13 @@ func (this *CreateNodeAction) RunPost(params struct {
|
||||
|
||||
// 保存
|
||||
createResp, err := this.RPC().NodeRPC().CreateNode(this.AdminContext(), &pb.CreateNodeRequest{
|
||||
Name: params.Name,
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Login: loginInfo,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsRoutes: dnsRouteCodes,
|
||||
Name: params.Name,
|
||||
NodeClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Login: loginInfo,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsRoutes: dnsRouteCodes,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -33,7 +33,7 @@ func (this *DeleteAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
// 删除
|
||||
_, err = this.RPC().NodeClusterRPC().DeleteNodeCluster(this.AdminContext(), &pb.DeleteNodeClusterRequest{ClusterId: params.ClusterId})
|
||||
_, err = this.RPC().NodeClusterRPC().DeleteNodeCluster(this.AdminContext(), &pb.DeleteNodeClusterRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -34,8 +34,8 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Field("name", params.Name).
|
||||
Require("请输入分组名称")
|
||||
createResp, err := this.RPC().NodeGroupRPC().CreateNodeGroup(this.AdminContext(), &pb.CreateNodeGroupRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
Name: params.Name,
|
||||
NodeClusterId: params.ClusterId,
|
||||
Name: params.Name,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -19,7 +19,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
groupsResp, err := this.RPC().NodeGroupRPC().FindAllEnabledNodeGroupsWithClusterId(this.AdminContext(), &pb.FindAllEnabledNodeGroupsWithClusterIdRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
NodeClusterId: params.ClusterId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -18,7 +18,7 @@ func (this *SelectPopupAction) Init() {
|
||||
func (this *SelectPopupAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
groupsResp, err := this.RPC().NodeGroupRPC().FindAllEnabledNodeGroupsWithClusterId(this.AdminContext(), &pb.FindAllEnabledNodeGroupsWithClusterIdRequest{ClusterId: params.ClusterId})
|
||||
groupsResp, err := this.RPC().NodeGroupRPC().FindAllEnabledNodeGroupsWithClusterId(this.AdminContext(), &pb.FindAllEnabledNodeGroupsWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
}
|
||||
|
||||
@@ -37,12 +37,12 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["keyword"] = params.Keyword
|
||||
|
||||
countResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
InstallState: types.Int32(params.InstalledState),
|
||||
ActiveState: types.Int32(params.ActiveState),
|
||||
Keyword: params.Keyword,
|
||||
NodeClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
InstallState: types.Int32(params.InstalledState),
|
||||
ActiveState: types.Int32(params.ActiveState),
|
||||
Keyword: params.Keyword,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -53,14 +53,14 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["page"] = page.AsHTML()
|
||||
|
||||
nodesResp, err := this.RPC().NodeRPC().ListEnabledNodesMatch(this.AdminContext(), &pb.ListEnabledNodesMatchRequest{
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
ClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
InstallState: types.Int32(params.InstalledState),
|
||||
ActiveState: types.Int32(params.ActiveState),
|
||||
Keyword: params.Keyword,
|
||||
Offset: page.Offset,
|
||||
Size: page.Size,
|
||||
NodeClusterId: params.ClusterId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
InstallState: types.Int32(params.InstalledState),
|
||||
ActiveState: types.Int32(params.ActiveState),
|
||||
Keyword: params.Keyword,
|
||||
})
|
||||
nodeMaps := []maps.Map{}
|
||||
for _, node := range nodesResp.Nodes {
|
||||
@@ -154,7 +154,7 @@ func (this *IndexAction) RunGet(params struct {
|
||||
// 所有分组
|
||||
groupMaps := []maps.Map{}
|
||||
groupsResp, err := this.RPC().NodeGroupRPC().FindAllEnabledNodeGroupsWithClusterId(this.AdminContext(), &pb.FindAllEnabledNodeGroupsWithClusterIdRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
NodeClusterId: params.ClusterId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *InstallManualAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "manual")
|
||||
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{ClusterId: params.ClusterId})
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *InstallNodesAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "register")
|
||||
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: params.ClusterId})
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -33,7 +33,7 @@ func (this *InstallNodesAction) RunGet(params struct {
|
||||
|
||||
cluster := clusterResp.Cluster
|
||||
|
||||
clusterAPINodesResp, err := this.RPC().NodeClusterRPC().FindAPINodesWithNodeCluster(this.AdminContext(), &pb.FindAPINodesWithNodeClusterRequest{ClusterId: params.ClusterId})
|
||||
clusterAPINodesResp, err := this.RPC().NodeClusterRPC().FindAPINodesWithNodeCluster(this.AdminContext(), &pb.FindAPINodesWithNodeClusterRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -23,7 +23,7 @@ func (this *InstallRemoteAction) RunGet(params struct {
|
||||
}) {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "install")
|
||||
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{ClusterId: params.ClusterId})
|
||||
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -53,7 +53,7 @@ func (this *InstallAction) RunGet(params struct {
|
||||
var clusterMap maps.Map = nil
|
||||
if node.Cluster != nil {
|
||||
clusterId := node.Cluster.Id
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: clusterId})
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -39,7 +39,7 @@ func (this *NodeAction) RunGet(params struct {
|
||||
var clusterMap maps.Map = nil
|
||||
if node.Cluster != nil {
|
||||
clusterId := node.Cluster.Id
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: clusterId})
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -247,16 +247,16 @@ func (this *UpdateAction) RunPost(params struct {
|
||||
|
||||
// 保存
|
||||
_, err := this.RPC().NodeRPC().UpdateNode(this.AdminContext(), &pb.UpdateNodeRequest{
|
||||
NodeId: params.NodeId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Name: params.Name,
|
||||
ClusterId: params.ClusterId,
|
||||
Login: loginInfo,
|
||||
MaxCPU: params.MaxCPU,
|
||||
IsOn: params.IsOn,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsRoutes: dnsRouteCodes,
|
||||
NodeId: params.NodeId,
|
||||
GroupId: params.GroupId,
|
||||
RegionId: params.RegionId,
|
||||
Name: params.Name,
|
||||
NodeClusterId: params.ClusterId,
|
||||
Login: loginInfo,
|
||||
MaxCPU: params.MaxCPU,
|
||||
IsOn: params.IsOn,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsRoutes: dnsRouteCodes,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
75
internal/web/actions/default/clusters/cluster/settings/cache/index.go
vendored
Normal file
75
internal/web/actions/default/clusters/cluster/settings/cache/index.go
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "setting", "")
|
||||
this.SecondMenu("cache")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
cluster, err := models.SharedNodeClusterDAO.FindEnabledNodeCluster(this.AdminContext(), params.ClusterId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if cluster == nil {
|
||||
this.NotFound("nodeCluster", params.ClusterId)
|
||||
return
|
||||
}
|
||||
|
||||
// 缓存设置
|
||||
this.Data["cachePolicy"] = nil
|
||||
if cluster.HttpCachePolicyId > 0 {
|
||||
cachePolicy, err := models.SharedHTTPCachePolicyDAO.FindEnabledHTTPCachePolicy(this.AdminContext(), cluster.HttpCachePolicyId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if cachePolicy != nil {
|
||||
this.Data["cachePolicy"] = maps.Map{
|
||||
"id": cachePolicy.Id,
|
||||
"name": cachePolicy.Name,
|
||||
"isOn": cachePolicy.IsOn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
CachePolicyId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo("设置集群 %d 的缓存策略为 %d", params.ClusterId, params.CachePolicyId)
|
||||
|
||||
if params.CachePolicyId <= 0 {
|
||||
this.Fail("请选择缓存策略")
|
||||
}
|
||||
|
||||
_, err := this.RPC().NodeClusterRPC().UpdateNodeClusterHTTPCachePolicyId(this.AdminContext(), &pb.UpdateNodeClusterHTTPCachePolicyIdRequest{
|
||||
NodeClusterId: params.ClusterId,
|
||||
HttpCachePolicyId: params.CachePolicyId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (this *HealthAction) Init() {
|
||||
func (this *HealthAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
configResp, err := this.RPC().NodeClusterRPC().FindNodeClusterHealthCheckConfig(this.AdminContext(), &pb.FindNodeClusterHealthCheckConfigRequest{ClusterId: params.ClusterId})
|
||||
configResp, err := this.RPC().NodeClusterRPC().FindNodeClusterHealthCheckConfig(this.AdminContext(), &pb.FindNodeClusterHealthCheckConfigRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -56,7 +56,7 @@ func (this *HealthAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
_, err = this.RPC().NodeClusterRPC().UpdateNodeClusterHealthCheck(this.AdminContext(), &pb.UpdateNodeClusterHealthCheckRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
NodeClusterId: params.ClusterId,
|
||||
HealthCheckJSON: params.HealthCheckJSON,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -28,7 +28,7 @@ func (this *HealthRunPopupAction) RunPost(params struct {
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "执行集群健康检查设置 %d", params.ClusterId)
|
||||
|
||||
resp, err := this.RPC().NodeClusterRPC().ExecuteNodeClusterHealthCheck(this.AdminContext(), &pb.ExecuteNodeClusterHealthCheckRequest{ClusterId: params.ClusterId})
|
||||
resp, err := this.RPC().NodeClusterRPC().ExecuteNodeClusterHealthCheck(this.AdminContext(), &pb.ExecuteNodeClusterHealthCheckRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.Fail(err.Error())
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func (this *IndexAction) Init() {
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: params.ClusterId})
|
||||
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -79,10 +79,10 @@ func (this *IndexAction) RunPost(params struct {
|
||||
Require("请输入集群名称")
|
||||
|
||||
_, err := this.RPC().NodeClusterRPC().UpdateNodeCluster(this.AdminContext(), &pb.UpdateNodeClusterRequest{
|
||||
ClusterId: params.ClusterId,
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
NodeClusterId: params.ClusterId,
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
@@ -2,8 +2,10 @@ package settings
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/cache"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/dns"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/toa"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/settings/waf"
|
||||
clusters "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
@@ -16,9 +18,17 @@ func init() {
|
||||
Helper(clusters.NewClusterHelper()).
|
||||
Prefix("/clusters/cluster/settings").
|
||||
GetPost("", new(IndexAction)).
|
||||
|
||||
// 健康检查
|
||||
GetPost("/health", new(HealthAction)).
|
||||
GetPost("/healthRunPopup", new(HealthRunPopupAction)).
|
||||
|
||||
// 缓存
|
||||
GetPost("/cache", new(cache.IndexAction)).
|
||||
|
||||
// WAF
|
||||
GetPost("/waf", new(waf.IndexAction)).
|
||||
|
||||
// DNS
|
||||
Prefix("/clusters/cluster/settings/dns").
|
||||
GetPost("", new(dns.IndexAction)).
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package waf
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "setting", "")
|
||||
this.SecondMenu("waf")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
cluster, err := models.SharedNodeClusterDAO.FindEnabledNodeCluster(this.AdminContext(), params.ClusterId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if cluster == nil {
|
||||
this.NotFound("nodeCluster", params.ClusterId)
|
||||
return
|
||||
}
|
||||
|
||||
// WAF设置
|
||||
this.Data["firewallPolicy"] = nil
|
||||
if cluster.HttpFirewallPolicyId > 0 {
|
||||
firewallPolicy, err := models.SharedHTTPFirewallPolicyDAO.FindEnabledHTTPFirewallPolicy(this.AdminContext(), cluster.HttpFirewallPolicyId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if firewallPolicy != nil {
|
||||
this.Data["firewallPolicy"] = maps.Map{
|
||||
"id": firewallPolicy.Id,
|
||||
"name": firewallPolicy.Name,
|
||||
"isOn": firewallPolicy.IsOn,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
HttpFirewallPolicyId int64
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
defer this.CreateLogInfo("设置集群 %d 的WAF策略为 %d", params.ClusterId, params.HttpFirewallPolicyId)
|
||||
|
||||
if params.HttpFirewallPolicyId <= 0 {
|
||||
this.Fail("请选择WAF策略")
|
||||
}
|
||||
|
||||
_, err := this.RPC().NodeClusterRPC().UpdateNodeClusterHTTPFirewallPolicyId(this.AdminContext(), &pb.UpdateNodeClusterHTTPFirewallPolicyIdRequest{
|
||||
NodeClusterId: params.ClusterId,
|
||||
HttpFirewallPolicyId: params.HttpFirewallPolicyId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
@@ -24,7 +24,7 @@ func (this *UpgradeRemoteAction) RunGet(params struct {
|
||||
this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "upgrade")
|
||||
|
||||
nodes := []maps.Map{}
|
||||
resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithClusterIdRequest{ClusterId: params.ClusterId})
|
||||
resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -38,7 +38,7 @@ func (this *ClusterHelper) BeforeAction(action *actions.ActionObject) {
|
||||
}
|
||||
|
||||
if clusterId > 0 {
|
||||
clusterResp, err := rpcClient.NodeClusterRPC().FindEnabledNodeCluster(rpcClient.Context(action.Context.GetInt64("adminId")), &pb.FindEnabledNodeClusterRequest{ClusterId: clusterId})
|
||||
clusterResp, err := rpcClient.NodeClusterRPC().FindEnabledNodeCluster(rpcClient.Context(action.Context.GetInt64("adminId")), &pb.FindEnabledNodeClusterRequest{NodeClusterId: clusterId})
|
||||
if err != nil {
|
||||
logs.Error(err)
|
||||
return
|
||||
@@ -77,6 +77,16 @@ func (this *ClusterHelper) createSettingMenu(clusterId string, selectedItem stri
|
||||
"url": "/clusters/cluster/settings?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "basic",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "缓存设置",
|
||||
"url": "/clusters/cluster/settings/cache?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "cache",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "WAF设置",
|
||||
"url": "/clusters/cluster/settings/waf?clusterId=" + clusterId,
|
||||
"isActive": selectedItem == "waf",
|
||||
})
|
||||
items = append(items, maps.Map{
|
||||
"name": "健康检查",
|
||||
"url": "/clusters/cluster/settings/health?clusterId=" + clusterId,
|
||||
|
||||
@@ -30,6 +30,12 @@ func (this *CreateAction) RunGet(params struct{}) {
|
||||
func (this *CreateAction) RunPost(params struct {
|
||||
Name string
|
||||
|
||||
// 缓存策略
|
||||
CachePolicyId int64
|
||||
|
||||
// WAF策略
|
||||
HttpFirewallPolicyId int64
|
||||
|
||||
// SSH相关
|
||||
GrantId int64
|
||||
InstallDir string
|
||||
@@ -44,6 +50,13 @@ func (this *CreateAction) RunPost(params struct {
|
||||
Field("name", params.Name).
|
||||
Require("请输入集群名称")
|
||||
|
||||
if params.CachePolicyId <= 0 {
|
||||
this.Fail("请选择或者创建缓存策略")
|
||||
}
|
||||
if params.HttpFirewallPolicyId <= 0 {
|
||||
this.Fail("请选择或者创建WAF策略")
|
||||
}
|
||||
|
||||
// 检查DNS名称
|
||||
if len(params.DnsName) > 0 {
|
||||
if !domainutils.ValidateDomainFormat(params.DnsName) {
|
||||
@@ -67,11 +80,13 @@ func (this *CreateAction) RunPost(params struct {
|
||||
// TODO 检查DnsDomainId的有效性
|
||||
|
||||
createResp, err := this.RPC().NodeClusterRPC().CreateNodeCluster(this.AdminContext(), &pb.CreateNodeClusterRequest{
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsName: params.DnsName,
|
||||
Name: params.Name,
|
||||
GrantId: params.GrantId,
|
||||
InstallDir: params.InstallDir,
|
||||
DnsDomainId: params.DnsDomainId,
|
||||
DnsName: params.DnsName,
|
||||
HttpCachePolicyId: params.CachePolicyId,
|
||||
HttpFirewallPolicyId: params.HttpFirewallPolicyId,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -79,7 +94,7 @@ func (this *CreateAction) RunPost(params struct {
|
||||
}
|
||||
|
||||
// 创建日志
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建节点集群:%d", createResp.ClusterId)
|
||||
defer this.CreateLog(oplogs.LevelInfo, "创建节点集群:%d", createResp.NodeClusterId)
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
}
|
||||
for _, cluster := range clustersResp.Clusters {
|
||||
// 全部节点数量
|
||||
countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{ClusterId: cluster.Id})
|
||||
countNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{NodeClusterId: cluster.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
@@ -46,8 +46,8 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
|
||||
// 在线节点
|
||||
countActiveNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodesMatch(this.AdminContext(), &pb.CountAllEnabledNodesMatchRequest{
|
||||
ClusterId: cluster.Id,
|
||||
ActiveState: types.Int32(configutils.BoolStateYes),
|
||||
NodeClusterId: cluster.Id,
|
||||
ActiveState: types.Int32(configutils.BoolStateYes),
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -55,7 +55,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
}
|
||||
|
||||
// 需要升级的节点
|
||||
countUpgradeNodesResp, err := this.RPC().NodeRPC().CountAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.CountAllUpgradeNodesWithClusterIdRequest{ClusterId: cluster.Id})
|
||||
countUpgradeNodesResp, err := this.RPC().NodeRPC().CountAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.CountAllUpgradeNodesWithClusterIdRequest{NodeClusterId: cluster.Id})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
|
||||
@@ -25,7 +25,7 @@ func (this *SyncAction) RunPost(params struct{}) {
|
||||
|
||||
for _, cluster := range clusters {
|
||||
_, err := this.RPC().NodeRPC().SyncNodesVersionWithCluster(this.AdminContext(), &pb.SyncNodesVersionWithClusterRequest{
|
||||
ClusterId: cluster.Id,
|
||||
NodeClusterId: cluster.Id,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
|
||||
Reference in New Issue
Block a user