mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #208 in YUNIONIO/onecloud from ~LIZEXI/onecloud:feature/lzx-network-list-by-region to release/2.1.0
* commit 'eb77372794804d7f500c188b28ba24ecda6542b3': region: network list by cloudregion
This commit is contained in:
@@ -1211,6 +1211,24 @@ func (manager *SNetworkManager) ListItemFilter(ctx context.Context, q *sqlchemy.
|
||||
sq := WireManager.Query("id").Equals("vpc_id", vpcObj.GetId())
|
||||
q = q.Filter(sqlchemy.In(q.Field("wire_id"), sq.SubQuery()))
|
||||
}
|
||||
regionStr := jsonutils.GetAnyString(query, []string{"region_id", "region", "cloudregion_id", "cloudregion"})
|
||||
if len(regionStr) > 0 {
|
||||
region, err := CloudregionManager.FetchByIdOrName(userCred.GetProjectId(), regionStr)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, httperrors.NewResourceNotFoundError("cloud region %s not found", regionStr)
|
||||
} else {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
}
|
||||
wires := WireManager.Query().SubQuery()
|
||||
vpcs := VpcManager.Query().SubQuery()
|
||||
sq := wires.Query(wires.Field("id")).
|
||||
Join(vpcs, sqlchemy.AND(
|
||||
sqlchemy.Equals(vpcs.Field("cloudregion_id"), region.GetId()),
|
||||
sqlchemy.Equals(wires.Field("vpc_id"), vpcs.Field("id"))))
|
||||
q = q.Filter(sqlchemy.In(q.Field("wire_id"), sq.SubQuery()))
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user