Automatic merge from release/2.7.0 -> master

* commit '3ed5b762b68abb13d71b8df2fc323789c251aa6f':
  feature: filter zones by city
This commit is contained in:
邱剑
2019-02-28 10:56:55 +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
}