Skip to content

Commit

Permalink
fix: sync share mode between vpc and wire
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Jul 31, 2020
1 parent d6fdf33 commit 9ea8072
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
20 changes: 11 additions & 9 deletions pkg/compute/models/cloudsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,15 +1176,17 @@ func syncOnPremiseCloudProviderInfo(
}
}

log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
if cloudprovider.IsSupportCompute(driver) {
log.Debugf("storageCachePairs count %d", len(storageCachePairs))
for i := range storageCachePairs {
// alway sync on-premise cached images
// if storageCachePairs[i].isNew || syncRange.DeepSync {
result := storageCachePairs[i].syncCloudImages(ctx, userCred)
syncResults.Add(StoragecachedimageManager, result)
msg := result.Result()
log.Infof("syncCloudImages result: %s", msg)
// }
}
}

return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/compute/models/storagecaches.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ func (cache *SStoragecache) SyncCloudImages(

syncResult := compare.SyncResult{}

log.Debugln("localCachedImages started")
localCachedImages := cache.getCachedImages()
log.Debugf("localCachedImages %d", len(localCachedImages))

Expand Down
15 changes: 11 additions & 4 deletions pkg/compute/models/wires.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func (manager *SWireManager) SyncWires(ctx context.Context, userCred mcclient.To
}
}
for i := 0; i < len(commondb); i += 1 {
err = commondb[i].syncWithCloudWire(ctx, userCred, commonext[i], provider)
err = commondb[i].syncWithCloudWire(ctx, userCred, commonext[i], vpc, provider)
if err != nil {
syncResult.UpdateError(err)
} else {
Expand Down Expand Up @@ -353,13 +353,19 @@ func (self *SWire) syncRemoveCloudWire(ctx context.Context, userCred mcclient.To
return err
}

func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.TokenCredential, extWire cloudprovider.ICloudWire, provider *SCloudprovider) error {
func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.TokenCredential, extWire cloudprovider.ICloudWire, vpc *SVpc, provider *SCloudprovider) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
// self.Name = extWire.GetName()
self.Bandwidth = extWire.GetBandwidth() // 10G

self.IsEmulated = extWire.IsEmulated()

if self.IsEmulated {
self.DomainId = vpc.DomainId
self.IsPublic = vpc.IsPublic
self.PublicScope = vpc.PublicScope
}

return nil
})
if err != nil {
Expand Down Expand Up @@ -408,6 +414,7 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
}

wire.IsEmulated = extWire.IsEmulated()

wire.DomainId = vpc.DomainId
wire.IsPublic = vpc.IsPublic
wire.PublicScope = vpc.PublicScope
Expand All @@ -418,10 +425,10 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl
return nil, err
}

/*if provider != nil {
if provider != nil && !wire.IsEmulated {
SyncCloudDomain(userCred, &wire, provider.GetOwnerId())
wire.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
}*/
}

db.OpsLog.LogEvent(&wire, db.ACT_CREATE, wire.GetShortDesc(ctx), userCred)
return &wire, nil
Expand Down

0 comments on commit 9ea8072

Please sign in to comment.