From 25f71da5ecb0069f4c185436b228d7e5539be1ac Mon Sep 17 00:00:00 2001 From: ioito Date: Tue, 28 Dec 2021 15:07:24 +0800 Subject: [PATCH] fix(region): vpc topology scope with system --- pkg/apis/compute/vpc.go | 1 + pkg/compute/models/vpcs.go | 3 ++- pkg/compute/models/wires.go | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/apis/compute/vpc.go b/pkg/apis/compute/vpc.go index 351b1599c5..e82cac3ed7 100644 --- a/pkg/apis/compute/vpc.go +++ b/pkg/apis/compute/vpc.go @@ -139,6 +139,7 @@ type HostnetworkTopologyOutput struct { type HostTopologyOutput struct { Name string `json:"name"` + Id string `json:"id"` Status string `json:"status"` HostStatus string `json:"host_status"` HostType string `json:"host_type"` diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index bae53092d6..8d736e3498 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -1754,6 +1754,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke hns := hosts[i].GetBaremetalnetworks() host := api.HostTopologyOutput{ Name: hosts[i].Name, + Id: hosts[i].Id, Status: hosts[i].Status, HostStatus: hosts[i].HostStatus, HostType: hosts[i].HostType, @@ -1785,7 +1786,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke netAddrs := make([]api.SNetworkUsedAddress, 0) - q := networks[j].getUsedAddressQuery(userCred, rbacutils.ScopeDomain, false) + q := networks[j].getUsedAddressQuery(userCred, rbacutils.ScopeSystem, false) err = q.All(&netAddrs) if err != nil { return nil, errors.Wrapf(err, "q.All") diff --git a/pkg/compute/models/wires.go b/pkg/compute/models/wires.go index 428abdc7d6..7a806a42eb 100644 --- a/pkg/compute/models/wires.go +++ b/pkg/compute/models/wires.go @@ -252,9 +252,7 @@ func (wire *SWire) GetHostwires() ([]SHostwire, error) { } func (self *SWire) GetHosts() ([]SHost, error) { - networks := NetworkManager.Query().Equals("wire_id", self.Id).SubQuery() - hns := HostnetworkManager.Query("baremetal_id") - sq := hns.Join(networks, sqlchemy.Equals(hns.Field("network_id"), networks.Field("id"))).SubQuery() + sq := HostwireManager.Query("host_id").Equals("wire_id", self.Id) q := HostManager.Query().In("id", sq) hosts := []SHost{} err := db.FetchModelObjects(HostManager, q, &hosts)