fix(region): The eip displays the internal ip address of the virtual machine (#23067)

This commit is contained in:
屈轩
2025-08-12 09:59:02 +08:00
committed by GitHub
parent 2d4ed27c0c
commit 0b5dd81c77
2 changed files with 15 additions and 0 deletions
+3
View File
@@ -94,6 +94,9 @@ type ElasticipDetails struct {
// 绑定资源名称
AssociateName string `json:"associate_name"`
// 虚拟机内网IP
ServerPrivateIp string `json:"server_private_ip"`
}
func (self ElasticipDetails) GetMetricTags() map[string]string {
+12
View File
@@ -1500,12 +1500,24 @@ func (manager *SElasticipManager) FetchCustomizeColumns(
log.Errorf("FetchIdNameMap2 group")
return rows
}
gns := []SGuestnetwork{}
err = GuestnetworkManager.Query().In("guest_id", guestIds).All(&gns)
if err != nil {
log.Errorf("FetchModelObjects GuestnetworkManager")
return rows
}
gnMap := map[string]string{}
for i := range gns {
gnMap[gns[i].GuestId] = gns[i].IpAddr
}
for i := range rows {
eip := objs[i].(*SElasticip)
if len(eip.AssociateId) > 0 {
switch eip.AssociateType {
case api.EIP_ASSOCIATE_TYPE_SERVER:
rows[i].AssociateName, _ = guests[eip.AssociateId]
rows[i].ServerPrivateIp = gnMap[eip.AssociateId]
case api.EIP_ASSOCIATE_TYPE_LOADBALANCER:
rows[i].AssociateName, _ = lbs[eip.AssociateId]
case api.EIP_ASSOCIATE_TYPE_NAT_GATEWAY: