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:
邱剑
2019-02-28 10:56:54 +08:00
2 changed files with 8 additions and 0 deletions
+1
View File
@@ -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"`
}
+7
View File
@@ -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
}