mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): duplicate project sync (#15660)
This commit is contained in:
@@ -286,7 +286,7 @@ func (self *SCloudregion) newFromCloudApp(ctx context.Context, userCred mcclient
|
||||
if result.IsError() {
|
||||
return &app, errors.Wrap(result.AllError(), "unable to SyncAppEnvironments")
|
||||
}
|
||||
SyncCloudProject(userCred, &app, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &app, provider.GetOwnerId(), ext, provider.Id)
|
||||
syncVirtualResourceMetadata(ctx, userCred, &app, ext)
|
||||
|
||||
db.OpsLog.LogEvent(&app, db.ACT_CREATE, app.GetShortDesc(ctx), userCred)
|
||||
|
||||
@@ -180,7 +180,7 @@ func (a *SApp) newFromCloudAppEnvironment(ctx context.Context, userCred mcclient
|
||||
return nil, errors.Wrapf(err, "newFromCloudAppEnvironment.Insert")
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &appEnvironment, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &appEnvironment, provider.GetOwnerId(), ext, provider.Id)
|
||||
db.OpsLog.LogEvent(&appEnvironment, db.ACT_CREATE, appEnvironment.GetShortDesc(ctx), userCred)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ func (manager *SBucketManager) newFromCloudBucket(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &bucket, provider.GetOwnerId(), extBucket, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &bucket, provider.GetOwnerId(), extBucket, provider.Id)
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
Obj: &bucket,
|
||||
Action: notifyclient.ActionSyncCreate,
|
||||
@@ -326,7 +326,7 @@ func (bucket *SBucket) syncWithCloudBucket(
|
||||
}
|
||||
|
||||
if provider != nil {
|
||||
SyncCloudProject(userCred, bucket, provider.GetOwnerId(), extBucket, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, bucket, provider.GetOwnerId(), extBucket, provider.Id)
|
||||
bucket.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
|
||||
}
|
||||
|
||||
|
||||
@@ -569,7 +569,7 @@ func (self *SCachedimage) syncWithCloudImage(ctx context.Context, userCred mccli
|
||||
})
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
SyncCloudProject(userCred, self, ownerId, image, managerId)
|
||||
SyncCloudProject(ctx, userCred, self, ownerId, image, managerId)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ func (manager *SCachedimageManager) newFromCloudImage(ctx context.Context, userC
|
||||
return nil, err
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &cachedImage, ownerId, image, managerId)
|
||||
SyncCloudProject(ctx, userCred, &cachedImage, ownerId, image, managerId)
|
||||
|
||||
return &cachedImage, nil
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/util/rbacscope"
|
||||
"yunion.io/x/pkg/util/stringutils"
|
||||
"yunion.io/x/pkg/util/timeutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -475,6 +476,10 @@ func createTenant(ctx context.Context, name, domainId, desc string) (string, str
|
||||
if err != nil {
|
||||
return "", "", errors.Wrap(err, "resp.GetString")
|
||||
}
|
||||
_, err = db.TenantCacheManager.FetchTenantById(ctx, projectId)
|
||||
if err != nil {
|
||||
log.Errorf("fetch tenant %s error: %v", name, err)
|
||||
}
|
||||
return domainId, projectId, nil
|
||||
}
|
||||
|
||||
@@ -482,6 +487,11 @@ func (self *SCloudaccount) getOrCreateTenant(ctx context.Context, name, domainId
|
||||
if len(domainId) == 0 {
|
||||
domainId = self.DomainId
|
||||
}
|
||||
ctx = context.WithValue(ctx, time.Now().String(), utils.GenRequestId(20))
|
||||
uuid := stringutils.UUID4()
|
||||
lockman.LockRawObject(ctx, domainId, fmt.Sprintf("%s-%s", uuid, name))
|
||||
defer lockman.ReleaseRawObject(ctx, domainId, fmt.Sprintf("%s-%s", uuid, name))
|
||||
|
||||
tenant, err := getTenant(ctx, projectId, name)
|
||||
if err != nil {
|
||||
if errors.Cause(err) != sql.ErrNoRows {
|
||||
|
||||
@@ -2138,7 +2138,7 @@ func (manager *SCloudproviderregionManager) initAllRecords() {
|
||||
}
|
||||
}
|
||||
|
||||
func SyncCloudProject(userCred mcclient.TokenCredential, model db.IVirtualModel, syncOwnerId mcclient.IIdentityProvider, extModel cloudprovider.IVirtualResource, managerId string) {
|
||||
func SyncCloudProject(ctx context.Context, userCred mcclient.TokenCredential, model db.IVirtualModel, syncOwnerId mcclient.IIdentityProvider, extModel cloudprovider.IVirtualResource, managerId string) {
|
||||
newOwnerId, err := func() (mcclient.IIdentityProvider, error) {
|
||||
_manager, err := CloudproviderManager.FetchById(managerId)
|
||||
if err != nil {
|
||||
@@ -2166,7 +2166,7 @@ func SyncCloudProject(userCred mcclient.TokenCredential, model db.IVirtualModel,
|
||||
domainId, projectId, newProj, isMatch := rule.IsMatchTags(extTags)
|
||||
if isMatch {
|
||||
if len(newProj) > 0 {
|
||||
domainId, projectId, err = account.getOrCreateTenant(context.TODO(), newProj, "", "", "auto create from tag")
|
||||
domainId, projectId, err = account.getOrCreateTenant(ctx, newProj, "", "", "auto create from tag")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "getOrCreateTenant(%s)", newProj)
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ func (self *SDBInstanceBackup) SyncWithCloudDBInstanceBackup(
|
||||
}
|
||||
|
||||
if len(self.ProjectId) == 0 {
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), extBackup, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), extBackup, provider.Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -533,7 +533,7 @@ func (manager *SDBInstanceBackupManager) newFromCloudDBInstanceBackup(
|
||||
}
|
||||
|
||||
if len(backup.ProjectId) == 0 {
|
||||
SyncCloudProject(userCred, &backup, provider.GetOwnerId(), extBackup, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &backup, provider.GetOwnerId(), extBackup, provider.Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1706,7 +1706,7 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
|
||||
return err
|
||||
}
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
if len(diff) > 0 {
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
@@ -1802,7 +1802,7 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &instance, extInstance)
|
||||
SyncCloudProject(userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&instance, db.ACT_CREATE, instance.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -1726,7 +1726,7 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extDisk)
|
||||
|
||||
if len(guests) == 0 {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extDisk, storage.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, self, syncOwnerId, extDisk, storage.ManagerId)
|
||||
} else {
|
||||
self.SyncCloudProjectId(userCred, guests[0].GetOwnerId())
|
||||
}
|
||||
@@ -1801,7 +1801,7 @@ func (manager *SDiskManager) newFromCloudDisk(ctx context.Context, userCred mccl
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &disk, extDisk)
|
||||
|
||||
SyncCloudProject(userCred, &disk, syncOwnerId, extDisk, storage.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, &disk, syncOwnerId, extDisk, storage.ManagerId)
|
||||
|
||||
db.OpsLog.LogEvent(&disk, db.ACT_CREATE, disk.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ func (self *SElasticSearch) SyncWithCloudElasticSearch(ctx context.Context, user
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
if provider := self.GetCloudprovider(); provider != nil {
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -597,7 +597,7 @@ func (self *SCloudregion) newFromCloudElasticSearch(ctx context.Context, userCre
|
||||
// 同步标签
|
||||
syncVirtualResourceMetadata(ctx, userCred, &es, ext)
|
||||
// 同步项目归属
|
||||
SyncCloudProject(userCred, &es, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &es, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&es, db.ACT_CREATE, es.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -631,7 +631,7 @@ func (self *SElasticcache) SyncWithCloudElasticcache(ctx context.Context, userCr
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "syncWithCloudElasticcache.Update")
|
||||
}
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extInstance)
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
if len(diff) > 0 {
|
||||
@@ -758,7 +758,7 @@ func (manager *SElasticcacheManager) newFromCloudElasticcache(ctx context.Contex
|
||||
return nil, errors.Wrapf(err, "newFromCloudElasticcache.Insert")
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
syncVirtualResourceMetadata(ctx, userCred, &instance, extInstance)
|
||||
db.OpsLog.LogEvent(&instance, db.ACT_CREATE, instance.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -560,7 +560,7 @@ func (self *SElasticip) SyncWithCloudEip(ctx context.Context, userCred mcclient.
|
||||
if res := self.GetAssociateResource(); res != nil && len(res.GetOwnerId().GetProjectId()) > 0 {
|
||||
self.SyncCloudProjectId(userCred, res.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, ext, self.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, self, syncOwnerId, ext, self.ManagerId)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -625,7 +625,7 @@ func (manager *SElasticipManager) newFromCloudEip(ctx context.Context, userCred
|
||||
if res := eip.GetAssociateResource(); res != nil {
|
||||
eip.SyncCloudProjectId(userCred, res.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, &eip, syncOwnerId, extEip, eip.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, &eip, syncOwnerId, extEip, eip.ManagerId)
|
||||
}
|
||||
|
||||
db.OpsLog.LogEvent(&eip, db.ACT_CREATE, eip.GetShortDesc(ctx), userCred)
|
||||
|
||||
@@ -2938,7 +2938,7 @@ func (self *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.Token
|
||||
self.SyncOsInfo(ctx, userCred, extVM)
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extVM)
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extVM, host.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, self, syncOwnerId, extVM, host.ManagerId)
|
||||
|
||||
if provider.GetFactory().IsSupportPrepaidResources() && recycle {
|
||||
vhost, _ := self.GetHost()
|
||||
@@ -3043,7 +3043,7 @@ func (manager *SGuestManager) newCloudVM(ctx context.Context, userCred mcclient.
|
||||
guest.SyncOsInfo(ctx, userCred, extVM)
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &guest, extVM)
|
||||
SyncCloudProject(userCred, &guest, syncOwnerId, extVM, host.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, &guest, syncOwnerId, extVM, host.ManagerId)
|
||||
|
||||
db.OpsLog.LogEvent(&guest, db.ACT_CREATE, guest.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ func (self *SIPv6Gateway) SyncWithCloudIPv6Gateway(ctx context.Context, userCred
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ func (self *SVpc) newFromCloudIPv6Gateway(ctx context.Context, userCred mcclient
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, ret, ext)
|
||||
SyncCloudProject(userCred, ret, provider.GetOwnerId(), ext, self.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, ret, provider.GetOwnerId(), ext, self.ManagerId)
|
||||
|
||||
db.OpsLog.LogEvent(ret, db.ACT_CREATE, ret.GetShortDesc(ctx), userCred)
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
|
||||
@@ -491,7 +491,7 @@ func (self *SKafka) SyncWithCloudKafka(ctx context.Context, userCred mcclient.To
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
if provider := self.GetCloudprovider(); provider != nil {
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -595,7 +595,7 @@ func (self *SCloudregion) newFromCloudKafka(ctx context.Context, userCred mcclie
|
||||
// 同步标签
|
||||
syncVirtualResourceMetadata(ctx, userCred, &kafka, ext)
|
||||
// 同步项目归属
|
||||
SyncCloudProject(userCred, &kafka, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &kafka, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&kafka, db.ACT_CREATE, kafka.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -396,7 +396,7 @@ func (man *SCachedLoadbalancerAclManager) newFromCloudLoadbalancerAcl(ctx contex
|
||||
return nil, errors.Wrap(err, "cachedLoadbalancerAclManager.new.InsertAcl")
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, localAcl, provider.GetOwnerId(), extAcl, provider.GetId())
|
||||
SyncCloudProject(ctx, userCred, localAcl, provider.GetOwnerId(), extAcl, provider.GetId())
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -267,7 +267,7 @@ func (self *SCloudprovider) newFromCloudLoadbalancerCertificate(ctx context.Cont
|
||||
return errors.Wrapf(err, "Insert lbcert")
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, c, self.GetOwnerId(), ext, self.GetId())
|
||||
SyncCloudProject(ctx, userCred, c, self.GetOwnerId(), ext, self.GetId())
|
||||
}
|
||||
lbcert.CertificateId = c.Id
|
||||
lbcert.Name = ext.GetName()
|
||||
|
||||
@@ -1122,7 +1122,7 @@ func (region *SCloudregion) newFromCloudLoadbalancer(ctx context.Context, userCr
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &lb, ext)
|
||||
SyncCloudProject(userCred, &lb, syncOwnerId, ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &lb, syncOwnerId, ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&lb, db.ACT_CREATE, lb.GetShortDesc(ctx), userCred)
|
||||
|
||||
@@ -1329,7 +1329,7 @@ func (lb *SLoadbalancer) syncWithCloudLoadbalancer(ctx context.Context, userCred
|
||||
networkIds := getExtLbNetworkIds(ext, lb.ManagerId)
|
||||
syncVirtualResourceMetadata(ctx, userCred, lb, ext)
|
||||
provider := lb.GetCloudprovider()
|
||||
SyncCloudProject(userCred, lb, provider.GetOwnerId(), ext, lb.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, lb, provider.GetOwnerId(), ext, lb.ManagerId)
|
||||
lb.syncLoadbalancerNetwork(ctx, userCred, networkIds)
|
||||
|
||||
return err
|
||||
|
||||
@@ -183,7 +183,7 @@ func (self *SMiscResource) SyncWithCloudMiscResource(ctx context.Context, userCr
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -221,7 +221,7 @@ func (self *SCloudregion) newFromCloudMiscResource(ctx context.Context, userCred
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &misc, ext)
|
||||
SyncCloudProject(userCred, &misc, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &misc, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&misc, db.ACT_CREATE, misc.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ func (self *SModelartsPool) SyncWithCloudModelartsPool(ctx context.Context, user
|
||||
return errors.Wrapf(err, "syncVirtualResourceMetadata")
|
||||
}
|
||||
if provider := self.GetCloudprovider(); provider != nil {
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -496,7 +496,7 @@ func (self *SCloudregion) newFromCloudModelartsPool(ctx context.Context, userCre
|
||||
// 同步标签
|
||||
syncVirtualResourceMetadata(ctx, userCred, &pool, ext)
|
||||
// 同步项目归属
|
||||
SyncCloudProject(userCred, &pool, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &pool, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&pool, db.ACT_CREATE, pool.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ func (self *SMongoDB) SyncWithCloudMongoDB(ctx context.Context, userCred mcclien
|
||||
}
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
if provider := self.GetCloudprovider(); provider != nil {
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -650,7 +650,7 @@ func (self *SCloudregion) newFromCloudMongoDB(ctx context.Context, userCred mccl
|
||||
})
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &ins, ext)
|
||||
SyncCloudProject(userCred, &ins, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, &ins, provider.GetOwnerId(), ext, provider.Id)
|
||||
db.OpsLog.LogEvent(&ins, db.ACT_CREATE, ins.GetShortDesc(ctx), userCred)
|
||||
|
||||
return &ins, nil
|
||||
|
||||
@@ -665,7 +665,7 @@ func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclien
|
||||
}
|
||||
|
||||
//syncVirtualResourceMetadata(ctx, userCred, self, extNet)
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extNet, vpc.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, self, syncOwnerId, extNet, vpc.ManagerId)
|
||||
|
||||
if provider != nil {
|
||||
shareInfo := provider.getAccountShareInfo()
|
||||
@@ -724,7 +724,7 @@ func (manager *SNetworkManager) newFromCloudNetwork(ctx context.Context, userCre
|
||||
|
||||
vpc, _ := wire.GetVpc()
|
||||
syncVirtualResourceMetadata(ctx, userCred, &net, extNet)
|
||||
SyncCloudProject(userCred, &net, syncOwnerId, extNet, vpc.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, &net, syncOwnerId, extNet, vpc.ManagerId)
|
||||
|
||||
if provider != nil {
|
||||
shareInfo := provider.getAccountShareInfo()
|
||||
|
||||
@@ -595,7 +595,7 @@ func (manager *SSnapshotPolicyManager) newFromCloudSnapshotPolicy(
|
||||
return nil, errors.Wrapf(err, "Insert")
|
||||
}
|
||||
// sync project
|
||||
SyncCloudProject(userCred, &snapshotPolicyTmp, syncOwnerId, ext, provider.GetId())
|
||||
SyncCloudProject(ctx, userCred, &snapshotPolicyTmp, syncOwnerId, ext, provider.GetId())
|
||||
// update snapshotpolicyCluster
|
||||
if snapshotpolicyCluster != nil {
|
||||
key := snapshotPolicyTmp.Key()
|
||||
|
||||
@@ -906,7 +906,7 @@ func (self *SSnapshot) SyncWithCloudSnapshot(ctx context.Context, userCred mccli
|
||||
if disk != nil {
|
||||
self.SyncCloudProjectId(userCred, disk.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, ext, self.GetCloudprovider().Id)
|
||||
SyncCloudProject(ctx, userCred, self, syncOwnerId, ext, self.GetCloudprovider().Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -959,7 +959,7 @@ func (manager *SSnapshotManager) newFromCloudSnapshot(ctx context.Context, userC
|
||||
if localDisk != nil {
|
||||
snapshot.SyncCloudProjectId(userCred, localDisk.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, &snapshot, syncOwnerId, extSnapshot, snapshot.ManagerId)
|
||||
SyncCloudProject(ctx, userCred, &snapshot, syncOwnerId, extSnapshot, snapshot.ManagerId)
|
||||
}
|
||||
|
||||
db.OpsLog.LogEvent(&snapshot, db.ACT_CREATE, snapshot.GetShortDesc(ctx), userCred)
|
||||
|
||||
@@ -160,7 +160,7 @@ func (self *STablestore) SyncWithCloudTablestore(ctx context.Context, userCred m
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ func (self *SCloudregion) newFromCloudTablestore(ctx context.Context, userCred m
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, ret, ext)
|
||||
SyncCloudProject(userCred, ret, provider.GetOwnerId(), ext, provider.Id)
|
||||
SyncCloudProject(ctx, userCred, ret, provider.GetOwnerId(), ext, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(ret, db.ACT_CREATE, ret.GetShortDesc(ctx), userCred)
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
|
||||
Reference in New Issue
Block a user