mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #7176 from ioito/automated-cherry-pick-of-#7174-upstream-release-3.2
Automated cherry pick of #7174: fix: 添加secgroup rule过滤参数
This commit is contained in:
@@ -114,6 +114,18 @@ func (manager *SSecurityGroupResourceBaseManager) ListItemFilter(
|
||||
}
|
||||
q = q.Equals("secgroup_id", secgrpObj.GetId())
|
||||
}
|
||||
if len(query.SecgroupName) > 0 {
|
||||
sq := SecurityGroupManager.Query("id").Like("name", "%"+query.SecgroupName+"%")
|
||||
q = q.In("secgroup_id", sq.SubQuery())
|
||||
}
|
||||
if len(query.Project) > 0 {
|
||||
tenant, err := db.TenantCacheManager.FetchTenantByIdOrName(ctx, query.Project)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewResourceNotFoundError2("projects", query.Project)
|
||||
}
|
||||
sq := SecurityGroupManager.Query("id").Equals("tenant_id", tenant.Id)
|
||||
q = q.In("secgroup_id", sq.SubQuery())
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,7 @@ func (manager *SSecurityGroupRuleManager) ListItemFilter(
|
||||
if len(query.Protocol) > 0 {
|
||||
sql = sql.Equals("protocol", query.Protocol)
|
||||
}
|
||||
sql = sql.GroupBy("secgroup_id")
|
||||
return sql, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user