diff --git a/pkg/apis/compute/wire.go b/pkg/apis/compute/wire.go index 70b376c92f..c87fd79de4 100644 --- a/pkg/apis/compute/wire.go +++ b/pkg/apis/compute/wire.go @@ -90,7 +90,8 @@ type WireListInput struct { HostResourceInput - Bandwidth *int `json:"bandwidth"` + Bandwidth *int `json:"bandwidth"` + HostType string `json:"host_type"` } type WireMergeInput struct { diff --git a/pkg/compute/models/wires.go b/pkg/compute/models/wires.go index 23e34b3dc7..274459a6ea 100644 --- a/pkg/compute/models/wires.go +++ b/pkg/compute/models/wires.go @@ -1306,6 +1306,12 @@ func (manager *SWireManager) ListItemFilter( sq := HostwireManager.Query("wire_id").Equals("host_id", hostObj.GetId()) q = q.Filter(sqlchemy.In(q.Field("id"), sq.SubQuery())) } + if len(query.HostType) > 0 { + hs := HostManager.Query("id").Equals("host_type", query.HostType).SubQuery() + sq := HostwireManager.Query("wire_id") + sq = sq.Join(hs, sqlchemy.Equals(sq.Field("host_id"), hs.Field("id"))) + q = q.Filter(sqlchemy.In(q.Field("id"), sq.SubQuery())) + } if query.Bandwidth != nil { q = q.Equals("bandwidth", *query.Bandwidth) diff --git a/pkg/mcclient/options/wire.go b/pkg/mcclient/options/wire.go index a14051afd0..95b5a94d51 100644 --- a/pkg/mcclient/options/wire.go +++ b/pkg/mcclient/options/wire.go @@ -21,10 +21,11 @@ type WireListOptions struct { Bandwidth *int `help:"List wires by bandwidth"` - Region string `help:"List wires in region"` - Zone string `help:"list wires in zone" json:"-"` - Vpc string `help:"List wires in vpc"` - Host string `help:"List wires attached to a host"` + Region string `help:"List wires in region"` + Zone string `help:"list wires in zone" json:"-"` + Vpc string `help:"List wires in vpc"` + Host string `help:"List wires attached to a host"` + HostType string `help:"List wires attached to host with HostType"` } func (wo *WireListOptions) GetContextId() string {