From 0b5dd81c775704ec6f28c4365a08083f43fc1763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Tue, 12 Aug 2025 09:59:02 +0800 Subject: [PATCH] fix(region): The eip displays the internal ip address of the virtual machine (#23067) --- pkg/apis/compute/elasticip.go | 3 +++ pkg/compute/models/elasticips.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/apis/compute/elasticip.go b/pkg/apis/compute/elasticip.go index 28e2842681..408ecb2985 100644 --- a/pkg/apis/compute/elasticip.go +++ b/pkg/apis/compute/elasticip.go @@ -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 { diff --git a/pkg/compute/models/elasticips.go b/pkg/compute/models/elasticips.go index e2ef910f4b..88ef8640c5 100644 --- a/pkg/compute/models/elasticips.go +++ b/pkg/compute/models/elasticips.go @@ -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: