mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-11-05 23:41:47 +08:00
Merge pull request #1130 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:feature/qj-filter-zone-by-city to release/2.7.0
* commit '0066830f37922ca09e972d83c46e153030a0b666': feature: filter zones by city
This commit is contained in:
@@ -11,6 +11,7 @@ func init() {
|
||||
type ZoneListOptions struct {
|
||||
options.BaseListOptions
|
||||
Region string `help:"cloud region ID or Name" json:"-"`
|
||||
City string `help:"Filter zone by city of cloudregions"`
|
||||
Usable *bool `help:"List all zones where networks are usable"`
|
||||
UsableVpc *bool `help:"List all zones where vpc are usable"`
|
||||
}
|
||||
|
||||
@@ -698,6 +698,13 @@ func (manager *SZoneManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQu
|
||||
subq := CloudregionManager.Query("id").Equals("provider", providerStr).SubQuery()
|
||||
q = q.In("cloudregion_id", subq)
|
||||
}
|
||||
|
||||
city, _ := query.GetString("city")
|
||||
if len(city) > 0 {
|
||||
subq := CloudregionManager.Query("id").Equals("city", city).SubQuery()
|
||||
q = q.In("cloudregion_id", subq)
|
||||
}
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user