fix: external project priority (#17811)

This commit is contained in:
屈轩
2023-08-21 15:11:28 +08:00
committed by GitHub
parent 276e1247b4
commit b4dd9943fe
11 changed files with 32 additions and 7 deletions
+2
View File
@@ -24,6 +24,7 @@ import (
"yunion.io/x/pkg/util/rbacscope"
"yunion.io/x/sqlchemy"
"yunion.io/x/onecloud/pkg/apis"
"yunion.io/x/onecloud/pkg/appsrv"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/mcclient"
@@ -365,6 +366,7 @@ type IVirtualModel interface {
IsOwner(userCred mcclient.TokenCredential) bool
// IsAdmin(userCred mcclient.TokenCredential) bool
SetProjectSrc(apis.TOwnerSource)
SyncCloudProjectId(userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider)
GetIVirtualModel() IVirtualModel
+9
View File
@@ -532,6 +532,15 @@ func (model *SVirtualResourceBase) GetShortDesc(ctx context.Context) *jsonutils.
return desc
}
func (model *SVirtualResourceBase) SetProjectSrc(src apis.TOwnerSource) {
if model.ProjectSrc != string(src) {
Update(model, func() error {
model.ProjectSrc = string(apis.OWNER_SOURCE_CLOUD)
return nil
})
}
}
func (model *SVirtualResourceBase) SyncCloudProjectId(userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider) {
if model.ProjectSrc != string(apis.OWNER_SOURCE_LOCAL) && ownerId != nil && len(ownerId.GetProjectId()) > 0 {
diff, _ := Update(model, func() error {