Skip to content
Snippets Groups Projects
Unverified Commit 939fc204 authored by Zexi Li's avatar Zexi Li Committed by GitHub
Browse files

Merge pull request #13074 from ioito/automated-cherry-pick-of-#13073-upstream-release-3.8

Automated cherry pick of #13073: fix(region): lb filter by owner
parents 8a6016a2 deaa4318
No related branches found
Tags v3.8.5
No related merge requests found
......@@ -36,6 +36,7 @@ import (
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rand"
"yunion.io/x/onecloud/pkg/util/rbacutils"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)
......@@ -79,6 +80,21 @@ func (man *SLoadbalancerBackendGroupManager) pendingDeleteSubs(ctx context.Conte
}
}
func (man *SLoadbalancerBackendGroupManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {
if userCred != nil {
sq := LoadbalancerManager.Query("id")
switch scope {
case rbacutils.ScopeProject:
sq = sq.Equals("tenant_id", userCred.GetProjectId())
return q.In("loadbalancer_id", sq.SubQuery())
case rbacutils.ScopeDomain:
sq = sq.Equals("domain_id", userCred.GetProjectDomainId())
return q.In("loadbalancer_id", sq.SubQuery())
}
}
return q
}
// 负载均衡后端服务器组列表
func (man *SLoadbalancerBackendGroupManager) ListItemFilter(
ctx context.Context,
......
......@@ -36,6 +36,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)
......@@ -211,6 +212,21 @@ func (man *SLoadbalancerListenerManager) pendingDeleteSubs(ctx context.Context,
}
}
func (man *SLoadbalancerListenerManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {
if userCred != nil {
sq := LoadbalancerManager.Query("id")
switch scope {
case rbacutils.ScopeProject:
sq = sq.Equals("tenant_id", userCred.GetProjectId())
return q.In("loadbalancer_id", sq.SubQuery())
case rbacutils.ScopeDomain:
sq = sq.Equals("domain_id", userCred.GetProjectDomainId())
return q.In("loadbalancer_id", sq.SubQuery())
}
}
return q
}
// 负载均衡监听器Listener列表
func (man *SLoadbalancerListenerManager) ListItemFilter(
ctx context.Context,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment