Merge pull request #12793 from ioito/hotfix/qx-network-filter-by-route-table

fix(region): add route table filter for networks
This commit is contained in:
Zexi Li
2021-12-07 12:05:35 +08:00
committed by GitHub
3 changed files with 11 additions and 2 deletions
+3
View File
@@ -78,6 +78,9 @@ type NetworkListInput struct {
UsableResourceListInput
// filter by route table which associate with it
RouteTableId string `json:"route_table_id"`
// description: Exact matching ip address in network.
// example: 10.168.222.1
Ip string `json:"ip"`
+5
View File
@@ -2057,6 +2057,11 @@ func (manager *SNetworkManager) ListItemFilter(
return nil, errors.Wrap(err, "SWireResourceBaseManager.ListItemFilter")
}
if len(input.RouteTableId) > 0 {
sq := RouteTableAssociationManager.Query("associated_resource_id").Equals("route_table_id", input.RouteTableId).Equals("association_type", string(cloudprovider.RouteTableAssociaToSubnet))
q = q.In("id", sq.SubQuery())
}
if input.Usable != nil && *input.Usable {
regions := CloudregionManager.Query("id").Equals("status", api.CLOUD_REGION_STATUS_INSERVER)
zones := ZoneManager.Query("id").Equals("status", api.ZONE_ENABLE).In("cloudregion_id", regions)
+3 -2
View File
@@ -44,8 +44,9 @@ type NetworkListOptions struct {
GuestIpStart []string `help:"search by guest_ip_start"`
GuestIpEnd []string `help:"search by guest_ip_end"`
BgpType []string `help:"filter by bgp_type"`
HostType string `help:"filter by host_type"`
BgpType []string `help:"filter by bgp_type"`
HostType string `help:"filter by host_type"`
RouteTableId string `help:"Filter by RouteTable"`
}
func (opts *NetworkListOptions) GetContextId() string {