mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-02 22:10:26 +08:00
节点配置中增加节点IP信息
This commit is contained in:
@@ -1018,6 +1018,13 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
|
||||
}
|
||||
config.AllowedIPs = append(config.AllowedIPs, apiNodeIPs...)
|
||||
|
||||
// 当前的节点IP地址
|
||||
nodeNodeIPs, err := SharedNodeIPAddressDAO.FindAllEnabledAddressStringsWithNode(tx, nodeId, nodeconfigs.NodeRoleNode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.IPAddresses = nodeNodeIPs
|
||||
|
||||
// 所属集群
|
||||
var primaryClusterId = int64(node.ClusterId)
|
||||
var clusterIds = []int64{primaryClusterId}
|
||||
@@ -1076,7 +1083,7 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, dataMap *shared
|
||||
continue
|
||||
}
|
||||
|
||||
// 节点IP地址
|
||||
// 所有节点IP地址
|
||||
nodeIPAddresses, err := SharedNodeIPAddressDAO.FindAllAccessibleIPAddressesWithClusterId(tx, nodeconfigs.NodeRoleNode, clusterId, cacheMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -256,6 +256,32 @@ func (this *NodeIPAddressDAO) FindAllEnabledAddressesWithNode(tx *dbs.Tx, nodeId
|
||||
return
|
||||
}
|
||||
|
||||
// FindAllEnabledAddressStringsWithNode 查找节点的所有的IP地址地府传
|
||||
func (this *NodeIPAddressDAO) FindAllEnabledAddressStringsWithNode(tx *dbs.Tx, nodeId int64, role nodeconfigs.NodeRole) (result []string, err error) {
|
||||
if len(role) == 0 {
|
||||
role = nodeconfigs.NodeRoleNode
|
||||
}
|
||||
ones, err := this.Query(tx).
|
||||
Attr("nodeId", nodeId).
|
||||
Attr("role", role).
|
||||
State(NodeIPAddressStateEnabled).
|
||||
Result("ip", "backupIP").
|
||||
FindAll()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, one := range ones {
|
||||
var addr = one.(*NodeIPAddress)
|
||||
result = append(result, addr.Ip)
|
||||
if len(addr.BackupIP) > 0 {
|
||||
result = append(result, addr.BackupIP)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// FindFirstNodeAccessIPAddress 查找节点的第一个可访问的IP地址
|
||||
func (this *NodeIPAddressDAO) FindFirstNodeAccessIPAddress(tx *dbs.Tx, nodeId int64, mustUp bool, role nodeconfigs.NodeRole) (ip string, addrId int64, err error) {
|
||||
if len(role) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user