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:
Zexi Li
2020-07-16 11:18:55 +08:00
committed by GitHub
5 changed files with 28 additions and 25 deletions
+12
View File
@@ -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
}
+1
View File
@@ -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
}