feat(region): add host_type filter for listing wires

This commit is contained in:
rainzm
2021-08-06 15:41:49 +08:00
parent f5f3d2600c
commit 2b9c4be9ec
3 changed files with 13 additions and 5 deletions
+2 -1
View File
@@ -90,7 +90,8 @@ type WireListInput struct {
HostResourceInput
Bandwidth *int `json:"bandwidth"`
Bandwidth *int `json:"bandwidth"`
HostType string `json:"host_type"`
}
type WireMergeInput struct {
+6
View File
@@ -1301,6 +1301,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)
+5 -4
View File
@@ -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 {