Skip to content
Snippets Groups Projects
Commit deaa4318 authored by ioito's avatar ioito
Browse files

fix(region): lb filter by owner

parent e34399fe
No related branches found
No related tags found
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