mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Merge pull request #10804 from ioito/hotfix/qx-mt-ag-policy
fix: owner id fix
This commit is contained in:
@@ -166,10 +166,18 @@ func (manager *SAccessGroupCacheManager) QueryDistinctExtraField(q *sqlchemy.SQu
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SAccessGroupCache) GetOwnerId() mcclient.IIdentityProvider {
|
||||
ag, err := self.GetAccessGroup()
|
||||
if err != nil {
|
||||
return &db.SOwnerId{}
|
||||
}
|
||||
return &db.SOwnerId{DomainId: ag.DomainId}
|
||||
}
|
||||
|
||||
func (manager *SAccessGroupCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {
|
||||
if userCred != nil {
|
||||
sq := AccessGroupManager.Query("id")
|
||||
if len(userCred.GetProjectDomainId()) > 0 {
|
||||
if scope == rbacutils.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 {
|
||||
sq = sq.Equals("domain_id", userCred.GetProjectDomainId())
|
||||
return q.In("access_group_id", sq)
|
||||
}
|
||||
|
||||
@@ -272,10 +272,18 @@ func (manager *SMountTargetManager) QueryDistinctExtraField(q *sqlchemy.SQuery,
|
||||
return q, httperrors.ErrNotFound
|
||||
}
|
||||
|
||||
func (self *SMountTarget) GetOwnerId() mcclient.IIdentityProvider {
|
||||
fs, err := self.GetFileSystem()
|
||||
if err != nil {
|
||||
return &db.SOwnerId{}
|
||||
}
|
||||
return &db.SOwnerId{DomainId: fs.DomainId}
|
||||
}
|
||||
|
||||
func (manager *SMountTargetManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery {
|
||||
if userCred != nil {
|
||||
sq := FileSystemManager.Query("id")
|
||||
if len(userCred.GetProjectDomainId()) > 0 {
|
||||
if scope == rbacutils.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 {
|
||||
sq = sq.Equals("domain_id", userCred.GetProjectDomainId())
|
||||
return q.In("file_system_id", sq)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user