mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: remove mutual dependency of cloudmux on onecloud (#15621)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -20,12 +20,12 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type ClassMetadataPredicate struct {
|
||||
@@ -102,7 +102,7 @@ func (p *ClassMetadataPredicate) PreExecute(ctx context.Context, u *core.Unit, c
|
||||
// no check if image if system public image
|
||||
public := jsonutils.QueryBoolean(obj.Info, "is_public", false)
|
||||
publicScope, _ := obj.Info.GetString("public_scope")
|
||||
if !public || publicScope != string(rbacutils.ScopeSystem) {
|
||||
if !public || publicScope != string(rbacscope.ScopeSystem) {
|
||||
stand = obj
|
||||
guestSource.keyword = "image"
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
computeapi "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
schedapi "yunion.io/x/onecloud/pkg/apis/scheduler"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type DiskSchedtagPredicate struct {
|
||||
@@ -139,8 +139,8 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core.
|
||||
|
||||
// domain ownership filter
|
||||
if storage.DomainId == u.SchedInfo.Domain {
|
||||
} else if storage.IsPublic && storage.PublicScope == string(rbacutils.ScopeSystem) {
|
||||
} else if storage.IsPublic && storage.PublicScope == string(rbacutils.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, storage.GetSharedDomains()) {
|
||||
} else if storage.IsPublic && storage.PublicScope == string(rbacscope.ScopeSystem) {
|
||||
} else if storage.IsPublic && storage.PublicScope == string(rbacscope.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, storage.GetSharedDomains()) {
|
||||
} else {
|
||||
return &FailReason{
|
||||
Reason: fmt.Sprintf("Storage %s is not accessible due to domain ownership", storage.Name),
|
||||
|
||||
@@ -17,10 +17,10 @@ package predicates
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type DomainPredicate struct {
|
||||
@@ -39,8 +39,8 @@ func (p *DomainPredicate) Execute(ctx context.Context, u *core.Unit, c core.Cand
|
||||
h := NewPredicateHelper(p, u, c)
|
||||
getter := c.Getter()
|
||||
if getter.DomainId() == u.SchedInfo.Domain {
|
||||
} else if getter.IsPublic() && getter.PublicScope() == string(rbacutils.ScopeSystem) {
|
||||
} else if getter.IsPublic() && getter.PublicScope() == string(rbacutils.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, getter.SharedDomains()) {
|
||||
} else if getter.IsPublic() && getter.PublicScope() == string(rbacscope.ScopeSystem) {
|
||||
} else if getter.IsPublic() && getter.PublicScope() == string(rbacscope.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, getter.SharedDomains()) {
|
||||
// } else if db.IsAdminAllowGet(context.Background(), u.SchedInfo.UserCred, getter) {
|
||||
} else {
|
||||
h.Exclude("domain_ownership")
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
@@ -29,7 +30,6 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/scheduler/algorithm/plugin"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/api"
|
||||
"yunion.io/x/onecloud/pkg/scheduler/core"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
// NetworkPredicate will filter the current network information with
|
||||
@@ -225,11 +225,11 @@ func IsNetworkAvailable(
|
||||
}
|
||||
}
|
||||
|
||||
if n.IsPublic && n.PublicScope == string(rbacutils.ScopeSystem) {
|
||||
if n.IsPublic && n.PublicScope == string(rbacscope.ScopeSystem) {
|
||||
// system-wide share
|
||||
} else if n.IsPublic && n.PublicScope == string(rbacutils.ScopeDomain) && (n.DomainId == data.Domain || utils.IsInStringArray(data.Domain, n.GetSharedDomains())) {
|
||||
} else if n.IsPublic && n.PublicScope == string(rbacscope.ScopeDomain) && (n.DomainId == data.Domain || utils.IsInStringArray(data.Domain, n.GetSharedDomains())) {
|
||||
// domain-wide share
|
||||
} else if n.PublicScope == string(rbacutils.ScopeProject) && utils.IsInStringArray(data.Project, n.GetSharedProjects()) {
|
||||
} else if n.PublicScope == string(rbacscope.ScopeProject) && utils.IsInStringArray(data.Project, n.GetSharedProjects()) {
|
||||
// project-wide share
|
||||
} else if n.ProjectId == data.Project {
|
||||
// owner
|
||||
|
||||
Reference in New Issue
Block a user