mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	集群可以设置systemd系统服务
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@@ -13,7 +13,7 @@ require (
 | 
				
			|||||||
	github.com/go-sql-driver/mysql v1.5.0
 | 
						github.com/go-sql-driver/mysql v1.5.0
 | 
				
			||||||
	github.com/go-yaml/yaml v2.1.0+incompatible
 | 
						github.com/go-yaml/yaml v2.1.0+incompatible
 | 
				
			||||||
	github.com/golang/protobuf v1.4.2
 | 
						github.com/golang/protobuf v1.4.2
 | 
				
			||||||
	github.com/iwind/TeaGo v0.0.0-20210103021650-62acfa30bcea // indirect
 | 
						github.com/iwind/TeaGo v0.0.0-20210106152225-413a5aba30aa // indirect
 | 
				
			||||||
	github.com/lionsoul2014/ip2region v2.2.0-release+incompatible
 | 
						github.com/lionsoul2014/ip2region v2.2.0-release+incompatible
 | 
				
			||||||
	github.com/mozillazg/go-pinyin v0.18.0
 | 
						github.com/mozillazg/go-pinyin v0.18.0
 | 
				
			||||||
	github.com/pkg/sftp v1.12.0
 | 
						github.com/pkg/sftp v1.12.0
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							@@ -176,6 +176,8 @@ github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhK
 | 
				
			|||||||
github.com/iwind/TeaGo v0.0.0-20200923021120-f5d76441fe9e/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
					github.com/iwind/TeaGo v0.0.0-20200923021120-f5d76441fe9e/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
				
			||||||
github.com/iwind/TeaGo v0.0.0-20210103021650-62acfa30bcea h1:ACgcrVeyHpKt8K6k92RrmPndxVq7Qx+zNXZBzRKv3+0=
 | 
					github.com/iwind/TeaGo v0.0.0-20210103021650-62acfa30bcea h1:ACgcrVeyHpKt8K6k92RrmPndxVq7Qx+zNXZBzRKv3+0=
 | 
				
			||||||
github.com/iwind/TeaGo v0.0.0-20210103021650-62acfa30bcea/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
					github.com/iwind/TeaGo v0.0.0-20210103021650-62acfa30bcea/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
				
			||||||
 | 
					github.com/iwind/TeaGo v0.0.0-20210106152225-413a5aba30aa h1:kGf94NRhZik+SPBbY+NgQhwIjJjqv1E1nqgLQ0BtOzw=
 | 
				
			||||||
 | 
					github.com/iwind/TeaGo v0.0.0-20210106152225-413a5aba30aa/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
 | 
				
			||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
 | 
					github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
 | 
				
			||||||
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
 | 
					github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
 | 
				
			||||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
 | 
					github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
package teaconst
 | 
					package teaconst
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	Version = "0.0.7.1"
 | 
						Version = "0.0.8"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ProductName   = "Edge API"
 | 
						ProductName   = "Edge API"
 | 
				
			||||||
	ProcessName   = "edge-api"
 | 
						ProcessName   = "edge-api"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,7 @@ import (
 | 
				
			|||||||
	_ "github.com/go-sql-driver/mysql"
 | 
						_ "github.com/go-sql-driver/mysql"
 | 
				
			||||||
	"github.com/iwind/TeaGo/Tea"
 | 
						"github.com/iwind/TeaGo/Tea"
 | 
				
			||||||
	"github.com/iwind/TeaGo/dbs"
 | 
						"github.com/iwind/TeaGo/dbs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
	"github.com/iwind/TeaGo/rands"
 | 
						"github.com/iwind/TeaGo/rands"
 | 
				
			||||||
	"github.com/iwind/TeaGo/types"
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
@@ -102,7 +103,7 @@ func (this *NodeClusterDAO) FindAllEnableClusters(tx *dbs.Tx) (result []*NodeClu
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 创建集群
 | 
					// 创建集群
 | 
				
			||||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, cachePolicyId int64, httpFirewallPolicyId int64) (clusterId int64, err error) {
 | 
					func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map) (clusterId int64, err error) {
 | 
				
			||||||
	uniqueId, err := this.genUniqueId(tx)
 | 
						uniqueId, err := this.genUniqueId(tx)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return 0, err
 | 
							return 0, err
 | 
				
			||||||
@@ -139,6 +140,13 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
 | 
				
			|||||||
	// WAF策略
 | 
						// WAF策略
 | 
				
			||||||
	op.HttpFirewallPolicyId = httpFirewallPolicyId
 | 
						op.HttpFirewallPolicyId = httpFirewallPolicyId
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 系统服务
 | 
				
			||||||
 | 
						systemServicesJSON, err := json.Marshal(systemServices)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return 0, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						op.SystemServices = systemServicesJSON
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	op.UseAllAPINodes = 1
 | 
						op.UseAllAPINodes = 1
 | 
				
			||||||
	op.ApiNodes = "[]"
 | 
						op.ApiNodes = "[]"
 | 
				
			||||||
	op.UniqueId = uniqueId
 | 
						op.UniqueId = uniqueId
 | 
				
			||||||
@@ -652,6 +660,89 @@ func (this *NodeClusterDAO) UpdateNodeClusterHTTPFirewallPolicyId(tx *dbs.Tx, cl
 | 
				
			|||||||
	return err
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 修改集群的系统服务设置
 | 
				
			||||||
 | 
					func (this *NodeClusterDAO) UpdateNodeClusterSystemService(tx *dbs.Tx, clusterId int64, serviceType nodeconfigs.SystemServiceType, params maps.Map) error {
 | 
				
			||||||
 | 
						if clusterId <= 0 {
 | 
				
			||||||
 | 
							return errors.New("invalid clusterId")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						service, err := this.Query(tx).
 | 
				
			||||||
 | 
							Pk(clusterId).
 | 
				
			||||||
 | 
							Result("systemServices").
 | 
				
			||||||
 | 
							FindStringCol("")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						servicesMap := map[string]maps.Map{}
 | 
				
			||||||
 | 
						if IsNotNull(service) {
 | 
				
			||||||
 | 
							err = json.Unmarshal([]byte(service), &servicesMap)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if params == nil {
 | 
				
			||||||
 | 
							params = maps.Map{}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						servicesMap[serviceType] = params
 | 
				
			||||||
 | 
						servicesJSON, err := json.Marshal(servicesMap)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err = this.Query(tx).
 | 
				
			||||||
 | 
							Pk(clusterId).
 | 
				
			||||||
 | 
							Set("systemServices", servicesJSON).
 | 
				
			||||||
 | 
							Update()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 查找集群的系统服务设置
 | 
				
			||||||
 | 
					func (this *NodeClusterDAO) FindNodeClusterSystemServiceParams(tx *dbs.Tx, clusterId int64, serviceType nodeconfigs.SystemServiceType) (params maps.Map, err error) {
 | 
				
			||||||
 | 
						if clusterId <= 0 {
 | 
				
			||||||
 | 
							return nil, errors.New("invalid clusterId")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						service, err := this.Query(tx).
 | 
				
			||||||
 | 
							Pk(clusterId).
 | 
				
			||||||
 | 
							Result("systemServices").
 | 
				
			||||||
 | 
							FindStringCol("")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						servicesMap := map[string]maps.Map{}
 | 
				
			||||||
 | 
						if IsNotNull(service) {
 | 
				
			||||||
 | 
							err = json.Unmarshal([]byte(service), &servicesMap)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return servicesMap[serviceType], nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 查找集群的所有服务设置
 | 
				
			||||||
 | 
					func (this *NodeClusterDAO) FindNodeClusterSystemServices(tx *dbs.Tx, clusterId int64) (services map[string]maps.Map, err error) {
 | 
				
			||||||
 | 
						if clusterId <= 0 {
 | 
				
			||||||
 | 
							return nil, errors.New("invalid clusterId")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						service, err := this.Query(tx).
 | 
				
			||||||
 | 
							Pk(clusterId).
 | 
				
			||||||
 | 
							Result("systemServices").
 | 
				
			||||||
 | 
							FindStringCol("")
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						servicesMap := map[string]maps.Map{}
 | 
				
			||||||
 | 
						if IsNotNull(service) {
 | 
				
			||||||
 | 
							err = json.Unmarshal([]byte(service), &servicesMap)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return servicesMap, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 生成唯一ID
 | 
					// 生成唯一ID
 | 
				
			||||||
func (this *NodeClusterDAO) genUniqueId(tx *dbs.Tx) (string, error) {
 | 
					func (this *NodeClusterDAO) genUniqueId(tx *dbs.Tx) (string, error) {
 | 
				
			||||||
	for {
 | 
						for {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ type NodeCluster struct {
 | 
				
			|||||||
	CachePolicyId        uint32 `field:"cachePolicyId"`        // 缓存策略ID
 | 
						CachePolicyId        uint32 `field:"cachePolicyId"`        // 缓存策略ID
 | 
				
			||||||
	HttpFirewallPolicyId uint32 `field:"httpFirewallPolicyId"` // WAF策略ID
 | 
						HttpFirewallPolicyId uint32 `field:"httpFirewallPolicyId"` // WAF策略ID
 | 
				
			||||||
	AccessLog            string `field:"accessLog"`            // 访问日志设置
 | 
						AccessLog            string `field:"accessLog"`            // 访问日志设置
 | 
				
			||||||
 | 
						SystemServices       string `field:"systemServices"`       // 系统服务设置
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type NodeClusterOperator struct {
 | 
					type NodeClusterOperator struct {
 | 
				
			||||||
@@ -49,6 +50,7 @@ type NodeClusterOperator struct {
 | 
				
			|||||||
	CachePolicyId        interface{} // 缓存策略ID
 | 
						CachePolicyId        interface{} // 缓存策略ID
 | 
				
			||||||
	HttpFirewallPolicyId interface{} // WAF策略ID
 | 
						HttpFirewallPolicyId interface{} // WAF策略ID
 | 
				
			||||||
	AccessLog            interface{} // 访问日志设置
 | 
						AccessLog            interface{} // 访问日志设置
 | 
				
			||||||
 | 
						SystemServices       interface{} // 系统服务设置
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func NewNodeClusterOperator() *NodeClusterOperator {
 | 
					func NewNodeClusterOperator() *NodeClusterOperator {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -553,6 +553,15 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64) (*nodeconfigs.N
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	config.TOA = toaConfig
 | 
						config.TOA = toaConfig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 系统服务
 | 
				
			||||||
 | 
						services, err := SharedNodeClusterDAO.FindNodeClusterSystemServices(tx, clusterId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if len(services) > 0 {
 | 
				
			||||||
 | 
							config.SystemServices = services
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return config, nil
 | 
						return config, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,3 +91,12 @@ func (this *BaseService) PermissionError() error {
 | 
				
			|||||||
func (this *BaseService) NullTx() *dbs.Tx {
 | 
					func (this *BaseService) NullTx() *dbs.Tx {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 获取当前的数据库
 | 
				
			||||||
 | 
					func (this *BaseService) RunTx(callback func(tx *dbs.Tx) error) error {
 | 
				
			||||||
 | 
						db, err := dbs.Default()
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return db.RunTx(callback)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,8 @@ import (
 | 
				
			|||||||
	rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
 | 
						rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeAPI/internal/tasks"
 | 
						"github.com/TeaOSLab/EdgeAPI/internal/tasks"
 | 
				
			||||||
	"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/dbs"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
	"github.com/iwind/TeaGo/types"
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
	"strconv"
 | 
						"strconv"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -24,9 +26,23 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
 | 
				
			|||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tx := this.NullTx()
 | 
						systemServices := map[string]maps.Map{}
 | 
				
			||||||
 | 
						if len(req.SystemServicesJSON) > 0 {
 | 
				
			||||||
 | 
							err = json.Unmarshal(req.SystemServicesJSON, &systemServices)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var clusterId int64
 | 
				
			||||||
 | 
						err = this.RunTx(func(tx *dbs.Tx) error {
 | 
				
			||||||
 | 
							clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.GrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return nil
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	clusterId, err := models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.GrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.HttpCachePolicyId, req.HttpFirewallPolicyId)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -777,3 +793,55 @@ func (this *NodeClusterService) UpdateNodeClusterHTTPFirewallPolicyId(ctx contex
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return this.Success()
 | 
						return this.Success()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 修改集群的系统服务设置
 | 
				
			||||||
 | 
					func (this *NodeClusterService) UpdateNodeClusterSystemService(ctx context.Context, req *pb.UpdateNodeClusterSystemServiceRequest) (*pb.RPCSuccess, error) {
 | 
				
			||||||
 | 
						_, err := this.ValidateAdmin(ctx, 0)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						params := maps.Map{}
 | 
				
			||||||
 | 
						if len(req.ParamsJSON) > 0 {
 | 
				
			||||||
 | 
							err = json.Unmarshal(req.ParamsJSON, ¶ms)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return nil, err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tx := this.NullTx()
 | 
				
			||||||
 | 
						err = models.SharedNodeClusterDAO.UpdateNodeClusterSystemService(tx, req.NodeClusterId, req.Type, params)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 增加节点版本号
 | 
				
			||||||
 | 
						err = models.SharedNodeDAO.IncreaseAllNodesLatestVersionMatch(tx, req.NodeClusterId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// 查找集群的系统服务设置
 | 
				
			||||||
 | 
					func (this *NodeClusterService) FindNodeClusterSystemService(ctx context.Context, req *pb.FindNodeClusterSystemServiceRequest) (*pb.FindNodeClusterSystemServiceResponse, error) {
 | 
				
			||||||
 | 
						_, err := this.ValidateAdmin(ctx, 0)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tx := this.NullTx()
 | 
				
			||||||
 | 
						params, err := models.SharedNodeClusterDAO.FindNodeClusterSystemServiceParams(tx, req.NodeClusterId, req.Type)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if params == nil {
 | 
				
			||||||
 | 
							params = maps.Map{}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						paramsJSON, err := json.Marshal(params)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return &pb.FindNodeClusterSystemServiceResponse{ParamsJSON: paramsJSON}, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user