diff --git a/cmd/climc/shell/zones.go b/cmd/climc/shell/zones.go index 42c984b709..d67fed688f 100644 --- a/cmd/climc/shell/zones.go +++ b/cmd/climc/shell/zones.go @@ -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"` } diff --git a/pkg/compute/models/zones.go b/pkg/compute/models/zones.go index f941b176c3..4fc7dfd417 100644 --- a/pkg/compute/models/zones.go +++ b/pkg/compute/models/zones.go @@ -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 }